authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-08-04 17:53:05-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-08-04 17:53:05-07:00
log8278eb88376341420817f15791fe7c1715e04a4f
tree4195bafa4e21a5787cb3ada46bc0816d67d487dd
parentac5c6b6061c6454a891c22a8258069370b57c05b

update libcxx to LLVM 15

release/15.x commit 134fd359a5d884f16662a9edd22ab24feeb1498c

841 files changed, 37007 insertions(+), 20860 deletions(-)

lib/libcxx/include/__algorithm/adjacent_find.h+21-13
...@@ -11,34 +11,42 @@...@@ -11,34 +11,42 @@
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>
14#include <__config>15#include <__config>
15#include <__iterator/iterator_traits.h>16#include <__iterator/iterator_traits.h>
17#include <__utility/move.h>
1618
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header20# pragma GCC system_header
19#endif21#endif
2022
21_LIBCPP_BEGIN_NAMESPACE_STD23_LIBCPP_BEGIN_NAMESPACE_STD
2224
25template <class _Iter, class _Sent, class _BinaryPredicate>
26_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _Iter
27__adjacent_find(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) {
28 if (__first == __last)
29 return __first;
30 _Iter __i = __first;
31 while (++__i != __last) {
32 if (__pred(*__first, *__i))
33 return __first;
34 __first = __i;
35 }
36 return __i;
37}
38
23template <class _ForwardIterator, class _BinaryPredicate>39template <class _ForwardIterator, class _BinaryPredicate>
24_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator40_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
25adjacent_find(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred) {41adjacent_find(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred) {
26 if (__first != __last) {42 return std::__adjacent_find(std::move(__first), std::move(__last), __pred);
27 _ForwardIterator __i = __first;
28 while (++__i != __last) {
29 if (__pred(*__first, *__i))
30 return __first;
31 __first = __i;
32 }
33 }
34 return __last;
35}43}
3644
37template <class _ForwardIterator>45template <class _ForwardIterator>
38_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator46_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
39adjacent_find(_ForwardIterator __first, _ForwardIterator __last) {47adjacent_find(_ForwardIterator __first, _ForwardIterator __last) {
40 typedef typename iterator_traits<_ForwardIterator>::value_type __v;48 typedef typename iterator_traits<_ForwardIterator>::value_type __v;
41 return _VSTD::adjacent_find(__first, __last, __equal_to<__v>());49 return std::adjacent_find(std::move(__first), std::move(__last), __equal_to<__v>());
42}50}
4351
44_LIBCPP_END_NAMESPACE_STD52_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/algorithm_family.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___ALGORITHM_ALGORITHM_FAMILY_H
10#define _LIBCPP___ALGORITHM_ALGORITHM_FAMILY_H
11
12#include <__algorithm/iterator_operations.h>
13#include <__algorithm/move.h>
14#include <__algorithm/ranges_move.h>
15#include <__config>
16#include <__utility/move.h>
17
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header
20#endif
21
22_LIBCPP_BEGIN_NAMESPACE_STD
23
24template <class _AlgPolicy>
25struct _AlgFamily;
26
27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
28
29template <>
30struct _AlgFamily<_RangeAlgPolicy> {
31 static constexpr auto __move = ranges::move;
32};
33
34#endif
35
36template <>
37struct _AlgFamily<_ClassicAlgPolicy> {
38
39 // move
40 template <class _InputIterator, class _OutputIterator>
41 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 static _OutputIterator
42 __move(_InputIterator __first, _InputIterator __last, _OutputIterator __result) {
43 return std::move(
44 std::move(__first),
45 std::move(__last),
46 std::move(__result));
47 }
48};
49
50_LIBCPP_END_NAMESPACE_STD
51
52#endif // _LIBCPP___ALGORITHM_ALGORITHM_FAMILY_H
lib/libcxx/include/__algorithm/all_of.h+1-1
...@@ -13,7 +13,7 @@...@@ -13,7 +13,7 @@
13#include <__config>13#include <__config>
1414
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16#pragma GCC system_header16# pragma GCC system_header
17#endif17#endif
1818
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/any_of.h+1-1
...@@ -13,7 +13,7 @@...@@ -13,7 +13,7 @@
13#include <__config>13#include <__config>
1414
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16#pragma GCC system_header16# pragma GCC system_header
17#endif17#endif
1818
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/binary_search.h+8-16
...@@ -16,38 +16,30 @@...@@ -16,38 +16,30 @@
16#include <__iterator/iterator_traits.h>16#include <__iterator/iterator_traits.h>
1717
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19#pragma GCC system_header19# pragma GCC system_header
20#endif20#endif
2121
22_LIBCPP_BEGIN_NAMESPACE_STD22_LIBCPP_BEGIN_NAMESPACE_STD
2323
24template <class _Compare, class _ForwardIterator, class _Tp>
25inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
26bool
27__binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
28{
29 __first = _VSTD::__lower_bound<_Compare>(__first, __last, __value_, __comp);
30 return __first != __last && !__comp(__value_, *__first);
31}
32
33template <class _ForwardIterator, class _Tp, class _Compare>24template <class _ForwardIterator, class _Tp, class _Compare>
34_LIBCPP_NODISCARD_EXT inline25_LIBCPP_NODISCARD_EXT inline
35_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1726_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
36bool27bool
37binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)28binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp)
38{29{
39 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;30 using _Comp_ref = typename __comp_ref_type<_Compare>::type;
40 return _VSTD::__binary_search<_Comp_ref>(__first, __last, __value_, __comp);31 __first = std::lower_bound<_ForwardIterator, _Tp, _Comp_ref>(__first, __last, __value, __comp);
32 return __first != __last && !__comp(__value, *__first);
41}33}
4234
43template <class _ForwardIterator, class _Tp>35template <class _ForwardIterator, class _Tp>
44_LIBCPP_NODISCARD_EXT inline36_LIBCPP_NODISCARD_EXT inline
45_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1737_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
46bool38bool
47binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)39binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value)
48{40{
49 return _VSTD::binary_search(__first, __last, __value_,41 return std::binary_search(__first, __last, __value,
50 __less<typename iterator_traits<_ForwardIterator>::value_type, _Tp>());42 __less<typename iterator_traits<_ForwardIterator>::value_type, _Tp>());
51}43}
5244
53_LIBCPP_END_NAMESPACE_STD45_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/clamp.h+2-2
...@@ -10,11 +10,11 @@...@@ -10,11 +10,11 @@
10#define _LIBCPP___ALGORITHM_CLAMP_H10#define _LIBCPP___ALGORITHM_CLAMP_H
1111
12#include <__algorithm/comp.h>12#include <__algorithm/comp.h>
13#include <__assert>
13#include <__config>14#include <__config>
14#include <__debug>
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
18#endif18#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/comp.h+1-1
...@@ -12,7 +12,7 @@...@@ -12,7 +12,7 @@
12#include <__config>12#include <__config>
1313
14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
15#pragma GCC system_header15# pragma GCC system_header
16#endif16#endif
1717
18_LIBCPP_BEGIN_NAMESPACE_STD18_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/comp_ref_type.h+9-14
...@@ -10,20 +10,15 @@...@@ -10,20 +10,15 @@
10#define _LIBCPP___ALGORITHM_COMP_REF_TYPE_H10#define _LIBCPP___ALGORITHM_COMP_REF_TYPE_H
1111
12#include <__config>12#include <__config>
1313#include <__debug>
14#ifdef _LIBCPP_DEBUG14#include <__utility/declval.h>
15# include <__debug>
16# include <__utility/declval.h>
17#endif
1815
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20#pragma GCC system_header17# pragma GCC system_header
21#endif18#endif
2219
23_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
2421
25#ifdef _LIBCPP_DEBUG
26
27template <class _Compare>22template <class _Compare>
28struct __debug_less23struct __debug_less
29{24{
...@@ -57,8 +52,10 @@ struct __debug_less...@@ -57,8 +52,10 @@ struct __debug_less
57 decltype((void)declval<_Compare&>()(52 decltype((void)declval<_Compare&>()(
58 declval<_LHS &>(), declval<_RHS &>()))53 declval<_LHS &>(), declval<_RHS &>()))
59 __do_compare_assert(int, _LHS & __l, _RHS & __r) {54 __do_compare_assert(int, _LHS & __l, _RHS & __r) {
60 _LIBCPP_ASSERT(!__comp_(__l, __r),55 _LIBCPP_DEBUG_ASSERT(!__comp_(__l, __r),
61 "Comparator does not induce a strict weak ordering");56 "Comparator does not induce a strict weak ordering");
57 (void)__l;
58 (void)__r;
62 }59 }
6360
64 template <class _LHS, class _RHS>61 template <class _LHS, class _RHS>
...@@ -67,16 +64,14 @@ struct __debug_less...@@ -67,16 +64,14 @@ struct __debug_less
67 void __do_compare_assert(long, _LHS &, _RHS &) {}64 void __do_compare_assert(long, _LHS &, _RHS &) {}
68};65};
6966
70#endif // _LIBCPP_DEBUG
71
72template <class _Comp>67template <class _Comp>
73struct __comp_ref_type {68struct __comp_ref_type {
74 // Pass the comparator by lvalue reference. Or in debug mode, using a69 // Pass the comparator by lvalue reference. Or in debug mode, using a
75 // debugging wrapper that stores a reference.70 // debugging wrapper that stores a reference.
76#ifndef _LIBCPP_DEBUG71#ifdef _LIBCPP_ENABLE_DEBUG_MODE
77 typedef _Comp& type;
78#else
79 typedef __debug_less<_Comp> type;72 typedef __debug_less<_Comp> type;
73#else
74 typedef _Comp& type;
80#endif75#endif
81};76};
8277
lib/libcxx/include/__algorithm/copy.h+70-39
...@@ -10,66 +10,97 @@...@@ -10,66 +10,97 @@
10#define _LIBCPP___ALGORITHM_COPY_H10#define _LIBCPP___ALGORITHM_COPY_H
1111
12#include <__algorithm/unwrap_iter.h>12#include <__algorithm/unwrap_iter.h>
13#include <__algorithm/unwrap_range.h>
13#include <__config>14#include <__config>
14#include <__iterator/iterator_traits.h>15#include <__iterator/iterator_traits.h>
16#include <__iterator/reverse_iterator.h>
17#include <__utility/move.h>
18#include <__utility/pair.h>
15#include <cstring>19#include <cstring>
16#include <type_traits>20#include <type_traits>
1721
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19#pragma GCC system_header23# pragma GCC system_header
20#endif24#endif
2125
22_LIBCPP_BEGIN_NAMESPACE_STD26_LIBCPP_BEGIN_NAMESPACE_STD
2327
24// copy28// copy
2529
26template <class _InputIterator, class _OutputIterator>30template <class _InIter, class _Sent, class _OutIter>
27inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1731inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
28_OutputIterator32pair<_InIter, _OutIter> __copy_impl(_InIter __first, _Sent __last, _OutIter __result) {
29__copy_constexpr(_InputIterator __first, _InputIterator __last, _OutputIterator __result)33 while (__first != __last) {
30{34 *__result = *__first;
31 for (; __first != __last; ++__first, (void) ++__result)35 ++__first;
32 *__result = *__first;36 ++__result;
33 return __result;37 }
38 return pair<_InIter, _OutIter>(std::move(__first), std::move(__result));
34}39}
3540
36template <class _InputIterator, class _OutputIterator>41template <class _InValueT,
37inline _LIBCPP_INLINE_VISIBILITY42 class _OutValueT,
38_OutputIterator43 class = __enable_if_t<is_same<typename remove_const<_InValueT>::type, _OutValueT>::value
39__copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result)44 && is_trivially_copy_assignable<_OutValueT>::value> >
40{45inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
41 return _VSTD::__copy_constexpr(__first, __last, __result);46pair<_InValueT*, _OutValueT*> __copy_impl(_InValueT* __first, _InValueT* __last, _OutValueT* __result) {
47 if (__libcpp_is_constant_evaluated()
48// TODO: Remove this once GCC supports __builtin_memmove during constant evaluation
49#ifndef _LIBCPP_COMPILER_GCC
50 && !is_trivially_copyable<_InValueT>::value
51#endif
52 )
53 return std::__copy_impl<_InValueT*, _InValueT*, _OutValueT*>(__first, __last, __result);
54 const size_t __n = static_cast<size_t>(__last - __first);
55 if (__n > 0)
56 ::__builtin_memmove(__result, __first, __n * sizeof(_OutValueT));
57 return std::make_pair(__first + __n, __result + __n);
58}
59
60template <class _InIter, class _OutIter,
61 __enable_if_t<is_same<typename remove_const<__iter_value_type<_InIter> >::type, __iter_value_type<_OutIter> >::value
62 && __is_cpp17_contiguous_iterator<typename _InIter::iterator_type>::value
63 && __is_cpp17_contiguous_iterator<typename _OutIter::iterator_type>::value
64 && is_trivially_copy_assignable<__iter_value_type<_OutIter> >::value
65 && __is_reverse_iterator<_InIter>::value
66 && __is_reverse_iterator<_OutIter>::value, int> = 0>
67inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
68pair<_InIter, _OutIter>
69__copy_impl(_InIter __first, _InIter __last, _OutIter __result) {
70 auto __first_base = std::__unwrap_iter(__first.base());
71 auto __last_base = std::__unwrap_iter(__last.base());
72 auto __result_base = std::__unwrap_iter(__result.base());
73 auto __result_first = __result_base - (__first_base - __last_base);
74 std::__copy_impl(__last_base, __first_base, __result_first);
75 return std::make_pair(__last, _OutIter(std::__rewrap_iter(__result.base(), __result_first)));
76}
77
78template <class _InIter, class _Sent, class _OutIter,
79 __enable_if_t<!(is_copy_constructible<_InIter>::value
80 && is_copy_constructible<_Sent>::value
81 && is_copy_constructible<_OutIter>::value), int> = 0 >
82inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
83pair<_InIter, _OutIter> __copy(_InIter __first, _Sent __last, _OutIter __result) {
84 return std::__copy_impl(std::move(__first), std::move(__last), std::move(__result));
42}85}
4386
44template <class _Tp, class _Up>87template <class _InIter, class _Sent, class _OutIter,
45inline _LIBCPP_INLINE_VISIBILITY88 __enable_if_t<is_copy_constructible<_InIter>::value
46typename enable_if89 && is_copy_constructible<_Sent>::value
47<90 && is_copy_constructible<_OutIter>::value, int> = 0>
48 is_same<typename remove_const<_Tp>::type, _Up>::value &&91inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
49 is_trivially_copy_assignable<_Up>::value,92pair<_InIter, _OutIter> __copy(_InIter __first, _Sent __last, _OutIter __result) {
50 _Up*93 auto __range = std::__unwrap_range(__first, __last);
51>::type94 auto __ret = std::__copy_impl(std::move(__range.first), std::move(__range.second), std::__unwrap_iter(__result));
52__copy(_Tp* __first, _Tp* __last, _Up* __result)95 return std::make_pair(
53{96 std::__rewrap_range<_Sent>(__first, __ret.first), std::__rewrap_iter(__result, __ret.second));
54 const size_t __n = static_cast<size_t>(__last - __first);
55 if (__n > 0)
56 _VSTD::memmove(__result, __first, __n * sizeof(_Up));
57 return __result + __n;
58}97}
5998
60template <class _InputIterator, class _OutputIterator>99template <class _InputIterator, class _OutputIterator>
61inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17100inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
62_OutputIterator101_OutputIterator
63copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result)102copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result) {
64{103 return std::__copy(__first, __last, __result).second;
65 if (__libcpp_is_constant_evaluated()) {
66 return _VSTD::__copy_constexpr(__first, __last, __result);
67 } else {
68 return _VSTD::__rewrap_iter(__result,
69 _VSTD::__copy(_VSTD::__unwrap_iter(__first),
70 _VSTD::__unwrap_iter(__last),
71 _VSTD::__unwrap_iter(__result)));
72 }
73}104}
74105
75_LIBCPP_END_NAMESPACE_STD106_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/copy_backward.h+29-47
...@@ -9,69 +9,51 @@...@@ -9,69 +9,51 @@
9#ifndef _LIBCPP___ALGORITHM_COPY_BACKWARD_H9#ifndef _LIBCPP___ALGORITHM_COPY_BACKWARD_H
10#define _LIBCPP___ALGORITHM_COPY_BACKWARD_H10#define _LIBCPP___ALGORITHM_COPY_BACKWARD_H
1111
12#include <__algorithm/copy.h>
13#include <__algorithm/iterator_operations.h>
14#include <__algorithm/ranges_copy.h>
12#include <__algorithm/unwrap_iter.h>15#include <__algorithm/unwrap_iter.h>
16#include <__concepts/same_as.h>
13#include <__config>17#include <__config>
14#include <__iterator/iterator_traits.h>18#include <__iterator/iterator_traits.h>
19#include <__iterator/reverse_iterator.h>
20#include <__ranges/subrange.h>
21#include <__utility/move.h>
22#include <__utility/pair.h>
15#include <cstring>23#include <cstring>
16#include <type_traits>24#include <type_traits>
1725
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)26#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19#pragma GCC system_header27# pragma GCC system_header
20#endif28#endif
2129
22_LIBCPP_BEGIN_NAMESPACE_STD30_LIBCPP_BEGIN_NAMESPACE_STD
2331
24template <class _BidirectionalIterator, class _OutputIterator>32template <class _AlgPolicy, class _InputIterator, class _OutputIterator,
25inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1733 __enable_if_t<is_same<_AlgPolicy, _ClassicAlgPolicy>::value, int> = 0>
26_OutputIterator34inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 pair<_InputIterator, _OutputIterator>
27__copy_backward_constexpr(_BidirectionalIterator __first, _BidirectionalIterator __last, _OutputIterator __result)35__copy_backward(_InputIterator __first, _InputIterator __last, _OutputIterator __result) {
28{36 auto __ret = std::__copy(
29 while (__first != __last)37 __unconstrained_reverse_iterator<_InputIterator>(__last),
30 *--__result = *--__last;38 __unconstrained_reverse_iterator<_InputIterator>(__first),
31 return __result;39 __unconstrained_reverse_iterator<_OutputIterator>(__result));
40 return pair<_InputIterator, _OutputIterator>(__ret.first.base(), __ret.second.base());
32}41}
3342
34template <class _BidirectionalIterator, class _OutputIterator>43#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
35inline _LIBCPP_INLINE_VISIBILITY44template <class _AlgPolicy, class _Iter1, class _Sent1, class _Iter2,
36_OutputIterator45 __enable_if_t<is_same<_AlgPolicy, _RangeAlgPolicy>::value, int> = 0>
37__copy_backward(_BidirectionalIterator __first, _BidirectionalIterator __last, _OutputIterator __result)46_LIBCPP_HIDE_FROM_ABI constexpr pair<_Iter1, _Iter2> __copy_backward(_Iter1 __first, _Sent1 __last, _Iter2 __result) {
38{47 auto __reverse_range = std::__reverse_range(std::ranges::subrange(std::move(__first), std::move(__last)));
39 return _VSTD::__copy_backward_constexpr(__first, __last, __result);48 auto __ret = ranges::copy(std::move(__reverse_range), std::make_reverse_iterator(__result));
40}49 return std::make_pair(__ret.in.base(), __ret.out.base());
41
42template <class _Tp, class _Up>
43inline _LIBCPP_INLINE_VISIBILITY
44typename enable_if
45<
46 is_same<typename remove_const<_Tp>::type, _Up>::value &&
47 is_trivially_copy_assignable<_Up>::value,
48 _Up*
49>::type
50__copy_backward(_Tp* __first, _Tp* __last, _Up* __result)
51{
52 const size_t __n = static_cast<size_t>(__last - __first);
53 if (__n > 0)
54 {
55 __result -= __n;
56 _VSTD::memmove(__result, __first, __n * sizeof(_Up));
57 }
58 return __result;
59}50}
51#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
6052
61template <class _BidirectionalIterator1, class _BidirectionalIterator2>53template <class _BidirectionalIterator1, class _BidirectionalIterator2>
62inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1754inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _BidirectionalIterator2
63_BidirectionalIterator255copy_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last, _BidirectionalIterator2 __result) {
64copy_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last,56 return std::__copy_backward<_ClassicAlgPolicy>(__first, __last, __result).second;
65 _BidirectionalIterator2 __result)
66{
67 if (__libcpp_is_constant_evaluated()) {
68 return _VSTD::__copy_backward_constexpr(__first, __last, __result);
69 } else {
70 return _VSTD::__rewrap_iter(__result,
71 _VSTD::__copy_backward(_VSTD::__unwrap_iter(__first),
72 _VSTD::__unwrap_iter(__last),
73 _VSTD::__unwrap_iter(__result)));
74 }
75}57}
7658
77_LIBCPP_END_NAMESPACE_STD59_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/copy_if.h+1-1
...@@ -12,7 +12,7 @@...@@ -12,7 +12,7 @@
12#include <__config>12#include <__config>
1313
14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
15#pragma GCC system_header15# pragma GCC system_header
16#endif16#endif
1717
18_LIBCPP_BEGIN_NAMESPACE_STD18_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/copy_n.h+1-1
...@@ -15,7 +15,7 @@...@@ -15,7 +15,7 @@
15#include <type_traits>15#include <type_traits>
1616
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header18# pragma GCC system_header
19#endif19#endif
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/count.h+3-3
...@@ -14,7 +14,7 @@...@@ -14,7 +14,7 @@
14#include <__iterator/iterator_traits.h>14#include <__iterator/iterator_traits.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
18#endif18#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -22,10 +22,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -22,10 +22,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD
22template <class _InputIterator, class _Tp>22template <class _InputIterator, class _Tp>
23_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1723_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
24 typename iterator_traits<_InputIterator>::difference_type24 typename iterator_traits<_InputIterator>::difference_type
25 count(_InputIterator __first, _InputIterator __last, const _Tp& __value_) {25 count(_InputIterator __first, _InputIterator __last, const _Tp& __value) {
26 typename iterator_traits<_InputIterator>::difference_type __r(0);26 typename iterator_traits<_InputIterator>::difference_type __r(0);
27 for (; __first != __last; ++__first)27 for (; __first != __last; ++__first)
28 if (*__first == __value_)28 if (*__first == __value)
29 ++__r;29 ++__r;
30 return __r;30 return __r;
31}31}
lib/libcxx/include/__algorithm/count_if.h+1-1
...@@ -14,7 +14,7 @@...@@ -14,7 +14,7 @@
14#include <__iterator/iterator_traits.h>14#include <__iterator/iterator_traits.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
18#endif18#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/equal.h+1-1
...@@ -16,7 +16,7 @@...@@ -16,7 +16,7 @@
16#include <__iterator/iterator_traits.h>16#include <__iterator/iterator_traits.h>
1717
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19#pragma GCC system_header19# pragma GCC system_header
20#endif20#endif
2121
22_LIBCPP_BEGIN_NAMESPACE_STD22_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/equal_range.h+49-47
...@@ -12,69 +12,71 @@...@@ -12,69 +12,71 @@
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/half_positive.h>14#include <__algorithm/half_positive.h>
15#include <__algorithm/iterator_operations.h>
15#include <__algorithm/lower_bound.h>16#include <__algorithm/lower_bound.h>
16#include <__algorithm/upper_bound.h>17#include <__algorithm/upper_bound.h>
17#include <__config>18#include <__config>
18#include <iterator>19#include <__functional/identity.h>
20#include <__functional/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>
26#include <__type_traits/is_copy_constructible.h>
27#include <__utility/move.h>
28#include <__utility/pair.h>
1929
20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)30#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
21#pragma GCC system_header31# pragma GCC system_header
22#endif32#endif
2333
24_LIBCPP_BEGIN_NAMESPACE_STD34_LIBCPP_BEGIN_NAMESPACE_STD
2535
26template <class _Compare, class _ForwardIterator, class _Tp>36template <class _AlgPolicy, class _Compare, class _Iter, class _Sent, class _Tp, class _Proj>
27_LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_ForwardIterator, _ForwardIterator>37_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_Iter, _Iter>
28__equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)38__equal_range(_Iter __first, _Sent __last, const _Tp& __value, _Compare&& __comp, _Proj&& __proj) {
29{39 auto __len = _IterOps<_AlgPolicy>::distance(__first, __last);
30 typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type;40 _Iter __end = _IterOps<_AlgPolicy>::next(__first, __last);
31 difference_type __len = _VSTD::distance(__first, __last);41 while (__len != 0) {
32 while (__len != 0)42 auto __half_len = std::__half_positive(__len);
33 {43 _Iter __mid = _IterOps<_AlgPolicy>::next(__first, __half_len);
34 difference_type __l2 = _VSTD::__half_positive(__len);44 if (std::__invoke(__comp, std::__invoke(__proj, *__mid), __value)) {
35 _ForwardIterator __m = __first;45 __first = ++__mid;
36 _VSTD::advance(__m, __l2);46 __len -= __half_len + 1;
37 if (__comp(*__m, __value_))47 } else if (std::__invoke(__comp, __value, std::__invoke(__proj, *__mid))) {
38 {48 __end = __mid;
39 __first = ++__m;49 __len = __half_len;
40 __len -= __l2 + 1;50 } else {
41 }51 _Iter __mp1 = __mid;
42 else if (__comp(__value_, *__m))52 return pair<_Iter, _Iter>(
43 {53 std::__lower_bound_impl<_AlgPolicy>(__first, __mid, __value, __comp, __proj),
44 __last = __m;54 std::__upper_bound<_AlgPolicy>(++__mp1, __end, __value, __comp, __proj));
45 __len = __l2;
46 }
47 else
48 {
49 _ForwardIterator __mp1 = __m;
50 return pair<_ForwardIterator, _ForwardIterator>
51 (
52 _VSTD::__lower_bound<_Compare>(__first, __m, __value_, __comp),
53 _VSTD::__upper_bound<_Compare>(++__mp1, __last, __value_, __comp)
54 );
55 }
56 }55 }
57 return pair<_ForwardIterator, _ForwardIterator>(__first, __first);56 }
57 return pair<_Iter, _Iter>(__first, __first);
58}58}
5959
60template <class _ForwardIterator, class _Tp, class _Compare>60template <class _ForwardIterator, class _Tp, class _Compare>
61_LIBCPP_NODISCARD_EXT inline61_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_ForwardIterator, _ForwardIterator>
62_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1762equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) {
63pair<_ForwardIterator, _ForwardIterator>63 static_assert(__is_callable<_Compare, decltype(*__first), const _Tp&>::value,
64equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)64 "The comparator has to be callable");
65{65 static_assert(is_copy_constructible<_ForwardIterator>::value,
66 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;66 "Iterator has to be copy constructible");
67 return _VSTD::__equal_range<_Comp_ref>(__first, __last, __value_, __comp);67 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
68 return std::__equal_range<_ClassicAlgPolicy>(
69 std::move(__first), std::move(__last), __value, static_cast<_Comp_ref>(__comp), std::__identity());
68}70}
6971
70template <class _ForwardIterator, class _Tp>72template <class _ForwardIterator, class _Tp>
71_LIBCPP_NODISCARD_EXT inline73_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_ForwardIterator, _ForwardIterator>
72_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1774equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {
73pair<_ForwardIterator, _ForwardIterator>75 return std::equal_range(
74equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)76 std::move(__first),
75{77 std::move(__last),
76 return _VSTD::equal_range(__first, __last, __value_,78 __value,
77 __less<typename iterator_traits<_ForwardIterator>::value_type, _Tp>());79 __less<typename iterator_traits<_ForwardIterator>::value_type, _Tp>());
78}80}
7981
80_LIBCPP_END_NAMESPACE_STD82_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/fill.h+9-7
...@@ -15,34 +15,36 @@...@@ -15,34 +15,36 @@
15#include <type_traits>15#include <type_traits>
1616
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header18# pragma GCC system_header
19#endif19#endif
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
23// fill isn't specialized for std::memset, because the compiler already optimizes the loop to a call to std::memset.
24
23template <class _ForwardIterator, class _Tp>25template <class _ForwardIterator, class _Tp>
24inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1726inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
25void27void
26__fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, forward_iterator_tag)28__fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, forward_iterator_tag)
27{29{
28 for (; __first != __last; ++__first)30 for (; __first != __last; ++__first)
29 *__first = __value_;31 *__first = __value;
30}32}
3133
32template <class _RandomAccessIterator, class _Tp>34template <class _RandomAccessIterator, class _Tp>
33inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1735inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
34void36void
35__fill(_RandomAccessIterator __first, _RandomAccessIterator __last, const _Tp& __value_, random_access_iterator_tag)37__fill(_RandomAccessIterator __first, _RandomAccessIterator __last, const _Tp& __value, random_access_iterator_tag)
36{38{
37 _VSTD::fill_n(__first, __last - __first, __value_);39 _VSTD::fill_n(__first, __last - __first, __value);
38}40}
3941
40template <class _ForwardIterator, class _Tp>42template <class _ForwardIterator, class _Tp>
41inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1743inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
42void44void
43fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)45fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value)
44{46{
45 _VSTD::__fill(__first, __last, __value_, typename iterator_traits<_ForwardIterator>::iterator_category());47 _VSTD::__fill(__first, __last, __value, typename iterator_traits<_ForwardIterator>::iterator_category());
46}48}
4749
48_LIBCPP_END_NAMESPACE_STD50_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/fill_n.h+7-5
...@@ -14,27 +14,29 @@...@@ -14,27 +14,29 @@
14#include <type_traits>14#include <type_traits>
1515
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17#pragma GCC system_header17# pragma GCC system_header
18#endif18#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
2121
22// fill_n isn't specialized for std::memset, because the compiler already optimizes the loop to a call to std::memset.
23
22template <class _OutputIterator, class _Size, class _Tp>24template <class _OutputIterator, class _Size, class _Tp>
23inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1725inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
24_OutputIterator26_OutputIterator
25__fill_n(_OutputIterator __first, _Size __n, const _Tp& __value_)27__fill_n(_OutputIterator __first, _Size __n, const _Tp& __value)
26{28{
27 for (; __n > 0; ++__first, (void) --__n)29 for (; __n > 0; ++__first, (void) --__n)
28 *__first = __value_;30 *__first = __value;
29 return __first;31 return __first;
30}32}
3133
32template <class _OutputIterator, class _Size, class _Tp>34template <class _OutputIterator, class _Size, class _Tp>
33inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1735inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
34_OutputIterator36_OutputIterator
35fill_n(_OutputIterator __first, _Size __n, const _Tp& __value_)37fill_n(_OutputIterator __first, _Size __n, const _Tp& __value)
36{38{
37 return _VSTD::__fill_n(__first, _VSTD::__convert_to_integral(__n), __value_);39 return _VSTD::__fill_n(__first, _VSTD::__convert_to_integral(__n), __value);
38}40}
3941
40_LIBCPP_END_NAMESPACE_STD42_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/find.h+3-3
...@@ -13,16 +13,16 @@...@@ -13,16 +13,16 @@
13#include <__config>13#include <__config>
1414
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16#pragma GCC system_header16# pragma GCC system_header
17#endif17#endif
1818
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _InputIterator, class _Tp>21template <class _InputIterator, class _Tp>
22_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _InputIterator22_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _InputIterator
23find(_InputIterator __first, _InputIterator __last, const _Tp& __value_) {23find(_InputIterator __first, _InputIterator __last, const _Tp& __value) {
24 for (; __first != __last; ++__first)24 for (; __first != __last; ++__first)
25 if (*__first == __value_)25 if (*__first == __value)
26 break;26 break;
27 return __first;27 return __first;
28}28}
lib/libcxx/include/__algorithm/find_end.h+131-52
...@@ -11,44 +11,69 @@...@@ -11,44 +11,69 @@
11#define _LIBCPP___ALGORITHM_FIND_END_OF_H11#define _LIBCPP___ALGORITHM_FIND_END_OF_H
1212
13#include <__algorithm/comp.h>13#include <__algorithm/comp.h>
14#include <__algorithm/iterator_operations.h>
15#include <__algorithm/search.h>
14#include <__config>16#include <__config>
17#include <__functional/identity.h>
18#include <__iterator/advance.h>
15#include <__iterator/iterator_traits.h>19#include <__iterator/iterator_traits.h>
20#include <__iterator/next.h>
21#include <__iterator/reverse_iterator.h>
22#include <__utility/pair.h>
23#include <type_traits>
1624
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)25#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header26# pragma GCC system_header
19#endif27#endif
2028
21_LIBCPP_BEGIN_NAMESPACE_STD29_LIBCPP_BEGIN_NAMESPACE_STD
2230
23template <class _BinaryPredicate, class _ForwardIterator1, class _ForwardIterator2>31template <
24_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator1 __find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1,32 class _AlgPolicy,
25 _ForwardIterator2 __first2, _ForwardIterator2 __last2,33 class _Iter1,
26 _BinaryPredicate __pred, forward_iterator_tag,34 class _Sent1,
27 forward_iterator_tag) {35 class _Iter2,
36 class _Sent2,
37 class _Pred,
38 class _Proj1,
39 class _Proj2>
40_LIBCPP_HIDE_FROM_ABI inline _LIBCPP_CONSTEXPR_AFTER_CXX11 pair<_Iter1, _Iter1> __find_end_impl(
41 _Iter1 __first1,
42 _Sent1 __last1,
43 _Iter2 __first2,
44 _Sent2 __last2,
45 _Pred& __pred,
46 _Proj1& __proj1,
47 _Proj2& __proj2,
48 forward_iterator_tag,
49 forward_iterator_tag) {
28 // modeled after search algorithm50 // modeled after search algorithm
29 _ForwardIterator1 __r = __last1; // __last1 is the "default" answer51 _Iter1 __match_first = _IterOps<_AlgPolicy>::next(__first1, __last1); // __last1 is the "default" answer
52 _Iter1 __match_last = __match_first;
30 if (__first2 == __last2)53 if (__first2 == __last2)
31 return __r;54 return pair<_Iter1, _Iter1>(__match_last, __match_last);
32 while (true) {55 while (true) {
33 while (true) {56 while (true) {
34 if (__first1 == __last1) // if source exhausted return last correct answer57 if (__first1 == __last1) // if source exhausted return last correct answer (or __last1 if never found)
35 return __r; // (or __last1 if never found)58 return pair<_Iter1, _Iter1>(__match_first, __match_last);
36 if (__pred(*__first1, *__first2))59 if (std::__invoke(__pred, std::__invoke(__proj1, *__first1), std::__invoke(__proj2, *__first2)))
37 break;60 break;
38 ++__first1;61 ++__first1;
39 }62 }
40 // *__first1 matches *__first2, now match elements after here63 // *__first1 matches *__first2, now match elements after here
41 _ForwardIterator1 __m1 = __first1;64 _Iter1 __m1 = __first1;
42 _ForwardIterator2 __m2 = __first2;65 _Iter2 __m2 = __first2;
43 while (true) {66 while (true) {
44 if (++__m2 == __last2) { // Pattern exhaused, record answer and search for another one67 if (++__m2 == __last2) { // Pattern exhaused, record answer and search for another one
45 __r = __first1;68 __match_first = __first1;
69 __match_last = ++__m1;
46 ++__first1;70 ++__first1;
47 break;71 break;
48 }72 }
49 if (++__m1 == __last1) // Source exhausted, return last answer73 if (++__m1 == __last1) // Source exhausted, return last answer
50 return __r;74 return pair<_Iter1, _Iter1>(__match_first, __match_last);
51 if (!__pred(*__m1, *__m2)) // mismatch, restart with a new __first75 // mismatch, restart with a new __first
76 if (!std::__invoke(__pred, std::__invoke(__proj1, *__m1), std::__invoke(__proj2, *__m2)))
52 {77 {
53 ++__first1;78 ++__first1;
54 break;79 break;
...@@ -57,33 +82,52 @@ _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator1 __find_end(_ForwardIterator1 __f...@@ -57,33 +82,52 @@ _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator1 __find_end(_ForwardIterator1 __f
57 }82 }
58}83}
5984
60template <class _BinaryPredicate, class _BidirectionalIterator1, class _BidirectionalIterator2>85template <
61_LIBCPP_CONSTEXPR_AFTER_CXX17 _BidirectionalIterator1 __find_end(86 class _IterOps,
62 _BidirectionalIterator1 __first1, _BidirectionalIterator1 __last1, _BidirectionalIterator2 __first2,87 class _Pred,
63 _BidirectionalIterator2 __last2, _BinaryPredicate __pred, bidirectional_iterator_tag, bidirectional_iterator_tag) {88 class _Iter1,
89 class _Sent1,
90 class _Iter2,
91 class _Sent2,
92 class _Proj1,
93 class _Proj2>
94_LIBCPP_CONSTEXPR_AFTER_CXX17 _Iter1 __find_end(
95 _Iter1 __first1,
96 _Sent1 __sent1,
97 _Iter2 __first2,
98 _Sent2 __sent2,
99 _Pred& __pred,
100 _Proj1& __proj1,
101 _Proj2& __proj2,
102 bidirectional_iterator_tag,
103 bidirectional_iterator_tag) {
104 auto __last1 = _IterOps::next(__first1, __sent1);
105 auto __last2 = _IterOps::next(__first2, __sent2);
64 // modeled after search algorithm (in reverse)106 // modeled after search algorithm (in reverse)
65 if (__first2 == __last2)107 if (__first2 == __last2)
66 return __last1; // Everything matches an empty sequence108 return __last1; // Everything matches an empty sequence
67 _BidirectionalIterator1 __l1 = __last1;109 _Iter1 __l1 = __last1;
68 _BidirectionalIterator2 __l2 = __last2;110 _Iter2 __l2 = __last2;
69 --__l2;111 --__l2;
70 while (true) {112 while (true) {
71 // Find last element in sequence 1 that matchs *(__last2-1), with a mininum of loop checks113 // Find last element in sequence 1 that matchs *(__last2-1), with a mininum of loop checks
72 while (true) {114 while (true) {
73 if (__first1 == __l1) // return __last1 if no element matches *__first2115 if (__first1 == __l1) // return __last1 if no element matches *__first2
74 return __last1;116 return __last1;
75 if (__pred(*--__l1, *__l2))117 if (std::__invoke(__pred, std::__invoke(__proj1, *--__l1), std::__invoke(__proj2, *__l2)))
76 break;118 break;
77 }119 }
78 // *__l1 matches *__l2, now match elements before here120 // *__l1 matches *__l2, now match elements before here
79 _BidirectionalIterator1 __m1 = __l1;121 _Iter1 __m1 = __l1;
80 _BidirectionalIterator2 __m2 = __l2;122 _Iter2 __m2 = __l2;
81 while (true) {123 while (true) {
82 if (__m2 == __first2) // If pattern exhausted, __m1 is the answer (works for 1 element pattern)124 if (__m2 == __first2) // If pattern exhausted, __m1 is the answer (works for 1 element pattern)
83 return __m1;125 return __m1;
84 if (__m1 == __first1) // Otherwise if source exhaused, pattern not found126 if (__m1 == __first1) // Otherwise if source exhaused, pattern not found
85 return __last1;127 return __last1;
86 if (!__pred(*--__m1, *--__m2)) // if there is a mismatch, restart with a new __l1128
129 // if there is a mismatch, restart with a new __l1
130 if (!std::__invoke(__pred, std::__invoke(__proj1, *--__m1), std::__invoke(__proj2, *--__m2)))
87 {131 {
88 break;132 break;
89 } // else there is a match, check next elements133 } // else there is a match, check next elements
...@@ -91,37 +135,53 @@ _LIBCPP_CONSTEXPR_AFTER_CXX17 _BidirectionalIterator1 __find_end(...@@ -91,37 +135,53 @@ _LIBCPP_CONSTEXPR_AFTER_CXX17 _BidirectionalIterator1 __find_end(
91 }135 }
92}136}
93137
94template <class _BinaryPredicate, class _RandomAccessIterator1, class _RandomAccessIterator2>138template <
95_LIBCPP_CONSTEXPR_AFTER_CXX11 _RandomAccessIterator1 __find_end(139 class _AlgPolicy,
96 _RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, _RandomAccessIterator2 __first2,140 class _Pred,
97 _RandomAccessIterator2 __last2, _BinaryPredicate __pred, random_access_iterator_tag, random_access_iterator_tag) {141 class _Iter1,
98 typedef typename iterator_traits<_RandomAccessIterator1>::difference_type _D1;142 class _Sent1,
99 typedef typename iterator_traits<_RandomAccessIterator2>::difference_type _D2;143 class _Iter2,
144 class _Sent2,
145 class _Proj1,
146 class _Proj2>
147_LIBCPP_CONSTEXPR_AFTER_CXX11 _Iter1 __find_end(
148 _Iter1 __first1,
149 _Sent1 __sent1,
150 _Iter2 __first2,
151 _Sent2 __sent2,
152 _Pred& __pred,
153 _Proj1& __proj1,
154 _Proj2& __proj2,
155 random_access_iterator_tag,
156 random_access_iterator_tag) {
157 typedef typename iterator_traits<_Iter1>::difference_type _D1;
158 auto __last1 = _IterOps<_AlgPolicy>::next(__first1, __sent1);
159 auto __last2 = _IterOps<_AlgPolicy>::next(__first2, __sent2);
100 // Take advantage of knowing source and pattern lengths. Stop short when source is smaller than pattern160 // Take advantage of knowing source and pattern lengths. Stop short when source is smaller than pattern
101 _D2 __len2 = __last2 - __first2;161 auto __len2 = __last2 - __first2;
102 if (__len2 == 0)162 if (__len2 == 0)
103 return __last1;163 return __last1;
104 _D1 __len1 = __last1 - __first1;164 auto __len1 = __last1 - __first1;
105 if (__len1 < __len2)165 if (__len1 < __len2)
106 return __last1;166 return __last1;
107 const _RandomAccessIterator1 __s = __first1 + _D1(__len2 - 1); // End of pattern match can't go before here167 const _Iter1 __s = __first1 + _D1(__len2 - 1); // End of pattern match can't go before here
108 _RandomAccessIterator1 __l1 = __last1;168 _Iter1 __l1 = __last1;
109 _RandomAccessIterator2 __l2 = __last2;169 _Iter2 __l2 = __last2;
110 --__l2;170 --__l2;
111 while (true) {171 while (true) {
112 while (true) {172 while (true) {
113 if (__s == __l1)173 if (__s == __l1)
114 return __last1;174 return __last1;
115 if (__pred(*--__l1, *__l2))175 if (std::__invoke(__pred, std::__invoke(__proj1, *--__l1), std::__invoke(__proj2, *__l2)))
116 break;176 break;
117 }177 }
118 _RandomAccessIterator1 __m1 = __l1;178 _Iter1 __m1 = __l1;
119 _RandomAccessIterator2 __m2 = __l2;179 _Iter2 __m2 = __l2;
120 while (true) {180 while (true) {
121 if (__m2 == __first2)181 if (__m2 == __first2)
122 return __m1;182 return __m1;
123 // no need to check range on __m1 because __s guarantees we have enough source183 // no need to check range on __m1 because __s guarantees we have enough source
124 if (!__pred(*--__m1, *--__m2)) {184 if (!std::__invoke(__pred, std::__invoke(__proj1, *--__m1), std::__invoke(*--__m2))) {
125 break;185 break;
126 }186 }
127 }187 }
...@@ -129,20 +189,39 @@ _LIBCPP_CONSTEXPR_AFTER_CXX11 _RandomAccessIterator1 __find_end(...@@ -129,20 +189,39 @@ _LIBCPP_CONSTEXPR_AFTER_CXX11 _RandomAccessIterator1 __find_end(
129}189}
130190
131template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>191template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
132_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator1192_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
133find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2,193_ForwardIterator1 __find_end_classic(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
134 _BinaryPredicate __pred) {194 _ForwardIterator2 __first2, _ForwardIterator2 __last2,
135 return _VSTD::__find_end<_BinaryPredicate&>(195 _BinaryPredicate& __pred) {
136 __first1, __last1, __first2, __last2, __pred, typename iterator_traits<_ForwardIterator1>::iterator_category(),196 auto __proj = __identity();
137 typename iterator_traits<_ForwardIterator2>::iterator_category());197 return std::__find_end_impl<_ClassicAlgPolicy>(
198 __first1,
199 __last1,
200 __first2,
201 __last2,
202 __pred,
203 __proj,
204 __proj,
205 typename iterator_traits<_ForwardIterator1>::iterator_category(),
206 typename iterator_traits<_ForwardIterator2>::iterator_category())
207 .first;
208}
209
210template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
211_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
212_ForwardIterator1 find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
213 _ForwardIterator2 __first2, _ForwardIterator2 __last2,
214 _BinaryPredicate __pred) {
215 return std::__find_end_classic(__first1, __last1, __first2, __last2, __pred);
138}216}
139217
140template <class _ForwardIterator1, class _ForwardIterator2>218template <class _ForwardIterator1, class _ForwardIterator2>
141_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator1219_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
142find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) {220_ForwardIterator1 find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
143 typedef typename iterator_traits<_ForwardIterator1>::value_type __v1;221 _ForwardIterator2 __first2, _ForwardIterator2 __last2) {
144 typedef typename iterator_traits<_ForwardIterator2>::value_type __v2;222 using __v1 = typename iterator_traits<_ForwardIterator1>::value_type;
145 return _VSTD::find_end(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>());223 using __v2 = typename iterator_traits<_ForwardIterator2>::value_type;
224 return std::find_end(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>());
146}225}
147226
148_LIBCPP_END_NAMESPACE_STD227_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/find_first_of.h+1-1
...@@ -15,7 +15,7 @@...@@ -15,7 +15,7 @@
15#include <__iterator/iterator_traits.h>15#include <__iterator/iterator_traits.h>
1616
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header18# pragma GCC system_header
19#endif19#endif
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/find_if.h+1-1
...@@ -13,7 +13,7 @@...@@ -13,7 +13,7 @@
13#include <__config>13#include <__config>
1414
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16#pragma GCC system_header16# pragma GCC system_header
17#endif17#endif
1818
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/find_if_not.h+1-1
...@@ -13,7 +13,7 @@...@@ -13,7 +13,7 @@
13#include <__config>13#include <__config>
1414
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16#pragma GCC system_header16# pragma GCC system_header
17#endif17#endif
1818
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/for_each.h+1-1
...@@ -13,7 +13,7 @@...@@ -13,7 +13,7 @@
13#include <__config>13#include <__config>
1414
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16#pragma GCC system_header16# pragma GCC system_header
17#endif17#endif
1818
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/for_each_n.h+1-1
...@@ -14,7 +14,7 @@...@@ -14,7 +14,7 @@
14#include <type_traits>14#include <type_traits>
1515
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17#pragma GCC system_header17# pragma GCC system_header
18#endif18#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/generate.h+1-1
...@@ -12,7 +12,7 @@...@@ -12,7 +12,7 @@
12#include <__config>12#include <__config>
1313
14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
15#pragma GCC system_header15# pragma GCC system_header
16#endif16#endif
1717
18_LIBCPP_BEGIN_NAMESPACE_STD18_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/generate_n.h+1-1
...@@ -13,7 +13,7 @@...@@ -13,7 +13,7 @@
13#include <type_traits>13#include <type_traits>
1414
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16#pragma GCC system_header16# pragma GCC system_header
17#endif17#endif
1818
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/half_positive.h+1-1
...@@ -13,7 +13,7 @@...@@ -13,7 +13,7 @@
13#include <type_traits>13#include <type_traits>
1414
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16#pragma GCC system_header16# pragma GCC system_header
17#endif17#endif
1818
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/in_found_result.h created+49
...@@ -0,0 +1,49 @@
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_IN_FOUND_RESULT_H
11#define _LIBCPP___ALGORITHM_IN_FOUND_RESULT_H
12
13#include <__concepts/convertible_to.h>
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#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
22
23_LIBCPP_BEGIN_NAMESPACE_STD
24
25namespace ranges {
26template <class _InIter1>
27struct in_found_result {
28 _LIBCPP_NO_UNIQUE_ADDRESS _InIter1 in;
29 bool found;
30
31 template <class _InIter2>
32 requires convertible_to<const _InIter1&, _InIter2>
33 _LIBCPP_HIDE_FROM_ABI constexpr operator in_found_result<_InIter2>() const & {
34 return {in, found};
35 }
36
37 template <class _InIter2>
38 requires convertible_to<_InIter1, _InIter2>
39 _LIBCPP_HIDE_FROM_ABI constexpr operator in_found_result<_InIter2>() && {
40 return {std::move(in), found};
41 }
42};
43} // namespace ranges
44
45_LIBCPP_END_NAMESPACE_STD
46
47#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
48
49#endif // _LIBCPP___ALGORITHM_IN_FOUND_RESULT_H
lib/libcxx/include/__algorithm/in_fun_result.h created+49
...@@ -0,0 +1,49 @@
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_IN_FUN_RESULT_H
11#define _LIBCPP___ALGORITHM_IN_FUN_RESULT_H
12
13#include <__concepts/convertible_to.h>
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_BEGIN_NAMESPACE_STD
22
23#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
24
25namespace ranges {
26template <class _InIter1, class _Func1>
27struct in_fun_result {
28 _LIBCPP_NO_UNIQUE_ADDRESS _InIter1 in;
29 _LIBCPP_NO_UNIQUE_ADDRESS _Func1 fun;
30
31 template <class _InIter2, class _Func2>
32 requires convertible_to<const _InIter1&, _InIter2> && convertible_to<const _Func1&, _Func2>
33 _LIBCPP_HIDE_FROM_ABI constexpr operator in_fun_result<_InIter2, _Func2>() const & {
34 return {in, fun};
35 }
36
37 template <class _InIter2, class _Func2>
38 requires convertible_to<_InIter1, _InIter2> && convertible_to<_Func1, _Func2>
39 _LIBCPP_HIDE_FROM_ABI constexpr operator in_fun_result<_InIter2, _Func2>() && {
40 return {std::move(in), std::move(fun)};
41 }
42};
43} // namespace ranges
44
45#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
46
47_LIBCPP_END_NAMESPACE_STD
48
49#endif // _LIBCPP___ALGORITHM_IN_FUN_RESULT_H
lib/libcxx/include/__algorithm/in_in_out_result.h+16-14
...@@ -15,39 +15,41 @@...@@ -15,39 +15,41 @@
15#include <__utility/move.h>15#include <__utility/move.h>
1616
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header18# pragma GCC system_header
19#endif19#endif
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
23#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)23#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
2424
25namespace ranges {25namespace ranges {
2626
27template <class _I1, class _I2, class _O1>27template <class _InIter1, class _InIter2, class _OutIter1>
28struct in_in_out_result {28struct in_in_out_result {
29 [[no_unique_address]] _I1 in1;29 _LIBCPP_NO_UNIQUE_ADDRESS _InIter1 in1;
30 [[no_unique_address]] _I2 in2;30 _LIBCPP_NO_UNIQUE_ADDRESS _InIter2 in2;
31 [[no_unique_address]] _O1 out;31 _LIBCPP_NO_UNIQUE_ADDRESS _OutIter1 out;
3232
33 template <class _II1, class _II2, class _OO1>33 template <class _InIter3, class _InIter4, class _OutIter2>
34 requires convertible_to<const _I1&, _II1> && convertible_to<const _I2&, _II2> && convertible_to<const _O1&, _OO1>34 requires convertible_to<const _InIter1&, _InIter3>
35 && convertible_to<const _InIter2&, _InIter4> && convertible_to<const _OutIter1&, _OutIter2>
35 _LIBCPP_HIDE_FROM_ABI constexpr36 _LIBCPP_HIDE_FROM_ABI constexpr
36 operator in_in_out_result<_II1, _II2, _OO1>() const& {37 operator in_in_out_result<_InIter3, _InIter4, _OutIter2>() const& {
37 return {in1, in2, out};38 return {in1, in2, out};
38 }39 }
3940
40 template <class _II1, class _II2, class _OO1>41 template <class _InIter3, class _InIter4, class _OutIter2>
41 requires convertible_to<_I1, _II1> && convertible_to<_I2, _II2> && convertible_to<_O1, _OO1>42 requires convertible_to<_InIter1, _InIter3>
43 && convertible_to<_InIter2, _InIter4> && convertible_to<_OutIter1, _OutIter2>
42 _LIBCPP_HIDE_FROM_ABI constexpr44 _LIBCPP_HIDE_FROM_ABI constexpr
43 operator in_in_out_result<_II1, _II2, _OO1>() && {45 operator in_in_out_result<_InIter3, _InIter4, _OutIter2>() && {
44 return {_VSTD::move(in1), _VSTD::move(in2), _VSTD::move(out)};46 return {std::move(in1), std::move(in2), std::move(out)};
45 }47 }
46};48};
4749
48} // namespace ranges50} // namespace ranges
4951
50#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)52#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
5153
52_LIBCPP_END_NAMESPACE_STD54_LIBCPP_END_NAMESPACE_STD
5355
lib/libcxx/include/__algorithm/in_in_result.h+14-12
...@@ -15,36 +15,38 @@...@@ -15,36 +15,38 @@
15#include <__utility/move.h>15#include <__utility/move.h>
1616
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header18# pragma GCC system_header
19#endif19#endif
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
23#if !defined(_LIBCPP_HAS_NO_CONCEPTS)23#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
2424
25namespace ranges {25namespace ranges {
2626
27template <class _I1, class _I2>27template <class _InIter1, class _InIter2>
28struct in_in_result {28struct in_in_result {
29 [[no_unique_address]] _I1 in1;29 _LIBCPP_NO_UNIQUE_ADDRESS _InIter1 in1;
30 [[no_unique_address]] _I2 in2;30 _LIBCPP_NO_UNIQUE_ADDRESS _InIter2 in2;
3131
32 template <class _II1, class _II2>32 template <class _InIter3, class _InIter4>
33 requires convertible_to<const _I1&, _II1> && convertible_to<const _I2&, _II2>33 requires convertible_to<const _InIter1&, _InIter3> && convertible_to<const _InIter2&, _InIter4>
34 _LIBCPP_HIDE_FROM_ABI constexpr34 _LIBCPP_HIDE_FROM_ABI constexpr
35 operator in_in_result<_II1, _II2>() const & {35 operator in_in_result<_InIter3, _InIter4>() const & {
36 return {in1, in2};36 return {in1, in2};
37 }37 }
3838
39 template <class _II1, class _II2>39 template <class _InIter3, class _InIter4>
40 requires convertible_to<_I1, _II1> && convertible_to<_I2, _II2>40 requires convertible_to<_InIter1, _InIter3> && convertible_to<_InIter2, _InIter4>
41 _LIBCPP_HIDE_FROM_ABI constexpr41 _LIBCPP_HIDE_FROM_ABI constexpr
42 operator in_in_result<_II1, _II2>() && { return {_VSTD::move(in1), _VSTD::move(in2)}; }42 operator in_in_result<_InIter3, _InIter4>() && {
43 return {std::move(in1), std::move(in2)};
44 }
43};45};
4446
45} // namespace ranges47} // namespace ranges
4648
47#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)49#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
4850
49_LIBCPP_END_NAMESPACE_STD51_LIBCPP_END_NAMESPACE_STD
5052
lib/libcxx/include/__algorithm/in_out_out_result.h created+54
...@@ -0,0 +1,54 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___ALGORITHM_IN_OUT_OUT_RESULT_H
11#define _LIBCPP___ALGORITHM_IN_OUT_OUT_RESULT_H
12
13#include <__concepts/convertible_to.h>
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_BEGIN_NAMESPACE_STD
22
23#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
24
25namespace ranges {
26template <class _InIter1, class _OutIter1, class _OutIter2>
27struct in_out_out_result {
28 _LIBCPP_NO_UNIQUE_ADDRESS _InIter1 in;
29 _LIBCPP_NO_UNIQUE_ADDRESS _OutIter1 out1;
30 _LIBCPP_NO_UNIQUE_ADDRESS _OutIter2 out2;
31
32 template <class _InIter2, class _OutIter3, class _OutIter4>
33 requires convertible_to<const _InIter1&, _InIter2>
34 && convertible_to<const _OutIter1&, _OutIter3> && convertible_to<const _OutIter2&, _OutIter4>
35 _LIBCPP_HIDE_FROM_ABI constexpr
36 operator in_out_out_result<_InIter2, _OutIter3, _OutIter4>() const& {
37 return {in, out1, out2};
38 }
39
40 template <class _InIter2, class _OutIter3, class _OutIter4>
41 requires convertible_to<_InIter1, _InIter2>
42 && convertible_to<_OutIter1, _OutIter3> && convertible_to<_OutIter2, _OutIter4>
43 _LIBCPP_HIDE_FROM_ABI constexpr
44 operator in_out_out_result<_InIter2, _OutIter3, _OutIter4>() && {
45 return {std::move(in), std::move(out1), std::move(out2)};
46 }
47};
48} // namespace ranges
49
50#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
51
52_LIBCPP_END_NAMESPACE_STD
53
54#endif // _LIBCPP___ALGORITHM_IN_OUT_OUT_RESULT_H
lib/libcxx/include/__algorithm/in_out_result.h+13-14
...@@ -15,39 +15,38 @@...@@ -15,39 +15,38 @@
15#include <__utility/move.h>15#include <__utility/move.h>
1616
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header18# pragma GCC system_header
19#endif19#endif
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
23#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)23#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
2424
25namespace ranges {25namespace ranges {
2626
27template<class _InputIterator, class _OutputIterator>27template<class _InIter1, class _OutIter1>
28struct in_out_result {28struct in_out_result {
29 [[no_unique_address]] _InputIterator in;29 _LIBCPP_NO_UNIQUE_ADDRESS _InIter1 in;
30 [[no_unique_address]] _OutputIterator out;30 _LIBCPP_NO_UNIQUE_ADDRESS _OutIter1 out;
3131
32 template <class _InputIterator2, class _OutputIterator2>32 template <class _InIter2, class _OutIter2>
33 requires convertible_to<const _InputIterator&, _InputIterator2> && convertible_to<const _OutputIterator&,33 requires convertible_to<const _InIter1&, _InIter2> && convertible_to<const _OutIter1&, _OutIter2>
34 _OutputIterator2>
35 _LIBCPP_HIDE_FROM_ABI34 _LIBCPP_HIDE_FROM_ABI
36 constexpr operator in_out_result<_InputIterator2, _OutputIterator2>() const & {35 constexpr operator in_out_result<_InIter2, _OutIter2>() const & {
37 return {in, out};36 return {in, out};
38 }37 }
3938
40 template <class _InputIterator2, class _OutputIterator2>39 template <class _InIter2, class _OutIter2>
41 requires convertible_to<_InputIterator, _InputIterator2> && convertible_to<_OutputIterator, _OutputIterator2>40 requires convertible_to<_InIter1, _InIter2> && convertible_to<_OutIter1, _OutIter2>
42 _LIBCPP_HIDE_FROM_ABI41 _LIBCPP_HIDE_FROM_ABI
43 constexpr operator in_out_result<_InputIterator2, _OutputIterator2>() && {42 constexpr operator in_out_result<_InIter2, _OutIter2>() && {
44 return {_VSTD::move(in), _VSTD::move(out)};43 return {std::move(in), std::move(out)};
45 }44 }
46};45};
4746
48} // namespace ranges47} // namespace ranges
4948
50#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)49#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
5150
52_LIBCPP_END_NAMESPACE_STD51_LIBCPP_END_NAMESPACE_STD
5352
lib/libcxx/include/__algorithm/includes.h+39-30
...@@ -12,49 +12,58 @@...@@ -12,49 +12,58 @@
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 <__functional/identity.h>
16#include <__functional/invoke.h>
15#include <__iterator/iterator_traits.h>17#include <__iterator/iterator_traits.h>
18#include <__type_traits/is_callable.h>
19#include <__utility/move.h>
1620
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header22# pragma GCC system_header
19#endif23#endif
2024
21_LIBCPP_BEGIN_NAMESPACE_STD25_LIBCPP_BEGIN_NAMESPACE_STD
2226
23template <class _Compare, class _InputIterator1, class _InputIterator2>27template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Comp, class _Proj1, class _Proj2>
24_LIBCPP_CONSTEXPR_AFTER_CXX17 bool28_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
25__includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2,29__includes(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2,
26 _Compare __comp)30 _Comp&& __comp, _Proj1&& __proj1, _Proj2&& __proj2) {
27{31 for (; __first2 != __last2; ++__first1) {
28 for (; __first2 != __last2; ++__first1)32 if (__first1 == __last1 || std::__invoke(
29 {33 __comp, std::__invoke(__proj2, *__first2), std::__invoke(__proj1, *__first1)))
30 if (__first1 == __last1 || __comp(*__first2, *__first1))34 return false;
31 return false;35 if (!std::__invoke(__comp, std::__invoke(__proj1, *__first1), std::__invoke(__proj2, *__first2)))
32 if (!__comp(*__first1, *__first2))36 ++__first2;
33 ++__first2;37 }
34 }38 return true;
35 return true;
36}39}
3740
38template <class _InputIterator1, class _InputIterator2, class _Compare>41template <class _InputIterator1, class _InputIterator2, class _Compare>
39_LIBCPP_NODISCARD_EXT inline42_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool includes(
40_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1743 _InputIterator1 __first1,
41bool44 _InputIterator1 __last1,
42includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2,45 _InputIterator2 __first2,
43 _Compare __comp)46 _InputIterator2 __last2,
44{47 _Compare __comp) {
45 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;48 static_assert(__is_callable<_Compare, decltype(*__first1), decltype(*__first2)>::value,
46 return _VSTD::__includes<_Comp_ref>(__first1, __last1, __first2, __last2, __comp);49 "Comparator has to be callable");
50
51 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
52 return std::__includes(
53 std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2),
54 static_cast<_Comp_ref>(__comp), __identity(), __identity());
47}55}
4856
49template <class _InputIterator1, class _InputIterator2>57template <class _InputIterator1, class _InputIterator2>
50_LIBCPP_NODISCARD_EXT inline58_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
51_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1759includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) {
52bool60 return std::includes(
53includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2)61 std::move(__first1),
54{62 std::move(__last1),
55 return _VSTD::includes(__first1, __last1, __first2, __last2,63 std::move(__first2),
56 __less<typename iterator_traits<_InputIterator1>::value_type,64 std::move(__last2),
57 typename iterator_traits<_InputIterator2>::value_type>());65 __less<typename iterator_traits<_InputIterator1>::value_type,
66 typename iterator_traits<_InputIterator2>::value_type>());
58}67}
5968
60_LIBCPP_END_NAMESPACE_STD69_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/inplace_merge.h+77-54
...@@ -9,20 +9,25 @@...@@ -9,20 +9,25 @@
9#ifndef _LIBCPP___ALGORITHM_INPLACE_MERGE_H9#ifndef _LIBCPP___ALGORITHM_INPLACE_MERGE_H
10#define _LIBCPP___ALGORITHM_INPLACE_MERGE_H10#define _LIBCPP___ALGORITHM_INPLACE_MERGE_H
1111
12#include <__algorithm/algorithm_family.h>
12#include <__algorithm/comp.h>13#include <__algorithm/comp.h>
13#include <__algorithm/comp_ref_type.h>14#include <__algorithm/comp_ref_type.h>
15#include <__algorithm/iterator_operations.h>
14#include <__algorithm/lower_bound.h>16#include <__algorithm/lower_bound.h>
15#include <__algorithm/min.h>17#include <__algorithm/min.h>
16#include <__algorithm/move.h>18#include <__algorithm/move.h>
17#include <__algorithm/rotate.h>19#include <__algorithm/rotate.h>
18#include <__algorithm/upper_bound.h>20#include <__algorithm/upper_bound.h>
19#include <__config>21#include <__config>
22#include <__functional/identity.h>
23#include <__iterator/advance.h>
24#include <__iterator/distance.h>
20#include <__iterator/iterator_traits.h>25#include <__iterator/iterator_traits.h>
21#include <__utility/swap.h>26#include <__iterator/reverse_iterator.h>
22#include <memory>27#include <memory>
2328
24#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)29#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
25#pragma GCC system_header30# pragma GCC system_header
26#endif31#endif
2732
28_LIBCPP_PUSH_MACROS33_LIBCPP_PUSH_MACROS
...@@ -50,72 +55,79 @@ public:...@@ -50,72 +55,79 @@ public:
50 bool operator()(const _T1& __x, const _T2& __y) {return __p_(__y, __x);}55 bool operator()(const _T1& __x, const _T2& __y) {return __p_(__y, __x);}
51};56};
5257
53template <class _Compare, class _InputIterator1, class _InputIterator2,58template <class _AlgPolicy, class _Compare, class _InputIterator1, class _Sent1,
54 class _OutputIterator>59 class _InputIterator2, class _Sent2, class _OutputIterator>
55void __half_inplace_merge(_InputIterator1 __first1, _InputIterator1 __last1,60void __half_inplace_merge(_InputIterator1 __first1, _Sent1 __last1,
56 _InputIterator2 __first2, _InputIterator2 __last2,61 _InputIterator2 __first2, _Sent2 __last2,
57 _OutputIterator __result, _Compare __comp)62 _OutputIterator __result, _Compare&& __comp)
58{63{
59 for (; __first1 != __last1; ++__result)64 for (; __first1 != __last1; ++__result)
60 {65 {
61 if (__first2 == __last2)66 if (__first2 == __last2)
62 {67 {
63 _VSTD::move(__first1, __last1, __result);68 _AlgFamily<_AlgPolicy>::__move(__first1, __last1, __result);
64 return;69 return;
65 }70 }
6671
67 if (__comp(*__first2, *__first1))72 if (__comp(*__first2, *__first1))
68 {73 {
69 *__result = _VSTD::move(*__first2);74 *__result = _IterOps<_AlgPolicy>::__iter_move(__first2);
70 ++__first2;75 ++__first2;
71 }76 }
72 else77 else
73 {78 {
74 *__result = _VSTD::move(*__first1);79 *__result = _IterOps<_AlgPolicy>::__iter_move(__first1);
75 ++__first1;80 ++__first1;
76 }81 }
77 }82 }
78 // __first2 through __last2 are already in the right spot.83 // __first2 through __last2 are already in the right spot.
79}84}
8085
81template <class _Compare, class _BidirectionalIterator>86template <class _AlgPolicy, class _Compare, class _BidirectionalIterator>
82void87void __buffered_inplace_merge(
83__buffered_inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last,88 _BidirectionalIterator __first,
84 _Compare __comp, typename iterator_traits<_BidirectionalIterator>::difference_type __len1,89 _BidirectionalIterator __middle,
85 typename iterator_traits<_BidirectionalIterator>::difference_type __len2,90 _BidirectionalIterator __last,
86 typename iterator_traits<_BidirectionalIterator>::value_type* __buff)91 _Compare&& __comp,
87{92 typename iterator_traits<_BidirectionalIterator>::difference_type __len1,
88 typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;93 typename iterator_traits<_BidirectionalIterator>::difference_type __len2,
94 typename iterator_traits<_BidirectionalIterator>::value_type* __buff) {
95 typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
89 __destruct_n __d(0);96 __destruct_n __d(0);
90 unique_ptr<value_type, __destruct_n&> __h2(__buff, __d);97 unique_ptr<value_type, __destruct_n&> __h2(__buff, __d);
91 if (__len1 <= __len2)98 if (__len1 <= __len2)
92 {99 {
93 value_type* __p = __buff;100 value_type* __p = __buff;
94 for (_BidirectionalIterator __i = __first; __i != __middle; __d.template __incr<value_type>(), (void) ++__i, (void) ++__p)101 for (_BidirectionalIterator __i = __first; __i != __middle; __d.template __incr<value_type>(), (void) ++__i, (void) ++__p)
95 ::new ((void*)__p) value_type(_VSTD::move(*__i));102 ::new ((void*)__p) value_type(_IterOps<_AlgPolicy>::__iter_move(__i));
96 _VSTD::__half_inplace_merge<_Compare>(__buff, __p, __middle, __last, __first, __comp);103 std::__half_inplace_merge<_AlgPolicy>(__buff, __p, __middle, __last, __first, __comp);
97 }104 }
98 else105 else
99 {106 {
100 value_type* __p = __buff;107 value_type* __p = __buff;
101 for (_BidirectionalIterator __i = __middle; __i != __last; __d.template __incr<value_type>(), (void) ++__i, (void) ++__p)108 for (_BidirectionalIterator __i = __middle; __i != __last; __d.template __incr<value_type>(), (void) ++__i, (void) ++__p)
102 ::new ((void*)__p) value_type(_VSTD::move(*__i));109 ::new ((void*)__p) value_type(_IterOps<_AlgPolicy>::__iter_move(__i));
103 typedef reverse_iterator<_BidirectionalIterator> _RBi;110 typedef __unconstrained_reverse_iterator<_BidirectionalIterator> _RBi;
104 typedef reverse_iterator<value_type*> _Rv;111 typedef __unconstrained_reverse_iterator<value_type*> _Rv;
105 typedef __invert<_Compare> _Inverted;112 typedef __invert<_Compare> _Inverted;
106 _VSTD::__half_inplace_merge<_Inverted>(_Rv(__p), _Rv(__buff),113 std::__half_inplace_merge<_AlgPolicy>(_Rv(__p), _Rv(__buff),
107 _RBi(__middle), _RBi(__first),114 _RBi(__middle), _RBi(__first),
108 _RBi(__last), _Inverted(__comp));115 _RBi(__last), _Inverted(__comp));
109 }116 }
110}117}
111118
112template <class _Compare, class _BidirectionalIterator>119template <class _AlgPolicy, class _Compare, class _BidirectionalIterator>
113void120void __inplace_merge(
114__inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last,121 _BidirectionalIterator __first,
115 _Compare __comp, typename iterator_traits<_BidirectionalIterator>::difference_type __len1,122 _BidirectionalIterator __middle,
116 typename iterator_traits<_BidirectionalIterator>::difference_type __len2,123 _BidirectionalIterator __last,
117 typename iterator_traits<_BidirectionalIterator>::value_type* __buff, ptrdiff_t __buff_size)124 _Compare&& __comp,
118{125 typename iterator_traits<_BidirectionalIterator>::difference_type __len1,
126 typename iterator_traits<_BidirectionalIterator>::difference_type __len2,
127 typename iterator_traits<_BidirectionalIterator>::value_type* __buff,
128 ptrdiff_t __buff_size) {
129 using _Ops = _IterOps<_AlgPolicy>;
130
119 typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type;131 typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type;
120 while (true)132 while (true)
121 {133 {
...@@ -123,7 +135,7 @@ __inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle,...@@ -123,7 +135,7 @@ __inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle,
123 if (__len2 == 0)135 if (__len2 == 0)
124 return;136 return;
125 if (__len1 <= __buff_size || __len2 <= __buff_size)137 if (__len1 <= __buff_size || __len2 <= __buff_size)
126 return _VSTD::__buffered_inplace_merge<_Compare>138 return std::__buffered_inplace_merge<_AlgPolicy>
127 (__first, __middle, __last, __comp, __len1, __len2, __buff);139 (__first, __middle, __last, __comp, __len1, __len2, __buff);
128 // shrink [__first, __middle) as much as possible (with no moves), returning if it shrinks to 0140 // shrink [__first, __middle) as much as possible (with no moves), returning if it shrinks to 0
129 for (; true; ++__first, (void) --__len1)141 for (; true; ++__first, (void) --__len1)
...@@ -150,36 +162,37 @@ __inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle,...@@ -150,36 +162,37 @@ __inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle,
150 { // __len >= 1, __len2 >= 2162 { // __len >= 1, __len2 >= 2
151 __len21 = __len2 / 2;163 __len21 = __len2 / 2;
152 __m2 = __middle;164 __m2 = __middle;
153 _VSTD::advance(__m2, __len21);165 _Ops::advance(__m2, __len21);
154 __m1 = _VSTD::__upper_bound<_Compare>(__first, __middle, *__m2, __comp);166 __m1 = std::__upper_bound<_AlgPolicy>(__first, __middle, *__m2, __comp, std::__identity());
155 __len11 = _VSTD::distance(__first, __m1);167 __len11 = _Ops::distance(__first, __m1);
156 }168 }
157 else169 else
158 {170 {
159 if (__len1 == 1)171 if (__len1 == 1)
160 { // __len1 >= __len2 && __len2 > 0, therefore __len2 == 1172 { // __len1 >= __len2 && __len2 > 0, therefore __len2 == 1
161 // It is known *__first > *__middle173 // It is known *__first > *__middle
162 swap(*__first, *__middle);174 _Ops::iter_swap(__first, __middle);
163 return;175 return;
164 }176 }
165 // __len1 >= 2, __len2 >= 1177 // __len1 >= 2, __len2 >= 1
166 __len11 = __len1 / 2;178 __len11 = __len1 / 2;
167 __m1 = __first;179 __m1 = __first;
168 _VSTD::advance(__m1, __len11);180 _Ops::advance(__m1, __len11);
169 __m2 = _VSTD::__lower_bound<_Compare>(__middle, __last, *__m1, __comp);181 __m2 = std::lower_bound(__middle, __last, *__m1, __comp);
170 __len21 = _VSTD::distance(__middle, __m2);182 __len21 = _Ops::distance(__middle, __m2);
171 }183 }
172 difference_type __len12 = __len1 - __len11; // distance(__m1, __middle)184 difference_type __len12 = __len1 - __len11; // distance(__m1, __middle)
173 difference_type __len22 = __len2 - __len21; // distance(__m2, __last)185 difference_type __len22 = __len2 - __len21; // distance(__m2, __last)
174 // [__first, __m1) [__m1, __middle) [__middle, __m2) [__m2, __last)186 // [__first, __m1) [__m1, __middle) [__middle, __m2) [__m2, __last)
175 // swap middle two partitions187 // swap middle two partitions
188 // TODO(alg-policy): pass `_AlgPolicy` once it's supported by `rotate`.
176 __middle = _VSTD::rotate(__m1, __middle, __m2);189 __middle = _VSTD::rotate(__m1, __middle, __m2);
177 // __len12 and __len21 now have swapped meanings190 // __len12 and __len21 now have swapped meanings
178 // merge smaller range with recursive call and larger with tail recursion elimination191 // merge smaller range with recursive call and larger with tail recursion elimination
179 if (__len11 + __len21 < __len12 + __len22)192 if (__len11 + __len21 < __len12 + __len22)
180 {193 {
181 _VSTD::__inplace_merge<_Compare>(__first, __m1, __middle, __comp, __len11, __len21, __buff, __buff_size);194 std::__inplace_merge<_AlgPolicy>(
182// _VSTD::__inplace_merge<_Compare>(__middle, __m2, __last, __comp, __len12, __len22, __buff, __buff_size);195 __first, __m1, __middle, __comp, __len11, __len21, __buff, __buff_size);
183 __first = __middle;196 __first = __middle;
184 __middle = __m2;197 __middle = __m2;
185 __len1 = __len12;198 __len1 = __len12;
...@@ -187,8 +200,8 @@ __inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle,...@@ -187,8 +200,8 @@ __inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle,
187 }200 }
188 else201 else
189 {202 {
190 _VSTD::__inplace_merge<_Compare>(__middle, __m2, __last, __comp, __len12, __len22, __buff, __buff_size);203 std::__inplace_merge<_AlgPolicy>(
191// _VSTD::__inplace_merge<_Compare>(__first, __m1, __middle, __comp, __len11, __len21, __buff, __buff_size);204 __middle, __m2, __last, __comp, __len12, __len22, __buff, __buff_size);
192 __last = __middle;205 __last = __middle;
193 __middle = __m1;206 __middle = __m1;
194 __len1 = __len11;207 __len1 = __len11;
...@@ -197,30 +210,40 @@ __inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle,...@@ -197,30 +210,40 @@ __inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle,
197 }210 }
198}211}
199212
200template <class _BidirectionalIterator, class _Compare>213template <class _AlgPolicy, class _BidirectionalIterator, class _Compare>
201inline _LIBCPP_INLINE_VISIBILITY214_LIBCPP_HIDE_FROM_ABI
202void215void
203inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last,216__inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last,
204 _Compare __comp)217 _Compare&& __comp)
205{218{
206 typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;219 typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
207 typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type;220 typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type;
208 difference_type __len1 = _VSTD::distance(__first, __middle);221 difference_type __len1 = _IterOps<_AlgPolicy>::distance(__first, __middle);
209 difference_type __len2 = _VSTD::distance(__middle, __last);222 difference_type __len2 = _IterOps<_AlgPolicy>::distance(__middle, __last);
210 difference_type __buf_size = _VSTD::min(__len1, __len2);223 difference_type __buf_size = _VSTD::min(__len1, __len2);
224// TODO: Remove the use of std::get_temporary_buffer
225_LIBCPP_SUPPRESS_DEPRECATED_PUSH
211 pair<value_type*, ptrdiff_t> __buf = _VSTD::get_temporary_buffer<value_type>(__buf_size);226 pair<value_type*, ptrdiff_t> __buf = _VSTD::get_temporary_buffer<value_type>(__buf_size);
227_LIBCPP_SUPPRESS_DEPRECATED_POP
212 unique_ptr<value_type, __return_temporary_buffer> __h(__buf.first);228 unique_ptr<value_type, __return_temporary_buffer> __h(__buf.first);
213 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;229 return std::__inplace_merge<_AlgPolicy>(
214 return _VSTD::__inplace_merge<_Comp_ref>(__first, __middle, __last, __comp, __len1, __len2,230 std::move(__first), std::move(__middle), std::move(__last), __comp, __len1, __len2, __buf.first, __buf.second);
215 __buf.first, __buf.second);231}
232
233template <class _BidirectionalIterator, class _Compare>
234inline _LIBCPP_HIDE_FROM_ABI void inplace_merge(
235 _BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last, _Compare __comp) {
236 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
237 std::__inplace_merge<_ClassicAlgPolicy>(
238 std::move(__first), std::move(__middle), std::move(__last), static_cast<_Comp_ref>(__comp));
216}239}
217240
218template <class _BidirectionalIterator>241template <class _BidirectionalIterator>
219inline _LIBCPP_INLINE_VISIBILITY242inline _LIBCPP_HIDE_FROM_ABI
220void243void
221inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last)244inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last)
222{245{
223 _VSTD::inplace_merge(__first, __middle, __last,246 std::inplace_merge(std::move(__first), std::move(__middle), std::move(__last),
224 __less<typename iterator_traits<_BidirectionalIterator>::value_type>());247 __less<typename iterator_traits<_BidirectionalIterator>::value_type>());
225}248}
226249
lib/libcxx/include/__algorithm/is_heap.h+2-2
...@@ -16,7 +16,7 @@...@@ -16,7 +16,7 @@
16#include <__iterator/iterator_traits.h>16#include <__iterator/iterator_traits.h>
1717
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19#pragma GCC system_header19# pragma GCC system_header
20#endif20#endif
2121
22_LIBCPP_BEGIN_NAMESPACE_STD22_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -28,7 +28,7 @@ bool...@@ -28,7 +28,7 @@ bool
28is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)28is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
29{29{
30 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;30 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
31 return _VSTD::__is_heap_until<_Comp_ref>(__first, __last, __comp) == __last;31 return std::__is_heap_until(__first, __last, static_cast<_Comp_ref>(__comp)) == __last;
32}32}
3333
34template<class _RandomAccessIterator>34template<class _RandomAccessIterator>
lib/libcxx/include/__algorithm/is_heap_until.h+3-3
...@@ -15,14 +15,14 @@...@@ -15,14 +15,14 @@
15#include <__iterator/iterator_traits.h>15#include <__iterator/iterator_traits.h>
1616
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header18# pragma GCC system_header
19#endif19#endif
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
23template <class _Compare, class _RandomAccessIterator>23template <class _Compare, class _RandomAccessIterator>
24_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator24_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator
25__is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)25__is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare&& __comp)
26{26{
27 typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;27 typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
28 difference_type __len = __last - __first;28 difference_type __len = __last - __first;
...@@ -52,7 +52,7 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17...@@ -52,7 +52,7 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
52is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)52is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
53{53{
54 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;54 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
55 return _VSTD::__is_heap_until<_Comp_ref>(__first, __last, __comp);55 return std::__is_heap_until(__first, __last, static_cast<_Comp_ref>(__comp));
56}56}
5757
58template<class _RandomAccessIterator>58template<class _RandomAccessIterator>
lib/libcxx/include/__algorithm/is_partitioned.h+1-1
...@@ -12,7 +12,7 @@...@@ -12,7 +12,7 @@
12#include <__config>12#include <__config>
1313
14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
15#pragma GCC system_header15# pragma GCC system_header
16#endif16#endif
1717
18_LIBCPP_BEGIN_NAMESPACE_STD18_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/is_permutation.h+1-1
...@@ -17,7 +17,7 @@...@@ -17,7 +17,7 @@
17#include <__iterator/next.h>17#include <__iterator/next.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
21#endif21#endif
2222
23_LIBCPP_BEGIN_NAMESPACE_STD23_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/is_sorted.h+1-1
...@@ -16,7 +16,7 @@...@@ -16,7 +16,7 @@
16#include <__iterator/iterator_traits.h>16#include <__iterator/iterator_traits.h>
1717
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19#pragma GCC system_header19# pragma GCC system_header
20#endif20#endif
2121
22_LIBCPP_BEGIN_NAMESPACE_STD22_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/is_sorted_until.h+1-1
...@@ -15,7 +15,7 @@...@@ -15,7 +15,7 @@
15#include <__iterator/iterator_traits.h>15#include <__iterator/iterator_traits.h>
1616
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header18# pragma GCC system_header
19#endif19#endif
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/iter_swap.h+1-1
...@@ -14,7 +14,7 @@...@@ -14,7 +14,7 @@
14#include <__utility/swap.h>14#include <__utility/swap.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
18#endif18#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/iterator_operations.h created+148
...@@ -0,0 +1,148 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_ITERATOR_OPERATIONS_H
10#define _LIBCPP___ALGORITHM_ITERATOR_OPERATIONS_H
11
12#include <__algorithm/iter_swap.h>
13#include <__config>
14#include <__iterator/advance.h>
15#include <__iterator/distance.h>
16#include <__iterator/iter_move.h>
17#include <__iterator/iter_swap.h>
18#include <__iterator/iterator_traits.h>
19#include <__iterator/next.h>
20#include <__iterator/readable_traits.h>
21#include <__utility/declval.h>
22#include <__utility/forward.h>
23#include <__utility/move.h>
24#include <type_traits>
25
26#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
27# pragma GCC system_header
28#endif
29
30_LIBCPP_BEGIN_NAMESPACE_STD
31
32template <class _AlgPolicy> struct _IterOps;
33
34#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
35struct _RangeAlgPolicy {};
36
37template <>
38struct _IterOps<_RangeAlgPolicy> {
39
40 template <class _Iter>
41 using __value_type = iter_value_t<_Iter>;
42
43 static constexpr auto advance = ranges::advance;
44 static constexpr auto distance = ranges::distance;
45 static constexpr auto __iter_move = ranges::iter_move;
46 static constexpr auto iter_swap = ranges::iter_swap;
47 static constexpr auto next = ranges::next;
48 static constexpr auto __advance_to = ranges::advance;
49};
50
51#endif
52
53struct _ClassicAlgPolicy {};
54
55template <>
56struct _IterOps<_ClassicAlgPolicy> {
57
58 template <class _Iter>
59 using __value_type = typename iterator_traits<_Iter>::value_type;
60
61 // advance
62 template <class _Iter, class _Distance>
63 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
64 static void advance(_Iter& __iter, _Distance __count) {
65 std::advance(__iter, __count);
66 }
67
68 // distance
69 template <class _Iter>
70 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
71 static typename iterator_traits<_Iter>::difference_type distance(_Iter __first, _Iter __last) {
72 return std::distance(__first, __last);
73 }
74
75 template <class _Iter>
76 using __deref_t = decltype(*std::declval<_Iter&>());
77
78 template <class _Iter>
79 using __move_t = decltype(std::move(*std::declval<_Iter&>()));
80
81 template <class _Iter>
82 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
83 static void __validate_iter_reference() {
84 static_assert(is_same<__deref_t<_Iter>, typename iterator_traits<__uncvref_t<_Iter> >::reference>::value,
85 "It looks like your iterator's `iterator_traits<It>::reference` does not match the return type of "
86 "dereferencing the iterator, i.e., calling `*it`. This is undefined behavior according to [input.iterators] "
87 "and can lead to dangling reference issues at runtime, so we are flagging this.");
88 }
89
90 // iter_move
91 template <class _Iter>
92 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 static
93 // If the result of dereferencing `_Iter` is a reference type, deduce the result of calling `std::move` on it. Note
94 // that the C++03 mode doesn't support `decltype(auto)` as the return type.
95 __enable_if_t<
96 is_reference<__deref_t<_Iter> >::value,
97 __move_t<_Iter> >
98 __iter_move(_Iter&& __i) {
99 __validate_iter_reference<_Iter>();
100
101 return std::move(*std::forward<_Iter>(__i));
102 }
103
104 template <class _Iter>
105 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 static
106 // If the result of dereferencing `_Iter` is a value type, deduce the return value of this function to also be a
107 // value -- otherwise, after `operator*` returns a temporary, this function would return a dangling reference to that
108 // temporary. Note that the C++03 mode doesn't support `auto` as the return type.
109 __enable_if_t<
110 !is_reference<__deref_t<_Iter> >::value,
111 __deref_t<_Iter> >
112 __iter_move(_Iter&& __i) {
113 __validate_iter_reference<_Iter>();
114
115 return *std::forward<_Iter>(__i);
116 }
117
118 // iter_swap
119 template <class _Iter1, class _Iter2>
120 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
121 static void iter_swap(_Iter1&& __a, _Iter2&& __b) {
122 std::iter_swap(std::forward<_Iter1>(__a), std::forward<_Iter2>(__b));
123 }
124
125 // next
126 template <class _Iterator>
127 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_AFTER_CXX11
128 _Iterator next(_Iterator, _Iterator __last) {
129 return __last;
130 }
131
132 template <class _Iter>
133 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_AFTER_CXX11
134 __uncvref_t<_Iter> next(_Iter&& __it,
135 typename iterator_traits<__uncvref_t<_Iter> >::difference_type __n = 1){
136 return std::next(std::forward<_Iter>(__it), __n);
137 }
138
139 template <class _Iter>
140 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_AFTER_CXX11
141 void __advance_to(_Iter& __first, _Iter __last) {
142 __first = __last;
143 }
144};
145
146_LIBCPP_END_NAMESPACE_STD
147
148#endif // _LIBCPP___ALGORITHM_ITERATOR_OPERATIONS_H
lib/libcxx/include/__algorithm/lexicographical_compare.h+1-1
...@@ -15,7 +15,7 @@...@@ -15,7 +15,7 @@
15#include <__iterator/iterator_traits.h>15#include <__iterator/iterator_traits.h>
1616
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header18# pragma GCC system_header
19#endif19#endif
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/lower_bound.h+36-34
...@@ -11,54 +11,56 @@...@@ -11,54 +11,56 @@
1111
12#include <__algorithm/comp.h>12#include <__algorithm/comp.h>
13#include <__algorithm/half_positive.h>13#include <__algorithm/half_positive.h>
14#include <__algorithm/iterator_operations.h>
14#include <__config>15#include <__config>
15#include <iterator>16#include <__functional/identity.h>
17#include <__functional/invoke.h>
18#include <__iterator/advance.h>
19#include <__iterator/distance.h>
20#include <__iterator/iterator_traits.h>
21#include <__type_traits/is_callable.h>
22#include <__type_traits/remove_reference.h>
23#include <type_traits>
1624
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)25#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header26# pragma GCC system_header
19#endif27#endif
2028
21_LIBCPP_BEGIN_NAMESPACE_STD29_LIBCPP_BEGIN_NAMESPACE_STD
2230
23template <class _Compare, class _ForwardIterator, class _Tp>31template <class _AlgPolicy, class _Iter, class _Sent, class _Type, class _Proj, class _Comp>
24_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator32_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
25__lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)33_Iter __lower_bound_impl(_Iter __first, _Sent __last, const _Type& __value, _Comp& __comp, _Proj& __proj) {
26{34 auto __len = _IterOps<_AlgPolicy>::distance(__first, __last);
27 typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type;35
28 difference_type __len = _VSTD::distance(__first, __last);36 while (__len != 0) {
29 while (__len != 0)37 auto __l2 = std::__half_positive(__len);
30 {38 _Iter __m = __first;
31 difference_type __l2 = _VSTD::__half_positive(__len);39 _IterOps<_AlgPolicy>::advance(__m, __l2);
32 _ForwardIterator __m = __first;40 if (std::__invoke(__comp, std::__invoke(__proj, *__m), __value)) {
33 _VSTD::advance(__m, __l2);41 __first = ++__m;
34 if (__comp(*__m, __value_))42 __len -= __l2 + 1;
35 {43 } else {
36 __first = ++__m;44 __len = __l2;
37 __len -= __l2 + 1;
38 }
39 else
40 __len = __l2;
41 }45 }
42 return __first;46 }
47 return __first;
43}48}
4449
45template <class _ForwardIterator, class _Tp, class _Compare>50template <class _ForwardIterator, class _Tp, class _Compare>
46_LIBCPP_NODISCARD_EXT inline51_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
47_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1752_ForwardIterator lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) {
48_ForwardIterator53 static_assert(__is_callable<_Compare, decltype(*__first), const _Tp&>::value,
49lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)54 "The comparator has to be callable");
50{55 auto __proj = std::__identity();
51 return _VSTD::__lower_bound<_Compare&>(__first, __last, __value_, __comp);56 return std::__lower_bound_impl<_ClassicAlgPolicy>(__first, __last, __value, __comp, __proj);
52}57}
5358
54template <class _ForwardIterator, class _Tp>59template <class _ForwardIterator, class _Tp>
55_LIBCPP_NODISCARD_EXT inline60_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
56_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1761_ForwardIterator lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {
57_ForwardIterator62 return std::lower_bound(__first, __last, __value,
58lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)63 __less<typename iterator_traits<_ForwardIterator>::value_type, _Tp>());
59{
60 return _VSTD::lower_bound(__first, __last, __value_,
61 __less<typename iterator_traits<_ForwardIterator>::value_type, _Tp>());
62}64}
6365
64_LIBCPP_END_NAMESPACE_STD66_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/make_heap.h+23-25
...@@ -11,47 +11,45 @@...@@ -11,47 +11,45 @@
1111
12#include <__algorithm/comp.h>12#include <__algorithm/comp.h>
13#include <__algorithm/comp_ref_type.h>13#include <__algorithm/comp_ref_type.h>
14#include <__algorithm/iterator_operations.h>
14#include <__algorithm/sift_down.h>15#include <__algorithm/sift_down.h>
15#include <__config>16#include <__config>
16#include <__iterator/iterator_traits.h>17#include <__iterator/iterator_traits.h>
18#include <__utility/move.h>
1719
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19#pragma GCC system_header21# pragma GCC system_header
20#endif22#endif
2123
22_LIBCPP_BEGIN_NAMESPACE_STD24_LIBCPP_BEGIN_NAMESPACE_STD
2325
24template <class _Compare, class _RandomAccessIterator>26template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
25_LIBCPP_CONSTEXPR_AFTER_CXX11 void27inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
26__make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)28void __make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare&& __comp) {
27{29 using _CompRef = typename __comp_ref_type<_Compare>::type;
28 typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;30 _CompRef __comp_ref = __comp;
29 difference_type __n = __last - __first;31
30 if (__n > 1)32 using difference_type = typename iterator_traits<_RandomAccessIterator>::difference_type;
31 {33 difference_type __n = __last - __first;
32 // start from the first parent, there is no need to consider children34 if (__n > 1) {
33 for (difference_type __start = (__n - 2) / 2; __start >= 0; --__start)35 // start from the first parent, there is no need to consider children
34 {36 for (difference_type __start = (__n - 2) / 2; __start >= 0; --__start) {
35 _VSTD::__sift_down<_Compare>(__first, __comp, __n, __first + __start);37 std::__sift_down<_AlgPolicy>(__first, __comp_ref, __n, __first + __start);
36 }
37 }38 }
39 }
38}40}
3941
40template <class _RandomAccessIterator, class _Compare>42template <class _RandomAccessIterator, class _Compare>
41inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1743inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
42void44void make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {
43make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)45 std::__make_heap<_ClassicAlgPolicy>(std::move(__first), std::move(__last), __comp);
44{
45 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
46 _VSTD::__make_heap<_Comp_ref>(__first, __last, __comp);
47}46}
4847
49template <class _RandomAccessIterator>48template <class _RandomAccessIterator>
50inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1749inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
51void50void make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) {
52make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)51 std::make_heap(std::move(__first), std::move(__last),
53{52 __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
54 _VSTD::make_heap(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
55}53}
5654
57_LIBCPP_END_NAMESPACE_STD55_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/make_projected.h created+126
...@@ -0,0 +1,126 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_MAKE_PROJECTED_H
10#define _LIBCPP___ALGORITHM_MAKE_PROJECTED_H
11
12#include <__concepts/same_as.h>
13#include <__config>
14#include <__functional/identity.h>
15#include <__functional/invoke.h>
16#include <__type_traits/decay.h>
17#include <__type_traits/enable_if.h>
18#include <__type_traits/integral_constant.h>
19#include <__type_traits/is_member_pointer.h>
20#include <__type_traits/is_same.h>
21#include <__utility/declval.h>
22#include <__utility/forward.h>
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 _Pred, class _Proj>
31struct _ProjectedPred {
32 _Pred& __pred; // Can be a unary or a binary predicate.
33 _Proj& __proj;
34
35 _LIBCPP_CONSTEXPR _ProjectedPred(_Pred& __pred_arg, _Proj& __proj_arg) : __pred(__pred_arg), __proj(__proj_arg) {}
36
37 template <class _Tp>
38 typename __invoke_of<_Pred&,
39 decltype(std::__invoke(std::declval<_Proj&>(), std::declval<_Tp>()))
40 >::type
41 _LIBCPP_CONSTEXPR operator()(_Tp&& __v) const {
42 return std::__invoke(__pred, std::__invoke(__proj, std::forward<_Tp>(__v)));
43 }
44
45 template <class _T1, class _T2>
46 typename __invoke_of<_Pred&,
47 decltype(std::__invoke(std::declval<_Proj&>(), std::declval<_T1>())),
48 decltype(std::__invoke(std::declval<_Proj&>(), std::declval<_T2>()))
49 >::type
50 _LIBCPP_CONSTEXPR operator()(_T1&& __lhs, _T2&& __rhs) const {
51 return std::__invoke(__pred,
52 std::__invoke(__proj, std::forward<_T1>(__lhs)),
53 std::__invoke(__proj, std::forward<_T2>(__rhs)));
54 }
55
56};
57
58template <class _Pred, class _Proj, class = void>
59struct __can_use_pristine_comp : false_type {};
60
61template <class _Pred, class _Proj>
62struct __can_use_pristine_comp<_Pred, _Proj, __enable_if_t<
63 !is_member_pointer<typename decay<_Pred>::type>::value && (
64#if _LIBCPP_STD_VER > 17
65 is_same<typename decay<_Proj>::type, identity>::value ||
66#endif
67 is_same<typename decay<_Proj>::type, __identity>::value
68 )
69> > : true_type {};
70
71template <class _Pred, class _Proj>
72_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR static
73__enable_if_t<
74 !__can_use_pristine_comp<_Pred, _Proj>::value,
75 _ProjectedPred<_Pred, _Proj>
76>
77__make_projected(_Pred& __pred, _Proj& __proj) {
78 return _ProjectedPred<_Pred, _Proj>(__pred, __proj);
79}
80
81// Avoid creating the functor and just use the pristine comparator -- for certain algorithms, this would enable
82// optimizations that rely on the type of the comparator. Additionally, this results in less layers of indirection in
83// the call stack when the comparator is invoked, even in an unoptimized build.
84template <class _Pred, class _Proj>
85_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR static
86__enable_if_t<
87 __can_use_pristine_comp<_Pred, _Proj>::value,
88 _Pred&
89>
90__make_projected(_Pred& __pred, _Proj&) {
91 return __pred;
92}
93
94_LIBCPP_END_NAMESPACE_STD
95
96#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
97
98_LIBCPP_BEGIN_NAMESPACE_STD
99
100namespace ranges {
101
102template <class _Comp, class _Proj1, class _Proj2>
103_LIBCPP_HIDE_FROM_ABI constexpr static
104decltype(auto) __make_projected_comp(_Comp& __comp, _Proj1& __proj1, _Proj2& __proj2) {
105 if constexpr (same_as<decay_t<_Proj1>, identity> && same_as<decay_t<_Proj2>, identity> &&
106 !is_member_pointer_v<decay_t<_Comp>>) {
107 // Avoid creating the lambda and just use the pristine comparator -- for certain algorithms, this would enable
108 // optimizations that rely on the type of the comparator.
109 return __comp;
110
111 } else {
112 return [&](auto&& __lhs, auto&& __rhs) {
113 return std::invoke(__comp,
114 std::invoke(__proj1, std::forward<decltype(__lhs)>(__lhs)),
115 std::invoke(__proj2, std::forward<decltype(__rhs)>(__rhs)));
116 };
117 }
118}
119
120} // namespace ranges
121
122_LIBCPP_END_NAMESPACE_STD
123
124#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
125
126#endif // _LIBCPP___ALGORITHM_MAKE_PROJECTED_H
lib/libcxx/include/__algorithm/max.h+1-1
...@@ -16,7 +16,7 @@...@@ -16,7 +16,7 @@
16#include <initializer_list>16#include <initializer_list>
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_LIBCPP_PUSH_MACROS22_LIBCPP_PUSH_MACROS
lib/libcxx/include/__algorithm/max_element.h+1-1
...@@ -15,7 +15,7 @@...@@ -15,7 +15,7 @@
15#include <__iterator/iterator_traits.h>15#include <__iterator/iterator_traits.h>
1616
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header18# pragma GCC system_header
19#endif19#endif
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/merge.h+1-1
...@@ -16,7 +16,7 @@...@@ -16,7 +16,7 @@
16#include <__iterator/iterator_traits.h>16#include <__iterator/iterator_traits.h>
1717
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19#pragma GCC system_header19# pragma GCC system_header
20#endif20#endif
2121
22_LIBCPP_BEGIN_NAMESPACE_STD22_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/min.h+1-1
...@@ -16,7 +16,7 @@...@@ -16,7 +16,7 @@
16#include <initializer_list>16#include <initializer_list>
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_LIBCPP_PUSH_MACROS22_LIBCPP_PUSH_MACROS
lib/libcxx/include/__algorithm/min_element.h+30-16
...@@ -12,36 +12,50 @@...@@ -12,36 +12,50 @@
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 <__functional/identity.h>
16#include <__functional/invoke.h>
15#include <__iterator/iterator_traits.h>17#include <__iterator/iterator_traits.h>
18#include <__type_traits/is_callable.h>
19#include <__utility/move.h>
1620
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header22# pragma GCC system_header
19#endif23#endif
2024
21_LIBCPP_BEGIN_NAMESPACE_STD25_LIBCPP_BEGIN_NAMESPACE_STD
2226
23template <class _Compare, class _ForwardIterator>27template <class _Comp, class _Iter, class _Sent, class _Proj>
24inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator28inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
25__min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)29_Iter __min_element(_Iter __first, _Sent __last, _Comp __comp, _Proj& __proj) {
26{30 if (__first == __last)
27 static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value,
28 "std::min_element requires a ForwardIterator");
29 if (__first != __last)
30 {
31 _ForwardIterator __i = __first;
32 while (++__i != __last)
33 if (__comp(*__i, *__first))
34 __first = __i;
35 }
36 return __first;31 return __first;
32
33 _Iter __i = __first;
34 while (++__i != __last)
35 if (std::__invoke(__comp, std::__invoke(__proj, *__i), std::__invoke(__proj, *__first)))
36 __first = __i;
37
38 return __first;
39}
40
41template <class _Comp, class _Iter, class _Sent>
42_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
43_Iter __min_element(_Iter __first, _Sent __last, _Comp __comp) {
44 auto __proj = __identity();
45 return std::__min_element<_Comp>(std::move(__first), std::move(__last), __comp, __proj);
37}46}
3847
39template <class _ForwardIterator, class _Compare>48template <class _ForwardIterator, class _Compare>
40_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator49_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator
41min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)50min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
42{51{
43 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;52 static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value,
44 return _VSTD::__min_element<_Comp_ref>(__first, __last, __comp);53 "std::min_element requires a ForwardIterator");
54 static_assert(__is_callable<_Compare, decltype(*__first), decltype(*__first)>::value,
55 "The comparator has to be callable");
56
57 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
58 return std::__min_element<_Comp_ref>(std::move(__first), std::move(__last), __comp);
45}59}
4660
47template <class _ForwardIterator>61template <class _ForwardIterator>
lib/libcxx/include/__algorithm/min_max_result.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___ALGORITHM_MIN_MAX_RESULT_H
11#define _LIBCPP___ALGORITHM_MIN_MAX_RESULT_H
12
13#include <__concepts/convertible_to.h>
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
26#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
27
28namespace ranges {
29
30template <class _T1>
31struct min_max_result {
32 _LIBCPP_NO_UNIQUE_ADDRESS _T1 min;
33 _LIBCPP_NO_UNIQUE_ADDRESS _T1 max;
34
35 template <class _T2>
36 requires convertible_to<const _T1&, _T2>
37 _LIBCPP_HIDE_FROM_ABI constexpr operator min_max_result<_T2>() const & {
38 return {min, max};
39 }
40
41 template <class _T2>
42 requires convertible_to<_T1, _T2>
43 _LIBCPP_HIDE_FROM_ABI constexpr operator min_max_result<_T2>() && {
44 return {std::move(min), std::move(max)};
45 }
46};
47
48} // namespace ranges
49
50#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
51
52_LIBCPP_END_NAMESPACE_STD
53
54_LIBCPP_POP_MACROS
55
56#endif // _LIBCPP___ALGORITHM_MIN_MAX_RESULT_H
lib/libcxx/include/__algorithm/minmax.h+13-39
...@@ -10,12 +10,15 @@...@@ -10,12 +10,15 @@
10#define _LIBCPP___ALGORITHM_MINMAX_H10#define _LIBCPP___ALGORITHM_MINMAX_H
1111
12#include <__algorithm/comp.h>12#include <__algorithm/comp.h>
13#include <__algorithm/minmax_element.h>
13#include <__config>14#include <__config>
15#include <__functional/identity.h>
16#include <__type_traits/is_callable.h>
17#include <__utility/pair.h>
14#include <initializer_list>18#include <initializer_list>
15#include <utility>
1619
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header21# pragma GCC system_header
19#endif22#endif
2023
21_LIBCPP_BEGIN_NAMESPACE_STD24_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -36,47 +39,18 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11...@@ -36,47 +39,18 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
36pair<const _Tp&, const _Tp&>39pair<const _Tp&, const _Tp&>
37minmax(const _Tp& __a, const _Tp& __b)40minmax(const _Tp& __a, const _Tp& __b)
38{41{
39 return _VSTD::minmax(__a, __b, __less<_Tp>());42 return std::minmax(__a, __b, __less<_Tp>());
40}43}
4144
42#ifndef _LIBCPP_CXX03_LANG45#ifndef _LIBCPP_CXX03_LANG
4346
44template<class _Tp, class _Compare>47template<class _Tp, class _Compare>
45_LIBCPP_NODISCARD_EXT inline48_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
46_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1149pair<_Tp, _Tp> minmax(initializer_list<_Tp> __t, _Compare __comp) {
47pair<_Tp, _Tp>50 static_assert(__is_callable<_Compare, _Tp, _Tp>::value, "The comparator has to be callable");
48minmax(initializer_list<_Tp> __t, _Compare __comp)51 __identity __proj;
49{52 auto __ret = std::__minmax_element_impl(__t.begin(), __t.end(), __comp, __proj);
50 typedef typename initializer_list<_Tp>::const_iterator _Iter;53 return pair<_Tp, _Tp>(*__ret.first, *__ret.second);
51 _Iter __first = __t.begin();
52 _Iter __last = __t.end();
53 pair<_Tp, _Tp> __result(*__first, *__first);
54
55 ++__first;
56 if (__t.size() % 2 == 0)
57 {
58 if (__comp(*__first, __result.first))
59 __result.first = *__first;
60 else
61 __result.second = *__first;
62 ++__first;
63 }
64
65 while (__first != __last)
66 {
67 _Tp __prev = *__first++;
68 if (__comp(*__first, __prev)) {
69 if ( __comp(*__first, __result.first)) __result.first = *__first;
70 if (!__comp(__prev, __result.second)) __result.second = __prev;
71 }
72 else {
73 if ( __comp(__prev, __result.first)) __result.first = __prev;
74 if (!__comp(*__first, __result.second)) __result.second = *__first;
75 }
76
77 __first++;
78 }
79 return __result;
80}54}
8155
82template<class _Tp>56template<class _Tp>
...@@ -85,7 +59,7 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11...@@ -85,7 +59,7 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
85pair<_Tp, _Tp>59pair<_Tp, _Tp>
86minmax(initializer_list<_Tp> __t)60minmax(initializer_list<_Tp> __t)
87{61{
88 return _VSTD::minmax(__t, __less<_Tp>());62 return std::minmax(__t, __less<_Tp>());
89}63}
9064
91#endif // _LIBCPP_CXX03_LANG65#endif // _LIBCPP_CXX03_LANG
lib/libcxx/include/__algorithm/minmax_element.h+69-53
...@@ -11,73 +11,89 @@...@@ -11,73 +11,89 @@
1111
12#include <__algorithm/comp.h>12#include <__algorithm/comp.h>
13#include <__config>13#include <__config>
14#include <__functional/identity.h>
14#include <__iterator/iterator_traits.h>15#include <__iterator/iterator_traits.h>
15#include <utility>16#include <__utility/pair.h>
17#include <type_traits>
1618
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header20# pragma GCC system_header
19#endif21#endif
2022
21_LIBCPP_BEGIN_NAMESPACE_STD23_LIBCPP_BEGIN_NAMESPACE_STD
2224
25template <class _Comp, class _Proj>
26class _MinmaxElementLessFunc {
27 _Comp& __comp_;
28 _Proj& __proj_;
29
30public:
31 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
32 _MinmaxElementLessFunc(_Comp& __comp, _Proj& __proj) : __comp_(__comp), __proj_(__proj) {}
33
34 template <class _Iter>
35 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
36 bool operator()(_Iter& __it1, _Iter& __it2) {
37 return std::__invoke(__comp_, std::__invoke(__proj_, *__it1), std::__invoke(__proj_, *__it2));
38 }
39};
40
41template <class _Iter, class _Sent, class _Proj, class _Comp>
42_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
43pair<_Iter, _Iter> __minmax_element_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {
44 auto __less = _MinmaxElementLessFunc<_Comp, _Proj>(__comp, __proj);
45
46 pair<_Iter, _Iter> __result(__first, __first);
47 if (__first == __last || ++__first == __last)
48 return __result;
49
50 if (__less(__first, __result.first))
51 __result.first = __first;
52 else
53 __result.second = __first;
54
55 while (++__first != __last) {
56 _Iter __i = __first;
57 if (++__first == __last) {
58 if (__less(__i, __result.first))
59 __result.first = __i;
60 else if (!__less(__i, __result.second))
61 __result.second = __i;
62 return __result;
63 }
64
65 if (__less(__first, __i)) {
66 if (__less(__first, __result.first))
67 __result.first = __first;
68 if (!__less(__i, __result.second))
69 __result.second = __i;
70 } else {
71 if (__less(__i, __result.first))
72 __result.first = __i;
73 if (!__less(__first, __result.second))
74 __result.second = __first;
75 }
76 }
77
78 return __result;
79}
80
23template <class _ForwardIterator, class _Compare>81template <class _ForwardIterator, class _Compare>
24_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX1182_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX11
25pair<_ForwardIterator, _ForwardIterator>83pair<_ForwardIterator, _ForwardIterator>
26minmax_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)84minmax_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) {
27{
28 static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value,85 static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value,
29 "std::minmax_element requires a ForwardIterator");86 "std::minmax_element requires a ForwardIterator");
30 pair<_ForwardIterator, _ForwardIterator> __result(__first, __first);87 static_assert(__is_callable<_Compare, decltype(*__first), decltype(*__first)>::value,
31 if (__first != __last)88 "The comparator has to be callable");
32 {89 auto __proj = __identity();
33 if (++__first != __last)90 return std::__minmax_element_impl(__first, __last, __comp, __proj);
34 {
35 if (__comp(*__first, *__result.first))
36 __result.first = __first;
37 else
38 __result.second = __first;
39 while (++__first != __last)
40 {
41 _ForwardIterator __i = __first;
42 if (++__first == __last)
43 {
44 if (__comp(*__i, *__result.first))
45 __result.first = __i;
46 else if (!__comp(*__i, *__result.second))
47 __result.second = __i;
48 break;
49 }
50 else
51 {
52 if (__comp(*__first, *__i))
53 {
54 if (__comp(*__first, *__result.first))
55 __result.first = __first;
56 if (!__comp(*__i, *__result.second))
57 __result.second = __i;
58 }
59 else
60 {
61 if (__comp(*__i, *__result.first))
62 __result.first = __i;
63 if (!__comp(*__first, *__result.second))
64 __result.second = __first;
65 }
66 }
67 }
68 }
69 }
70 return __result;
71}91}
7292
73template <class _ForwardIterator>93template <class _ForwardIterator>
74_LIBCPP_NODISCARD_EXT inline94_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
75_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1195pair<_ForwardIterator, _ForwardIterator> minmax_element(_ForwardIterator __first, _ForwardIterator __last) {
76pair<_ForwardIterator, _ForwardIterator>96 return std::minmax_element(__first, __last, __less<typename iterator_traits<_ForwardIterator>::value_type>());
77minmax_element(_ForwardIterator __first, _ForwardIterator __last)
78{
79 return _VSTD::minmax_element(__first, __last,
80 __less<typename iterator_traits<_ForwardIterator>::value_type>());
81}97}
8298
83_LIBCPP_END_NAMESPACE_STD99_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/mismatch.h+2-2
...@@ -13,10 +13,10 @@...@@ -13,10 +13,10 @@
13#include <__algorithm/comp.h>13#include <__algorithm/comp.h>
14#include <__config>14#include <__config>
15#include <__iterator/iterator_traits.h>15#include <__iterator/iterator_traits.h>
16#include <utility>16#include <__utility/pair.h>
1717
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19#pragma GCC system_header19# pragma GCC system_header
20#endif20#endif
2121
22_LIBCPP_BEGIN_NAMESPACE_STD22_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/move.h+78-41
...@@ -11,66 +11,103 @@...@@ -11,66 +11,103 @@
1111
12#include <__algorithm/unwrap_iter.h>12#include <__algorithm/unwrap_iter.h>
13#include <__config>13#include <__config>
14#include <__iterator/iterator_traits.h>
15#include <__iterator/reverse_iterator.h>
14#include <__utility/move.h>16#include <__utility/move.h>
17#include <__utility/pair.h>
15#include <cstring>18#include <cstring>
16#include <type_traits>19#include <type_traits>
17#include <utility>
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
21#endif23#endif
2224
23_LIBCPP_BEGIN_NAMESPACE_STD25_LIBCPP_BEGIN_NAMESPACE_STD
2426
25// move27// move
2628
27template <class _InputIterator, class _OutputIterator>29template <class _InIter, class _Sent, class _OutIter>
28inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1430inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
29_OutputIterator31pair<_InIter, _OutIter> __move_impl(_InIter __first, _Sent __last, _OutIter __result) {
30__move_constexpr(_InputIterator __first, _InputIterator __last, _OutputIterator __result)32 while (__first != __last) {
31{33 *__result = std::move(*__first);
32 for (; __first != __last; ++__first, (void) ++__result)34 ++__first;
33 *__result = _VSTD::move(*__first);35 ++__result;
34 return __result;36 }
37 return std::make_pair(std::move(__first), std::move(__result));
35}38}
3639
37template <class _InputIterator, class _OutputIterator>40template <class _InType,
38inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1441 class _OutType,
39_OutputIterator42 class = __enable_if_t<is_same<typename remove_const<_InType>::type, _OutType>::value
40__move(_InputIterator __first, _InputIterator __last, _OutputIterator __result)43 && is_trivially_move_assignable<_OutType>::value> >
41{44inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
42 return _VSTD::__move_constexpr(__first, __last, __result);45pair<_InType*, _OutType*> __move_impl(_InType* __first, _InType* __last, _OutType* __result) {
46 if (__libcpp_is_constant_evaluated()
47// TODO: Remove this once GCC supports __builtin_memmove during constant evaluation
48#ifndef _LIBCPP_COMPILER_GCC
49 && !is_trivially_copyable<_InType>::value
50#endif
51 )
52 return std::__move_impl<_InType*, _InType*, _OutType*>(__first, __last, __result);
53 const size_t __n = static_cast<size_t>(__last - __first);
54 ::__builtin_memmove(__result, __first, __n * sizeof(_OutType));
55 return std::make_pair(__first + __n, __result + __n);
43}56}
4457
45template <class _Tp, class _Up>58template <class>
46inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1459struct __is_trivially_move_assignable_unwrapped_impl : false_type {};
47typename enable_if60
48<61template <class _Type>
49 is_same<typename remove_const<_Tp>::type, _Up>::value &&62struct __is_trivially_move_assignable_unwrapped_impl<_Type*> : is_trivially_move_assignable<_Type> {};
50 is_trivially_move_assignable<_Up>::value,63
51 _Up*64template <class _Iter>
52>::type65struct __is_trivially_move_assignable_unwrapped
53__move(_Tp* __first, _Tp* __last, _Up* __result)66 : __is_trivially_move_assignable_unwrapped_impl<decltype(std::__unwrap_iter<_Iter>(std::declval<_Iter>()))> {};
54{67
55 const size_t __n = static_cast<size_t>(__last - __first);68template <class _InIter,
56 if (__n > 0)69 class _OutIter,
57 _VSTD::memmove(__result, __first, __n * sizeof(_Up));70 __enable_if_t<is_same<typename remove_const<typename iterator_traits<_InIter>::value_type>::type,
58 return __result + __n;71 typename iterator_traits<_OutIter>::value_type>::value
72 && __is_cpp17_contiguous_iterator<_InIter>::value
73 && __is_cpp17_contiguous_iterator<_OutIter>::value
74 && is_trivially_move_assignable<__iter_value_type<_OutIter> >::value, int> = 0>
75inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
76pair<reverse_iterator<_InIter>, reverse_iterator<_OutIter> >
77__move_impl(reverse_iterator<_InIter> __first,
78 reverse_iterator<_InIter> __last,
79 reverse_iterator<_OutIter> __result) {
80 auto __first_base = std::__unwrap_iter(__first.base());
81 auto __last_base = std::__unwrap_iter(__last.base());
82 auto __result_base = std::__unwrap_iter(__result.base());
83 auto __result_first = __result_base - (__first_base - __last_base);
84 std::__move_impl(__last_base, __first_base, __result_first);
85 return std::make_pair(__last, reverse_iterator<_OutIter>(std::__rewrap_iter(__result.base(), __result_first)));
86}
87
88template <class _InIter, class _Sent, class _OutIter>
89inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
90__enable_if_t<is_copy_constructible<_InIter>::value
91 && is_copy_constructible<_Sent>::value
92 && is_copy_constructible<_OutIter>::value, pair<_InIter, _OutIter> >
93__move(_InIter __first, _Sent __last, _OutIter __result) {
94 auto __ret = std::__move_impl(std::__unwrap_iter(__first), std::__unwrap_iter(__last), std::__unwrap_iter(__result));
95 return std::make_pair(std::__rewrap_iter(__first, __ret.first), std::__rewrap_iter(__result, __ret.second));
96}
97
98template <class _InIter, class _Sent, class _OutIter>
99inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
100__enable_if_t<!is_copy_constructible<_InIter>::value
101 || !is_copy_constructible<_Sent>::value
102 || !is_copy_constructible<_OutIter>::value, pair<_InIter, _OutIter> >
103__move(_InIter __first, _Sent __last, _OutIter __result) {
104 return std::__move_impl(std::move(__first), std::move(__last), std::move(__result));
59}105}
60106
61template <class _InputIterator, class _OutputIterator>107template <class _InputIterator, class _OutputIterator>
62inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17108inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
63_OutputIterator109_OutputIterator move(_InputIterator __first, _InputIterator __last, _OutputIterator __result) {
64move(_InputIterator __first, _InputIterator __last, _OutputIterator __result)110 return std::__move(__first, __last, __result).second;
65{
66 if (__libcpp_is_constant_evaluated()) {
67 return _VSTD::__move_constexpr(__first, __last, __result);
68 } else {
69 return _VSTD::__rewrap_iter(__result,
70 _VSTD::__move(_VSTD::__unwrap_iter(__first),
71 _VSTD::__unwrap_iter(__last),
72 _VSTD::__unwrap_iter(__result)));
73 }
74}111}
75112
76_LIBCPP_END_NAMESPACE_STD113_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/move_backward.h+2-2
...@@ -11,12 +11,12 @@...@@ -11,12 +11,12 @@
1111
12#include <__algorithm/unwrap_iter.h>12#include <__algorithm/unwrap_iter.h>
13#include <__config>13#include <__config>
14#include <__utility/move.h>
14#include <cstring>15#include <cstring>
15#include <type_traits>16#include <type_traits>
16#include <utility>
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_LIBCPP_BEGIN_NAMESPACE_STD22_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/next_permutation.h+1-1
...@@ -17,7 +17,7 @@...@@ -17,7 +17,7 @@
17#include <__utility/swap.h>17#include <__utility/swap.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
21#endif21#endif
2222
23_LIBCPP_BEGIN_NAMESPACE_STD23_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/none_of.h+1-1
...@@ -13,7 +13,7 @@...@@ -13,7 +13,7 @@
13#include <__config>13#include <__config>
1414
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16#pragma GCC system_header16# pragma GCC system_header
17#endif17#endif
1818
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/nth_element.h+42-31
...@@ -11,17 +11,16 @@...@@ -11,17 +11,16 @@
1111
12#include <__algorithm/comp.h>12#include <__algorithm/comp.h>
13#include <__algorithm/comp_ref_type.h>13#include <__algorithm/comp_ref_type.h>
14#include <__algorithm/iterator_operations.h>
14#include <__algorithm/sort.h>15#include <__algorithm/sort.h>
15#include <__config>16#include <__config>
17#include <__debug>
18#include <__debug_utils/randomize_range.h>
16#include <__iterator/iterator_traits.h>19#include <__iterator/iterator_traits.h>
17#include <__utility/swap.h>20#include <__utility/move.h>
18
19#if defined(_LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY)
20# include <__algorithm/shuffle.h>
21#endif
2221
23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
24#pragma GCC system_header23# pragma GCC system_header
25#endif24#endif
2625
27_LIBCPP_BEGIN_NAMESPACE_STD26_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -42,10 +41,12 @@ __nth_element_find_guard(_RandomAccessIterator& __i, _RandomAccessIterator& __j,...@@ -42,10 +41,12 @@ __nth_element_find_guard(_RandomAccessIterator& __i, _RandomAccessIterator& __j,
42 }41 }
43}42}
4443
45template <class _Compare, class _RandomAccessIterator>44template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
46_LIBCPP_CONSTEXPR_AFTER_CXX11 void45_LIBCPP_CONSTEXPR_AFTER_CXX11 void
47__nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last, _Compare __comp)46__nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last, _Compare __comp)
48{47{
48 using _Ops = _IterOps<_AlgPolicy>;
49
49 // _Compare is known to be a reference type50 // _Compare is known to be a reference type
50 typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;51 typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
51 const difference_type __limit = 7;52 const difference_type __limit = 7;
...@@ -61,24 +62,24 @@ __nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _Rando...@@ -61,24 +62,24 @@ __nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _Rando
61 return;62 return;
62 case 2:63 case 2:
63 if (__comp(*--__last, *__first))64 if (__comp(*--__last, *__first))
64 swap(*__first, *__last);65 _Ops::iter_swap(__first, __last);
65 return;66 return;
66 case 3:67 case 3:
67 {68 {
68 _RandomAccessIterator __m = __first;69 _RandomAccessIterator __m = __first;
69 _VSTD::__sort3<_Compare>(__first, ++__m, --__last, __comp);70 std::__sort3<_AlgPolicy, _Compare>(__first, ++__m, --__last, __comp);
70 return;71 return;
71 }72 }
72 }73 }
73 if (__len <= __limit)74 if (__len <= __limit)
74 {75 {
75 _VSTD::__selection_sort<_Compare>(__first, __last, __comp);76 std::__selection_sort<_AlgPolicy, _Compare>(__first, __last, __comp);
76 return;77 return;
77 }78 }
78 // __len > __limit >= 379 // __len > __limit >= 3
79 _RandomAccessIterator __m = __first + __len/2;80 _RandomAccessIterator __m = __first + __len/2;
80 _RandomAccessIterator __lm1 = __last;81 _RandomAccessIterator __lm1 = __last;
81 unsigned __n_swaps = _VSTD::__sort3<_Compare>(__first, __m, --__lm1, __comp);82 unsigned __n_swaps = std::__sort3<_AlgPolicy, _Compare>(__first, __m, --__lm1, __comp);
82 // *__m is median83 // *__m is median
83 // partition [__first, __m) < *__m and *__m <= [__m, __last)84 // partition [__first, __m) < *__m and *__m <= [__m, __last)
84 // (this inhibits tossing elements equivalent to __m around unnecessarily)85 // (this inhibits tossing elements equivalent to __m around unnecessarily)
...@@ -91,7 +92,7 @@ __nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _Rando...@@ -91,7 +92,7 @@ __nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _Rando
91 {92 {
92 // *__first == *__m, *__first doesn't go in first part93 // *__first == *__m, *__first doesn't go in first part
93 if (_VSTD::__nth_element_find_guard<_Compare>(__i, __j, __m, __comp)) {94 if (_VSTD::__nth_element_find_guard<_Compare>(__i, __j, __m, __comp)) {
94 swap(*__i, *__j);95 _Ops::iter_swap(__i, __j);
95 ++__n_swaps;96 ++__n_swaps;
96 } else {97 } else {
97 // *__first == *__m, *__m <= all other elements98 // *__first == *__m, *__m <= all other elements
...@@ -103,7 +104,7 @@ __nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _Rando...@@ -103,7 +104,7 @@ __nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _Rando
103 if (__i == __j) {104 if (__i == __j) {
104 return; // [__first, __last) all equivalent elements105 return; // [__first, __last) all equivalent elements
105 } else if (__comp(*__first, *__i)) {106 } else if (__comp(*__first, *__i)) {
106 swap(*__i, *__j);107 _Ops::iter_swap(__i, __j);
107 ++__n_swaps;108 ++__n_swaps;
108 ++__i;109 ++__i;
109 break;110 break;
...@@ -122,7 +123,7 @@ __nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _Rando...@@ -122,7 +123,7 @@ __nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _Rando
122 ;123 ;
123 if (__i >= __j)124 if (__i >= __j)
124 break;125 break;
125 swap(*__i, *__j);126 _Ops::iter_swap(__i, __j);
126 ++__n_swaps;127 ++__n_swaps;
127 ++__i;128 ++__i;
128 }129 }
...@@ -153,7 +154,7 @@ __nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _Rando...@@ -153,7 +154,7 @@ __nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _Rando
153 ;154 ;
154 if (__i >= __j)155 if (__i >= __j)
155 break;156 break;
156 swap(*__i, *__j);157 _Ops::iter_swap(__i, __j);
157 ++__n_swaps;158 ++__n_swaps;
158 // It is known that __m != __j159 // It is known that __m != __j
159 // If __m just moved, follow it160 // If __m just moved, follow it
...@@ -165,7 +166,7 @@ __nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _Rando...@@ -165,7 +166,7 @@ __nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _Rando
165 // [__first, __i) < *__m and *__m <= [__i, __last)166 // [__first, __i) < *__m and *__m <= [__i, __last)
166 if (__i != __m && __comp(*__m, *__i))167 if (__i != __m && __comp(*__m, *__i))
167 {168 {
168 swap(*__i, *__m);169 _Ops::iter_swap(__i, __m);
169 ++__n_swaps;170 ++__n_swaps;
170 }171 }
171 // [__first, __i) < *__i and *__i <= [__i+1, __last)172 // [__first, __i) < *__i and *__i <= [__i+1, __last)
...@@ -221,26 +222,36 @@ __nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _Rando...@@ -221,26 +222,36 @@ __nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _Rando
221 }222 }
222}223}
223224
224template <class _RandomAccessIterator, class _Compare>225template <class _AlgPolicy, class _RandomAccessIterator, class _Compare>
225inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17226inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
226void227void __nth_element_impl(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last,
227nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last, _Compare __comp)228 _Compare& __comp) {
228{229 if (__nth == __last)
229 _LIBCPP_DEBUG_RANDOMIZE_RANGE(__first, __last);230 return;
230 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;231
231 _VSTD::__nth_element<_Comp_ref>(__first, __nth, __last, __comp);232 std::__debug_randomize_range<_AlgPolicy>(__first, __last);
232 _LIBCPP_DEBUG_RANDOMIZE_RANGE(__first, __nth);233
234 using _Comp_ref = typename __comp_ref_type<_Compare>::type;
235 std::__nth_element<_AlgPolicy, _Comp_ref>(__first, __nth, __last, __comp);
236
237 std::__debug_randomize_range<_AlgPolicy>(__first, __nth);
233 if (__nth != __last) {238 if (__nth != __last) {
234 _LIBCPP_DEBUG_RANDOMIZE_RANGE(++__nth, __last);239 std::__debug_randomize_range<_AlgPolicy>(++__nth, __last);
235 }240 }
236}241}
237242
243template <class _RandomAccessIterator, class _Compare>
244inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
245void nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last,
246 _Compare __comp) {
247 std::__nth_element_impl<_ClassicAlgPolicy>(std::move(__first), std::move(__nth), std::move(__last), __comp);
248}
249
238template <class _RandomAccessIterator>250template <class _RandomAccessIterator>
239inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17251inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
240void252void nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last) {
241nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last)253 std::nth_element(std::move(__first), std::move(__nth), std::move(__last), __less<typename
242{254 iterator_traits<_RandomAccessIterator>::value_type>());
243 _VSTD::nth_element(__first, __nth, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
244}255}
245256
246_LIBCPP_END_NAMESPACE_STD257_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/partial_sort.h+51-28
...@@ -11,41 +11,64 @@...@@ -11,41 +11,64 @@
1111
12#include <__algorithm/comp.h>12#include <__algorithm/comp.h>
13#include <__algorithm/comp_ref_type.h>13#include <__algorithm/comp_ref_type.h>
14#include <__algorithm/iterator_operations.h>
14#include <__algorithm/make_heap.h>15#include <__algorithm/make_heap.h>
15#include <__algorithm/sift_down.h>16#include <__algorithm/sift_down.h>
16#include <__algorithm/sort_heap.h>17#include <__algorithm/sort_heap.h>
17#include <__config>18#include <__config>
19#include <__debug>
20#include <__debug_utils/randomize_range.h>
18#include <__iterator/iterator_traits.h>21#include <__iterator/iterator_traits.h>
19#include <__utility/swap.h>22#include <__utility/move.h>
2023#include <type_traits>
21#if defined(_LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY)
22# include <__algorithm/shuffle.h>
23#endif
2424
25#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)25#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
26#pragma GCC system_header26# pragma GCC system_header
27#endif27#endif
2828
29_LIBCPP_BEGIN_NAMESPACE_STD29_LIBCPP_BEGIN_NAMESPACE_STD
3030
31template <class _Compare, class _RandomAccessIterator>31template <class _AlgPolicy, class _Compare, class _RandomAccessIterator, class _Sentinel>
32_LIBCPP_CONSTEXPR_AFTER_CXX17 void32_LIBCPP_CONSTEXPR_AFTER_CXX17
33__partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last,33_RandomAccessIterator __partial_sort_impl(
34 _Compare __comp)34 _RandomAccessIterator __first, _RandomAccessIterator __middle, _Sentinel __last, _Compare&& __comp) {
35{35 if (__first == __middle) {
36 if (__first == __middle)36 return _IterOps<_AlgPolicy>::next(__middle, __last);
37 return;37 }
38 _VSTD::__make_heap<_Compare>(__first, __middle, __comp);38
39 typename iterator_traits<_RandomAccessIterator>::difference_type __len = __middle - __first;39 std::__make_heap<_AlgPolicy>(__first, __middle, __comp);
40 for (_RandomAccessIterator __i = __middle; __i != __last; ++__i)40
41 {41 typename iterator_traits<_RandomAccessIterator>::difference_type __len = __middle - __first;
42 if (__comp(*__i, *__first))42 _RandomAccessIterator __i = __middle;
43 {43 for (; __i != __last; ++__i)
44 swap(*__i, *__first);44 {
45 _VSTD::__sift_down<_Compare>(__first, __comp, __len, __first);45 if (__comp(*__i, *__first))
46 }46 {
47 }47 _IterOps<_AlgPolicy>::iter_swap(__i, __first);
48 _VSTD::__sort_heap<_Compare>(__first, __middle, __comp);48 std::__sift_down<_AlgPolicy>(__first, __comp, __len, __first);
49 }
50
51 }
52 std::__sort_heap<_AlgPolicy>(std::move(__first), std::move(__middle), __comp);
53
54 return __i;
55}
56
57template <class _AlgPolicy, class _Compare, class _RandomAccessIterator, class _Sentinel>
58_LIBCPP_CONSTEXPR_AFTER_CXX17
59_RandomAccessIterator __partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _Sentinel __last,
60 _Compare& __comp) {
61 if (__first == __middle)
62 return _IterOps<_AlgPolicy>::next(__middle, __last);
63
64 std::__debug_randomize_range<_AlgPolicy>(__first, __last);
65
66 using _Comp_ref = typename __comp_ref_type<_Compare>::type;
67 auto __last_iter = std::__partial_sort_impl<_AlgPolicy>(__first, __middle, __last, static_cast<_Comp_ref>(__comp));
68
69 std::__debug_randomize_range<_AlgPolicy>(__middle, __last);
70
71 return __last_iter;
49}72}
5073
51template <class _RandomAccessIterator, class _Compare>74template <class _RandomAccessIterator, class _Compare>
...@@ -54,10 +77,10 @@ void...@@ -54,10 +77,10 @@ void
54partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last,77partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last,
55 _Compare __comp)78 _Compare __comp)
56{79{
57 _LIBCPP_DEBUG_RANDOMIZE_RANGE(__first, __last);80 static_assert(std::is_copy_constructible<_RandomAccessIterator>::value, "Iterators must be copy constructible.");
58 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;81 static_assert(std::is_copy_assignable<_RandomAccessIterator>::value, "Iterators must be copy assignable.");
59 _VSTD::__partial_sort<_Comp_ref>(__first, __middle, __last, __comp);82
60 _LIBCPP_DEBUG_RANDOMIZE_RANGE(__middle, __last);83 (void)std::__partial_sort<_ClassicAlgPolicy>(std::move(__first), std::move(__middle), std::move(__last), __comp);
61}84}
6285
63template <class _RandomAccessIterator>86template <class _RandomAccessIterator>
lib/libcxx/include/__algorithm/partial_sort_copy.h+31-13
...@@ -11,39 +11,52 @@...@@ -11,39 +11,52 @@
1111
12#include <__algorithm/comp.h>12#include <__algorithm/comp.h>
13#include <__algorithm/comp_ref_type.h>13#include <__algorithm/comp_ref_type.h>
14#include <__algorithm/iterator_operations.h>
14#include <__algorithm/make_heap.h>15#include <__algorithm/make_heap.h>
16#include <__algorithm/make_projected.h>
15#include <__algorithm/sift_down.h>17#include <__algorithm/sift_down.h>
16#include <__algorithm/sort_heap.h>18#include <__algorithm/sort_heap.h>
17#include <__config>19#include <__config>
20#include <__functional/identity.h>
21#include <__functional/invoke.h>
18#include <__iterator/iterator_traits.h>22#include <__iterator/iterator_traits.h>
23#include <__type_traits/is_callable.h>
24#include <__utility/move.h>
25#include <__utility/pair.h>
1926
20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)27#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
21#pragma GCC system_header28# pragma GCC system_header
22#endif29#endif
2330
24_LIBCPP_BEGIN_NAMESPACE_STD31_LIBCPP_BEGIN_NAMESPACE_STD
2532
26template <class _Compare, class _InputIterator, class _RandomAccessIterator>33template <class _AlgPolicy, class _Compare,
27_LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator34 class _InputIterator, class _Sentinel1, class _RandomAccessIterator, class _Sentinel2,
28__partial_sort_copy(_InputIterator __first, _InputIterator __last,35 class _Proj1, class _Proj2>
29 _RandomAccessIterator __result_first, _RandomAccessIterator __result_last, _Compare __comp)36_LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_InputIterator, _RandomAccessIterator>
37__partial_sort_copy(_InputIterator __first, _Sentinel1 __last,
38 _RandomAccessIterator __result_first, _Sentinel2 __result_last,
39 _Compare&& __comp, _Proj1&& __proj1, _Proj2&& __proj2)
30{40{
31 _RandomAccessIterator __r = __result_first;41 _RandomAccessIterator __r = __result_first;
42 auto&& __projected_comp = std::__make_projected(__comp, __proj2);
43
32 if (__r != __result_last)44 if (__r != __result_last)
33 {45 {
34 for (; __first != __last && __r != __result_last; ++__first, (void) ++__r)46 for (; __first != __last && __r != __result_last; ++__first, (void) ++__r)
35 *__r = *__first;47 *__r = *__first;
36 _VSTD::__make_heap<_Compare>(__result_first, __r, __comp);48 std::__make_heap<_AlgPolicy>(__result_first, __r, __projected_comp);
37 typename iterator_traits<_RandomAccessIterator>::difference_type __len = __r - __result_first;49 typename iterator_traits<_RandomAccessIterator>::difference_type __len = __r - __result_first;
38 for (; __first != __last; ++__first)50 for (; __first != __last; ++__first)
39 if (__comp(*__first, *__result_first))51 if (std::__invoke(__comp, std::__invoke(__proj1, *__first), std::__invoke(__proj2, *__result_first))) {
40 {
41 *__result_first = *__first;52 *__result_first = *__first;
42 _VSTD::__sift_down<_Compare>(__result_first, __comp, __len, __result_first);53 std::__sift_down<_AlgPolicy>(__result_first, __projected_comp, __len, __result_first);
43 }54 }
44 _VSTD::__sort_heap<_Compare>(__result_first, __r, __comp);55 std::__sort_heap<_AlgPolicy>(__result_first, __r, __projected_comp);
45 }56 }
46 return __r;57
58 return pair<_InputIterator, _RandomAccessIterator>(
59 _IterOps<_AlgPolicy>::next(std::move(__first), std::move(__last)), std::move(__r));
47}60}
4861
49template <class _InputIterator, class _RandomAccessIterator, class _Compare>62template <class _InputIterator, class _RandomAccessIterator, class _Compare>
...@@ -52,8 +65,13 @@ _RandomAccessIterator...@@ -52,8 +65,13 @@ _RandomAccessIterator
52partial_sort_copy(_InputIterator __first, _InputIterator __last,65partial_sort_copy(_InputIterator __first, _InputIterator __last,
53 _RandomAccessIterator __result_first, _RandomAccessIterator __result_last, _Compare __comp)66 _RandomAccessIterator __result_first, _RandomAccessIterator __result_last, _Compare __comp)
54{67{
55 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;68 static_assert(__is_callable<_Compare, decltype(*__first), decltype(*__result_first)>::value,
56 return _VSTD::__partial_sort_copy<_Comp_ref>(__first, __last, __result_first, __result_last, __comp);69 "Comparator has to be callable");
70
71 using _Comp_ref = typename __comp_ref_type<_Compare>::type;
72 auto __result = std::__partial_sort_copy<_ClassicAlgPolicy>(__first, __last, __result_first, __result_last,
73 static_cast<_Comp_ref>(__comp), __identity(), __identity());
74 return __result.second;
57}75}
5876
59template <class _InputIterator, class _RandomAccessIterator>77template <class _InputIterator, class _RandomAccessIterator>
lib/libcxx/include/__algorithm/partition.h+34-17
...@@ -9,50 +9,58 @@...@@ -9,50 +9,58 @@
9#ifndef _LIBCPP___ALGORITHM_PARTITION_H9#ifndef _LIBCPP___ALGORITHM_PARTITION_H
10#define _LIBCPP___ALGORITHM_PARTITION_H10#define _LIBCPP___ALGORITHM_PARTITION_H
1111
12#include <__algorithm/iterator_operations.h>
12#include <__config>13#include <__config>
13#include <__iterator/iterator_traits.h>14#include <__iterator/iterator_traits.h>
14#include <__utility/swap.h>15#include <__utility/move.h>
16#include <__utility/pair.h>
17#include <type_traits>
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
18#endif21#endif
1922
20_LIBCPP_BEGIN_NAMESPACE_STD23_LIBCPP_BEGIN_NAMESPACE_STD
2124
22template <class _Predicate, class _ForwardIterator>25template <class _Predicate, class _AlgPolicy, class _ForwardIterator, class _Sentinel>
23_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator26_LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_ForwardIterator, _ForwardIterator>
24__partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred, forward_iterator_tag)27__partition_impl(_ForwardIterator __first, _Sentinel __last, _Predicate __pred, forward_iterator_tag)
25{28{
26 while (true)29 while (true)
27 {30 {
28 if (__first == __last)31 if (__first == __last)
29 return __first;32 return std::make_pair(std::move(__first), std::move(__first));
30 if (!__pred(*__first))33 if (!__pred(*__first))
31 break;34 break;
32 ++__first;35 ++__first;
33 }36 }
34 for (_ForwardIterator __p = __first; ++__p != __last;)37
38 _ForwardIterator __p = __first;
39 while (++__p != __last)
35 {40 {
36 if (__pred(*__p))41 if (__pred(*__p))
37 {42 {
38 swap(*__first, *__p);43 _IterOps<_AlgPolicy>::iter_swap(__first, __p);
39 ++__first;44 ++__first;
40 }45 }
41 }46 }
42 return __first;47 return std::make_pair(std::move(__first), std::move(__p));
43}48}
4449
45template <class _Predicate, class _BidirectionalIterator>50template <class _Predicate, class _AlgPolicy, class _BidirectionalIterator, class _Sentinel>
46_LIBCPP_CONSTEXPR_AFTER_CXX17 _BidirectionalIterator51_LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_BidirectionalIterator, _BidirectionalIterator>
47__partition(_BidirectionalIterator __first, _BidirectionalIterator __last, _Predicate __pred,52__partition_impl(_BidirectionalIterator __first, _Sentinel __sentinel, _Predicate __pred,
48 bidirectional_iterator_tag)53 bidirectional_iterator_tag)
49{54{
55 _BidirectionalIterator __original_last = _IterOps<_AlgPolicy>::next(__first, __sentinel);
56 _BidirectionalIterator __last = __original_last;
57
50 while (true)58 while (true)
51 {59 {
52 while (true)60 while (true)
53 {61 {
54 if (__first == __last)62 if (__first == __last)
55 return __first;63 return std::make_pair(std::move(__first), std::move(__original_last));
56 if (!__pred(*__first))64 if (!__pred(*__first))
57 break;65 break;
58 ++__first;66 ++__first;
...@@ -60,20 +68,29 @@ __partition(_BidirectionalIterator __first, _BidirectionalIterator __last, _Pred...@@ -60,20 +68,29 @@ __partition(_BidirectionalIterator __first, _BidirectionalIterator __last, _Pred
60 do68 do
61 {69 {
62 if (__first == --__last)70 if (__first == --__last)
63 return __first;71 return std::make_pair(std::move(__first), std::move(__original_last));
64 } while (!__pred(*__last));72 } while (!__pred(*__last));
65 swap(*__first, *__last);73 _IterOps<_AlgPolicy>::iter_swap(__first, __last);
66 ++__first;74 ++__first;
67 }75 }
68}76}
6977
78template <class _AlgPolicy, class _ForwardIterator, class _Sentinel, class _Predicate, class _IterCategory>
79inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
80pair<_ForwardIterator, _ForwardIterator> __partition(
81 _ForwardIterator __first, _Sentinel __last, _Predicate&& __pred, _IterCategory __iter_category) {
82 return std::__partition_impl<__uncvref_t<_Predicate>&, _AlgPolicy>(
83 std::move(__first), std::move(__last), __pred, __iter_category);
84}
85
70template <class _ForwardIterator, class _Predicate>86template <class _ForwardIterator, class _Predicate>
71inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1787inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
72_ForwardIterator88_ForwardIterator
73partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)89partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)
74{90{
75 return _VSTD::__partition<_Predicate&>(91 using _IterCategory = typename iterator_traits<_ForwardIterator>::iterator_category;
76 __first, __last, __pred, typename iterator_traits<_ForwardIterator>::iterator_category());92 auto __result = std::__partition<_ClassicAlgPolicy>(std::move(__first), std::move(__last), __pred, _IterCategory());
93 return __result.first;
77}94}
7895
79_LIBCPP_END_NAMESPACE_STD96_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/partition_copy.h+2-2
...@@ -11,10 +11,10 @@...@@ -11,10 +11,10 @@
1111
12#include <__config>12#include <__config>
13#include <__iterator/iterator_traits.h>13#include <__iterator/iterator_traits.h>
14#include <utility> // pair14#include <__utility/pair.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
18#endif18#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/partition_point.h+4-2
...@@ -11,10 +11,12 @@...@@ -11,10 +11,12 @@
1111
12#include <__algorithm/half_positive.h>12#include <__algorithm/half_positive.h>
13#include <__config>13#include <__config>
14#include <iterator>14#include <__iterator/advance.h>
15#include <__iterator/distance.h>
16#include <__iterator/iterator_traits.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
18#endif20#endif
1921
20_LIBCPP_BEGIN_NAMESPACE_STD22_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/pop_heap.h+40-23
...@@ -11,45 +11,62 @@...@@ -11,45 +11,62 @@
1111
12#include <__algorithm/comp.h>12#include <__algorithm/comp.h>
13#include <__algorithm/comp_ref_type.h>13#include <__algorithm/comp_ref_type.h>
14#include <__algorithm/iterator_operations.h>
15#include <__algorithm/push_heap.h>
14#include <__algorithm/sift_down.h>16#include <__algorithm/sift_down.h>
17#include <__assert>
15#include <__config>18#include <__config>
16#include <__iterator/iterator_traits.h>19#include <__iterator/iterator_traits.h>
17#include <__utility/swap.h>20#include <__utility/move.h>
21#include <type_traits>
1822
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20#pragma GCC system_header24# pragma GCC system_header
21#endif25#endif
2226
23_LIBCPP_BEGIN_NAMESPACE_STD27_LIBCPP_BEGIN_NAMESPACE_STD
2428
25template <class _Compare, class _RandomAccessIterator>29template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
26inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1730inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
27void31void __pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare& __comp,
28__pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp,32 typename iterator_traits<_RandomAccessIterator>::difference_type __len) {
29 typename iterator_traits<_RandomAccessIterator>::difference_type __len)33 _LIBCPP_ASSERT(__len > 0, "The heap given to pop_heap must be non-empty");
30{34
31 if (__len > 1)35 using _CompRef = typename __comp_ref_type<_Compare>::type;
32 {36 _CompRef __comp_ref = __comp;
33 swap(*__first, *--__last);37
34 _VSTD::__sift_down<_Compare>(__first, __comp, __len - 1, __first);38 using value_type = typename iterator_traits<_RandomAccessIterator>::value_type;
39 if (__len > 1) {
40 value_type __top = _IterOps<_AlgPolicy>::__iter_move(__first); // create a hole at __first
41 _RandomAccessIterator __hole = std::__floyd_sift_down<_AlgPolicy>(__first, __comp_ref, __len);
42 --__last;
43
44 if (__hole == __last) {
45 *__hole = std::move(__top);
46 } else {
47 *__hole = _IterOps<_AlgPolicy>::__iter_move(__last);
48 ++__hole;
49 *__last = std::move(__top);
50 std::__sift_up<_AlgPolicy>(__first, __hole, __comp_ref, __hole - __first);
35 }51 }
52 }
36}53}
3754
38template <class _RandomAccessIterator, class _Compare>55template <class _RandomAccessIterator, class _Compare>
39inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1756inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
40void57void pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {
41pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)58 static_assert(std::is_copy_constructible<_RandomAccessIterator>::value, "Iterators must be copy constructible.");
42{59 static_assert(std::is_copy_assignable<_RandomAccessIterator>::value, "Iterators must be copy assignable.");
43 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;60
44 _VSTD::__pop_heap<_Comp_ref>(__first, __last, __comp, __last - __first);61 typename iterator_traits<_RandomAccessIterator>::difference_type __len = __last - __first;
62 std::__pop_heap<_ClassicAlgPolicy>(std::move(__first), std::move(__last), __comp, __len);
45}63}
4664
47template <class _RandomAccessIterator>65template <class _RandomAccessIterator>
48inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1766inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
49void67void pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) {
50pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)68 std::pop_heap(std::move(__first), std::move(__last),
51{69 __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
52 _VSTD::pop_heap(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
53}70}
5471
55_LIBCPP_END_NAMESPACE_STD72_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/prev_permutation.h+1-1
...@@ -17,7 +17,7 @@...@@ -17,7 +17,7 @@
17#include <__utility/swap.h>17#include <__utility/swap.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
21#endif21#endif
2222
23_LIBCPP_BEGIN_NAMESPACE_STD23_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/push_heap.h+44-36
...@@ -11,58 +11,66 @@...@@ -11,58 +11,66 @@
1111
12#include <__algorithm/comp.h>12#include <__algorithm/comp.h>
13#include <__algorithm/comp_ref_type.h>13#include <__algorithm/comp_ref_type.h>
14#include <__algorithm/iterator_operations.h>
14#include <__config>15#include <__config>
15#include <__iterator/iterator_traits.h>16#include <__iterator/iterator_traits.h>
16#include <__utility/move.h>17#include <__utility/move.h>
18#include <type_traits>
1719
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19#pragma GCC system_header21# pragma GCC system_header
20#endif22#endif
2123
22_LIBCPP_BEGIN_NAMESPACE_STD24_LIBCPP_BEGIN_NAMESPACE_STD
2325
24template <class _Compare, class _RandomAccessIterator>26template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
25_LIBCPP_CONSTEXPR_AFTER_CXX11 void27_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
26__sift_up(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp,28void __sift_up(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare&& __comp,
27 typename iterator_traits<_RandomAccessIterator>::difference_type __len)29 typename iterator_traits<_RandomAccessIterator>::difference_type __len) {
28{30 using value_type = typename iterator_traits<_RandomAccessIterator>::value_type;
29 typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;31
30 if (__len > 1)32 if (__len > 1) {
31 {33 __len = (__len - 2) / 2;
32 __len = (__len - 2) / 2;34 _RandomAccessIterator __ptr = __first + __len;
33 _RandomAccessIterator __ptr = __first + __len;35
34 if (__comp(*__ptr, *--__last))36 if (__comp(*__ptr, *--__last)) {
35 {37 value_type __t(_IterOps<_AlgPolicy>::__iter_move(__last));
36 value_type __t(_VSTD::move(*__last));38 do {
37 do39 *__last = _IterOps<_AlgPolicy>::__iter_move(__ptr);
38 {40 __last = __ptr;
39 *__last = _VSTD::move(*__ptr);41 if (__len == 0)
40 __last = __ptr;42 break;
41 if (__len == 0)43 __len = (__len - 1) / 2;
42 break;44 __ptr = __first + __len;
43 __len = (__len - 1) / 2;45 } while (__comp(*__ptr, __t));
44 __ptr = __first + __len;46
45 } while (__comp(*__ptr, __t));47 *__last = std::move(__t);
46 *__last = _VSTD::move(__t);
47 }
48 }48 }
49 }
50}
51
52template <class _AlgPolicy, class _RandomAccessIterator, class _Compare>
53inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
54void __push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare& __comp) {
55 using _CompRef = typename __comp_ref_type<_Compare>::type;
56 typename iterator_traits<_RandomAccessIterator>::difference_type __len = __last - __first;
57 std::__sift_up<_AlgPolicy, _CompRef>(std::move(__first), std::move(__last), __comp, __len);
49}58}
5059
51template <class _RandomAccessIterator, class _Compare>60template <class _RandomAccessIterator, class _Compare>
52inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1761inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
53void62void push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {
54push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)63 static_assert(std::is_copy_constructible<_RandomAccessIterator>::value, "Iterators must be copy constructible.");
55{64 static_assert(std::is_copy_assignable<_RandomAccessIterator>::value, "Iterators must be copy assignable.");
56 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;65
57 _VSTD::__sift_up<_Comp_ref>(__first, __last, __comp, __last - __first);66 std::__push_heap<_ClassicAlgPolicy>(std::move(__first), std::move(__last), __comp);
58}67}
5968
60template <class _RandomAccessIterator>69template <class _RandomAccessIterator>
61inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1770inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
62void71void push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) {
63push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)72 std::push_heap(std::move(__first), std::move(__last),
64{73 __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
65 _VSTD::push_heap(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
66}74}
6775
68_LIBCPP_END_NAMESPACE_STD76_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/ranges_adjacent_find.h created+78
...@@ -0,0 +1,78 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_ADJACENT_FIND_H
10#define _LIBCPP___ALGORITHM_RANGES_ADJACENT_FIND_H
11
12#include <__config>
13#include <__functional/identity.h>
14#include <__functional/invoke.h>
15#include <__functional/ranges_operations.h>
16#include <__iterator/concepts.h>
17#include <__iterator/projected.h>
18#include <__ranges/access.h>
19#include <__ranges/concepts.h>
20#include <__ranges/dangling.h>
21#include <__utility/move.h>
22
23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
24# pragma GCC system_header
25#endif
26
27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
28
29_LIBCPP_BEGIN_NAMESPACE_STD
30
31namespace ranges {
32namespace __adjacent_find {
33struct __fn {
34
35 template <class _Iter, class _Sent, class _Proj, class _Pred>
36 _LIBCPP_HIDE_FROM_ABI constexpr static
37 _Iter __adjacent_find_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) {
38 if (__first == __last)
39 return __first;
40
41 auto __i = __first;
42 while (++__i != __last) {
43 if (std::invoke(__pred, std::invoke(__proj, *__first), std::invoke(__proj, *__i)))
44 return __first;
45 __first = __i;
46 }
47 return __i;
48 }
49
50 template <forward_iterator _Iter, sentinel_for<_Iter> _Sent,
51 class _Proj = identity,
52 indirect_binary_predicate<projected<_Iter, _Proj>, projected<_Iter, _Proj>> _Pred = ranges::equal_to>
53 _LIBCPP_HIDE_FROM_ABI constexpr
54 _Iter operator()(_Iter __first, _Sent __last, _Pred __pred = {}, _Proj __proj = {}) const {
55 return __adjacent_find_impl(std::move(__first), std::move(__last), __pred, __proj);
56 }
57
58 template <forward_range _Range,
59 class _Proj = identity,
60 indirect_binary_predicate<projected<iterator_t<_Range>, _Proj>,
61 projected<iterator_t<_Range>, _Proj>> _Pred = ranges::equal_to>
62 _LIBCPP_HIDE_FROM_ABI constexpr
63 borrowed_iterator_t<_Range> operator()(_Range&& __range, _Pred __pred = {}, _Proj __proj = {}) const {
64 return __adjacent_find_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
65 }
66};
67} // namespace __adjacent_find
68
69inline namespace __cpo {
70 inline constexpr auto adjacent_find = __adjacent_find::__fn{};
71} // namespace __cpo
72} // namespace ranges
73
74_LIBCPP_END_NAMESPACE_STD
75
76#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
77
78#endif // _LIBCPP___ALGORITHM_RANGES_ADJACENT_FIND_H
lib/libcxx/include/__algorithm/ranges_all_of.h created+68
...@@ -0,0 +1,68 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_ALL_OF_H
10#define _LIBCPP___ALGORITHM_RANGES_ALL_OF_H
11
12#include <__config>
13#include <__functional/identity.h>
14#include <__functional/invoke.h>
15#include <__iterator/concepts.h>
16#include <__iterator/projected.h>
17#include <__ranges/access.h>
18#include <__ranges/concepts.h>
19#include <__utility/move.h>
20
21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
22# pragma GCC system_header
23#endif
24
25#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
26
27_LIBCPP_BEGIN_NAMESPACE_STD
28
29namespace ranges {
30namespace __all_of {
31struct __fn {
32
33 template <class _Iter, class _Sent, class _Proj, class _Pred>
34 _LIBCPP_HIDE_FROM_ABI constexpr static
35 bool __all_of_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) {
36 for (; __first != __last; ++__first) {
37 if (!std::invoke(__pred, std::invoke(__proj, *__first)))
38 return false;
39 }
40 return true;
41 }
42
43 template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity,
44 indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>
45 _LIBCPP_HIDE_FROM_ABI constexpr
46 bool operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) const {
47 return __all_of_impl(std::move(__first), std::move(__last), __pred, __proj);
48 }
49
50 template <input_range _Range, class _Proj = identity,
51 indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
52 _LIBCPP_HIDE_FROM_ABI constexpr
53 bool operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const {
54 return __all_of_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
55 }
56};
57} // namespace __all_of
58
59inline namespace __cpo {
60 inline constexpr auto all_of = __all_of::__fn{};
61} // namespace __cpo
62} // namespace ranges
63
64_LIBCPP_END_NAMESPACE_STD
65
66#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
67
68#endif // _LIBCPP___ALGORITHM_RANGES_ALL_OF_H
lib/libcxx/include/__algorithm/ranges_any_of.h created+68
...@@ -0,0 +1,68 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_ANY_OF_H
10#define _LIBCPP___ALGORITHM_RANGES_ANY_OF_H
11
12#include <__config>
13#include <__functional/identity.h>
14#include <__functional/invoke.h>
15#include <__iterator/concepts.h>
16#include <__iterator/projected.h>
17#include <__ranges/access.h>
18#include <__ranges/concepts.h>
19#include <__utility/move.h>
20
21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
22# pragma GCC system_header
23#endif
24
25#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
26
27_LIBCPP_BEGIN_NAMESPACE_STD
28
29namespace ranges {
30namespace __any_of {
31struct __fn {
32
33 template <class _Iter, class _Sent, class _Proj, class _Pred>
34 _LIBCPP_HIDE_FROM_ABI constexpr static
35 bool __any_of_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) {
36 for (; __first != __last; ++__first) {
37 if (std::invoke(__pred, std::invoke(__proj, *__first)))
38 return true;
39 }
40 return false;
41 }
42
43 template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity,
44 indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>
45 _LIBCPP_HIDE_FROM_ABI constexpr
46 bool operator()(_Iter __first, _Sent __last, _Pred __pred = {}, _Proj __proj = {}) const {
47 return __any_of_impl(std::move(__first), std::move(__last), __pred, __proj);
48 }
49
50 template <input_range _Range, class _Proj = identity,
51 indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
52 _LIBCPP_HIDE_FROM_ABI constexpr
53 bool operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const {
54 return __any_of_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
55 }
56};
57} // namespace __any_of
58
59inline namespace __cpo {
60 inline constexpr auto any_of = __any_of::__fn{};
61} // namespace __cpo
62} // namespace ranges
63
64_LIBCPP_END_NAMESPACE_STD
65
66#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
67
68#endif // _LIBCPP___ALGORITHM_RANGES_ANY_OF_H
lib/libcxx/include/__algorithm/ranges_binary_search.h created+63
...@@ -0,0 +1,63 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_BINARY_SEARCH_H
10#define _LIBCPP___ALGORITHM_RANGES_BINARY_SEARCH_H
11
12#include <__algorithm/iterator_operations.h>
13#include <__algorithm/lower_bound.h>
14#include <__config>
15#include <__functional/identity.h>
16#include <__functional/invoke.h>
17#include <__functional/ranges_operations.h>
18#include <__iterator/concepts.h>
19#include <__iterator/projected.h>
20#include <__ranges/access.h>
21#include <__ranges/concepts.h>
22
23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
24# pragma GCC system_header
25#endif
26
27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
28
29_LIBCPP_BEGIN_NAMESPACE_STD
30
31namespace ranges {
32namespace __binary_search {
33struct __fn {
34 template <forward_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity,
35 indirect_strict_weak_order<const _Type*, projected<_Iter, _Proj>> _Comp = ranges::less>
36 _LIBCPP_HIDE_FROM_ABI constexpr
37 bool operator()(_Iter __first, _Sent __last, const _Type& __value, _Comp __comp = {}, _Proj __proj = {}) const {
38 auto __ret = std::__lower_bound_impl<_RangeAlgPolicy>(__first, __last, __value, __comp, __proj);
39 return __ret != __last && !std::invoke(__comp, __value, std::invoke(__proj, *__first));
40 }
41
42 template <forward_range _Range, class _Type, class _Proj = identity,
43 indirect_strict_weak_order<const _Type*, projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
44 _LIBCPP_HIDE_FROM_ABI constexpr
45 bool operator()(_Range&& __r, const _Type& __value, _Comp __comp = {}, _Proj __proj = {}) const {
46 auto __first = ranges::begin(__r);
47 auto __last = ranges::end(__r);
48 auto __ret = std::__lower_bound_impl<_RangeAlgPolicy>(__first, __last, __value, __comp, __proj);
49 return __ret != __last && !std::invoke(__comp, __value, std::invoke(__proj, *__first));
50 }
51};
52} // namespace __binary_search
53
54inline namespace __cpo {
55 inline constexpr auto binary_search = __binary_search::__fn{};
56} // namespace __cpo
57} // namespace ranges
58
59_LIBCPP_END_NAMESPACE_STD
60
61#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
62
63#endif // _LIBCPP___ALGORITHM_RANGES_BINARY_SEARCH_H
lib/libcxx/include/__algorithm/ranges_copy.h created+65
...@@ -0,0 +1,65 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_COPY_H
10#define _LIBCPP___ALGORITHM_RANGES_COPY_H
11
12#include <__algorithm/copy.h>
13#include <__algorithm/in_out_result.h>
14#include <__config>
15#include <__functional/identity.h>
16#include <__iterator/concepts.h>
17#include <__ranges/access.h>
18#include <__ranges/concepts.h>
19#include <__ranges/dangling.h>
20#include <__utility/move.h>
21
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23# pragma GCC system_header
24#endif
25
26#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
27
28_LIBCPP_BEGIN_NAMESPACE_STD
29
30namespace ranges {
31
32template <class _InIter, class _OutIter>
33using copy_result = in_out_result<_InIter, _OutIter>;
34
35namespace __copy {
36struct __fn {
37
38 template <input_iterator _InIter, sentinel_for<_InIter> _Sent, weakly_incrementable _OutIter>
39 requires indirectly_copyable<_InIter, _OutIter>
40 _LIBCPP_HIDE_FROM_ABI constexpr
41 copy_result<_InIter, _OutIter> operator()(_InIter __first, _Sent __last, _OutIter __result) const {
42 auto __ret = std::__copy(std::move(__first), std::move(__last), std::move(__result));
43 return {std::move(__ret.first), std::move(__ret.second)};
44 }
45
46 template <input_range _Range, weakly_incrementable _OutIter>
47 requires indirectly_copyable<iterator_t<_Range>, _OutIter>
48 _LIBCPP_HIDE_FROM_ABI constexpr
49 copy_result<borrowed_iterator_t<_Range>, _OutIter> operator()(_Range&& __r, _OutIter __result) const {
50 auto __ret = std::__copy(ranges::begin(__r), ranges::end(__r), std::move(__result));
51 return {std::move(__ret.first), std::move(__ret.second)};
52 }
53};
54} // namespace __copy
55
56inline namespace __cpo {
57 inline constexpr auto copy = __copy::__fn{};
58} // namespace __cpo
59} // namespace ranges
60
61_LIBCPP_END_NAMESPACE_STD
62
63#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
64
65#endif // _LIBCPP___ALGORITHM_RANGES_COPY_H
lib/libcxx/include/__algorithm/ranges_copy_backward.h created+66
...@@ -0,0 +1,66 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_COPY_BACKWARD_H
10#define _LIBCPP___ALGORITHM_RANGES_COPY_BACKWARD_H
11
12#include <__algorithm/copy_backward.h>
13#include <__algorithm/in_out_result.h>
14#include <__algorithm/iterator_operations.h>
15#include <__config>
16#include <__iterator/concepts.h>
17#include <__iterator/reverse_iterator.h>
18#include <__ranges/access.h>
19#include <__ranges/concepts.h>
20#include <__ranges/dangling.h>
21#include <__utility/move.h>
22
23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
24# pragma GCC system_header
25#endif
26
27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
28
29_LIBCPP_BEGIN_NAMESPACE_STD
30
31namespace ranges {
32
33template<class _Ip, class _Op>
34using copy_backward_result = in_out_result<_Ip, _Op>;
35
36namespace __copy_backward {
37struct __fn {
38
39 template <bidirectional_iterator _InIter1, sentinel_for<_InIter1> _Sent1, bidirectional_iterator _InIter2>
40 requires indirectly_copyable<_InIter1, _InIter2>
41 _LIBCPP_HIDE_FROM_ABI constexpr
42 copy_backward_result<_InIter1, _InIter2> operator()(_InIter1 __first, _Sent1 __last, _InIter2 __result) const {
43 auto __ret = std::__copy_backward<_RangeAlgPolicy>(std::move(__first), std::move(__last), std::move(__result));
44 return {std::move(__ret.first), std::move(__ret.second)};
45 }
46
47 template <bidirectional_range _Range, bidirectional_iterator _Iter>
48 requires indirectly_copyable<iterator_t<_Range>, _Iter>
49 _LIBCPP_HIDE_FROM_ABI constexpr
50 copy_backward_result<borrowed_iterator_t<_Range>, _Iter> operator()(_Range&& __r, _Iter __result) const {
51 auto __ret = std::__copy_backward<_RangeAlgPolicy>(ranges::begin(__r), ranges::end(__r), std::move(__result));
52 return {std::move(__ret.first), std::move(__ret.second)};
53 }
54};
55} // namespace __copy_backward
56
57inline namespace __cpo {
58 inline constexpr auto copy_backward = __copy_backward::__fn{};
59} // namespace __cpo
60} // namespace ranges
61
62_LIBCPP_END_NAMESPACE_STD
63
64#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
65
66#endif // _LIBCPP___ALGORITHM_RANGES_COPY_BACKWARD_H
lib/libcxx/include/__algorithm/ranges_copy_if.h created+81
...@@ -0,0 +1,81 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_COPY_IF_H
10#define _LIBCPP___ALGORITHM_RANGES_COPY_IF_H
11
12#include <__algorithm/in_out_result.h>
13#include <__config>
14#include <__functional/identity.h>
15#include <__functional/invoke.h>
16#include <__iterator/concepts.h>
17#include <__iterator/projected.h>
18#include <__ranges/access.h>
19#include <__ranges/concepts.h>
20#include <__ranges/dangling.h>
21#include <__utility/move.h>
22
23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
24# pragma GCC system_header
25#endif
26
27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
28
29_LIBCPP_BEGIN_NAMESPACE_STD
30
31namespace ranges {
32
33template<class _Ip, class _Op>
34using copy_if_result = in_out_result<_Ip, _Op>;
35
36namespace __copy_if {
37struct __fn {
38
39 template <class _InIter, class _Sent, class _OutIter, class _Proj, class _Pred>
40 _LIBCPP_HIDE_FROM_ABI static constexpr
41 copy_if_result <_InIter, _OutIter>
42 __copy_if_impl(_InIter __first, _Sent __last, _OutIter __result, _Pred& __pred, _Proj& __proj) {
43 for (; __first != __last; ++__first) {
44 if (std::invoke(__pred, std::invoke(__proj, *__first))) {
45 *__result = *__first;
46 ++__result;
47 }
48 }
49 return {std::move(__first), std::move(__result)};
50 }
51
52 template <input_iterator _Iter, sentinel_for<_Iter> _Sent, weakly_incrementable _OutIter, class _Proj = identity,
53 indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>
54 requires indirectly_copyable<_Iter, _OutIter>
55 _LIBCPP_HIDE_FROM_ABI constexpr
56 copy_if_result<_Iter, _OutIter>
57 operator()(_Iter __first, _Sent __last, _OutIter __result, _Pred __pred, _Proj __proj = {}) const {
58 return __copy_if_impl(std::move(__first), std::move(__last), std::move(__result), __pred, __proj);
59 }
60
61 template <input_range _Range, weakly_incrementable _OutIter, class _Proj = identity,
62 indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
63 requires indirectly_copyable<iterator_t<_Range>, _OutIter>
64 _LIBCPP_HIDE_FROM_ABI constexpr
65 copy_if_result<borrowed_iterator_t<_Range>, _OutIter>
66 operator()(_Range&& __r, _OutIter __result, _Pred __pred, _Proj __proj = {}) const {
67 return __copy_if_impl(ranges::begin(__r), ranges::end(__r), std::move(__result), __pred, __proj);
68 }
69};
70} // namespace __copy_if
71
72inline namespace __cpo {
73 inline constexpr auto copy_if = __copy_if::__fn{};
74} // namespace __cpo
75} // namespace ranges
76
77_LIBCPP_END_NAMESPACE_STD
78
79#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
80
81#endif // _LIBCPP___ALGORITHM_RANGES_COPY_IF_H
lib/libcxx/include/__algorithm/ranges_copy_n.h created+76
...@@ -0,0 +1,76 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_COPY_N_H
10#define _LIBCPP___ALGORITHM_RANGES_COPY_N_H
11
12#include <__algorithm/copy.h>
13#include <__algorithm/in_out_result.h>
14#include <__algorithm/ranges_copy.h>
15#include <__config>
16#include <__functional/identity.h>
17#include <__iterator/concepts.h>
18#include <__iterator/incrementable_traits.h>
19#include <__iterator/unreachable_sentinel.h>
20#include <__iterator/wrap_iter.h>
21#include <__utility/move.h>
22
23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
24# pragma GCC system_header
25#endif
26
27_LIBCPP_BEGIN_NAMESPACE_STD
28
29#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
30
31namespace ranges {
32
33template <class _Ip, class _Op>
34using copy_n_result = in_out_result<_Ip, _Op>;
35
36namespace __copy_n {
37struct __fn {
38
39 template <class _InIter, class _DiffType, class _OutIter>
40 _LIBCPP_HIDE_FROM_ABI constexpr static
41 copy_n_result<_InIter, _OutIter> __go(_InIter __first, _DiffType __n, _OutIter __result) {
42 while (__n != 0) {
43 *__result = *__first;
44 ++__first;
45 ++__result;
46 --__n;
47 }
48 return {std::move(__first), std::move(__result)};
49 }
50
51 template <random_access_iterator _InIter, class _DiffType, random_access_iterator _OutIter>
52 _LIBCPP_HIDE_FROM_ABI constexpr static
53 copy_n_result<_InIter, _OutIter> __go(_InIter __first, _DiffType __n, _OutIter __result) {
54 auto __ret = std::__copy(__first, __first + __n, __result);
55 return {__ret.first, __ret.second};
56 }
57
58 template <input_iterator _Ip, weakly_incrementable _Op>
59 requires indirectly_copyable<_Ip, _Op>
60 _LIBCPP_HIDE_FROM_ABI constexpr
61 copy_n_result<_Ip, _Op> operator()(_Ip __first, iter_difference_t<_Ip> __n, _Op __result) const {
62 return __go(std::move(__first), __n, std::move(__result));
63 }
64};
65} // namespace __copy_n
66
67inline namespace __cpo {
68 inline constexpr auto copy_n = __copy_n::__fn{};
69} // namespace __cpo
70} // namespace ranges
71
72#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
73
74_LIBCPP_END_NAMESPACE_STD
75
76#endif // _LIBCPP___ALGORITHM_RANGES_COPY_N_H
lib/libcxx/include/__algorithm/ranges_count.h created+62
...@@ -0,0 +1,62 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_COUNT_H
10#define _LIBCPP___ALGORITHM_RANGES_COUNT_H
11
12#include <__algorithm/ranges_count_if.h>
13#include <__config>
14#include <__functional/identity.h>
15#include <__functional/ranges_operations.h>
16#include <__iterator/concepts.h>
17#include <__iterator/incrementable_traits.h>
18#include <__iterator/iterator_traits.h>
19#include <__iterator/projected.h>
20#include <__ranges/access.h>
21#include <__ranges/concepts.h>
22#include <__utility/move.h>
23
24#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
25# pragma GCC system_header
26#endif
27
28#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
29
30_LIBCPP_BEGIN_NAMESPACE_STD
31
32namespace ranges {
33namespace __count {
34struct __fn {
35 template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity>
36 requires indirect_binary_predicate<ranges::equal_to, projected<_Iter, _Proj>, const _Type*>
37 _LIBCPP_HIDE_FROM_ABI constexpr
38 iter_difference_t<_Iter> operator()(_Iter __first, _Sent __last, const _Type& __value, _Proj __proj = {}) const {
39 auto __pred = [&](auto&& __e) { return __e == __value; };
40 return ranges::__count_if_impl(std::move(__first), std::move(__last), __pred, __proj);
41 }
42
43 template <input_range _Range, class _Type, class _Proj = identity>
44 requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Range>, _Proj>, const _Type*>
45 _LIBCPP_HIDE_FROM_ABI constexpr
46 range_difference_t<_Range> operator()(_Range&& __r, const _Type& __value, _Proj __proj = {}) const {
47 auto __pred = [&](auto&& __e) { return __e == __value; };
48 return ranges::__count_if_impl(ranges::begin(__r), ranges::end(__r), __pred, __proj);
49 }
50};
51} // namespace __count
52
53inline namespace __cpo {
54 inline constexpr auto count = __count::__fn{};
55} // namespace __cpo
56} // namespace ranges
57
58_LIBCPP_END_NAMESPACE_STD
59
60#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
61
62#endif // _LIBCPP___ALGORITHM_RANGES_COUNT_H
lib/libcxx/include/__algorithm/ranges_count_if.h created+72
...@@ -0,0 +1,72 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_COUNT_IF_H
10#define _LIBCPP___ALGORITHM_RANGES_COUNT_IF_H
11
12#include <__config>
13#include <__functional/identity.h>
14#include <__functional/invoke.h>
15#include <__functional/ranges_operations.h>
16#include <__iterator/concepts.h>
17#include <__iterator/incrementable_traits.h>
18#include <__iterator/iterator_traits.h>
19#include <__iterator/projected.h>
20#include <__ranges/access.h>
21#include <__ranges/concepts.h>
22#include <__utility/move.h>
23
24#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
25# pragma GCC system_header
26#endif
27
28#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
29
30_LIBCPP_BEGIN_NAMESPACE_STD
31
32namespace ranges {
33template <class _Iter, class _Sent, class _Proj, class _Pred>
34_LIBCPP_HIDE_FROM_ABI constexpr
35iter_difference_t<_Iter> __count_if_impl(_Iter __first, _Sent __last,
36 _Pred& __pred, _Proj& __proj) {
37 iter_difference_t<_Iter> __counter(0);
38 for (; __first != __last; ++__first) {
39 if (std::invoke(__pred, std::invoke(__proj, *__first)))
40 ++__counter;
41 }
42 return __counter;
43}
44
45namespace __count_if {
46struct __fn {
47 template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity,
48 indirect_unary_predicate<projected<_Iter, _Proj>> _Predicate>
49 _LIBCPP_HIDE_FROM_ABI constexpr
50 iter_difference_t<_Iter> operator()(_Iter __first, _Sent __last, _Predicate __pred, _Proj __proj = {}) const {
51 return ranges::__count_if_impl(std::move(__first), std::move(__last), __pred, __proj);
52 }
53
54 template <input_range _Range, class _Proj = identity,
55 indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Predicate>
56 _LIBCPP_HIDE_FROM_ABI constexpr
57 range_difference_t<_Range> operator()(_Range&& __r, _Predicate __pred, _Proj __proj = {}) const {
58 return ranges::__count_if_impl(ranges::begin(__r), ranges::end(__r), __pred, __proj);
59 }
60};
61} // namespace __count_if
62
63inline namespace __cpo {
64 inline constexpr auto count_if = __count_if::__fn{};
65} // namespace __cpo
66} // namespace ranges
67
68_LIBCPP_END_NAMESPACE_STD
69
70#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
71
72#endif // _LIBCPP___ALGORITHM_RANGES_COUNT_IF_H
lib/libcxx/include/__algorithm/ranges_equal.h created+115
...@@ -0,0 +1,115 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_EQUAL_H
10#define _LIBCPP___ALGORITHM_RANGES_EQUAL_H
11
12#include <__config>
13#include <__functional/identity.h>
14#include <__functional/invoke.h>
15#include <__functional/ranges_operations.h>
16#include <__iterator/concepts.h>
17#include <__iterator/distance.h>
18#include <__iterator/indirectly_comparable.h>
19#include <__ranges/access.h>
20#include <__ranges/concepts.h>
21#include <__utility/move.h>
22
23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
24# pragma GCC system_header
25#endif
26
27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
28
29_LIBCPP_BEGIN_NAMESPACE_STD
30
31namespace ranges {
32namespace __equal {
33struct __fn {
34private:
35 template <class _Iter1, class _Sent1,
36 class _Iter2, class _Sent2,
37 class _Pred,
38 class _Proj1,
39 class _Proj2>
40 _LIBCPP_HIDE_FROM_ABI constexpr static
41 bool __equal_impl(_Iter1 __first1, _Sent1 __last1,
42 _Iter2 __first2, _Sent2 __last2,
43 _Pred& __pred,
44 _Proj1& __proj1,
45 _Proj2& __proj2) {
46 while (__first1 != __last1 && __first2 != __last2) {
47 if (!std::invoke(__pred, std::invoke(__proj1, *__first1), std::invoke(__proj2, *__first2)))
48 return false;
49 ++__first1;
50 ++__first2;
51 }
52 return __first1 == __last1 && __first2 == __last2;
53 }
54
55public:
56
57 template <input_iterator _Iter1, sentinel_for<_Iter1> _Sent1,
58 input_iterator _Iter2, sentinel_for<_Iter2> _Sent2,
59 class _Pred = ranges::equal_to,
60 class _Proj1 = identity,
61 class _Proj2 = identity>
62 requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2>
63 _LIBCPP_HIDE_FROM_ABI constexpr
64 bool operator()(_Iter1 __first1, _Sent1 __last1,
65 _Iter2 __first2, _Sent2 __last2,
66 _Pred __pred = {},
67 _Proj1 __proj1 = {},
68 _Proj2 __proj2 = {}) const {
69 if constexpr (sized_sentinel_for<_Sent1, _Iter1> && sized_sentinel_for<_Sent2, _Iter2>) {
70 if (__last1 - __first1 != __last2 - __first2)
71 return false;
72 }
73 return __equal_impl(std::move(__first1), std::move(__last1),
74 std::move(__first2), std::move(__last2),
75 __pred,
76 __proj1,
77 __proj2);
78 }
79
80 template <input_range _Range1,
81 input_range _Range2,
82 class _Pred = ranges::equal_to,
83 class _Proj1 = identity,
84 class _Proj2 = identity>
85 requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2>
86 _LIBCPP_HIDE_FROM_ABI constexpr
87 bool operator()(_Range1&& __range1,
88 _Range2&& __range2,
89 _Pred __pred = {},
90 _Proj1 __proj1 = {},
91 _Proj2 __proj2 = {}) const {
92 if constexpr (sized_range<_Range1> && sized_range<_Range2>) {
93 if (ranges::distance(__range1) != ranges::distance(__range2))
94 return false;
95 }
96 return __equal_impl(ranges::begin(__range1), ranges::end(__range1),
97 ranges::begin(__range2), ranges::end(__range2),
98 __pred,
99 __proj1,
100 __proj2);
101 return false;
102 }
103};
104} // namespace __equal
105
106inline namespace __cpo {
107 inline constexpr auto equal = __equal::__fn{};
108} // namespace __cpo
109} // namespace ranges
110
111_LIBCPP_END_NAMESPACE_STD
112
113#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
114
115#endif // _LIBCPP___ALGORITHM_RANGES_EQUAL_H
lib/libcxx/include/__algorithm/ranges_equal_range.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___ALGORITHM_RANGES_EQUAL_RANGE_H
10#define _LIBCPP___ALGORITHM_RANGES_EQUAL_RANGE_H
11
12#include <__algorithm/equal_range.h>
13#include <__algorithm/iterator_operations.h>
14#include <__config>
15#include <__functional/identity.h>
16#include <__functional/invoke.h>
17#include <__functional/ranges_operations.h>
18#include <__iterator/concepts.h>
19#include <__iterator/iterator_traits.h>
20#include <__iterator/projected.h>
21#include <__ranges/access.h>
22#include <__ranges/concepts.h>
23#include <__ranges/dangling.h>
24#include <__ranges/subrange.h>
25#include <__utility/forward.h>
26#include <__utility/move.h>
27
28#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
29# pragma GCC system_header
30#endif
31
32#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
33
34_LIBCPP_BEGIN_NAMESPACE_STD
35
36namespace ranges {
37namespace __equal_range {
38
39struct __fn {
40 template <
41 forward_iterator _Iter,
42 sentinel_for<_Iter> _Sent,
43 class _Tp,
44 class _Proj = identity,
45 indirect_strict_weak_order<const _Tp*, projected<_Iter, _Proj>> _Comp = ranges::less>
46 _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter>
47 operator()(_Iter __first, _Sent __last, const _Tp& __value, _Comp __comp = {}, _Proj __proj = {}) const {
48 auto __ret = std::__equal_range<_RangeAlgPolicy>(
49 std::move(__first), std::move(__last), __value, __comp, __proj);
50 return {std::move(__ret.first), std::move(__ret.second)};
51 }
52
53 template <
54 forward_range _Range,
55 class _Tp,
56 class _Proj = identity,
57 indirect_strict_weak_order<const _Tp*, projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
58 _LIBCPP_HIDE_FROM_ABI constexpr borrowed_subrange_t<_Range>
59 operator()(_Range&& __range, const _Tp& __value, _Comp __comp = {}, _Proj __proj = {}) const {
60 auto __ret = std::__equal_range<_RangeAlgPolicy>(
61 ranges::begin(__range), ranges::end(__range), __value, __comp, __proj);
62 return {std::move(__ret.first), std::move(__ret.second)};
63 }
64};
65
66} // namespace __equal_range
67
68inline namespace __cpo {
69 inline constexpr auto equal_range = __equal_range::__fn{};
70} // namespace __cpo
71} // namespace ranges
72
73_LIBCPP_END_NAMESPACE_STD
74
75#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
76
77#endif // _LIBCPP___ALGORITHM_RANGES_EQUAL_RANGE_H
lib/libcxx/include/__algorithm/ranges_fill.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___ALGORITHM_RANGES_FILL_H
10#define _LIBCPP___ALGORITHM_RANGES_FILL_H
11
12#include <__algorithm/ranges_fill_n.h>
13#include <__config>
14#include <__iterator/concepts.h>
15#include <__ranges/access.h>
16#include <__ranges/concepts.h>
17#include <__ranges/dangling.h>
18
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20# pragma GCC system_header
21#endif
22
23#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
24
25_LIBCPP_BEGIN_NAMESPACE_STD
26
27namespace ranges {
28namespace __fill {
29struct __fn {
30 template <class _Type, output_iterator<const _Type&> _Iter, sentinel_for<_Iter> _Sent>
31 _LIBCPP_HIDE_FROM_ABI constexpr
32 _Iter operator()(_Iter __first, _Sent __last, const _Type& __value) const {
33 if constexpr(random_access_iterator<_Iter> && sized_sentinel_for<_Sent, _Iter>) {
34 return ranges::fill_n(__first, __last - __first, __value);
35 } else {
36 for (; __first != __last; ++__first)
37 *__first = __value;
38 return __first;
39 }
40 }
41
42 template <class _Type, output_range<const _Type&> _Range>
43 _LIBCPP_HIDE_FROM_ABI constexpr
44 borrowed_iterator_t<_Range> operator()(_Range&& __range, const _Type& __value) const {
45 return (*this)(ranges::begin(__range), ranges::end(__range), __value);
46 }
47};
48} // namespace __fill
49
50inline namespace __cpo {
51 inline constexpr auto fill = __fill::__fn{};
52} // namespace __cpo
53} // namespace ranges
54
55_LIBCPP_END_NAMESPACE_STD
56
57#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
58
59#endif // _LIBCPP___ALGORITHM_RANGES_FILL_H
lib/libcxx/include/__algorithm/ranges_fill_n.h created+48
...@@ -0,0 +1,48 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_FILL_N_H
10#define _LIBCPP___ALGORITHM_RANGES_FILL_N_H
11
12#include <__config>
13#include <__iterator/concepts.h>
14#include <__iterator/incrementable_traits.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 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
21
22_LIBCPP_BEGIN_NAMESPACE_STD
23
24namespace ranges {
25namespace __fill_n {
26struct __fn {
27 template <class _Type, output_iterator<const _Type&> _Iter>
28 _LIBCPP_HIDE_FROM_ABI constexpr
29 _Iter operator()(_Iter __first, iter_difference_t<_Iter> __n, const _Type& __value) const {
30 for (; __n != 0; --__n) {
31 *__first = __value;
32 ++__first;
33 }
34 return __first;
35 }
36};
37} // namespace __fill_n
38
39inline namespace __cpo {
40 inline constexpr auto fill_n = __fill_n::__fn{};
41} // namespace __cpo
42} // namespace ranges
43
44_LIBCPP_END_NAMESPACE_STD
45
46#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
47
48#endif // _LIBCPP___ALGORITHM_RANGES_FILL_N_H
lib/libcxx/include/__algorithm/ranges_find.h created+63
...@@ -0,0 +1,63 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_FIND_H
10#define _LIBCPP___ALGORITHM_RANGES_FIND_H
11
12#include <__algorithm/ranges_find_if.h>
13#include <__config>
14#include <__functional/identity.h>
15#include <__functional/invoke.h>
16#include <__functional/ranges_operations.h>
17#include <__iterator/concepts.h>
18#include <__iterator/projected.h>
19#include <__ranges/access.h>
20#include <__ranges/concepts.h>
21#include <__ranges/dangling.h>
22#include <__utility/forward.h>
23#include <__utility/move.h>
24
25#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
26# pragma GCC system_header
27#endif
28
29#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
30
31_LIBCPP_BEGIN_NAMESPACE_STD
32
33namespace ranges {
34namespace __find {
35struct __fn {
36 template <input_iterator _Ip, sentinel_for<_Ip> _Sp, class _Tp, class _Proj = identity>
37 requires indirect_binary_predicate<ranges::equal_to, projected<_Ip, _Proj>, const _Tp*>
38 _LIBCPP_HIDE_FROM_ABI constexpr
39 _Ip operator()(_Ip __first, _Sp __last, const _Tp& __value, _Proj __proj = {}) const {
40 auto __pred = [&](auto&& __e) { return std::forward<decltype(__e)>(__e) == __value; };
41 return ranges::__find_if_impl(std::move(__first), std::move(__last), __pred, __proj);
42 }
43
44 template <input_range _Rp, class _Tp, class _Proj = identity>
45 requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Rp>, _Proj>, const _Tp*>
46 _LIBCPP_HIDE_FROM_ABI constexpr
47 borrowed_iterator_t<_Rp> operator()(_Rp&& __r, const _Tp& __value, _Proj __proj = {}) const {
48 auto __pred = [&](auto&& __e) { return std::forward<decltype(__e)>(__e) == __value; };
49 return ranges::__find_if_impl(ranges::begin(__r), ranges::end(__r), __pred, __proj);
50 }
51};
52} // namespace __find
53
54inline namespace __cpo {
55 inline constexpr auto find = __find::__fn{};
56} // namespace __cpo
57} // namespace ranges
58
59_LIBCPP_END_NAMESPACE_STD
60
61#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
62
63#endif // _LIBCPP___ALGORITHM_RANGES_FIND_H
lib/libcxx/include/__algorithm/ranges_find_end.h created+97
...@@ -0,0 +1,97 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_FIND_END_H
10#define _LIBCPP___ALGORITHM_RANGES_FIND_END_H
11
12#include <__algorithm/find_end.h>
13#include <__algorithm/iterator_operations.h>
14#include <__algorithm/ranges_iterator_concept.h>
15#include <__config>
16#include <__functional/identity.h>
17#include <__functional/ranges_operations.h>
18#include <__iterator/concepts.h>
19#include <__iterator/indirectly_comparable.h>
20#include <__iterator/iterator_traits.h>
21#include <__ranges/access.h>
22#include <__ranges/concepts.h>
23#include <__ranges/subrange.h>
24
25#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
26# pragma GCC system_header
27#endif
28
29#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
30
31_LIBCPP_BEGIN_NAMESPACE_STD
32
33namespace ranges {
34namespace __find_end {
35struct __fn {
36 template <forward_iterator _Iter1, sentinel_for<_Iter1> _Sent1,
37 forward_iterator _Iter2, sentinel_for<_Iter2> _Sent2,
38 class _Pred = ranges::equal_to,
39 class _Proj1 = identity,
40 class _Proj2 = identity>
41 requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2>
42 _LIBCPP_HIDE_FROM_ABI constexpr
43 subrange<_Iter1> operator()(_Iter1 __first1, _Sent1 __last1,
44 _Iter2 __first2, _Sent2 __last2,
45 _Pred __pred = {},
46 _Proj1 __proj1 = {},
47 _Proj2 __proj2 = {}) const {
48 auto __ret = std::__find_end_impl<_RangeAlgPolicy>(
49 __first1,
50 __last1,
51 __first2,
52 __last2,
53 __pred,
54 __proj1,
55 __proj2,
56 __iterator_concept<_Iter1>(),
57 __iterator_concept<_Iter2>());
58 return {__ret.first, __ret.second};
59 }
60
61 template <forward_range _Range1,
62 forward_range _Range2,
63 class _Pred = ranges::equal_to,
64 class _Proj1 = identity,
65 class _Proj2 = identity>
66 requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2>
67 _LIBCPP_HIDE_FROM_ABI constexpr
68 borrowed_subrange_t<_Range1> operator()(_Range1&& __range1,
69 _Range2&& __range2,
70 _Pred __pred = {},
71 _Proj1 __proj1 = {},
72 _Proj2 __proj2 = {}) const {
73 auto __ret = std::__find_end_impl<_RangeAlgPolicy>(
74 ranges::begin(__range1),
75 ranges::end(__range1),
76 ranges::begin(__range2),
77 ranges::end(__range2),
78 __pred,
79 __proj1,
80 __proj2,
81 __iterator_concept<iterator_t<_Range1>>(),
82 __iterator_concept<iterator_t<_Range2>>());
83 return {__ret.first, __ret.second};
84 }
85};
86} // namespace __find_end
87
88inline namespace __cpo {
89 inline constexpr auto find_end = __find_end::__fn{};
90} // namespace __cpo
91} // namespace ranges
92
93_LIBCPP_END_NAMESPACE_STD
94
95#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
96
97#endif // _LIBCPP___ALGORITHM_RANGES_FIND_END_H
lib/libcxx/include/__algorithm/ranges_find_first_of.h created+101
...@@ -0,0 +1,101 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_FIND_FIRST_OF_H
10#define _LIBCPP___ALGORITHM_RANGES_FIND_FIRST_OF_H
11
12#include <__config>
13#include <__functional/identity.h>
14#include <__functional/invoke.h>
15#include <__functional/ranges_operations.h>
16#include <__iterator/concepts.h>
17#include <__iterator/indirectly_comparable.h>
18#include <__ranges/access.h>
19#include <__ranges/concepts.h>
20#include <__ranges/dangling.h>
21#include <__utility/move.h>
22
23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
24# pragma GCC system_header
25#endif
26
27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
28
29_LIBCPP_BEGIN_NAMESPACE_STD
30
31namespace ranges {
32namespace __find_first_of {
33struct __fn {
34
35 template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Pred, class _Proj1, class _Proj2>
36 _LIBCPP_HIDE_FROM_ABI constexpr static
37 _Iter1 __find_first_of_impl(_Iter1 __first1, _Sent1 __last1,
38 _Iter2 __first2, _Sent2 __last2,
39 _Pred& __pred,
40 _Proj1& __proj1,
41 _Proj2& __proj2) {
42 for (; __first1 != __last1; ++__first1) {
43 for (auto __j = __first2; __j != __last2; ++__j) {
44 if (std::invoke(__pred, std::invoke(__proj1, *__first1), std::invoke(__proj2, *__j)))
45 return __first1;
46 }
47 }
48 return __first1;
49 }
50
51 template <input_iterator _Iter1, sentinel_for<_Iter1> _Sent1,
52 forward_iterator _Iter2, sentinel_for<_Iter2> _Sent2,
53 class _Pred = ranges::equal_to,
54 class _Proj1 = identity,
55 class _Proj2 = identity>
56 requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2>
57 _LIBCPP_HIDE_FROM_ABI constexpr
58 _Iter1 operator()(_Iter1 __first1, _Sent1 __last1,
59 _Iter2 __first2, _Sent2 __last2,
60 _Pred __pred = {},
61 _Proj1 __proj1 = {},
62 _Proj2 __proj2 = {}) const {
63 return __find_first_of_impl(std::move(__first1), std::move(__last1),
64 std::move(__first2), std::move(__last2),
65 __pred,
66 __proj1,
67 __proj2);
68 }
69
70 template <input_range _Range1,
71 forward_range _Range2,
72 class _Pred = ranges::equal_to,
73 class _Proj1 = identity,
74 class _Proj2 = identity>
75 requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2>
76 _LIBCPP_HIDE_FROM_ABI constexpr
77 borrowed_iterator_t<_Range1> operator()(_Range1&& __range1,
78 _Range2&& __range2,
79 _Pred __pred = {},
80 _Proj1 __proj1 = {},
81 _Proj2 __proj2 = {}) const {
82 return __find_first_of_impl(ranges::begin(__range1), ranges::end(__range1),
83 ranges::begin(__range2), ranges::end(__range2),
84 __pred,
85 __proj1,
86 __proj2);
87 }
88
89};
90} // namespace __find_first_of
91
92inline namespace __cpo {
93 inline constexpr auto find_first_of = __find_first_of::__fn{};
94} // namespace __cpo
95} // namespace ranges
96
97_LIBCPP_END_NAMESPACE_STD
98
99#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
100
101#endif // _LIBCPP___ALGORITHM_RANGES_FIND_FIRST_OF_H
lib/libcxx/include/__algorithm/ranges_find_if.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___ALGORITHM_RANGES_FIND_IF_H
10#define _LIBCPP___ALGORITHM_RANGES_FIND_IF_H
11
12#include <__config>
13#include <__functional/identity.h>
14#include <__functional/invoke.h>
15#include <__functional/ranges_operations.h>
16#include <__iterator/concepts.h>
17#include <__iterator/projected.h>
18#include <__ranges/access.h>
19#include <__ranges/concepts.h>
20#include <__ranges/dangling.h>
21#include <__utility/move.h>
22
23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
24# pragma GCC system_header
25#endif
26
27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
28
29_LIBCPP_BEGIN_NAMESPACE_STD
30
31namespace ranges {
32
33template <class _Ip, class _Sp, class _Pred, class _Proj>
34_LIBCPP_HIDE_FROM_ABI static constexpr
35_Ip __find_if_impl(_Ip __first, _Sp __last, _Pred& __pred, _Proj& __proj) {
36 for (; __first != __last; ++__first) {
37 if (std::invoke(__pred, std::invoke(__proj, *__first)))
38 break;
39 }
40 return __first;
41}
42
43namespace __find_if {
44struct __fn {
45
46 template <input_iterator _Ip, sentinel_for<_Ip> _Sp, class _Proj = identity,
47 indirect_unary_predicate<projected<_Ip, _Proj>> _Pred>
48 _LIBCPP_HIDE_FROM_ABI constexpr
49 _Ip operator()(_Ip __first, _Sp __last, _Pred __pred, _Proj __proj = {}) const {
50 return ranges::__find_if_impl(std::move(__first), std::move(__last), __pred, __proj);
51 }
52
53 template <input_range _Rp, class _Proj = identity,
54 indirect_unary_predicate<projected<iterator_t<_Rp>, _Proj>> _Pred>
55 _LIBCPP_HIDE_FROM_ABI constexpr
56 borrowed_iterator_t<_Rp> operator()(_Rp&& __r, _Pred __pred, _Proj __proj = {}) const {
57 return ranges::__find_if_impl(ranges::begin(__r), ranges::end(__r), __pred, __proj);
58 }
59};
60} // namespace __find_if
61
62inline namespace __cpo {
63 inline constexpr auto find_if = __find_if::__fn{};
64} // namespace __cpo
65} // namespace ranges
66
67_LIBCPP_END_NAMESPACE_STD
68
69#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
70
71#endif // _LIBCPP___ALGORITHM_RANGES_FIND_IF_H
lib/libcxx/include/__algorithm/ranges_find_if_not.h created+63
...@@ -0,0 +1,63 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_FIND_IF_NOT_H
10#define _LIBCPP___ALGORITHM_RANGES_FIND_IF_NOT_H
11
12#include <__algorithm/ranges_find_if.h>
13#include <__config>
14#include <__functional/identity.h>
15#include <__functional/invoke.h>
16#include <__functional/ranges_operations.h>
17#include <__iterator/concepts.h>
18#include <__iterator/projected.h>
19#include <__ranges/access.h>
20#include <__ranges/concepts.h>
21#include <__ranges/dangling.h>
22#include <__utility/forward.h>
23#include <__utility/move.h>
24
25#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
26# pragma GCC system_header
27#endif
28
29#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
30
31_LIBCPP_BEGIN_NAMESPACE_STD
32
33namespace ranges {
34namespace __find_if_not {
35struct __fn {
36 template <input_iterator _Ip, sentinel_for<_Ip> _Sp, class _Proj = identity,
37 indirect_unary_predicate<projected<_Ip, _Proj>> _Pred>
38 _LIBCPP_HIDE_FROM_ABI constexpr
39 _Ip operator()(_Ip __first, _Sp __last, _Pred __pred, _Proj __proj = {}) const {
40 auto __pred2 = [&](auto&& __e) { return !std::invoke(__pred, std::forward<decltype(__e)>(__e)); };
41 return ranges::__find_if_impl(std::move(__first), std::move(__last), __pred2, __proj);
42 }
43
44 template <input_range _Rp, class _Proj = identity,
45 indirect_unary_predicate<projected<iterator_t<_Rp>, _Proj>> _Pred>
46 _LIBCPP_HIDE_FROM_ABI constexpr
47 borrowed_iterator_t<_Rp> operator()(_Rp&& __r, _Pred __pred, _Proj __proj = {}) const {
48 auto __pred2 = [&](auto&& __e) { return !std::invoke(__pred, std::forward<decltype(__e)>(__e)); };
49 return ranges::__find_if_impl(ranges::begin(__r), ranges::end(__r), __pred2, __proj);
50 }
51};
52} // namespace __find_if_not
53
54inline namespace __cpo {
55 inline constexpr auto find_if_not = __find_if_not::__fn{};
56} // namespace __cpo
57} // namespace ranges
58
59_LIBCPP_END_NAMESPACE_STD
60
61#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
62
63#endif // _LIBCPP___ALGORITHM_RANGES_FIND_IF_NOT_H
lib/libcxx/include/__algorithm/ranges_for_each.h created+78
...@@ -0,0 +1,78 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_FOR_EACH_H
10#define _LIBCPP___ALGORITHM_RANGES_FOR_EACH_H
11
12#include <__algorithm/in_fun_result.h>
13#include <__config>
14#include <__functional/identity.h>
15#include <__functional/invoke.h>
16#include <__iterator/concepts.h>
17#include <__iterator/projected.h>
18#include <__ranges/access.h>
19#include <__ranges/concepts.h>
20#include <__ranges/dangling.h>
21#include <__utility/move.h>
22
23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
24# pragma GCC system_header
25#endif
26
27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
28
29_LIBCPP_BEGIN_NAMESPACE_STD
30
31namespace ranges {
32
33template <class _Iter, class _Func>
34using for_each_result = in_fun_result<_Iter, _Func>;
35
36namespace __for_each {
37struct __fn {
38private:
39 template <class _Iter, class _Sent, class _Proj, class _Func>
40 _LIBCPP_HIDE_FROM_ABI constexpr static
41 for_each_result<_Iter, _Func> __for_each_impl(_Iter __first, _Sent __last, _Func& __func, _Proj& __proj) {
42 for (; __first != __last; ++__first)
43 std::invoke(__func, std::invoke(__proj, *__first));
44 return {std::move(__first), std::move(__func)};
45 }
46
47public:
48 template <input_iterator _Iter, sentinel_for<_Iter> _Sent,
49 class _Proj = identity,
50 indirectly_unary_invocable<projected<_Iter, _Proj>> _Func>
51 _LIBCPP_HIDE_FROM_ABI constexpr
52 for_each_result<_Iter, _Func> operator()(_Iter __first, _Sent __last, _Func __func, _Proj __proj = {}) const {
53 return __for_each_impl(std::move(__first), std::move(__last), __func, __proj);
54 }
55
56 template <input_range _Range,
57 class _Proj = identity,
58 indirectly_unary_invocable<projected<iterator_t<_Range>, _Proj>> _Func>
59 _LIBCPP_HIDE_FROM_ABI constexpr
60 for_each_result<borrowed_iterator_t<_Range>, _Func> operator()(_Range&& __range,
61 _Func __func,
62 _Proj __proj = {}) const {
63 return __for_each_impl(ranges::begin(__range), ranges::end(__range), __func, __proj);
64 }
65
66};
67} // namespace __for_each
68
69inline namespace __cpo {
70 inline constexpr auto for_each = __for_each::__fn{};
71} // namespace __cpo
72} // namespace ranges
73
74_LIBCPP_END_NAMESPACE_STD
75
76#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
77
78#endif // _LIBCPP___ALGORITHM_RANGES_FOR_EACH_H
lib/libcxx/include/__algorithm/ranges_for_each_n.h created+66
...@@ -0,0 +1,66 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_FOR_EACH_N_H
10#define _LIBCPP___ALGORITHM_RANGES_FOR_EACH_N_H
11
12#include <__algorithm/in_fun_result.h>
13#include <__config>
14#include <__functional/identity.h>
15#include <__functional/invoke.h>
16#include <__iterator/concepts.h>
17#include <__iterator/incrementable_traits.h>
18#include <__iterator/iterator_traits.h>
19#include <__iterator/projected.h>
20#include <__ranges/concepts.h>
21#include <__utility/move.h>
22
23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
24# pragma GCC system_header
25#endif
26
27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
28
29_LIBCPP_BEGIN_NAMESPACE_STD
30
31namespace ranges {
32
33template <class _Iter, class _Func>
34using for_each_n_result = in_fun_result<_Iter, _Func>;
35
36namespace __for_each_n {
37struct __fn {
38
39 template <input_iterator _Iter,
40 class _Proj = identity,
41 indirectly_unary_invocable<projected<_Iter, _Proj>> _Func>
42 _LIBCPP_HIDE_FROM_ABI constexpr
43 for_each_n_result<_Iter, _Func> operator()(_Iter __first,
44 iter_difference_t<_Iter> __count,
45 _Func __func,
46 _Proj __proj = {}) const {
47 while (__count-- > 0) {
48 std::invoke(__func, std::invoke(__proj, *__first));
49 ++__first;
50 }
51 return {std::move(__first), std::move(__func)};
52 }
53
54};
55} // namespace __for_each_n
56
57inline namespace __cpo {
58 inline constexpr auto for_each_n = __for_each_n::__fn{};
59} // namespace __cpo
60} // namespace ranges
61
62_LIBCPP_END_NAMESPACE_STD
63
64#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
65
66#endif // _LIBCPP___ALGORITHM_RANGES_FOR_EACH_N_H
lib/libcxx/include/__algorithm/ranges_generate.h created+73
...@@ -0,0 +1,73 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_GENERATE_H
10#define _LIBCPP___ALGORITHM_RANGES_GENERATE_H
11
12#include <__concepts/constructible.h>
13#include <__concepts/invocable.h>
14#include <__config>
15#include <__functional/invoke.h>
16#include <__iterator/concepts.h>
17#include <__iterator/iterator_traits.h>
18#include <__ranges/access.h>
19#include <__ranges/concepts.h>
20#include <__ranges/dangling.h>
21#include <__utility/move.h>
22
23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
24# pragma GCC system_header
25#endif
26
27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
28
29_LIBCPP_BEGIN_NAMESPACE_STD
30
31namespace ranges {
32namespace __generate {
33
34struct __fn {
35
36 template <class _OutIter, class _Sent, class _Func>
37 _LIBCPP_HIDE_FROM_ABI constexpr
38 static _OutIter __generate_fn_impl(_OutIter __first, _Sent __last, _Func& __gen) {
39 for (; __first != __last; ++__first) {
40 *__first = __gen();
41 }
42
43 return __first;
44 }
45
46 template <input_or_output_iterator _OutIter, sentinel_for<_OutIter> _Sent, copy_constructible _Func>
47 requires invocable<_Func&> && indirectly_writable<_OutIter, invoke_result_t<_Func&>>
48 _LIBCPP_HIDE_FROM_ABI constexpr
49 _OutIter operator()(_OutIter __first, _Sent __last, _Func __gen) const {
50 return __generate_fn_impl(std::move(__first), std::move(__last), __gen);
51 }
52
53 template <class _Range, copy_constructible _Func>
54 requires invocable<_Func&> && output_range<_Range, invoke_result_t<_Func&>>
55 _LIBCPP_HIDE_FROM_ABI constexpr
56 borrowed_iterator_t<_Range> operator()(_Range&& __range, _Func __gen) const {
57 return __generate_fn_impl(ranges::begin(__range), ranges::end(__range), __gen);
58 }
59
60};
61
62} // namespace __generate
63
64inline namespace __cpo {
65 inline constexpr auto generate = __generate::__fn{};
66} // namespace __cpo
67} // namespace ranges
68
69_LIBCPP_END_NAMESPACE_STD
70
71#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
72
73#endif // _LIBCPP___ALGORITHM_RANGES_GENERATE_H
lib/libcxx/include/__algorithm/ranges_generate_n.h created+62
...@@ -0,0 +1,62 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_GENERATE_N_H
10#define _LIBCPP___ALGORITHM_RANGES_GENERATE_N_H
11
12#include <__concepts/constructible.h>
13#include <__concepts/invocable.h>
14#include <__config>
15#include <__functional/identity.h>
16#include <__functional/invoke.h>
17#include <__iterator/concepts.h>
18#include <__iterator/incrementable_traits.h>
19#include <__iterator/iterator_traits.h>
20#include <__ranges/access.h>
21#include <__ranges/concepts.h>
22#include <__utility/move.h>
23
24#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
25# pragma GCC system_header
26#endif
27
28#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
29
30_LIBCPP_BEGIN_NAMESPACE_STD
31
32namespace ranges {
33namespace __generate_n {
34
35struct __fn {
36
37 template <input_or_output_iterator _OutIter, copy_constructible _Func>
38 requires invocable<_Func&> && indirectly_writable<_OutIter, invoke_result_t<_Func&>>
39 _LIBCPP_HIDE_FROM_ABI constexpr
40 _OutIter operator()(_OutIter __first, iter_difference_t<_OutIter> __n, _Func __gen) const {
41 for (; __n > 0; --__n) {
42 *__first = __gen();
43 ++__first;
44 }
45
46 return __first;
47 }
48
49};
50
51} // namespace __generate_n
52
53inline namespace __cpo {
54 inline constexpr auto generate_n = __generate_n::__fn{};
55} // namespace __cpo
56} // namespace ranges
57
58_LIBCPP_END_NAMESPACE_STD
59
60#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
61
62#endif // _LIBCPP___ALGORITHM_RANGES_GENERATE_N_H
lib/libcxx/include/__algorithm/ranges_includes.h created+95
...@@ -0,0 +1,95 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_INCLUDES_H
10#define _LIBCPP___ALGORITHM_RANGES_INCLUDES_H
11
12#include <__algorithm/includes.h>
13#include <__algorithm/make_projected.h>
14#include <__config>
15#include <__functional/identity.h>
16#include <__functional/invoke.h>
17#include <__functional/ranges_operations.h>
18#include <__iterator/concepts.h>
19#include <__iterator/iterator_traits.h>
20#include <__iterator/projected.h>
21#include <__ranges/access.h>
22#include <__ranges/concepts.h>
23#include <__utility/forward.h>
24#include <__utility/move.h>
25
26#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
27# pragma GCC system_header
28#endif
29
30#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
31
32_LIBCPP_BEGIN_NAMESPACE_STD
33
34namespace ranges {
35namespace __includes {
36
37struct __fn {
38 template <
39 input_iterator _Iter1,
40 sentinel_for<_Iter1> _Sent1,
41 input_iterator _Iter2,
42 sentinel_for<_Iter2> _Sent2,
43 class _Proj1 = identity,
44 class _Proj2 = identity,
45 indirect_strict_weak_order<projected<_Iter1, _Proj1>, projected<_Iter2, _Proj2>> _Comp = ranges::less>
46 _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
47 _Iter1 __first1,
48 _Sent1 __last1,
49 _Iter2 __first2,
50 _Sent2 __last2,
51 _Comp __comp = {},
52 _Proj1 __proj1 = {},
53 _Proj2 __proj2 = {}) const {
54 return std::__includes(
55 std::move(__first1),
56 std::move(__last1),
57 std::move(__first2),
58 std::move(__last2),
59 std::move(__comp),
60 std::move(__proj1),
61 std::move(__proj2));
62 }
63
64 template <
65 input_range _Range1,
66 input_range _Range2,
67 class _Proj1 = identity,
68 class _Proj2 = identity,
69 indirect_strict_weak_order<projected<iterator_t<_Range1>, _Proj1>, projected<iterator_t<_Range2>, _Proj2>>
70 _Comp = ranges::less>
71 _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
72 _Range1&& __range1, _Range2&& __range2, _Comp __comp = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
73 return std::__includes(
74 ranges::begin(__range1),
75 ranges::end(__range1),
76 ranges::begin(__range2),
77 ranges::end(__range2),
78 std::move(__comp),
79 std::move(__proj1),
80 std::move(__proj2));
81 }
82};
83
84} // namespace __includes
85
86inline namespace __cpo {
87 inline constexpr auto includes = __includes::__fn{};
88} // namespace __cpo
89} // namespace ranges
90
91_LIBCPP_END_NAMESPACE_STD
92
93#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
94
95#endif // _LIBCPP___ALGORITHM_RANGES_INCLUDES_H
lib/libcxx/include/__algorithm/ranges_inplace_merge.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___ALGORITHM_RANGES_INPLACE_MERGE_H
10#define _LIBCPP___ALGORITHM_RANGES_INPLACE_MERGE_H
11
12#include <__algorithm/inplace_merge.h>
13#include <__algorithm/iterator_operations.h>
14#include <__algorithm/make_projected.h>
15#include <__config>
16#include <__functional/identity.h>
17#include <__functional/invoke.h>
18#include <__functional/ranges_operations.h>
19#include <__iterator/concepts.h>
20#include <__iterator/iterator_traits.h>
21#include <__iterator/next.h>
22#include <__iterator/projected.h>
23#include <__iterator/sortable.h>
24#include <__ranges/access.h>
25#include <__ranges/concepts.h>
26#include <__ranges/dangling.h>
27#include <__utility/forward.h>
28#include <__utility/move.h>
29
30#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
31# pragma GCC system_header
32#endif
33
34#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
35
36_LIBCPP_BEGIN_NAMESPACE_STD
37
38namespace ranges {
39namespace __inplace_merge {
40
41 struct __fn {
42 template <class _Iter, class _Sent, class _Comp, class _Proj>
43 _LIBCPP_HIDE_FROM_ABI static constexpr auto
44 __inplace_merge_impl(_Iter __first, _Iter __middle, _Sent __last, _Comp&& __comp, _Proj&& __proj) {
45 auto __last_iter = ranges::next(__middle, __last);
46 std::__inplace_merge<_RangeAlgPolicy>(
47 std::move(__first), std::move(__middle), __last_iter, std::__make_projected(__comp, __proj));
48 return __last_iter;
49 }
50
51 template <
52 bidirectional_iterator _Iter,
53 sentinel_for<_Iter> _Sent,
54 class _Comp = ranges::less,
55 class _Proj = identity>
56 requires sortable<_Iter, _Comp, _Proj>
57 _LIBCPP_HIDE_FROM_ABI _Iter
58 operator()(_Iter __first, _Iter __middle, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
59 return __inplace_merge_impl(
60 std::move(__first), std::move(__middle), std::move(__last), std::move(__comp), std::move(__proj));
61 }
62
63 template <bidirectional_range _Range, class _Comp = ranges::less, class _Proj = identity>
64 requires sortable<
65 iterator_t<_Range>,
66 _Comp,
67 _Proj> _LIBCPP_HIDE_FROM_ABI borrowed_iterator_t<_Range>
68 operator()(_Range&& __range, iterator_t<_Range> __middle, _Comp __comp = {}, _Proj __proj = {}) const {
69 return __inplace_merge_impl(
70 ranges::begin(__range), std::move(__middle), ranges::end(__range), std::move(__comp), std::move(__proj));
71 }
72 };
73
74} // namespace __inplace_merge
75
76inline namespace __cpo {
77 inline constexpr auto inplace_merge = __inplace_merge::__fn{};
78} // namespace __cpo
79} // namespace ranges
80
81_LIBCPP_END_NAMESPACE_STD
82
83#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
84
85#endif // _LIBCPP___ALGORITHM_RANGES_INPLACE_MERGE_H
lib/libcxx/include/__algorithm/ranges_is_heap.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___ALGORITHM_RANGES_IS_HEAP_H
10#define _LIBCPP___ALGORITHM_RANGES_IS_HEAP_H
11
12#include <__algorithm/is_heap_until.h>
13#include <__algorithm/make_projected.h>
14#include <__config>
15#include <__functional/identity.h>
16#include <__functional/ranges_operations.h>
17#include <__iterator/concepts.h>
18#include <__iterator/iterator_traits.h>
19#include <__iterator/next.h>
20#include <__iterator/projected.h>
21#include <__ranges/access.h>
22#include <__ranges/concepts.h>
23#include <__utility/move.h>
24
25#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
26# pragma GCC system_header
27#endif
28
29#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
30
31_LIBCPP_BEGIN_NAMESPACE_STD
32
33namespace ranges {
34namespace __is_heap {
35
36struct __fn {
37
38 template <class _Iter, class _Sent, class _Proj, class _Comp>
39 _LIBCPP_HIDE_FROM_ABI constexpr
40 static bool __is_heap_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {
41 auto __last_iter = ranges::next(__first, __last);
42 auto&& __projected_comp = std::__make_projected(__comp, __proj);
43
44 auto __result = std::__is_heap_until(std::move(__first), std::move(__last_iter), __projected_comp);
45 return __result == __last;
46 }
47
48 template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity,
49 indirect_strict_weak_order<projected<_Iter, _Proj>> _Comp = ranges::less>
50 _LIBCPP_HIDE_FROM_ABI constexpr
51 bool operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
52 return __is_heap_fn_impl(std::move(__first), std::move(__last), __comp, __proj);
53 }
54
55 template <random_access_range _Range, class _Proj = identity,
56 indirect_strict_weak_order<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
57 _LIBCPP_HIDE_FROM_ABI constexpr
58 bool operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const {
59 return __is_heap_fn_impl(ranges::begin(__range), ranges::end(__range), __comp, __proj);
60 }
61};
62
63} // namespace __is_heap
64
65inline namespace __cpo {
66 inline constexpr auto is_heap = __is_heap::__fn{};
67} // namespace __cpo
68} // namespace ranges
69
70_LIBCPP_END_NAMESPACE_STD
71
72#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
73
74#endif // _LIBCPP___ALGORITHM_RANGES_IS_HEAP_H
lib/libcxx/include/__algorithm/ranges_is_heap_until.h created+75
...@@ -0,0 +1,75 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_IS_HEAP_UNTIL_H
10#define _LIBCPP___ALGORITHM_RANGES_IS_HEAP_UNTIL_H
11
12#include <__algorithm/is_heap_until.h>
13#include <__algorithm/make_projected.h>
14#include <__config>
15#include <__functional/identity.h>
16#include <__functional/ranges_operations.h>
17#include <__iterator/concepts.h>
18#include <__iterator/iterator_traits.h>
19#include <__iterator/next.h>
20#include <__iterator/projected.h>
21#include <__ranges/access.h>
22#include <__ranges/concepts.h>
23#include <__ranges/dangling.h>
24#include <__utility/move.h>
25
26#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
27# pragma GCC system_header
28#endif
29
30#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
31
32_LIBCPP_BEGIN_NAMESPACE_STD
33
34namespace ranges {
35namespace __is_heap_until {
36
37struct __fn {
38
39 template <class _Iter, class _Sent, class _Proj, class _Comp>
40 _LIBCPP_HIDE_FROM_ABI constexpr
41 static _Iter __is_heap_until_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {
42 auto __last_iter = ranges::next(__first, __last);
43 auto&& __projected_comp = std::__make_projected(__comp, __proj);
44
45 return std::__is_heap_until(std::move(__first), std::move(__last_iter), __projected_comp);
46 }
47
48 template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity,
49 indirect_strict_weak_order<projected<_Iter, _Proj>> _Comp = ranges::less>
50 _LIBCPP_HIDE_FROM_ABI constexpr
51 _Iter operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
52 return __is_heap_until_fn_impl(std::move(__first), std::move(__last), __comp, __proj);
53 }
54
55 template <random_access_range _Range, class _Proj = identity,
56 indirect_strict_weak_order<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
57 _LIBCPP_HIDE_FROM_ABI constexpr
58 borrowed_iterator_t<_Range> operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const {
59 return __is_heap_until_fn_impl(ranges::begin(__range), ranges::end(__range), __comp, __proj);
60 }
61
62};
63
64} // namespace __is_heap_until
65
66inline namespace __cpo {
67 inline constexpr auto is_heap_until = __is_heap_until::__fn{};
68} // namespace __cpo
69} // namespace ranges
70
71_LIBCPP_END_NAMESPACE_STD
72
73#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
74
75#endif // _LIBCPP___ALGORITHM_RANGES_IS_HEAP_UNTIL_H
lib/libcxx/include/__algorithm/ranges_is_partitioned.h created+81
...@@ -0,0 +1,81 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_IS_PARTITIONED_H
10#define _LIBCPP___ALGORITHM_RANGES_IS_PARTITIONED_H
11
12#include <__config>
13#include <__functional/identity.h>
14#include <__functional/invoke.h>
15#include <__iterator/concepts.h>
16#include <__iterator/indirectly_comparable.h>
17#include <__iterator/projected.h>
18#include <__ranges/access.h>
19#include <__ranges/concepts.h>
20#include <__utility/move.h>
21
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23# pragma GCC system_header
24#endif
25
26#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
27
28_LIBCPP_BEGIN_NAMESPACE_STD
29
30namespace ranges {
31namespace __is_partitioned {
32struct __fn {
33
34 template <class _Iter, class _Sent, class _Proj, class _Pred>
35 _LIBCPP_HIDE_FROM_ABI constexpr static
36 bool __is_parititioned_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) {
37 for (; __first != __last; ++__first) {
38 if (!std::invoke(__pred, std::invoke(__proj, *__first)))
39 break;
40 }
41
42 if (__first == __last)
43 return true;
44 ++__first;
45
46 for (; __first != __last; ++__first) {
47 if (std::invoke(__pred, std::invoke(__proj, *__first)))
48 return false;
49 }
50
51 return true;
52 }
53
54 template <input_iterator _Iter, sentinel_for<_Iter> _Sent,
55 class _Proj = identity,
56 indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>
57 _LIBCPP_HIDE_FROM_ABI constexpr
58 bool operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) const {
59 return __is_parititioned_impl(std::move(__first), std::move(__last), __pred, __proj);
60 }
61
62 template <input_range _Range,
63 class _Proj = identity,
64 indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
65 _LIBCPP_HIDE_FROM_ABI constexpr
66 bool operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const {
67 return __is_parititioned_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
68 }
69};
70} // namespace __is_partitioned
71
72inline namespace __cpo {
73 inline constexpr auto is_partitioned = __is_partitioned::__fn{};
74} // namespace __cpo
75} // namespace ranges
76
77_LIBCPP_END_NAMESPACE_STD
78
79#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
80
81#endif // _LIBCPP___ALGORITHM_RANGES_IS_PARTITIONED_H
lib/libcxx/include/__algorithm/ranges_is_sorted.h created+61
...@@ -0,0 +1,61 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP__ALGORITHM_RANGES_IS_SORTED_H
10#define _LIBCPP__ALGORITHM_RANGES_IS_SORTED_H
11
12#include <__algorithm/ranges_is_sorted_until.h>
13#include <__config>
14#include <__functional/identity.h>
15#include <__functional/ranges_operations.h>
16#include <__iterator/concepts.h>
17#include <__iterator/projected.h>
18#include <__ranges/access.h>
19#include <__ranges/concepts.h>
20#include <__utility/move.h>
21
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23# pragma GCC system_header
24#endif
25
26#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
27
28_LIBCPP_BEGIN_NAMESPACE_STD
29
30namespace ranges {
31namespace __is_sorted {
32struct __fn {
33 template <forward_iterator _Iter, sentinel_for<_Iter> _Sent,
34 class _Proj = identity,
35 indirect_strict_weak_order<projected<_Iter, _Proj>> _Comp = ranges::less>
36 _LIBCPP_HIDE_FROM_ABI constexpr
37 bool operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
38 return ranges::__is_sorted_until_impl(std::move(__first), __last, __comp, __proj) == __last;
39 }
40
41 template <forward_range _Range,
42 class _Proj = identity,
43 indirect_strict_weak_order<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
44 _LIBCPP_HIDE_FROM_ABI constexpr
45 bool operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const {
46 auto __last = ranges::end(__range);
47 return ranges::__is_sorted_until_impl(ranges::begin(__range), __last, __comp, __proj) == __last;
48 }
49};
50} // namespace __is_sorted
51
52inline namespace __cpo {
53 inline constexpr auto is_sorted = __is_sorted::__fn{};
54} // namespace __cpo
55} // namespace ranges
56
57_LIBCPP_END_NAMESPACE_STD
58
59#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
60
61#endif // _LIBCPP__ALGORITHM_RANGES_IS_SORTED_H
lib/libcxx/include/__algorithm/ranges_is_sorted_until.h created+76
...@@ -0,0 +1,76 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP__ALGORITHM_RANGES_IS_SORTED_UNTIL_H
10#define _LIBCPP__ALGORITHM_RANGES_IS_SORTED_UNTIL_H
11
12#include <__config>
13#include <__functional/identity.h>
14#include <__functional/invoke.h>
15#include <__functional/ranges_operations.h>
16#include <__iterator/concepts.h>
17#include <__iterator/projected.h>
18#include <__ranges/access.h>
19#include <__ranges/concepts.h>
20#include <__ranges/dangling.h>
21#include <__utility/move.h>
22
23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
24# pragma GCC system_header
25#endif
26
27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
28
29_LIBCPP_BEGIN_NAMESPACE_STD
30
31namespace ranges {
32
33template <class _Iter, class _Sent, class _Proj, class _Comp>
34_LIBCPP_HIDE_FROM_ABI constexpr
35_Iter __is_sorted_until_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {
36 if (__first == __last)
37 return __first;
38 auto __i = __first;
39 while (++__i != __last) {
40 if (std::invoke(__comp, std::invoke(__proj, *__i), std::invoke(__proj, *__first)))
41 return __i;
42 __first = __i;
43 }
44 return __i;
45}
46
47namespace __is_sorted_until {
48struct __fn {
49 template <forward_iterator _Iter, sentinel_for<_Iter> _Sent,
50 class _Proj = identity,
51 indirect_strict_weak_order<projected<_Iter, _Proj>> _Comp = ranges::less>
52 _LIBCPP_HIDE_FROM_ABI constexpr
53 _Iter operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
54 return ranges::__is_sorted_until_impl(std::move(__first), std::move(__last), __comp, __proj);
55 }
56
57 template <forward_range _Range,
58 class _Proj = identity,
59 indirect_strict_weak_order<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
60 _LIBCPP_HIDE_FROM_ABI constexpr
61 borrowed_iterator_t<_Range> operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const {
62 return ranges::__is_sorted_until_impl(ranges::begin(__range), ranges::end(__range), __comp, __proj);
63 }
64};
65} // namespace __is_sorted_until
66
67inline namespace __cpo {
68 inline constexpr auto is_sorted_until = __is_sorted_until::__fn{};
69} // namespace __cpo
70} // namespace ranges
71
72_LIBCPP_END_NAMESPACE_STD
73
74#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
75
76#endif // _LIBCPP__ALGORITHM_RANGES_IS_SORTED_UNTIL_H
lib/libcxx/include/__algorithm/ranges_iterator_concept.h created+51
...@@ -0,0 +1,51 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_ITERATOR_CONCEPT_H
10#define _LIBCPP___ALGORITHM_RANGES_ITERATOR_CONCEPT_H
11
12#include <__config>
13#include <__iterator/concepts.h>
14#include <__iterator/iterator_traits.h>
15#include <type_traits>
16
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header
19#endif
20
21#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
22
23_LIBCPP_BEGIN_NAMESPACE_STD
24
25namespace ranges {
26
27template <class _IterMaybeQualified>
28consteval auto __get_iterator_concept() {
29 using _Iter = __uncvref_t<_IterMaybeQualified>;
30
31 if constexpr (contiguous_iterator<_Iter>)
32 return contiguous_iterator_tag();
33 else if constexpr (random_access_iterator<_Iter>)
34 return random_access_iterator_tag();
35 else if constexpr (bidirectional_iterator<_Iter>)
36 return bidirectional_iterator_tag();
37 else if constexpr (forward_iterator<_Iter>)
38 return forward_iterator_tag();
39 else if constexpr (input_iterator<_Iter>)
40 return input_iterator_tag();
41}
42
43template <class _Iter>
44using __iterator_concept = decltype(__get_iterator_concept<_Iter>());
45
46} // namespace ranges
47_LIBCPP_END_NAMESPACE_STD
48
49#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
50
51#endif // _LIBCPP___ALGORITHM_RANGES_ITERATOR_CONCEPT_H
lib/libcxx/include/__algorithm/ranges_lexicographical_compare.h created+98
...@@ -0,0 +1,98 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_LEXICOGRAPHICAL_COMPARE_H
10#define _LIBCPP___ALGORITHM_RANGES_LEXICOGRAPHICAL_COMPARE_H
11
12#include <__config>
13#include <__functional/identity.h>
14#include <__functional/invoke.h>
15#include <__functional/ranges_operations.h>
16#include <__iterator/concepts.h>
17#include <__iterator/projected.h>
18#include <__ranges/access.h>
19#include <__ranges/concepts.h>
20#include <__utility/move.h>
21
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23# pragma GCC system_header
24#endif
25
26#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
27
28_LIBCPP_BEGIN_NAMESPACE_STD
29
30namespace ranges {
31namespace __lexicographical_compare {
32struct __fn {
33
34 template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Proj1, class _Proj2, class _Comp>
35 _LIBCPP_HIDE_FROM_ABI constexpr static
36 bool __lexicographical_compare_impl(_Iter1 __first1, _Sent1 __last1,
37 _Iter2 __first2, _Sent2 __last2,
38 _Comp& __comp,
39 _Proj1& __proj1,
40 _Proj2& __proj2) {
41 while (__first2 != __last2) {
42 if (__first1 == __last1
43 || std::invoke(__comp, std::invoke(__proj1, *__first1), std::invoke(__proj2, *__first2)))
44 return true;
45 if (std::invoke(__comp, std::invoke(__proj2, *__first2), std::invoke(__proj1, *__first1)))
46 return false;
47 ++__first1;
48 ++__first2;
49 }
50 return false;
51 }
52
53 template <input_iterator _Iter1, sentinel_for<_Iter1> _Sent1,
54 input_iterator _Iter2, sentinel_for<_Iter2> _Sent2,
55 class _Proj1 = identity,
56 class _Proj2 = identity,
57 indirect_strict_weak_order<projected<_Iter1, _Proj1>, projected<_Iter2, _Proj2>> _Comp = ranges::less>
58 _LIBCPP_HIDE_FROM_ABI constexpr
59 bool operator()(_Iter1 __first1, _Sent1 __last1,
60 _Iter2 __first2, _Sent2 __last2,
61 _Comp __comp = {},
62 _Proj1 __proj1 = {},
63 _Proj2 __proj2 = {}) const {
64 return __lexicographical_compare_impl(std::move(__first1), std::move(__last1),
65 std::move(__first2), std::move(__last2),
66 __comp,
67 __proj1,
68 __proj2);
69 }
70
71 template <input_range _Range1,
72 input_range _Range2,
73 class _Proj1 = identity,
74 class _Proj2 = identity,
75 indirect_strict_weak_order<projected<iterator_t<_Range1>, _Proj1>,
76 projected<iterator_t<_Range2>, _Proj2>> _Comp = ranges::less>
77 _LIBCPP_HIDE_FROM_ABI constexpr
78 bool operator()(_Range1&& __range1, _Range2&& __range2, _Comp __comp = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
79 return __lexicographical_compare_impl(ranges::begin(__range1), ranges::end(__range1),
80 ranges::begin(__range2), ranges::end(__range2),
81 __comp,
82 __proj1,
83 __proj2);
84 }
85
86};
87} // namespace __lexicographical_compare
88
89inline namespace __cpo {
90 inline constexpr auto lexicographical_compare = __lexicographical_compare::__fn{};
91} // namespace __cpo
92} // namespace ranges
93
94_LIBCPP_END_NAMESPACE_STD
95
96#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
97
98#endif // _LIBCPP___ALGORITHM_RANGES_LEXICOGRAPHICAL_COMPARE_H
lib/libcxx/include/__algorithm/ranges_lower_bound.h created+66
...@@ -0,0 +1,66 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_LOWER_BOUND_H
10#define _LIBCPP___ALGORITHM_RANGES_LOWER_BOUND_H
11
12#include <__algorithm/iterator_operations.h>
13#include <__algorithm/lower_bound.h>
14#include <__config>
15#include <__functional/identity.h>
16#include <__functional/invoke.h>
17#include <__functional/ranges_operations.h>
18#include <__iterator/advance.h>
19#include <__iterator/concepts.h>
20#include <__iterator/iterator_traits.h>
21#include <__iterator/projected.h>
22#include <__ranges/access.h>
23#include <__ranges/concepts.h>
24#include <__ranges/dangling.h>
25
26#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
27# pragma GCC system_header
28#endif
29
30#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
31
32_LIBCPP_BEGIN_NAMESPACE_STD
33
34namespace ranges {
35
36namespace __lower_bound {
37struct __fn {
38 template <forward_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity,
39 indirect_strict_weak_order<const _Type*, projected<_Iter, _Proj>> _Comp = ranges::less>
40 _LIBCPP_HIDE_FROM_ABI constexpr
41 _Iter operator()(_Iter __first, _Sent __last, const _Type& __value, _Comp __comp = {}, _Proj __proj = {}) const {
42 return std::__lower_bound_impl<_RangeAlgPolicy>(__first, __last, __value, __comp, __proj);
43 }
44
45 template <forward_range _Range, class _Type, class _Proj = identity,
46 indirect_strict_weak_order<const _Type*, projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
47 _LIBCPP_HIDE_FROM_ABI constexpr
48 borrowed_iterator_t<_Range> operator()(_Range&& __r,
49 const _Type& __value,
50 _Comp __comp = {},
51 _Proj __proj = {}) const {
52 return std::__lower_bound_impl<_RangeAlgPolicy>(ranges::begin(__r), ranges::end(__r), __value, __comp, __proj);
53 }
54};
55} // namespace __lower_bound
56
57inline namespace __cpo {
58 inline constexpr auto lower_bound = __lower_bound::__fn{};
59} // namespace __cpo
60} // namespace ranges
61
62_LIBCPP_END_NAMESPACE_STD
63
64#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
65
66#endif // _LIBCPP___ALGORITHM_RANGES_LOWER_BOUND_H
lib/libcxx/include/__algorithm/ranges_make_heap.h created+80
...@@ -0,0 +1,80 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_MAKE_HEAP_H
10#define _LIBCPP___ALGORITHM_RANGES_MAKE_HEAP_H
11
12#include <__algorithm/iterator_operations.h>
13#include <__algorithm/make_heap.h>
14#include <__algorithm/make_projected.h>
15#include <__concepts/same_as.h>
16#include <__config>
17#include <__functional/identity.h>
18#include <__functional/invoke.h>
19#include <__functional/ranges_operations.h>
20#include <__iterator/concepts.h>
21#include <__iterator/iterator_traits.h>
22#include <__iterator/next.h>
23#include <__iterator/projected.h>
24#include <__iterator/sortable.h>
25#include <__ranges/access.h>
26#include <__ranges/concepts.h>
27#include <__ranges/dangling.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#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
36
37_LIBCPP_BEGIN_NAMESPACE_STD
38
39namespace ranges {
40namespace __make_heap {
41
42struct __fn {
43 template <class _Iter, class _Sent, class _Comp, class _Proj>
44 _LIBCPP_HIDE_FROM_ABI constexpr static
45 _Iter __make_heap_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {
46 auto __last_iter = ranges::next(__first, __last);
47
48 auto&& __projected_comp = std::__make_projected(__comp, __proj);
49 std::__make_heap<_RangeAlgPolicy>(std::move(__first), __last_iter, __projected_comp);
50
51 return __last_iter;
52 }
53
54 template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Comp = ranges::less, class _Proj = identity>
55 requires sortable<_Iter, _Comp, _Proj>
56 _LIBCPP_HIDE_FROM_ABI constexpr
57 _Iter operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
58 return __make_heap_fn_impl(std::move(__first), std::move(__last), __comp, __proj);
59 }
60
61 template <random_access_range _Range, class _Comp = ranges::less, class _Proj = identity>
62 requires sortable<iterator_t<_Range>, _Comp, _Proj>
63 _LIBCPP_HIDE_FROM_ABI constexpr
64 borrowed_iterator_t<_Range> operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
65 return __make_heap_fn_impl(ranges::begin(__r), ranges::end(__r), __comp, __proj);
66 }
67};
68
69} // namespace __make_heap
70
71inline namespace __cpo {
72 inline constexpr auto make_heap = __make_heap::__fn{};
73} // namespace __cpo
74} // namespace ranges
75
76_LIBCPP_END_NAMESPACE_STD
77
78#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
79
80#endif // _LIBCPP___ALGORITHM_RANGES_MAKE_HEAP_H
lib/libcxx/include/__algorithm/ranges_max.h created+93
...@@ -0,0 +1,93 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_MAX_H
10#define _LIBCPP___ALGORITHM_RANGES_MAX_H
11
12#include <__algorithm/ranges_min_element.h>
13#include <__assert>
14#include <__concepts/copyable.h>
15#include <__config>
16#include <__functional/identity.h>
17#include <__functional/invoke.h>
18#include <__functional/ranges_operations.h>
19#include <__iterator/concepts.h>
20#include <__iterator/projected.h>
21#include <__ranges/access.h>
22#include <__ranges/concepts.h>
23#include <__utility/move.h>
24#include <initializer_list>
25
26#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
27# pragma GCC system_header
28#endif
29
30#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
31
32_LIBCPP_PUSH_MACROS
33#include <__undef_macros>
34
35_LIBCPP_BEGIN_NAMESPACE_STD
36
37namespace ranges {
38namespace __max {
39struct __fn {
40 template <class _Tp, class _Proj = identity,
41 indirect_strict_weak_order<projected<const _Tp*, _Proj>> _Comp = ranges::less>
42 _LIBCPP_HIDE_FROM_ABI constexpr
43 const _Tp& operator()(const _Tp& __a, const _Tp& __b, _Comp __comp = {}, _Proj __proj = {}) const {
44 return std::invoke(__comp, std::invoke(__proj, __a), std::invoke(__proj, __b)) ? __b : __a;
45 }
46
47 template <copyable _Tp, class _Proj = identity,
48 indirect_strict_weak_order<projected<const _Tp*, _Proj>> _Comp = ranges::less>
49 _LIBCPP_HIDE_FROM_ABI constexpr
50 _Tp operator()(initializer_list<_Tp> __il, _Comp __comp = {}, _Proj __proj = {}) const {
51 _LIBCPP_ASSERT(__il.begin() != __il.end(), "initializer_list must contain at least one element");
52
53 auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) { return std::invoke(__comp, __rhs, __lhs); };
54 return *ranges::__min_element_impl(__il.begin(), __il.end(), __comp_lhs_rhs_swapped, __proj);
55 }
56
57 template <input_range _Rp, class _Proj = identity,
58 indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less>
59 requires indirectly_copyable_storable<iterator_t<_Rp>, range_value_t<_Rp>*>
60 _LIBCPP_HIDE_FROM_ABI constexpr
61 range_value_t<_Rp> operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
62 auto __first = ranges::begin(__r);
63 auto __last = ranges::end(__r);
64
65 _LIBCPP_ASSERT(__first != __last, "range must contain at least one element");
66
67 if constexpr (forward_range<_Rp>) {
68 auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) { return std::invoke(__comp, __rhs, __lhs); };
69 return *ranges::__min_element_impl(std::move(__first), std::move(__last), __comp_lhs_rhs_swapped, __proj);
70 } else {
71 range_value_t<_Rp> __result = *__first;
72 while (++__first != __last) {
73 if (std::invoke(__comp, std::invoke(__proj, __result), std::invoke(__proj, *__first)))
74 __result = *__first;
75 }
76 return __result;
77 }
78 }
79};
80} // namespace __max
81
82inline namespace __cpo {
83 inline constexpr auto max = __max::__fn{};
84} // namespace __cpo
85} // namespace ranges
86
87_LIBCPP_END_NAMESPACE_STD
88
89_LIBCPP_POP_MACROS
90
91#endif // _LIBCPP_STD_VER > 17 && && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
92
93#endif // _LIBCPP___ALGORITHM_RANGES_MAX_H
lib/libcxx/include/__algorithm/ranges_max_element.h created+61
...@@ -0,0 +1,61 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_MAX_ELEMENT_H
10#define _LIBCPP___ALGORITHM_RANGES_MAX_ELEMENT_H
11
12#include <__algorithm/ranges_min_element.h>
13#include <__config>
14#include <__functional/identity.h>
15#include <__functional/invoke.h>
16#include <__functional/ranges_operations.h>
17#include <__iterator/concepts.h>
18#include <__iterator/projected.h>
19#include <__ranges/access.h>
20#include <__ranges/concepts.h>
21#include <__ranges/dangling.h>
22
23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
24# pragma GCC system_header
25#endif
26
27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
28
29_LIBCPP_BEGIN_NAMESPACE_STD
30
31namespace ranges {
32namespace __max_element {
33struct __fn {
34 template <forward_iterator _Ip, sentinel_for<_Ip> _Sp, class _Proj = identity,
35 indirect_strict_weak_order<projected<_Ip, _Proj>> _Comp = ranges::less>
36 _LIBCPP_HIDE_FROM_ABI constexpr
37 _Ip operator()(_Ip __first, _Sp __last, _Comp __comp = {}, _Proj __proj = {}) const {
38 auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) { return std::invoke(__comp, __rhs, __lhs); };
39 return ranges::__min_element_impl(__first, __last, __comp_lhs_rhs_swapped, __proj);
40 }
41
42 template <forward_range _Rp, class _Proj = identity,
43 indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less>
44 _LIBCPP_HIDE_FROM_ABI constexpr
45 borrowed_iterator_t<_Rp> operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
46 auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) { return std::invoke(__comp, __rhs, __lhs); };
47 return ranges::__min_element_impl(ranges::begin(__r), ranges::end(__r), __comp_lhs_rhs_swapped, __proj);
48 }
49};
50} // namespace __max_element
51
52inline namespace __cpo {
53 inline constexpr auto max_element = __max_element::__fn{};
54} // namespace __cpo
55} // namespace ranges
56
57_LIBCPP_END_NAMESPACE_STD
58
59#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
60
61#endif // _LIBCPP___ALGORITHM_RANGES_MAX_ELEMENT_H
lib/libcxx/include/__algorithm/ranges_merge.h created+142
...@@ -0,0 +1,142 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_MERGE_H
10#define _LIBCPP___ALGORITHM_RANGES_MERGE_H
11
12#include <__algorithm/in_in_out_result.h>
13#include <__algorithm/ranges_copy.h>
14#include <__config>
15#include <__functional/identity.h>
16#include <__functional/invoke.h>
17#include <__functional/ranges_operations.h>
18#include <__iterator/concepts.h>
19#include <__iterator/mergeable.h>
20#include <__ranges/access.h>
21#include <__ranges/concepts.h>
22#include <__ranges/dangling.h>
23#include <__utility/move.h>
24#include <type_traits>
25
26#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
27# pragma GCC system_header
28#endif
29
30#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
31
32_LIBCPP_BEGIN_NAMESPACE_STD
33
34namespace ranges {
35
36template <class _InIter1, class _InIter2, class _OutIter>
37using merge_result = in_in_out_result<_InIter1, _InIter2, _OutIter>;
38
39namespace __merge {
40
41template <
42 class _InIter1,
43 class _Sent1,
44 class _InIter2,
45 class _Sent2,
46 class _OutIter,
47 class _Comp,
48 class _Proj1,
49 class _Proj2>
50_LIBCPP_HIDE_FROM_ABI constexpr merge_result<__uncvref_t<_InIter1>, __uncvref_t<_InIter2>, __uncvref_t<_OutIter>>
51__merge_impl(
52 _InIter1&& __first1,
53 _Sent1&& __last1,
54 _InIter2&& __first2,
55 _Sent2&& __last2,
56 _OutIter&& __result,
57 _Comp&& __comp,
58 _Proj1&& __proj1,
59 _Proj2&& __proj2) {
60 for (; __first1 != __last1 && __first2 != __last2; ++__result) {
61 if (std::invoke(__comp, std::invoke(__proj2, *__first2), std::invoke(__proj1, *__first1))) {
62 *__result = *__first2;
63 ++__first2;
64 } else {
65 *__result = *__first1;
66 ++__first1;
67 }
68 }
69 auto __ret1 = ranges::copy(std::move(__first1), std::move(__last1), std::move(__result));
70 auto __ret2 = ranges::copy(std::move(__first2), std::move(__last2), std::move(__ret1.out));
71 return {std::move(__ret1.in), std::move(__ret2.in), std::move(__ret2.out)};
72}
73
74struct __fn {
75 template <
76 input_iterator _InIter1,
77 sentinel_for<_InIter1> _Sent1,
78 input_iterator _InIter2,
79 sentinel_for<_InIter2> _Sent2,
80 weakly_incrementable _OutIter,
81 class _Comp = less,
82 class _Proj1 = identity,
83 class _Proj2 = identity>
84 requires mergeable<_InIter1, _InIter2, _OutIter, _Comp, _Proj1, _Proj2>
85 _LIBCPP_HIDE_FROM_ABI constexpr merge_result<_InIter1, _InIter2, _OutIter> operator()(
86 _InIter1 __first1,
87 _Sent1 __last1,
88 _InIter2 __first2,
89 _Sent2 __last2,
90 _OutIter __result,
91 _Comp __comp = {},
92 _Proj1 __proj1 = {},
93 _Proj2 __proj2 = {}) const {
94 return __merge::__merge_impl(__first1, __last1, __first2, __last2, __result, __comp, __proj1, __proj2);
95 }
96
97 template <
98 input_range _Range1,
99 input_range _Range2,
100 weakly_incrementable _OutIter,
101 class _Comp = less,
102 class _Proj1 = identity,
103 class _Proj2 = identity>
104 requires mergeable<
105 iterator_t<_Range1>,
106 iterator_t<_Range2>,
107 _OutIter,
108 _Comp,
109 _Proj1,
110 _Proj2>
111 _LIBCPP_HIDE_FROM_ABI constexpr merge_result<borrowed_iterator_t<_Range1>, borrowed_iterator_t<_Range2>, _OutIter>
112 operator()(
113 _Range1&& __range1,
114 _Range2&& __range2,
115 _OutIter __result,
116 _Comp __comp = {},
117 _Proj1 __proj1 = {},
118 _Proj2 __proj2 = {}) const {
119 return __merge::__merge_impl(
120 ranges::begin(__range1),
121 ranges::end(__range1),
122 ranges::begin(__range2),
123 ranges::end(__range2),
124 __result,
125 __comp,
126 __proj1,
127 __proj2);
128 }
129};
130
131} // namespace __merge
132
133inline namespace __cpo {
134 inline constexpr auto merge = __merge::__fn{};
135} // namespace __cpo
136} // namespace ranges
137
138_LIBCPP_END_NAMESPACE_STD
139
140#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
141
142#endif // _LIBCPP___ALGORITHM_RANGES_MERGE_H
lib/libcxx/include/__algorithm/ranges_min.h created+89
...@@ -0,0 +1,89 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_MIN_H
10#define _LIBCPP___ALGORITHM_RANGES_MIN_H
11
12#include <__algorithm/ranges_min_element.h>
13#include <__assert>
14#include <__concepts/copyable.h>
15#include <__config>
16#include <__functional/identity.h>
17#include <__functional/invoke.h>
18#include <__functional/ranges_operations.h>
19#include <__iterator/concepts.h>
20#include <__iterator/projected.h>
21#include <__ranges/access.h>
22#include <__ranges/concepts.h>
23#include <initializer_list>
24
25#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
26# pragma GCC system_header
27#endif
28
29#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
30
31_LIBCPP_PUSH_MACROS
32#include <__undef_macros>
33
34_LIBCPP_BEGIN_NAMESPACE_STD
35
36namespace ranges {
37namespace __min {
38struct __fn {
39 template <class _Tp, class _Proj = identity,
40 indirect_strict_weak_order<projected<const _Tp*, _Proj>> _Comp = ranges::less>
41 _LIBCPP_HIDE_FROM_ABI constexpr
42 const _Tp& operator()(const _Tp& __a, const _Tp& __b, _Comp __comp = {}, _Proj __proj = {}) const {
43 return std::invoke(__comp, std::invoke(__proj, __b), std::invoke(__proj, __a)) ? __b : __a;
44 }
45
46 template <copyable _Tp, class _Proj = identity,
47 indirect_strict_weak_order<projected<const _Tp*, _Proj>> _Comp = ranges::less>
48 _LIBCPP_HIDE_FROM_ABI constexpr
49 _Tp operator()(initializer_list<_Tp> __il, _Comp __comp = {}, _Proj __proj = {}) const {
50 _LIBCPP_ASSERT(__il.begin() != __il.end(), "initializer_list must contain at least one element");
51 return *ranges::__min_element_impl(__il.begin(), __il.end(), __comp, __proj);
52 }
53
54 template <input_range _Rp, class _Proj = identity,
55 indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less>
56 requires indirectly_copyable_storable<iterator_t<_Rp>, range_value_t<_Rp>*>
57 _LIBCPP_HIDE_FROM_ABI constexpr
58 range_value_t<_Rp> operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
59 auto __first = ranges::begin(__r);
60 auto __last = ranges::end(__r);
61
62 _LIBCPP_ASSERT(__first != __last, "range must contain at least one element");
63
64 if constexpr (forward_range<_Rp>) {
65 return *ranges::__min_element_impl(__first, __last, __comp, __proj);
66 } else {
67 range_value_t<_Rp> __result = *__first;
68 while (++__first != __last) {
69 if (std::invoke(__comp, std::invoke(__proj, *__first), std::invoke(__proj, __result)))
70 __result = *__first;
71 }
72 return __result;
73 }
74 }
75};
76} // namespace __min
77
78inline namespace __cpo {
79 inline constexpr auto min = __min::__fn{};
80} // namespace __cpo
81} // namespace ranges
82
83_LIBCPP_END_NAMESPACE_STD
84
85_LIBCPP_POP_MACROS
86
87#endif // _LIBCPP_STD_VER > 17 && && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
88
89#endif // _LIBCPP___ALGORITHM_RANGES_MIN_H
lib/libcxx/include/__algorithm/ranges_min_element.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___ALGORITHM_RANGES_MIN_ELEMENT_H
10#define _LIBCPP___ALGORITHM_RANGES_MIN_ELEMENT_H
11
12#include <__config>
13#include <__functional/identity.h>
14#include <__functional/invoke.h>
15#include <__functional/ranges_operations.h>
16#include <__iterator/concepts.h>
17#include <__iterator/projected.h>
18#include <__ranges/access.h>
19#include <__ranges/concepts.h>
20#include <__ranges/dangling.h>
21#include <__utility/forward.h>
22
23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
24# pragma GCC system_header
25#endif
26
27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
28
29_LIBCPP_BEGIN_NAMESPACE_STD
30
31namespace ranges {
32
33// TODO(ranges): `ranges::min_element` can now simply delegate to `std::__min_element`.
34template <class _Ip, class _Sp, class _Proj, class _Comp>
35_LIBCPP_HIDE_FROM_ABI static constexpr
36_Ip __min_element_impl(_Ip __first, _Sp __last, _Comp& __comp, _Proj& __proj) {
37 if (__first == __last)
38 return __first;
39
40 _Ip __i = __first;
41 while (++__i != __last)
42 if (std::invoke(__comp, std::invoke(__proj, *__i), std::invoke(__proj, *__first)))
43 __first = __i;
44 return __first;
45}
46
47namespace __min_element {
48struct __fn {
49 template <forward_iterator _Ip, sentinel_for<_Ip> _Sp, class _Proj = identity,
50 indirect_strict_weak_order<projected<_Ip, _Proj>> _Comp = ranges::less>
51 _LIBCPP_HIDE_FROM_ABI constexpr
52 _Ip operator()(_Ip __first, _Sp __last, _Comp __comp = {}, _Proj __proj = {}) const {
53 return ranges::__min_element_impl(__first, __last, __comp, __proj);
54 }
55
56 template <forward_range _Rp, class _Proj = identity,
57 indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less>
58 _LIBCPP_HIDE_FROM_ABI constexpr
59 borrowed_iterator_t<_Rp> operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
60 return ranges::__min_element_impl(ranges::begin(__r), ranges::end(__r), __comp, __proj);
61 }
62};
63} // namespace __min_element
64
65inline namespace __cpo {
66 inline constexpr auto min_element = __min_element::__fn{};
67} // namespace __cpo
68} // namespace ranges
69
70_LIBCPP_END_NAMESPACE_STD
71
72#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
73
74#endif // _LIBCPP___ALGORITHM_RANGES_MIN_ELEMENT_H
lib/libcxx/include/__algorithm/ranges_minmax.h created+133
...@@ -0,0 +1,133 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_MINMAX_H
10#define _LIBCPP___ALGORITHM_RANGES_MINMAX_H
11
12#include <__algorithm/min_max_result.h>
13#include <__algorithm/minmax_element.h>
14#include <__assert>
15#include <__concepts/copyable.h>
16#include <__config>
17#include <__functional/identity.h>
18#include <__functional/invoke.h>
19#include <__functional/ranges_operations.h>
20#include <__iterator/concepts.h>
21#include <__iterator/projected.h>
22#include <__ranges/access.h>
23#include <__ranges/concepts.h>
24#include <__utility/forward.h>
25#include <__utility/move.h>
26#include <initializer_list>
27
28#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
29# pragma GCC system_header
30#endif
31
32#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
33
34_LIBCPP_PUSH_MACROS
35#include <__undef_macros>
36
37_LIBCPP_BEGIN_NAMESPACE_STD
38
39namespace ranges {
40template <class _T1>
41using minmax_result = min_max_result<_T1>;
42
43namespace __minmax {
44struct __fn {
45 template <class _Type, class _Proj = identity,
46 indirect_strict_weak_order<projected<const _Type*, _Proj>> _Comp = ranges::less>
47 _LIBCPP_HIDE_FROM_ABI constexpr ranges::minmax_result<const _Type&>
48 operator()(const _Type& __a, const _Type& __b, _Comp __comp = {}, _Proj __proj = {}) const {
49 if (std::invoke(__comp, std::invoke(__proj, __b), std::invoke(__proj, __a)))
50 return {__b, __a};
51 return {__a, __b};
52 }
53
54 template <copyable _Type, class _Proj = identity,
55 indirect_strict_weak_order<projected<const _Type*, _Proj>> _Comp = ranges::less>
56 _LIBCPP_HIDE_FROM_ABI constexpr
57 ranges::minmax_result<_Type> operator()(initializer_list<_Type> __il, _Comp __comp = {}, _Proj __proj = {}) const {
58 _LIBCPP_ASSERT(__il.begin() != __il.end(), "initializer_list has to contain at least one element");
59 auto __iters = std::__minmax_element_impl(__il.begin(), __il.end(), __comp, __proj);
60 return ranges::minmax_result<_Type> { *__iters.first, *__iters.second };
61 }
62
63 template <input_range _Range, class _Proj = identity,
64 indirect_strict_weak_order<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
65 requires indirectly_copyable_storable<iterator_t<_Range>, range_value_t<_Range>*>
66 _LIBCPP_HIDE_FROM_ABI constexpr
67 ranges::minmax_result<range_value_t<_Range>> operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
68 auto __first = ranges::begin(__r);
69 auto __last = ranges::end(__r);
70 using _ValueT = range_value_t<_Range>;
71
72 _LIBCPP_ASSERT(__first != __last, "range has to contain at least one element");
73
74 if constexpr (forward_range<_Range>) {
75 auto __result = std::__minmax_element_impl(__first, __last, __comp, __proj);
76 return {*__result.first, *__result.second};
77 } else {
78 // input_iterators can't be copied, so the implementation for input_iterators has to store
79 // the values instead of a pointer to the correct values
80 auto __less = [&](auto&& __a, auto&& __b) -> bool {
81 return std::invoke(__comp, std::invoke(__proj, std::forward<decltype(__a)>(__a)),
82 std::invoke(__proj, std::forward<decltype(__b)>(__b)));
83 };
84
85 ranges::minmax_result<_ValueT> __result = {*__first, __result.min};
86 if (__first == __last || ++__first == __last)
87 return __result;
88
89 if (__less(*__first, __result.min))
90 __result.min = *__first;
91 else
92 __result.max = *__first;
93
94 while (++__first != __last) {
95 _ValueT __i = *__first;
96 if (++__first == __last) {
97 if (__less(__i, __result.min))
98 __result.min = __i;
99 else if (!__less(__i, __result.max))
100 __result.max = __i;
101 return __result;
102 }
103
104 if (__less(*__first, __i)) {
105 if (__less(*__first, __result.min))
106 __result.min = *__first;
107 if (!__less(__i, __result.max))
108 __result.max = std::move(__i);
109 } else {
110 if (__less(__i, __result.min))
111 __result.min = std::move(__i);
112 if (!__less(*__first, __result.max))
113 __result.max = *__first;
114 }
115 }
116 return __result;
117 }
118 }
119};
120} // namespace __minmax
121
122inline namespace __cpo {
123 inline constexpr auto minmax = __minmax::__fn{};
124} // namespace __cpo
125} // namespace ranges
126
127_LIBCPP_END_NAMESPACE_STD
128
129_LIBCPP_POP_MACROS
130
131#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
132
133#endif // _LIBCPP___ALGORITHM_RANGES_MINMAX_H
lib/libcxx/include/__algorithm/ranges_minmax_element.h created+72
...@@ -0,0 +1,72 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_MINMAX_ELEMENT_H
10#define _LIBCPP___ALGORITHM_RANGES_MINMAX_ELEMENT_H
11
12#include <__algorithm/min_max_result.h>
13#include <__algorithm/minmax_element.h>
14#include <__config>
15#include <__functional/identity.h>
16#include <__functional/invoke.h>
17#include <__functional/ranges_operations.h>
18#include <__iterator/concepts.h>
19#include <__iterator/projected.h>
20#include <__ranges/access.h>
21#include <__ranges/concepts.h>
22#include <__ranges/dangling.h>
23#include <__utility/forward.h>
24#include <__utility/move.h>
25#include <__utility/pair.h>
26#include <type_traits>
27
28#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
29# pragma GCC system_header
30#endif
31
32#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
33
34_LIBCPP_BEGIN_NAMESPACE_STD
35
36namespace ranges {
37
38template <class _T1>
39using minmax_element_result = min_max_result<_T1>;
40
41namespace __minmax_element {
42struct __fn {
43 template <forward_iterator _Ip, sentinel_for<_Ip> _Sp, class _Proj = identity,
44 indirect_strict_weak_order<projected<_Ip, _Proj>> _Comp = ranges::less>
45 _LIBCPP_HIDE_FROM_ABI constexpr
46 ranges::minmax_element_result<_Ip> operator()(_Ip __first, _Sp __last, _Comp __comp = {}, _Proj __proj = {}) const {
47 auto __ret = std::__minmax_element_impl(std::move(__first), std::move(__last), __comp, __proj);
48 return {__ret.first, __ret.second};
49 }
50
51 template <forward_range _Rp, class _Proj = identity,
52 indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less>
53 _LIBCPP_HIDE_FROM_ABI constexpr
54 ranges::minmax_element_result<borrowed_iterator_t<_Rp>>
55 operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
56 auto __ret = std::__minmax_element_impl(ranges::begin(__r), ranges::end(__r), __comp, __proj);
57 return {__ret.first, __ret.second};
58 }
59};
60} // namespace __minmax_element
61
62inline namespace __cpo {
63 inline constexpr auto minmax_element = __minmax_element::__fn{};
64} // namespace __cpo
65
66} // namespace ranges
67
68_LIBCPP_END_NAMESPACE_STD
69
70#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
71
72#endif // _LIBCPP___ALGORITHM_RANGES_MINMAX_H
lib/libcxx/include/__algorithm/ranges_mismatch.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___ALGORITHM_RANGES_MISMATCH_H
10#define _LIBCPP___ALGORITHM_RANGES_MISMATCH_H
11
12#include <__algorithm/in_in_result.h>
13#include <__config>
14#include <__functional/identity.h>
15#include <__functional/invoke.h>
16#include <__functional/ranges_operations.h>
17#include <__iterator/concepts.h>
18#include <__iterator/indirectly_comparable.h>
19#include <__ranges/access.h>
20#include <__ranges/concepts.h>
21#include <__ranges/dangling.h>
22#include <__utility/move.h>
23
24#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
25# pragma GCC system_header
26#endif
27
28_LIBCPP_BEGIN_NAMESPACE_STD
29
30#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
31
32namespace ranges {
33
34template <class _I1, class _I2>
35using mismatch_result = in_in_result<_I1, _I2>;
36
37namespace __mismatch {
38struct __fn {
39 template <class _I1, class _S1, class _I2, class _S2,
40 class _Pred, class _Proj1, class _Proj2>
41 static _LIBCPP_HIDE_FROM_ABI constexpr
42 mismatch_result<_I1, _I2>
43 __go(_I1 __first1, _S1 __last1, _I2 __first2, _S2 __last2,
44 _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) {
45 while (__first1 != __last1 && __first2 != __last2) {
46 if (!std::invoke(__pred, std::invoke(__proj1, *__first1), std::invoke(__proj2, *__first2)))
47 break;
48 ++__first1;
49 ++__first2;
50 }
51 return {std::move(__first1), std::move(__first2)};
52 }
53
54 template <input_iterator _I1, sentinel_for<_I1> _S1,
55 input_iterator _I2, sentinel_for<_I2> _S2,
56 class _Pred = ranges::equal_to, class _Proj1 = identity, class _Proj2 = identity>
57 requires indirectly_comparable<_I1, _I2, _Pred, _Proj1, _Proj2>
58 _LIBCPP_HIDE_FROM_ABI constexpr
59 mismatch_result<_I1, _I2> operator()(_I1 __first1, _S1 __last1, _I2 __first2, _S2 __last2,
60 _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
61 return __go(std::move(__first1), __last1, std::move(__first2), __last2, __pred, __proj1, __proj2);
62 }
63
64 template <input_range _R1, input_range _R2,
65 class _Pred = ranges::equal_to, class _Proj1 = identity, class _Proj2 = identity>
66 requires indirectly_comparable<iterator_t<_R1>, iterator_t<_R2>, _Pred, _Proj1, _Proj2>
67 _LIBCPP_HIDE_FROM_ABI constexpr
68 mismatch_result<borrowed_iterator_t<_R1>, borrowed_iterator_t<_R2>>
69 operator()(_R1&& __r1, _R2&& __r2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
70 return __go(ranges::begin(__r1), ranges::end(__r1), ranges::begin(__r2), ranges::end(__r2),
71 __pred, __proj1, __proj2);
72 }
73};
74} // namespace __mismatch
75
76inline namespace __cpo {
77 constexpr inline auto mismatch = __mismatch::__fn{};
78} // namespace __cpo
79} // namespace ranges
80
81#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
82
83_LIBCPP_END_NAMESPACE_STD
84
85#endif // _LIBCPP___ALGORITHM_RANGES_MISMATCH_H
lib/libcxx/include/__algorithm/ranges_move.h created+83
...@@ -0,0 +1,83 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_MOVE_H
10#define _LIBCPP___ALGORITHM_RANGES_MOVE_H
11
12#include <__algorithm/in_out_result.h>
13#include <__algorithm/move.h>
14#include <__config>
15#include <__iterator/concepts.h>
16#include <__iterator/iter_move.h>
17#include <__ranges/access.h>
18#include <__ranges/concepts.h>
19#include <__ranges/dangling.h>
20#include <__utility/move.h>
21
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23# pragma GCC system_header
24#endif
25
26#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
27
28_LIBCPP_BEGIN_NAMESPACE_STD
29
30namespace ranges {
31
32template <class _InIter, class _OutIter>
33using move_result = in_out_result<_InIter, _OutIter>;
34
35namespace __move {
36struct __fn {
37
38 template <class _InIter, class _Sent, class _OutIter>
39 requires __iter_move::__move_deref<_InIter> // check that we are allowed to std::move() the value
40 _LIBCPP_HIDE_FROM_ABI constexpr static
41 move_result<_InIter, _OutIter> __move_impl(_InIter __first, _Sent __last, _OutIter __result) {
42 auto __ret = std::__move(std::move(__first), std::move(__last), std::move(__result));
43 return {std::move(__ret.first), std::move(__ret.second)};
44 }
45
46 template <class _InIter, class _Sent, class _OutIter>
47 _LIBCPP_HIDE_FROM_ABI constexpr static
48 move_result<_InIter, _OutIter> __move_impl(_InIter __first, _Sent __last, _OutIter __result) {
49 while (__first != __last) {
50 *__result = ranges::iter_move(__first);
51 ++__first;
52 ++__result;
53 }
54 return {std::move(__first), std::move(__result)};
55 }
56
57 template <input_iterator _InIter, sentinel_for<_InIter> _Sent, weakly_incrementable _OutIter>
58 requires indirectly_movable<_InIter, _OutIter>
59 _LIBCPP_HIDE_FROM_ABI constexpr
60 move_result<_InIter, _OutIter> operator()(_InIter __first, _Sent __last, _OutIter __result) const {
61 return __move_impl(std::move(__first), std::move(__last), std::move(__result));
62 }
63
64 template <input_range _Range, weakly_incrementable _OutIter>
65 requires indirectly_movable<iterator_t<_Range>, _OutIter>
66 _LIBCPP_HIDE_FROM_ABI constexpr
67 move_result<borrowed_iterator_t<_Range>, _OutIter> operator()(_Range&& __range, _OutIter __result) const {
68 return __move_impl(ranges::begin(__range), ranges::end(__range), std::move(__result));
69 }
70
71};
72} // namespace __move
73
74inline namespace __cpo {
75 inline constexpr auto move = __move::__fn{};
76} // namespace __cpo
77} // namespace ranges
78
79_LIBCPP_END_NAMESPACE_STD
80
81#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
82
83#endif // _LIBCPP___ALGORITHM_RANGES_MOVE_H
lib/libcxx/include/__algorithm/ranges_move_backward.h created+75
...@@ -0,0 +1,75 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_MOVE_BACKWARD_H
10#define _LIBCPP___ALGORITHM_RANGES_MOVE_BACKWARD_H
11
12#include <__algorithm/in_out_result.h>
13#include <__algorithm/ranges_move.h>
14#include <__config>
15#include <__iterator/concepts.h>
16#include <__iterator/iter_move.h>
17#include <__iterator/next.h>
18#include <__iterator/reverse_iterator.h>
19#include <__ranges/access.h>
20#include <__ranges/concepts.h>
21#include <__ranges/dangling.h>
22#include <__utility/move.h>
23
24#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
25# pragma GCC system_header
26#endif
27
28#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
29
30_LIBCPP_BEGIN_NAMESPACE_STD
31
32namespace ranges {
33
34template <class _InIter, class _OutIter>
35using move_backward_result = in_out_result<_InIter, _OutIter>;
36
37namespace __move_backward {
38struct __fn {
39
40 template <class _InIter, class _Sent, class _OutIter>
41 _LIBCPP_HIDE_FROM_ABI constexpr static
42 move_backward_result<_InIter, _OutIter> __move_backward_impl(_InIter __first, _Sent __last, _OutIter __result) {
43 auto __ret = ranges::move(std::make_reverse_iterator(ranges::next(__first, __last)),
44 std::make_reverse_iterator(__first),
45 std::make_reverse_iterator(__result));
46 return {std::move(__ret.in.base()), std::move(__ret.out.base())};
47 }
48
49 template <bidirectional_iterator _InIter, sentinel_for<_InIter> _Sent, bidirectional_iterator _OutIter>
50 requires indirectly_movable<_InIter, _OutIter>
51 _LIBCPP_HIDE_FROM_ABI constexpr
52 move_backward_result<_InIter, _OutIter> operator()(_InIter __first, _Sent __last, _OutIter __result) const {
53 return __move_backward_impl(std::move(__first), std::move(__last), std::move(__result));
54 }
55
56 template <bidirectional_range _Range, bidirectional_iterator _Iter>
57 requires indirectly_movable<iterator_t<_Range>, _Iter>
58 _LIBCPP_HIDE_FROM_ABI constexpr
59 move_backward_result<borrowed_iterator_t<_Range>, _Iter> operator()(_Range&& __range, _Iter __result) const {
60 return __move_backward_impl(ranges::begin(__range), ranges::end(__range), std::move(__result));
61 }
62
63};
64} // namespace __move_backward
65
66inline namespace __cpo {
67 inline constexpr auto move_backward = __move_backward::__fn{};
68} // namespace __cpo
69} // namespace ranges
70
71_LIBCPP_END_NAMESPACE_STD
72
73#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
74
75#endif // _LIBCPP___ALGORITHM_RANGES_MOVE_BACKWARD_H
lib/libcxx/include/__algorithm/ranges_none_of.h created+68
...@@ -0,0 +1,68 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_NONE_OF_H
10#define _LIBCPP___ALGORITHM_RANGES_NONE_OF_H
11
12#include <__config>
13#include <__functional/identity.h>
14#include <__functional/invoke.h>
15#include <__iterator/concepts.h>
16#include <__iterator/projected.h>
17#include <__ranges/access.h>
18#include <__ranges/concepts.h>
19#include <__utility/move.h>
20
21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
22# pragma GCC system_header
23#endif
24
25#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
26
27_LIBCPP_BEGIN_NAMESPACE_STD
28
29namespace ranges {
30namespace __none_of {
31struct __fn {
32
33 template <class _Iter, class _Sent, class _Proj, class _Pred>
34 _LIBCPP_HIDE_FROM_ABI constexpr static
35 bool __none_of_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) {
36 for (; __first != __last; ++__first) {
37 if (std::invoke(__pred, std::invoke(__proj, *__first)))
38 return false;
39 }
40 return true;
41 }
42
43 template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity,
44 indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>
45 _LIBCPP_HIDE_FROM_ABI constexpr
46 bool operator()(_Iter __first, _Sent __last, _Pred __pred = {}, _Proj __proj = {}) const {
47 return __none_of_impl(std::move(__first), std::move(__last), __pred, __proj);
48 }
49
50 template <input_range _Range, class _Proj = identity,
51 indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
52 _LIBCPP_HIDE_FROM_ABI constexpr
53 bool operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const {
54 return __none_of_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
55 }
56};
57} // namespace __none_of
58
59inline namespace __cpo {
60 inline constexpr auto none_of = __none_of::__fn{};
61} // namespace __cpo
62} // namespace ranges
63
64_LIBCPP_END_NAMESPACE_STD
65
66#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
67
68#endif // _LIBCPP___ALGORITHM_RANGES_NONE_OF_H
lib/libcxx/include/__algorithm/ranges_nth_element.h created+80
...@@ -0,0 +1,80 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_NTH_ELEMENT_H
10#define _LIBCPP___ALGORITHM_RANGES_NTH_ELEMENT_H
11
12#include <__algorithm/iterator_operations.h>
13#include <__algorithm/make_projected.h>
14#include <__algorithm/nth_element.h>
15#include <__config>
16#include <__functional/identity.h>
17#include <__functional/invoke.h>
18#include <__functional/ranges_operations.h>
19#include <__iterator/concepts.h>
20#include <__iterator/iterator_traits.h>
21#include <__iterator/next.h>
22#include <__iterator/projected.h>
23#include <__iterator/sortable.h>
24#include <__ranges/access.h>
25#include <__ranges/concepts.h>
26#include <__ranges/dangling.h>
27#include <__utility/forward.h>
28#include <__utility/move.h>
29
30#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
31# pragma GCC system_header
32#endif
33
34#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
35
36_LIBCPP_BEGIN_NAMESPACE_STD
37
38namespace ranges {
39namespace __nth_element {
40
41struct __fn {
42 template <class _Iter, class _Sent, class _Comp, class _Proj>
43 _LIBCPP_HIDE_FROM_ABI constexpr static
44 _Iter __nth_element_fn_impl(_Iter __first, _Iter __nth, _Sent __last, _Comp& __comp, _Proj& __proj) {
45 auto __last_iter = ranges::next(__first, __last);
46
47 auto&& __projected_comp = std::__make_projected(__comp, __proj);
48 std::__nth_element_impl<_RangeAlgPolicy>(std::move(__first), std::move(__nth), __last_iter, __projected_comp);
49
50 return __last_iter;
51 }
52
53 template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Comp = ranges::less, class _Proj = identity>
54 requires sortable<_Iter, _Comp, _Proj>
55 _LIBCPP_HIDE_FROM_ABI constexpr
56 _Iter operator()(_Iter __first, _Iter __nth, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
57 return __nth_element_fn_impl(std::move(__first), std::move(__nth), std::move(__last), __comp, __proj);
58 }
59
60 template <random_access_range _Range, class _Comp = ranges::less, class _Proj = identity>
61 requires sortable<iterator_t<_Range>, _Comp, _Proj>
62 _LIBCPP_HIDE_FROM_ABI constexpr
63 borrowed_iterator_t<_Range> operator()(_Range&& __r, iterator_t<_Range> __nth, _Comp __comp = {},
64 _Proj __proj = {}) const {
65 return __nth_element_fn_impl(ranges::begin(__r), std::move(__nth), ranges::end(__r), __comp, __proj);
66 }
67};
68
69} // namespace __nth_element
70
71inline namespace __cpo {
72 inline constexpr auto nth_element = __nth_element::__fn{};
73} // namespace __cpo
74} // namespace ranges
75
76_LIBCPP_END_NAMESPACE_STD
77
78#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
79
80#endif // _LIBCPP___ALGORITHM_RANGES_NTH_ELEMENT_H
lib/libcxx/include/__algorithm/ranges_partial_sort.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___ALGORITHM_RANGES_PARTIAL_SORT_H
10#define _LIBCPP___ALGORITHM_RANGES_PARTIAL_SORT_H
11
12#include <__algorithm/iterator_operations.h>
13#include <__algorithm/make_projected.h>
14#include <__algorithm/partial_sort.h>
15#include <__concepts/same_as.h>
16#include <__config>
17#include <__functional/identity.h>
18#include <__functional/invoke.h>
19#include <__functional/ranges_operations.h>
20#include <__iterator/concepts.h>
21#include <__iterator/iterator_traits.h>
22#include <__iterator/next.h>
23#include <__iterator/projected.h>
24#include <__iterator/sortable.h>
25#include <__ranges/access.h>
26#include <__ranges/concepts.h>
27#include <__ranges/dangling.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#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
36
37_LIBCPP_BEGIN_NAMESPACE_STD
38
39namespace ranges {
40namespace __partial_sort {
41
42struct __fn {
43 template <class _Iter, class _Sent, class _Comp, class _Proj>
44 _LIBCPP_HIDE_FROM_ABI constexpr static
45 _Iter __partial_sort_fn_impl(_Iter __first, _Iter __middle, _Sent __last, _Comp& __comp, _Proj& __proj) {
46 auto&& __projected_comp = std::__make_projected(__comp, __proj);
47 return std::__partial_sort<_RangeAlgPolicy>(std::move(__first), std::move(__middle), __last, __projected_comp);
48 }
49
50 template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Comp = ranges::less, class _Proj = identity>
51 requires sortable<_Iter, _Comp, _Proj>
52 _LIBCPP_HIDE_FROM_ABI constexpr
53 _Iter operator()(_Iter __first, _Iter __middle, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
54 return __partial_sort_fn_impl(std::move(__first), std::move(__middle), std::move(__last), __comp, __proj);
55 }
56
57 template <random_access_range _Range, class _Comp = ranges::less, class _Proj = identity>
58 requires sortable<iterator_t<_Range>, _Comp, _Proj>
59 _LIBCPP_HIDE_FROM_ABI constexpr
60 borrowed_iterator_t<_Range> operator()(_Range&& __r, iterator_t<_Range> __middle, _Comp __comp = {},
61 _Proj __proj = {}) const {
62 return __partial_sort_fn_impl(ranges::begin(__r), std::move(__middle), ranges::end(__r), __comp, __proj);
63 }
64};
65
66} // namespace __partial_sort
67
68inline namespace __cpo {
69 inline constexpr auto partial_sort = __partial_sort::__fn{};
70} // namespace __cpo
71} // namespace ranges
72
73_LIBCPP_END_NAMESPACE_STD
74
75#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
76
77#endif // _LIBCPP___ALGORITHM_RANGES_PARTIAL_SORT_H
lib/libcxx/include/__algorithm/ranges_partial_sort_copy.h created+91
...@@ -0,0 +1,91 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_PARTIAL_SORT_COPY_H
10#define _LIBCPP___ALGORITHM_RANGES_PARTIAL_SORT_COPY_H
11
12#include <__algorithm/in_out_result.h>
13#include <__algorithm/iterator_operations.h>
14#include <__algorithm/make_projected.h>
15#include <__algorithm/partial_sort_copy.h>
16#include <__config>
17#include <__functional/identity.h>
18#include <__functional/ranges_operations.h>
19#include <__iterator/concepts.h>
20#include <__iterator/iterator_traits.h>
21#include <__iterator/projected.h>
22#include <__iterator/sortable.h>
23#include <__ranges/access.h>
24#include <__ranges/concepts.h>
25#include <__ranges/dangling.h>
26#include <__utility/move.h>
27
28#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
29# pragma GCC system_header
30#endif
31
32#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
33
34_LIBCPP_BEGIN_NAMESPACE_STD
35
36namespace ranges {
37
38template <class _InIter, class _OutIter>
39using partial_sort_copy_result = in_out_result<_InIter, _OutIter>;
40
41namespace __partial_sort_copy {
42
43struct __fn {
44
45 template <input_iterator _Iter1, sentinel_for<_Iter1> _Sent1,
46 random_access_iterator _Iter2, sentinel_for<_Iter2> _Sent2,
47 class _Comp = ranges::less, class _Proj1 = identity, class _Proj2 = identity>
48 requires indirectly_copyable<_Iter1, _Iter2> && sortable<_Iter2, _Comp, _Proj2> &&
49 indirect_strict_weak_order<_Comp, projected<_Iter1, _Proj1>, projected<_Iter2, _Proj2>>
50 _LIBCPP_HIDE_FROM_ABI constexpr
51 partial_sort_copy_result<_Iter1, _Iter2>
52 operator()(_Iter1 __first, _Sent1 __last, _Iter2 __result_first, _Sent2 __result_last,
53 _Comp __comp = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
54 auto __result = std::__partial_sort_copy<_RangeAlgPolicy>(
55 std::move(__first), std::move(__last), std::move(__result_first), std::move(__result_last),
56 __comp, __proj1, __proj2
57 );
58 return {std::move(__result.first), std::move(__result.second)};
59 }
60
61 template <input_range _Range1, random_access_range _Range2, class _Comp = ranges::less,
62 class _Proj1 = identity, class _Proj2 = identity>
63 requires indirectly_copyable<iterator_t<_Range1>, iterator_t<_Range2>> &&
64 sortable<iterator_t<_Range2>, _Comp, _Proj2> &&
65 indirect_strict_weak_order<_Comp, projected<iterator_t<_Range1>, _Proj1>,
66 projected<iterator_t<_Range2>, _Proj2>>
67 _LIBCPP_HIDE_FROM_ABI constexpr
68 partial_sort_copy_result<borrowed_iterator_t<_Range1>, borrowed_iterator_t<_Range2>>
69 operator()(_Range1&& __range, _Range2&& __result_range, _Comp __comp = {},
70 _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
71 auto __result = std::__partial_sort_copy<_RangeAlgPolicy>(
72 ranges::begin(__range), ranges::end(__range), ranges::begin(__result_range), ranges::end(__result_range),
73 __comp, __proj1, __proj2
74 );
75 return {std::move(__result.first), std::move(__result.second)};
76 }
77
78};
79
80} // namespace __partial_sort_copy
81
82inline namespace __cpo {
83 inline constexpr auto partial_sort_copy = __partial_sort_copy::__fn{};
84} // namespace __cpo
85} // namespace ranges
86
87_LIBCPP_END_NAMESPACE_STD
88
89#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
90
91#endif // _LIBCPP___ALGORITHM_RANGES_PARTIAL_SORT_COPY_H
lib/libcxx/include/__algorithm/ranges_partition.h created+82
...@@ -0,0 +1,82 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_PARTITION_H
10#define _LIBCPP___ALGORITHM_RANGES_PARTITION_H
11
12#include <__algorithm/iterator_operations.h>
13#include <__algorithm/make_projected.h>
14#include <__algorithm/partition.h>
15#include <__algorithm/ranges_iterator_concept.h>
16#include <__config>
17#include <__functional/identity.h>
18#include <__functional/invoke.h>
19#include <__functional/ranges_operations.h>
20#include <__iterator/concepts.h>
21#include <__iterator/iterator_traits.h>
22#include <__iterator/permutable.h>
23#include <__iterator/projected.h>
24#include <__ranges/access.h>
25#include <__ranges/concepts.h>
26#include <__ranges/subrange.h>
27#include <__utility/forward.h>
28#include <__utility/move.h>
29#include <type_traits>
30
31#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
32# pragma GCC system_header
33#endif
34
35#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
36
37_LIBCPP_BEGIN_NAMESPACE_STD
38
39namespace ranges {
40namespace __partition {
41
42struct __fn {
43
44 template <class _Iter, class _Sent, class _Proj, class _Pred>
45 _LIBCPP_HIDE_FROM_ABI static constexpr
46 subrange<__uncvref_t<_Iter>> __partition_fn_impl(_Iter&& __first, _Sent&& __last, _Pred&& __pred, _Proj&& __proj) {
47 auto&& __projected_pred = std::__make_projected(__pred, __proj);
48 auto __result = std::__partition<_RangeAlgPolicy>(
49 std::move(__first), std::move(__last), __projected_pred, __iterator_concept<_Iter>());
50
51 return {std::move(__result.first), std::move(__result.second)};
52 }
53
54 template <permutable _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity,
55 indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>
56 _LIBCPP_HIDE_FROM_ABI constexpr
57 subrange<_Iter> operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) const {
58 return __partition_fn_impl(__first, __last, __pred, __proj);
59 }
60
61 template <forward_range _Range, class _Proj = identity,
62 indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
63 requires permutable<iterator_t<_Range>>
64 _LIBCPP_HIDE_FROM_ABI constexpr
65 borrowed_subrange_t<_Range> operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const {
66 return __partition_fn_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
67 }
68
69};
70
71} // namespace __partition
72
73inline namespace __cpo {
74 inline constexpr auto partition = __partition::__fn{};
75} // namespace __cpo
76} // namespace ranges
77
78_LIBCPP_END_NAMESPACE_STD
79
80#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
81
82#endif // _LIBCPP___ALGORITHM_RANGES_PARTITION_H
lib/libcxx/include/__algorithm/ranges_partition_copy.h created+98
...@@ -0,0 +1,98 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_PARTITION_COPY_H
10#define _LIBCPP___ALGORITHM_RANGES_PARTITION_COPY_H
11
12#include <__algorithm/in_out_out_result.h>
13#include <__config>
14#include <__functional/identity.h>
15#include <__functional/invoke.h>
16#include <__iterator/concepts.h>
17#include <__iterator/iterator_traits.h>
18#include <__iterator/projected.h>
19#include <__ranges/access.h>
20#include <__ranges/concepts.h>
21#include <__ranges/dangling.h>
22#include <__utility/move.h>
23#include <type_traits>
24
25#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
26# pragma GCC system_header
27#endif
28
29#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
30
31_LIBCPP_BEGIN_NAMESPACE_STD
32
33namespace ranges {
34
35template <class _InIter, class _OutIter1, class _OutIter2>
36using partition_copy_result = in_out_out_result<_InIter, _OutIter1, _OutIter2>;
37
38namespace __partition_copy {
39
40struct __fn {
41
42 // TODO(ranges): delegate to the classic algorithm.
43 template <class _InIter, class _Sent, class _OutIter1, class _OutIter2, class _Proj, class _Pred>
44 _LIBCPP_HIDE_FROM_ABI constexpr
45 static partition_copy_result<
46 __uncvref_t<_InIter>, __uncvref_t<_OutIter1>, __uncvref_t<_OutIter2>
47 > __partition_copy_fn_impl( _InIter&& __first, _Sent&& __last, _OutIter1&& __out_true, _OutIter2&& __out_false,
48 _Pred& __pred, _Proj& __proj) {
49 for (; __first != __last; ++__first) {
50 if (std::invoke(__pred, std::invoke(__proj, *__first))) {
51 *__out_true = *__first;
52 ++__out_true;
53
54 } else {
55 *__out_false = *__first;
56 ++__out_false;
57 }
58 }
59
60 return {std::move(__first), std::move(__out_true), std::move(__out_false)};
61 }
62
63 template <input_iterator _InIter, sentinel_for<_InIter> _Sent,
64 weakly_incrementable _OutIter1, weakly_incrementable _OutIter2,
65 class _Proj = identity, indirect_unary_predicate<projected<_InIter, _Proj>> _Pred>
66 requires indirectly_copyable<_InIter, _OutIter1> && indirectly_copyable<_InIter, _OutIter2>
67 _LIBCPP_HIDE_FROM_ABI constexpr
68 partition_copy_result<_InIter, _OutIter1, _OutIter2>
69 operator()(_InIter __first, _Sent __last, _OutIter1 __out_true, _OutIter2 __out_false,
70 _Pred __pred, _Proj __proj = {}) const {
71 return __partition_copy_fn_impl(
72 std::move(__first), std::move(__last), std::move(__out_true), std::move(__out_false), __pred, __proj);
73 }
74
75 template <input_range _Range, weakly_incrementable _OutIter1, weakly_incrementable _OutIter2,
76 class _Proj = identity, indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
77 requires indirectly_copyable<iterator_t<_Range>, _OutIter1> && indirectly_copyable<iterator_t<_Range>, _OutIter2>
78 _LIBCPP_HIDE_FROM_ABI constexpr
79 partition_copy_result<borrowed_iterator_t<_Range>, _OutIter1, _OutIter2>
80 operator()(_Range&& __range, _OutIter1 __out_true, _OutIter2 __out_false, _Pred __pred, _Proj __proj = {}) const {
81 return __partition_copy_fn_impl(
82 ranges::begin(__range), ranges::end(__range), std::move(__out_true), std::move(__out_false), __pred, __proj);
83 }
84
85};
86
87} // namespace __partition_copy
88
89inline namespace __cpo {
90 inline constexpr auto partition_copy = __partition_copy::__fn{};
91} // namespace __cpo
92} // namespace ranges
93
94_LIBCPP_END_NAMESPACE_STD
95
96#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
97
98#endif // _LIBCPP___ALGORITHM_RANGES_PARTITION_COPY_H
lib/libcxx/include/__algorithm/ranges_partition_point.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___ALGORITHM_RANGES_PARTITION_POINT_H
10#define _LIBCPP___ALGORITHM_RANGES_PARTITION_POINT_H
11
12#include <__algorithm/half_positive.h>
13#include <__config>
14#include <__functional/identity.h>
15#include <__functional/invoke.h>
16#include <__iterator/concepts.h>
17#include <__iterator/distance.h>
18#include <__iterator/iterator_traits.h>
19#include <__iterator/next.h>
20#include <__iterator/projected.h>
21#include <__ranges/access.h>
22#include <__ranges/concepts.h>
23#include <__ranges/dangling.h>
24#include <__utility/move.h>
25
26#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
27# pragma GCC system_header
28#endif
29
30#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
31
32_LIBCPP_BEGIN_NAMESPACE_STD
33
34namespace ranges {
35namespace __partition_point {
36
37struct __fn {
38
39 // TODO(ranges): delegate to the classic algorithm.
40 template <class _Iter, class _Sent, class _Proj, class _Pred>
41 _LIBCPP_HIDE_FROM_ABI constexpr
42 static _Iter __partition_point_fn_impl(_Iter&& __first, _Sent&& __last, _Pred& __pred, _Proj& __proj) {
43 auto __len = ranges::distance(__first, __last);
44
45 while (__len != 0) {
46 auto __half_len = std::__half_positive(__len);
47 auto __mid = ranges::next(__first, __half_len);
48
49 if (std::invoke(__pred, std::invoke(__proj, *__mid))) {
50 __first = ++__mid;
51 __len -= __half_len + 1;
52
53 } else {
54 __len = __half_len;
55 }
56 }
57
58 return __first;
59 }
60
61 template <forward_iterator _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity,
62 indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>
63 _LIBCPP_HIDE_FROM_ABI constexpr
64 _Iter operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) const {
65 return __partition_point_fn_impl(std::move(__first), std::move(__last), __pred, __proj);
66 }
67
68 template <forward_range _Range, class _Proj = identity,
69 indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
70 _LIBCPP_HIDE_FROM_ABI constexpr
71 borrowed_iterator_t<_Range> operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const {
72 return __partition_point_fn_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
73 }
74
75};
76
77} // namespace __partition_point
78
79inline namespace __cpo {
80 inline constexpr auto partition_point = __partition_point::__fn{};
81} // namespace __cpo
82} // namespace ranges
83
84_LIBCPP_END_NAMESPACE_STD
85
86#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
87
88#endif // _LIBCPP___ALGORITHM_RANGES_PARTITION_POINT_H
lib/libcxx/include/__algorithm/ranges_pop_heap.h created+81
...@@ -0,0 +1,81 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_POP_HEAP_H
10#define _LIBCPP___ALGORITHM_RANGES_POP_HEAP_H
11
12#include <__algorithm/iterator_operations.h>
13#include <__algorithm/make_projected.h>
14#include <__algorithm/pop_heap.h>
15#include <__concepts/same_as.h>
16#include <__config>
17#include <__functional/identity.h>
18#include <__functional/invoke.h>
19#include <__functional/ranges_operations.h>
20#include <__iterator/concepts.h>
21#include <__iterator/iterator_traits.h>
22#include <__iterator/next.h>
23#include <__iterator/projected.h>
24#include <__iterator/sortable.h>
25#include <__ranges/access.h>
26#include <__ranges/concepts.h>
27#include <__ranges/dangling.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#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
36
37_LIBCPP_BEGIN_NAMESPACE_STD
38
39namespace ranges {
40namespace __pop_heap {
41
42struct __fn {
43 template <class _Iter, class _Sent, class _Comp, class _Proj>
44 _LIBCPP_HIDE_FROM_ABI constexpr static
45 _Iter __pop_heap_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {
46 auto __last_iter = ranges::next(__first, __last);
47 auto __len = __last_iter - __first;
48
49 auto&& __projected_comp = std::__make_projected(__comp, __proj);
50 std::__pop_heap<_RangeAlgPolicy>(std::move(__first), __last_iter, __projected_comp, __len);
51
52 return __last_iter;
53 }
54
55 template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Comp = ranges::less, class _Proj = identity>
56 requires sortable<_Iter, _Comp, _Proj>
57 _LIBCPP_HIDE_FROM_ABI constexpr
58 _Iter operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
59 return __pop_heap_fn_impl(std::move(__first), std::move(__last), __comp, __proj);
60 }
61
62 template <random_access_range _Range, class _Comp = ranges::less, class _Proj = identity>
63 requires sortable<iterator_t<_Range>, _Comp, _Proj>
64 _LIBCPP_HIDE_FROM_ABI constexpr
65 borrowed_iterator_t<_Range> operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
66 return __pop_heap_fn_impl(ranges::begin(__r), ranges::end(__r), __comp, __proj);
67 }
68};
69
70} // namespace __pop_heap
71
72inline namespace __cpo {
73 inline constexpr auto pop_heap = __pop_heap::__fn{};
74} // namespace __cpo
75} // namespace ranges
76
77_LIBCPP_END_NAMESPACE_STD
78
79#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
80
81#endif // _LIBCPP___ALGORITHM_RANGES_POP_HEAP_H
lib/libcxx/include/__algorithm/ranges_push_heap.h created+80
...@@ -0,0 +1,80 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_PUSH_HEAP_H
10#define _LIBCPP___ALGORITHM_RANGES_PUSH_HEAP_H
11
12#include <__algorithm/iterator_operations.h>
13#include <__algorithm/make_projected.h>
14#include <__algorithm/push_heap.h>
15#include <__concepts/same_as.h>
16#include <__config>
17#include <__functional/identity.h>
18#include <__functional/invoke.h>
19#include <__functional/ranges_operations.h>
20#include <__iterator/concepts.h>
21#include <__iterator/iterator_traits.h>
22#include <__iterator/next.h>
23#include <__iterator/projected.h>
24#include <__iterator/sortable.h>
25#include <__ranges/access.h>
26#include <__ranges/concepts.h>
27#include <__ranges/dangling.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#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
36
37_LIBCPP_BEGIN_NAMESPACE_STD
38
39namespace ranges {
40namespace __push_heap {
41
42struct __fn {
43 template <class _Iter, class _Sent, class _Comp, class _Proj>
44 _LIBCPP_HIDE_FROM_ABI constexpr static
45 _Iter __push_heap_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {
46 auto __last_iter = ranges::next(__first, __last);
47
48 auto&& __projected_comp = std::__make_projected(__comp, __proj);
49 std::__push_heap<_RangeAlgPolicy>(std::move(__first), __last_iter, __projected_comp);
50
51 return __last_iter;
52 }
53
54 template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Comp = ranges::less, class _Proj = identity>
55 requires sortable<_Iter, _Comp, _Proj>
56 _LIBCPP_HIDE_FROM_ABI constexpr
57 _Iter operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
58 return __push_heap_fn_impl(std::move(__first), std::move(__last), __comp, __proj);
59 }
60
61 template <random_access_range _Range, class _Comp = ranges::less, class _Proj = identity>
62 requires sortable<iterator_t<_Range>, _Comp, _Proj>
63 _LIBCPP_HIDE_FROM_ABI constexpr
64 borrowed_iterator_t<_Range> operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
65 return __push_heap_fn_impl(ranges::begin(__r), ranges::end(__r), __comp, __proj);
66 }
67};
68
69} // namespace __push_heap
70
71inline namespace __cpo {
72 inline constexpr auto push_heap = __push_heap::__fn{};
73} // namespace __cpo
74} // namespace ranges
75
76_LIBCPP_END_NAMESPACE_STD
77
78#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
79
80#endif // _LIBCPP___ALGORITHM_RANGES_PUSH_HEAP_H
lib/libcxx/include/__algorithm/ranges_remove.h created+64
...@@ -0,0 +1,64 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_REMOVE_H
10#define _LIBCPP___ALGORITHM_RANGES_REMOVE_H
11#include <__config>
12
13#include <__algorithm/ranges_remove_if.h>
14#include <__functional/identity.h>
15#include <__functional/ranges_operations.h>
16#include <__iterator/concepts.h>
17#include <__iterator/permutable.h>
18#include <__iterator/projected.h>
19#include <__ranges/access.h>
20#include <__ranges/concepts.h>
21#include <__ranges/subrange.h>
22#include <__utility/move.h>
23
24#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
25# pragma GCC system_header
26#endif
27
28#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
29
30_LIBCPP_BEGIN_NAMESPACE_STD
31
32namespace ranges {
33namespace __remove {
34struct __fn {
35
36 template <permutable _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity>
37 requires indirect_binary_predicate<ranges::equal_to, projected<_Iter, _Proj>, const _Type*>
38 _LIBCPP_HIDE_FROM_ABI constexpr
39 subrange<_Iter> operator()(_Iter __first, _Sent __last, const _Type& __value, _Proj __proj = {}) const {
40 auto __pred = [&](auto&& __other) { return __value == __other; };
41 return ranges::__remove_if_impl(std::move(__first), std::move(__last), __pred, __proj);
42 }
43
44 template <forward_range _Range, class _Type, class _Proj = identity>
45 requires permutable<iterator_t<_Range>>
46 && indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Range>, _Proj>, const _Type*>
47 _LIBCPP_HIDE_FROM_ABI constexpr
48 borrowed_subrange_t<_Range> operator()(_Range&& __range, const _Type& __value, _Proj __proj = {}) const {
49 auto __pred = [&](auto&& __other) { return __value == __other; };
50 return ranges::__remove_if_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
51 }
52};
53} // namespace __remove
54
55inline namespace __cpo {
56 inline constexpr auto remove = __remove::__fn{};
57} // namespace __cpo
58} // namespace ranges
59
60_LIBCPP_END_NAMESPACE_STD
61
62#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
63
64#endif // _LIBCPP___ALGORITHM_RANGES_REMOVE_H
lib/libcxx/include/__algorithm/ranges_remove_copy.h created+81
...@@ -0,0 +1,81 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_REMOVE_COPY_H
10#define _LIBCPP___ALGORITHM_RANGES_REMOVE_COPY_H
11
12#include <__algorithm/in_out_result.h>
13#include <__algorithm/make_projected.h>
14#include <__algorithm/remove_copy.h>
15#include <__config>
16#include <__functional/identity.h>
17#include <__functional/invoke.h>
18#include <__functional/ranges_operations.h>
19#include <__iterator/concepts.h>
20#include <__iterator/iterator_traits.h>
21#include <__iterator/projected.h>
22#include <__ranges/access.h>
23#include <__ranges/concepts.h>
24#include <__ranges/dangling.h>
25#include <__utility/forward.h>
26#include <__utility/move.h>
27
28#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
29# pragma GCC system_header
30#endif
31
32#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
33
34_LIBCPP_BEGIN_NAMESPACE_STD
35
36namespace ranges {
37
38template <class _InIter, class _OutIter>
39using remove_copy_result = in_out_result<_InIter, _OutIter>;
40
41namespace __remove_copy {
42
43struct __fn {
44
45 template <input_iterator _InIter, sentinel_for<_InIter> _Sent, weakly_incrementable _OutIter, class _Type,
46 class _Proj = identity>
47 requires indirectly_copyable<_InIter, _OutIter> &&
48 indirect_binary_predicate<ranges::equal_to, projected<_InIter, _Proj>, const _Type*>
49 _LIBCPP_HIDE_FROM_ABI constexpr
50 remove_copy_result<_InIter, _OutIter>
51 operator()(_InIter __first, _Sent __last, _OutIter __result, const _Type& __value, _Proj __proj = {}) const {
52 // TODO: implement
53 (void)__first; (void)__last; (void)__result; (void)__value; (void)__proj;
54 return {};
55 }
56
57 template <input_range _Range, weakly_incrementable _OutIter, class _Type, class _Proj = identity>
58 requires indirectly_copyable<iterator_t<_Range>, _OutIter> &&
59 indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Range>, _Proj>, const _Type*>
60 _LIBCPP_HIDE_FROM_ABI constexpr
61 remove_copy_result<borrowed_iterator_t<_Range>, _OutIter>
62 operator()(_Range&& __range, _OutIter __result, const _Type& __value, _Proj __proj = {}) const {
63 // TODO: implement
64 (void)__range; (void)__result; (void)__value; (void)__proj;
65 return {};
66 }
67
68};
69
70} // namespace __remove_copy
71
72inline namespace __cpo {
73 inline constexpr auto remove_copy = __remove_copy::__fn{};
74} // namespace __cpo
75} // namespace ranges
76
77_LIBCPP_END_NAMESPACE_STD
78
79#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
80
81#endif // _LIBCPP___ALGORITHM_RANGES_REMOVE_COPY_H
lib/libcxx/include/__algorithm/ranges_remove_copy_if.h created+80
...@@ -0,0 +1,80 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_REMOVE_COPY_IF_H
10#define _LIBCPP___ALGORITHM_RANGES_REMOVE_COPY_IF_H
11
12#include <__algorithm/in_out_result.h>
13#include <__algorithm/make_projected.h>
14#include <__algorithm/remove_copy_if.h>
15#include <__config>
16#include <__functional/identity.h>
17#include <__functional/invoke.h>
18#include <__functional/ranges_operations.h>
19#include <__iterator/concepts.h>
20#include <__iterator/iterator_traits.h>
21#include <__iterator/projected.h>
22#include <__ranges/access.h>
23#include <__ranges/concepts.h>
24#include <__ranges/dangling.h>
25#include <__utility/forward.h>
26#include <__utility/move.h>
27
28#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
29# pragma GCC system_header
30#endif
31
32#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
33
34_LIBCPP_BEGIN_NAMESPACE_STD
35
36namespace ranges {
37
38template <class _InIter, class _OutIter>
39using remove_copy_if_result = in_out_result<_InIter, _OutIter>;
40
41namespace __remove_copy_if {
42
43struct __fn {
44
45 template <input_iterator _InIter, sentinel_for<_InIter> _Sent, weakly_incrementable _OutIter,
46 class _Proj = identity, indirect_unary_predicate<projected<_InIter, _Proj>> _Pred>
47 requires indirectly_copyable<_InIter, _OutIter>
48 _LIBCPP_HIDE_FROM_ABI constexpr
49 remove_copy_if_result<_InIter, _OutIter>
50 operator()(_InIter __first, _Sent __last, _OutIter __result, _Pred __pred, _Proj __proj = {}) const {
51 // TODO: implement
52 (void)__first; (void)__last; (void)__result; (void)__pred; (void)__proj;
53 return {};
54 }
55
56 template <input_range _Range, weakly_incrementable _OutIter, class _Proj = identity,
57 indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
58 requires indirectly_copyable<iterator_t<_Range>, _OutIter>
59 _LIBCPP_HIDE_FROM_ABI constexpr
60 remove_copy_if_result<borrowed_iterator_t<_Range>, _OutIter>
61 operator()(_Range&& __range, _OutIter __result, _Pred __pred, _Proj __proj = {}) const {
62 // TODO: implement
63 (void)__range; (void)__result; (void)__pred; (void)__proj;
64 return {};
65 }
66
67};
68
69} // namespace __remove_copy_if
70
71inline namespace __cpo {
72 inline constexpr auto remove_copy_if = __remove_copy_if::__fn{};
73} // namespace __cpo
74} // namespace ranges
75
76_LIBCPP_END_NAMESPACE_STD
77
78#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
79
80#endif // _LIBCPP___ALGORITHM_RANGES_REMOVE_COPY_IF_H
lib/libcxx/include/__algorithm/ranges_remove_if.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___ALGORITHM_RANGES_REMOVE_IF_H
10#define _LIBCPP___ALGORITHM_RANGES_REMOVE_IF_H
11#include <__config>
12
13#include <__algorithm/ranges_find_if.h>
14#include <__functional/identity.h>
15#include <__functional/invoke.h>
16#include <__functional/ranges_operations.h>
17#include <__iterator/concepts.h>
18#include <__iterator/iter_move.h>
19#include <__iterator/permutable.h>
20#include <__iterator/projected.h>
21#include <__ranges/access.h>
22#include <__ranges/concepts.h>
23#include <__ranges/subrange.h>
24#include <__utility/move.h>
25
26#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
27# pragma GCC system_header
28#endif
29
30#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
31
32_LIBCPP_BEGIN_NAMESPACE_STD
33
34namespace ranges {
35
36template <class _Iter, class _Sent, class _Proj, class _Pred>
37_LIBCPP_HIDE_FROM_ABI constexpr
38subrange<_Iter> __remove_if_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) {
39 auto __new_end = ranges::__find_if_impl(__first, __last, __pred, __proj);
40 if (__new_end == __last)
41 return {__new_end, __new_end};
42
43 _Iter __i = __new_end;
44 while (++__i != __last) {
45 if (!std::invoke(__pred, std::invoke(__proj, *__i))) {
46 *__new_end = ranges::iter_move(__i);
47 ++__new_end;
48 }
49 }
50 return {__new_end, __i};
51}
52
53namespace __remove_if {
54struct __fn {
55
56 template <permutable _Iter, sentinel_for<_Iter> _Sent,
57 class _Proj = identity,
58 indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>
59 _LIBCPP_HIDE_FROM_ABI constexpr
60 subrange<_Iter> operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) const {
61 return ranges::__remove_if_impl(std::move(__first), std::move(__last), __pred, __proj);
62 }
63
64 template <forward_range _Range,
65 class _Proj = identity,
66 indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
67 requires permutable<iterator_t<_Range>>
68 _LIBCPP_HIDE_FROM_ABI constexpr
69 borrowed_subrange_t<_Range> operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const {
70 return ranges::__remove_if_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
71 }
72
73};
74} // namespace __remove_if
75
76inline namespace __cpo {
77 inline constexpr auto remove_if = __remove_if::__fn{};
78} // namespace __cpo
79} // namespace ranges
80
81_LIBCPP_END_NAMESPACE_STD
82
83#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
84
85#endif // _LIBCPP___ALGORITHM_RANGES_REMOVE_IF_H
lib/libcxx/include/__algorithm/ranges_replace.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___ALGORITHM_RANGES_REPLACE_H
10#define _LIBCPP___ALGORITHM_RANGES_REPLACE_H
11
12#include <__algorithm/ranges_replace_if.h>
13#include <__config>
14#include <__functional/identity.h>
15#include <__functional/ranges_operations.h>
16#include <__iterator/concepts.h>
17#include <__iterator/projected.h>
18#include <__ranges/access.h>
19#include <__ranges/concepts.h>
20#include <__ranges/dangling.h>
21#include <__utility/move.h>
22
23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
24# pragma GCC system_header
25#endif
26
27#if _LIBCPP_STD_VER > 17 && !defined (_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
28
29_LIBCPP_BEGIN_NAMESPACE_STD
30
31namespace ranges {
32namespace __replace {
33struct __fn {
34
35 template <input_iterator _Iter, sentinel_for<_Iter> _Sent,
36 class _Type1,
37 class _Type2,
38 class _Proj = identity>
39 requires indirectly_writable<_Iter, const _Type2&>
40 && indirect_binary_predicate<ranges::equal_to, projected<_Iter, _Proj>, const _Type1*>
41 _LIBCPP_HIDE_FROM_ABI constexpr
42 _Iter operator()(_Iter __first, _Sent __last,
43 const _Type1& __old_value,
44 const _Type2& __new_value,
45 _Proj __proj = {}) const {
46 auto __pred = [&](const auto& __val) { return __val == __old_value; };
47 return ranges::__replace_if_impl(std::move(__first), std::move(__last), __pred, __new_value, __proj);
48 }
49
50 template <input_range _Range,
51 class _Type1,
52 class _Type2,
53 class _Proj = identity>
54 requires indirectly_writable<iterator_t<_Range>, const _Type2&>
55 && indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Range>, _Proj>, const _Type1*>
56 _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Range>
57 operator()(_Range&& __range, const _Type1& __old_value, const _Type2& __new_value, _Proj __proj = {}) const {
58 auto __pred = [&](auto&& __val) { return __val == __old_value; };
59 return ranges::__replace_if_impl(ranges::begin(__range), ranges::end(__range), __pred, __new_value, __proj);
60 }
61
62};
63} // namespace __replace
64
65inline namespace __cpo {
66 inline constexpr auto replace = __replace::__fn{};
67} // namespace __cpo
68} // namespace ranges
69
70_LIBCPP_END_NAMESPACE_STD
71
72#endif // _LIBCPP_STD_VER > 17 && !defined (_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
73
74#endif // _LIBCPP___ALGORITHM_RANGES_REPLACE_H
lib/libcxx/include/__algorithm/ranges_replace_copy.h created+84
...@@ -0,0 +1,84 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_REPLACE_COPY_H
10#define _LIBCPP___ALGORITHM_RANGES_REPLACE_COPY_H
11
12#include <__algorithm/in_out_result.h>
13#include <__algorithm/make_projected.h>
14#include <__algorithm/replace_copy.h>
15#include <__config>
16#include <__functional/identity.h>
17#include <__functional/invoke.h>
18#include <__functional/ranges_operations.h>
19#include <__iterator/concepts.h>
20#include <__iterator/iterator_traits.h>
21#include <__iterator/projected.h>
22#include <__ranges/access.h>
23#include <__ranges/concepts.h>
24#include <__ranges/dangling.h>
25#include <__utility/forward.h>
26#include <__utility/move.h>
27
28#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
29# pragma GCC system_header
30#endif
31
32#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
33
34_LIBCPP_BEGIN_NAMESPACE_STD
35
36namespace ranges {
37
38template <class _InIter, class _OutIter>
39using replace_copy_result = in_out_result<_InIter, _OutIter>;
40
41namespace __replace_copy {
42
43struct __fn {
44
45 template <input_iterator _InIter, sentinel_for<_InIter> _Sent, class _Type1, class _Type2,
46 output_iterator<const _Type2&> _OutIter, class _Proj = identity>
47 requires indirectly_copyable<_InIter, _OutIter> &&
48 indirect_binary_predicate<ranges::equal_to, projected<_InIter, _Proj>, const _Type1*>
49 _LIBCPP_HIDE_FROM_ABI constexpr
50 replace_copy_result<_InIter, _OutIter>
51 operator()(_InIter __first, _Sent __last, _OutIter __result, const _Type1& __old_value, const _Type2& __new_value,
52 _Proj __proj = {}) const {
53 // TODO: implement
54 (void)__first; (void)__last; (void)__result; (void)__old_value; (void)__new_value; (void)__proj;
55 return {};
56 }
57
58 template <input_range _Range, class _Type1, class _Type2, output_iterator<const _Type2&> _OutIter,
59 class _Proj = identity>
60 requires indirectly_copyable<iterator_t<_Range>, _OutIter> &&
61 indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Range>, _Proj>, const _Type1*>
62 _LIBCPP_HIDE_FROM_ABI constexpr
63 replace_copy_result<borrowed_iterator_t<_Range>, _OutIter>
64 operator()(_Range&& __range, _OutIter __result, const _Type1& __old_value, const _Type2& __new_value,
65 _Proj __proj = {}) const {
66 // TODO: implement
67 (void)__range; (void)__result; (void)__old_value; (void)__new_value; (void)__proj;
68 return {};
69 }
70
71};
72
73} // namespace __replace_copy
74
75inline namespace __cpo {
76 inline constexpr auto replace_copy = __replace_copy::__fn{};
77} // namespace __cpo
78} // namespace ranges
79
80_LIBCPP_END_NAMESPACE_STD
81
82#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
83
84#endif // _LIBCPP___ALGORITHM_RANGES_REPLACE_COPY_H
lib/libcxx/include/__algorithm/ranges_replace_copy_if.h created+81
...@@ -0,0 +1,81 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_REPLACE_COPY_IF_H
10#define _LIBCPP___ALGORITHM_RANGES_REPLACE_COPY_IF_H
11
12#include <__algorithm/in_out_result.h>
13#include <__algorithm/make_projected.h>
14#include <__algorithm/replace_copy_if.h>
15#include <__config>
16#include <__functional/identity.h>
17#include <__functional/invoke.h>
18#include <__functional/ranges_operations.h>
19#include <__iterator/concepts.h>
20#include <__iterator/iterator_traits.h>
21#include <__iterator/projected.h>
22#include <__ranges/access.h>
23#include <__ranges/concepts.h>
24#include <__ranges/dangling.h>
25#include <__utility/forward.h>
26#include <__utility/move.h>
27
28#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
29# pragma GCC system_header
30#endif
31
32#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
33
34_LIBCPP_BEGIN_NAMESPACE_STD
35
36namespace ranges {
37
38template <class _InIter, class _OutIter>
39using replace_copy_if_result = in_out_result<_InIter, _OutIter>;
40
41namespace __replace_copy_if {
42
43struct __fn {
44
45 template <input_iterator _InIter, sentinel_for<_InIter> _Sent, class _Type, output_iterator<const _Type&> _OutIter,
46 class _Proj = identity, indirect_unary_predicate<projected<_InIter, _Proj>> _Pred>
47 requires indirectly_copyable<_InIter, _OutIter>
48 _LIBCPP_HIDE_FROM_ABI constexpr
49 replace_copy_if_result<_InIter, _OutIter>
50 operator()(_InIter __first, _Sent __last, _OutIter __result, _Pred __pred, const _Type& __new_value,
51 _Proj __proj = {}) const {
52 // TODO: implement
53 (void)__first; (void)__last; (void)__result; (void)__pred; (void)__new_value; (void)__proj;
54 return {};
55 }
56
57 template <input_range _Range, class _Type, output_iterator<const _Type&> _OutIter, class _Proj = identity,
58 indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
59 requires indirectly_copyable<iterator_t<_Range>, _OutIter>
60 _LIBCPP_HIDE_FROM_ABI constexpr
61 replace_copy_if_result<borrowed_iterator_t<_Range>, _OutIter>
62 operator()(_Range&& __range, _OutIter __result, _Pred __pred, const _Type& __new_value, _Proj __proj = {}) const {
63 // TODO: implement
64 (void)__range; (void)__result; (void)__pred; (void)__new_value; (void)__proj;
65 return {};
66 }
67
68};
69
70} // namespace __replace_copy_if
71
72inline namespace __cpo {
73 inline constexpr auto replace_copy_if = __replace_copy_if::__fn{};
74} // namespace __cpo
75} // namespace ranges
76
77_LIBCPP_END_NAMESPACE_STD
78
79#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
80
81#endif // _LIBCPP___ALGORITHM_RANGES_REPLACE_COPY_IF_H
lib/libcxx/include/__algorithm/ranges_replace_if.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___ALGORITHM_RANGES_REPLACE_IF_H
10#define _LIBCPP___ALGORITHM_RANGES_REPLACE_IF_H
11
12#include <__config>
13#include <__functional/identity.h>
14#include <__functional/invoke.h>
15#include <__iterator/concepts.h>
16#include <__iterator/projected.h>
17#include <__ranges/access.h>
18#include <__ranges/concepts.h>
19#include <__ranges/dangling.h>
20#include <__utility/move.h>
21
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23# pragma GCC system_header
24#endif
25
26#if _LIBCPP_STD_VER > 17 && !defined (_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
27
28_LIBCPP_BEGIN_NAMESPACE_STD
29
30namespace ranges {
31
32template <class _Iter, class _Sent, class _Type, class _Proj, class _Pred>
33_LIBCPP_HIDE_FROM_ABI constexpr
34_Iter __replace_if_impl(_Iter __first, _Sent __last, _Pred& __pred, const _Type& __new_value, _Proj& __proj) {
35 for (; __first != __last; ++__first) {
36 if (std::invoke(__pred, std::invoke(__proj, *__first)))
37 *__first = __new_value;
38 }
39 return __first;
40}
41
42namespace __replace_if {
43struct __fn {
44
45 template <input_iterator _Iter, sentinel_for<_Iter> _Sent,
46 class _Type,
47 class _Proj = identity,
48 indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>
49 requires indirectly_writable<_Iter, const _Type&>
50 _LIBCPP_HIDE_FROM_ABI constexpr
51 _Iter operator()(_Iter __first, _Sent __last, _Pred __pred, const _Type& __new_value, _Proj __proj = {}) const {
52 return ranges::__replace_if_impl(std::move(__first), std::move(__last), __pred, __new_value, __proj);
53 }
54
55 template <input_range _Range,
56 class _Type,
57 class _Proj = identity,
58 indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
59 requires indirectly_writable<iterator_t<_Range>, const _Type&>
60 _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Range>
61 operator()(_Range&& __range, _Pred __pred, const _Type& __new_value, _Proj __proj = {}) const {
62 return ranges::__replace_if_impl(ranges::begin(__range), ranges::end(__range), __pred, __new_value, __proj);
63 }
64
65};
66} // namespace __replace_if
67
68inline namespace __cpo {
69 inline constexpr auto replace_if = __replace_if::__fn{};
70} // namespace __cpo
71} // namespace ranges
72
73_LIBCPP_END_NAMESPACE_STD
74
75#endif // _LIBCPP_STD_VER > 17 && !defined (_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
76
77#endif // _LIBCPP___ALGORITHM_RANGES_REPLACE_IF_H
lib/libcxx/include/__algorithm/ranges_reverse.h created+83
...@@ -0,0 +1,83 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_REVERSE_H
10#define _LIBCPP___ALGORITHM_RANGES_REVERSE_H
11
12#include <__config>
13#include <__iterator/concepts.h>
14#include <__iterator/iter_swap.h>
15#include <__iterator/next.h>
16#include <__iterator/permutable.h>
17#include <__ranges/access.h>
18#include <__ranges/concepts.h>
19#include <__ranges/dangling.h>
20
21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
22# pragma GCC system_header
23#endif
24
25#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
26
27_LIBCPP_BEGIN_NAMESPACE_STD
28
29namespace ranges {
30namespace __reverse {
31struct __fn {
32
33 template <bidirectional_iterator _Iter, sentinel_for<_Iter> _Sent>
34 requires permutable<_Iter>
35 _LIBCPP_HIDE_FROM_ABI constexpr
36 _Iter operator()(_Iter __first, _Sent __last) const {
37 if constexpr (random_access_iterator<_Iter>) {
38 if (__first == __last)
39 return __first;
40
41 auto __end = ranges::next(__first, __last);
42 auto __ret = __end;
43
44 while (__first < --__end) {
45 ranges::iter_swap(__first, __end);
46 ++__first;
47 }
48 return __ret;
49 } else {
50 auto __end = ranges::next(__first, __last);
51 auto __ret = __end;
52
53 while (__first != __end) {
54 if (__first == --__end)
55 break;
56
57 ranges::iter_swap(__first, __end);
58 ++__first;
59 }
60 return __ret;
61 }
62 }
63
64 template <bidirectional_range _Range>
65 requires permutable<iterator_t<_Range>>
66 _LIBCPP_HIDE_FROM_ABI constexpr
67 borrowed_iterator_t<_Range> operator()(_Range&& __range) const {
68 return (*this)(ranges::begin(__range), ranges::end(__range));
69 }
70
71};
72} // namespace __reverse
73
74inline namespace __cpo {
75 inline constexpr auto reverse = __reverse::__fn{};
76} // namespace __cpo
77} // namespace ranges
78
79_LIBCPP_END_NAMESPACE_STD
80
81#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
82
83#endif // _LIBCPP___ALGORITHM_RANGES_REVERSE_H
lib/libcxx/include/__algorithm/ranges_reverse_copy.h created+67
...@@ -0,0 +1,67 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_REVERSE_COPY_H
10#define _LIBCPP___ALGORITHM_RANGES_REVERSE_COPY_H
11
12#include <__algorithm/in_out_result.h>
13#include <__algorithm/ranges_copy.h>
14#include <__config>
15#include <__iterator/concepts.h>
16#include <__iterator/next.h>
17#include <__iterator/reverse_iterator.h>
18#include <__ranges/access.h>
19#include <__ranges/concepts.h>
20#include <__ranges/dangling.h>
21#include <__ranges/subrange.h>
22#include <__utility/move.h>
23
24#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
25# pragma GCC system_header
26#endif
27
28#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
29
30_LIBCPP_BEGIN_NAMESPACE_STD
31
32namespace ranges {
33
34template <class _InIter, class _OutIter>
35using reverse_copy_result = in_out_result<_InIter, _OutIter>;
36
37namespace __reverse_copy {
38struct __fn {
39
40 template <bidirectional_iterator _InIter, sentinel_for<_InIter> _Sent, weakly_incrementable _OutIter>
41 requires indirectly_copyable<_InIter, _OutIter>
42 _LIBCPP_HIDE_FROM_ABI constexpr
43 reverse_copy_result<_InIter, _OutIter> operator()(_InIter __first, _Sent __last, _OutIter __result) const {
44 return (*this)(subrange(std::move(__first), std::move(__last)), std::move(__result));
45 }
46
47 template <bidirectional_range _Range, weakly_incrementable _OutIter>
48 requires indirectly_copyable<iterator_t<_Range>, _OutIter>
49 _LIBCPP_HIDE_FROM_ABI constexpr
50 reverse_copy_result<borrowed_iterator_t<_Range>, _OutIter> operator()(_Range&& __range, _OutIter __result) const {
51 auto __ret = ranges::copy(std::__reverse_range(__range), std::move(__result));
52 return {ranges::next(ranges::begin(__range), ranges::end(__range)), std::move(__ret.out)};
53 }
54
55};
56} // namespace __reverse_copy
57
58inline namespace __cpo {
59 inline constexpr auto reverse_copy = __reverse_copy::__fn{};
60} // namespace __cpo
61} // namespace ranges
62
63_LIBCPP_END_NAMESPACE_STD
64
65#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
66
67#endif // _LIBCPP___ALGORITHM_RANGES_REVERSE_COPY_H
lib/libcxx/include/__algorithm/ranges_rotate_copy.h created+68
...@@ -0,0 +1,68 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_ROTATE_COPY_H
10#define _LIBCPP___ALGORITHM_RANGES_ROTATE_COPY_H
11
12#include <__algorithm/in_out_result.h>
13#include <__algorithm/ranges_copy.h>
14#include <__config>
15#include <__iterator/concepts.h>
16#include <__iterator/reverse_iterator.h>
17#include <__ranges/access.h>
18#include <__ranges/concepts.h>
19#include <__ranges/dangling.h>
20#include <__utility/move.h>
21
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23# pragma GCC system_header
24#endif
25
26#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
27
28_LIBCPP_BEGIN_NAMESPACE_STD
29
30namespace ranges {
31
32template <class _InIter, class _OutIter>
33using rotate_copy_result = in_out_result<_InIter, _OutIter>;
34
35namespace __rotate_copy {
36struct __fn {
37
38 template <bidirectional_iterator _InIter, sentinel_for<_InIter> _Sent, weakly_incrementable _OutIter>
39 requires indirectly_copyable<_InIter, _OutIter>
40 _LIBCPP_HIDE_FROM_ABI constexpr
41 rotate_copy_result<_InIter, _OutIter>
42 operator()(_InIter __first, _InIter __middle, _Sent __last, _OutIter __result) const {
43 auto __res1 = ranges::copy(__middle, __last, std::move(__result));
44 auto __res2 = ranges::copy(__first, __middle, std::move(__res1.out));
45 return {std::move(__res1.in), std::move(__res2.out)};
46 }
47
48 template <bidirectional_range _Range, weakly_incrementable _OutIter>
49 requires indirectly_copyable<iterator_t<_Range>, _OutIter>
50 _LIBCPP_HIDE_FROM_ABI constexpr
51 rotate_copy_result<borrowed_iterator_t<_Range>, _OutIter>
52 operator()(_Range&& __range, iterator_t<_Range> __middle, _OutIter __result) const {
53 return (*this)(ranges::begin(__range), std::move(__middle), ranges::end(__range), std::move(__result));
54 }
55
56};
57} // namespace __rotate_copy
58
59inline namespace __cpo {
60 inline constexpr auto rotate_copy = __rotate_copy::__fn{};
61} // namespace __cpo
62} // namespace ranges
63
64_LIBCPP_END_NAMESPACE_STD
65
66#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
67
68#endif // _LIBCPP___ALGORITHM_RANGES_ROTATE_COPY_H
lib/libcxx/include/__algorithm/ranges_search.h created+134
...@@ -0,0 +1,134 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_SEARCH_H
10#define _LIBCPP___ALGORITHM_RANGES_SEARCH_H
11
12#include <__algorithm/iterator_operations.h>
13#include <__algorithm/search.h>
14#include <__config>
15#include <__functional/identity.h>
16#include <__functional/ranges_operations.h>
17#include <__iterator/advance.h>
18#include <__iterator/concepts.h>
19#include <__iterator/distance.h>
20#include <__iterator/indirectly_comparable.h>
21#include <__ranges/access.h>
22#include <__ranges/concepts.h>
23#include <__ranges/size.h>
24#include <__ranges/subrange.h>
25
26#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
27# pragma GCC system_header
28#endif
29
30#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
31
32_LIBCPP_BEGIN_NAMESPACE_STD
33
34namespace ranges {
35namespace __search {
36struct __fn {
37 template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Pred, class _Proj1, class _Proj2>
38 _LIBCPP_HIDE_FROM_ABI static constexpr subrange<_Iter1> __ranges_search_impl(
39 _Iter1 __first1,
40 _Sent1 __last1,
41 _Iter2 __first2,
42 _Sent2 __last2,
43 _Pred& __pred,
44 _Proj1& __proj1,
45 _Proj2& __proj2) {
46 if constexpr (sized_sentinel_for<_Sent2, _Iter2>) {
47 auto __size2 = ranges::distance(__first2, __last2);
48 if (__size2 == 0)
49 return {__first1, __first1};
50
51 if constexpr (sized_sentinel_for<_Sent1, _Iter1>) {
52 auto __size1 = ranges::distance(__first1, __last1);
53 if (__size1 < __size2) {
54 ranges::advance(__first1, __last1);
55 return {__first1, __first1};
56 }
57
58 if constexpr (random_access_iterator<_Iter1> && random_access_iterator<_Iter2>) {
59 auto __ret = std::__search_random_access_impl<_RangeAlgPolicy>(
60 __first1, __last1, __first2, __last2, __pred, __proj1, __proj2, __size1, __size2);
61 return {__ret.first, __ret.second};
62 }
63 }
64 }
65
66 auto __ret =
67 std::__search_forward_impl<_RangeAlgPolicy>(__first1, __last1, __first2, __last2, __pred, __proj1, __proj2);
68 return {__ret.first, __ret.second};
69 }
70
71 template <forward_iterator _Iter1, sentinel_for<_Iter1> _Sent1,
72 forward_iterator _Iter2, sentinel_for<_Iter2> _Sent2,
73 class _Pred = ranges::equal_to,
74 class _Proj1 = identity,
75 class _Proj2 = identity>
76 requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2>
77 _LIBCPP_HIDE_FROM_ABI constexpr
78 subrange<_Iter1> operator()(_Iter1 __first1, _Sent1 __last1,
79 _Iter2 __first2, _Sent2 __last2,
80 _Pred __pred = {},
81 _Proj1 __proj1 = {},
82 _Proj2 __proj2 = {}) const {
83 return __ranges_search_impl(__first1, __last1, __first2, __last2, __pred, __proj1, __proj2);
84 }
85
86 template <forward_range _Range1,
87 forward_range _Range2,
88 class _Pred = ranges::equal_to,
89 class _Proj1 = identity,
90 class _Proj2 = identity>
91 requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2>
92 _LIBCPP_HIDE_FROM_ABI constexpr
93 borrowed_subrange_t<_Range1> operator()(_Range1&& __range1,
94 _Range2&& __range2,
95 _Pred __pred = {},
96 _Proj1 __proj1 = {},
97 _Proj2 __proj2 = {}) const {
98 auto __first1 = ranges::begin(__range1);
99 if constexpr (sized_range<_Range2>) {
100 auto __size2 = ranges::size(__range2);
101 if (__size2 == 0)
102 return {__first1, __first1};
103 if constexpr (sized_range<_Range1>) {
104 auto __size1 = ranges::size(__range1);
105 if (__size1 < __size2) {
106 ranges::advance(__first1, ranges::end(__range1));
107 return {__first1, __first1};
108 }
109 }
110 }
111
112 return __ranges_search_impl(
113 ranges::begin(__range1),
114 ranges::end(__range1),
115 ranges::begin(__range2),
116 ranges::end(__range2),
117 __pred,
118 __proj1,
119 __proj2);
120 }
121
122};
123} // namespace __search
124
125inline namespace __cpo {
126 inline constexpr auto search = __search::__fn{};
127} // namespace __cpo
128} // namespace ranges
129
130_LIBCPP_END_NAMESPACE_STD
131
132#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
133
134#endif // _LIBCPP___ALGORITHM_RANGES_SEARCH_H
lib/libcxx/include/__algorithm/ranges_search_n.h created+120
...@@ -0,0 +1,120 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_SEARCH_N_H
10#define _LIBCPP___ALGORITHM_RANGES_SEARCH_N_H
11
12#include <__algorithm/iterator_operations.h>
13#include <__algorithm/search_n.h>
14#include <__config>
15#include <__functional/identity.h>
16#include <__functional/ranges_operations.h>
17#include <__iterator/advance.h>
18#include <__iterator/concepts.h>
19#include <__iterator/distance.h>
20#include <__iterator/incrementable_traits.h>
21#include <__iterator/indirectly_comparable.h>
22#include <__iterator/iterator_traits.h>
23#include <__ranges/access.h>
24#include <__ranges/concepts.h>
25#include <__ranges/size.h>
26#include <__ranges/subrange.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#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
34
35_LIBCPP_BEGIN_NAMESPACE_STD
36
37namespace ranges {
38namespace __search_n {
39struct __fn {
40
41 template <class _Iter1, class _Sent1, class _SizeT, class _Type, class _Pred, class _Proj>
42 _LIBCPP_HIDE_FROM_ABI static constexpr subrange<_Iter1> __ranges_search_n_impl(
43 _Iter1 __first, _Sent1 __last, _SizeT __count, const _Type& __value, _Pred& __pred, _Proj& __proj) {
44 if (__count == 0)
45 return {__first, __first};
46
47 if constexpr (sized_sentinel_for<_Sent1, _Iter1>) {
48 auto __size = ranges::distance(__first, __last);
49 if (__size < __count) {
50 ranges::advance(__first, __last);
51 return {__first, __first};
52 }
53
54 if constexpr (random_access_iterator<_Iter1>) {
55 auto __ret = __search_n_random_access_impl<_RangeAlgPolicy>(__first, __last,
56 __count,
57 __value,
58 __pred,
59 __proj,
60 __size);
61 return {std::move(__ret.first), std::move(__ret.second)};
62 }
63 }
64
65 auto __ret = std::__search_n_forward_impl<_RangeAlgPolicy>(__first, __last,
66 __count,
67 __value,
68 __pred,
69 __proj);
70 return {std::move(__ret.first), std::move(__ret.second)};
71 }
72
73 template <forward_iterator _Iter, sentinel_for<_Iter> _Sent,
74 class _Type,
75 class _Pred = ranges::equal_to,
76 class _Proj = identity>
77 requires indirectly_comparable<_Iter, const _Type*, _Pred, _Proj>
78 _LIBCPP_HIDE_FROM_ABI constexpr
79 subrange<_Iter> operator()(_Iter __first, _Sent __last,
80 iter_difference_t<_Iter> __count,
81 const _Type& __value,
82 _Pred __pred = {},
83 _Proj __proj = _Proj{}) const {
84 return __ranges_search_n_impl(__first, __last, __count, __value, __pred, __proj);
85 }
86
87 template <forward_range _Range, class _Type, class _Pred = ranges::equal_to, class _Proj = identity>
88 requires indirectly_comparable<iterator_t<_Range>, const _Type*, _Pred, _Proj>
89 _LIBCPP_HIDE_FROM_ABI constexpr
90 borrowed_subrange_t<_Range> operator()(_Range&& __range,
91 range_difference_t<_Range> __count,
92 const _Type& __value,
93 _Pred __pred = {},
94 _Proj __proj = {}) const {
95 auto __first = ranges::begin(__range);
96 if (__count <= 0)
97 return {__first, __first};
98 if constexpr (sized_range<_Range>) {
99 auto __size1 = ranges::size(__range);
100 if (__size1 < static_cast<range_size_t<_Range>>(__count)) {
101 ranges::advance(__first, ranges::end(__range));
102 return {__first, __first};
103 }
104 }
105
106 return __ranges_search_n_impl(ranges::begin(__range), ranges::end(__range), __count, __value, __pred, __proj);
107 }
108};
109} // namespace __search_n
110
111inline namespace __cpo {
112 inline constexpr auto search_n = __search_n::__fn{};
113} // namespace __cpo
114} // namespace ranges
115
116_LIBCPP_END_NAMESPACE_STD
117
118#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
119
120#endif // _LIBCPP___ALGORITHM_RANGES_SEARCH_N_H
lib/libcxx/include/__algorithm/ranges_set_difference.h created+104
...@@ -0,0 +1,104 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_SET_DIFFERENCE_H
10#define _LIBCPP___ALGORITHM_RANGES_SET_DIFFERENCE_H
11
12#include <__algorithm/in_out_result.h>
13#include <__algorithm/make_projected.h>
14#include <__algorithm/set_difference.h>
15#include <__config>
16#include <__functional/identity.h>
17#include <__functional/invoke.h>
18#include <__functional/ranges_operations.h>
19#include <__iterator/concepts.h>
20#include <__iterator/mergeable.h>
21#include <__ranges/access.h>
22#include <__ranges/concepts.h>
23#include <__ranges/dangling.h>
24#include <__type_traits/decay.h>
25#include <__utility/move.h>
26
27#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
28# pragma GCC system_header
29#endif
30
31#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
32
33_LIBCPP_BEGIN_NAMESPACE_STD
34
35namespace ranges {
36
37template <class _InIter, class _OutIter>
38using set_difference_result = in_out_result<_InIter, _OutIter>;
39
40namespace __set_difference {
41
42struct __fn {
43 template <
44 input_iterator _InIter1,
45 sentinel_for<_InIter1> _Sent1,
46 input_iterator _InIter2,
47 sentinel_for<_InIter2> _Sent2,
48 weakly_incrementable _OutIter,
49 class _Comp = less,
50 class _Proj1 = identity,
51 class _Proj2 = identity>
52 requires mergeable<_InIter1, _InIter2, _OutIter, _Comp, _Proj1, _Proj2>
53 _LIBCPP_HIDE_FROM_ABI constexpr set_difference_result<_InIter1, _OutIter> operator()(
54 _InIter1 __first1,
55 _Sent1 __last1,
56 _InIter2 __first2,
57 _Sent2 __last2,
58 _OutIter __result,
59 _Comp __comp = {},
60 _Proj1 __proj1 = {},
61 _Proj2 __proj2 = {}) const {
62 auto __ret = std::__set_difference(
63 __first1, __last1, __first2, __last2, __result, ranges::__make_projected_comp(__comp, __proj1, __proj2));
64 return {std::move(__ret.first), std::move(__ret.second)};
65 }
66
67 template <
68 input_range _Range1,
69 input_range _Range2,
70 weakly_incrementable _OutIter,
71 class _Comp = less,
72 class _Proj1 = identity,
73 class _Proj2 = identity>
74 requires mergeable<iterator_t<_Range1>, iterator_t<_Range2>, _OutIter, _Comp, _Proj1, _Proj2>
75 _LIBCPP_HIDE_FROM_ABI constexpr set_difference_result<borrowed_iterator_t<_Range1>, _OutIter>
76 operator()(
77 _Range1&& __range1,
78 _Range2&& __range2,
79 _OutIter __result,
80 _Comp __comp = {},
81 _Proj1 __proj1 = {},
82 _Proj2 __proj2 = {}) const {
83 auto __ret = std::__set_difference(
84 ranges::begin(__range1),
85 ranges::end(__range1),
86 ranges::begin(__range2),
87 ranges::end(__range2),
88 __result,
89 ranges::__make_projected_comp(__comp, __proj1, __proj2));
90 return {std::move(__ret.first), std::move(__ret.second)};
91 }
92};
93
94} // namespace __set_difference
95
96inline namespace __cpo {
97 inline constexpr auto set_difference = __set_difference::__fn{};
98} // namespace __cpo
99} // namespace ranges
100
101_LIBCPP_END_NAMESPACE_STD
102
103#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
104#endif // _LIBCPP___ALGORITHM_RANGES_SET_DIFFERENCE_H
lib/libcxx/include/__algorithm/ranges_set_intersection.h created+117
...@@ -0,0 +1,117 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_SET_INTERSECTION_H
10#define _LIBCPP___ALGORITHM_RANGES_SET_INTERSECTION_H
11
12#include <__algorithm/in_in_out_result.h>
13#include <__algorithm/iterator_operations.h>
14#include <__algorithm/make_projected.h>
15#include <__algorithm/set_intersection.h>
16#include <__config>
17#include <__functional/identity.h>
18#include <__functional/invoke.h>
19#include <__functional/ranges_operations.h>
20#include <__iterator/concepts.h>
21#include <__iterator/mergeable.h>
22#include <__ranges/access.h>
23#include <__ranges/concepts.h>
24#include <__ranges/dangling.h>
25#include <__utility/move.h>
26
27#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
28# pragma GCC system_header
29#endif
30
31#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
32
33_LIBCPP_BEGIN_NAMESPACE_STD
34
35namespace ranges {
36
37template <class _InIter1, class _InIter2, class _OutIter>
38using set_intersection_result = in_in_out_result<_InIter1, _InIter2, _OutIter>;
39
40namespace __set_intersection {
41
42struct __fn {
43 template <
44 input_iterator _InIter1,
45 sentinel_for<_InIter1> _Sent1,
46 input_iterator _InIter2,
47 sentinel_for<_InIter2> _Sent2,
48 weakly_incrementable _OutIter,
49 class _Comp = less,
50 class _Proj1 = identity,
51 class _Proj2 = identity>
52 requires mergeable<_InIter1, _InIter2, _OutIter, _Comp, _Proj1, _Proj2>
53 _LIBCPP_HIDE_FROM_ABI constexpr set_intersection_result<_InIter1, _InIter2, _OutIter> operator()(
54 _InIter1 __first1,
55 _Sent1 __last1,
56 _InIter2 __first2,
57 _Sent2 __last2,
58 _OutIter __result,
59 _Comp __comp = {},
60 _Proj1 __proj1 = {},
61 _Proj2 __proj2 = {}) const {
62 auto __ret = std::__set_intersection<_RangeAlgPolicy>(
63 std::move(__first1),
64 std::move(__last1),
65 std::move(__first2),
66 std::move(__last2),
67 std::move(__result),
68 ranges::__make_projected_comp(__comp, __proj1, __proj2));
69 return {std::move(__ret.__in1_), std::move(__ret.__in2_), std::move(__ret.__out_)};
70 }
71
72 template <
73 input_range _Range1,
74 input_range _Range2,
75 weakly_incrementable _OutIter,
76 class _Comp = less,
77 class _Proj1 = identity,
78 class _Proj2 = identity>
79 requires mergeable<
80 iterator_t<_Range1>,
81 iterator_t<_Range2>,
82 _OutIter,
83 _Comp,
84 _Proj1,
85 _Proj2>
86 _LIBCPP_HIDE_FROM_ABI constexpr set_intersection_result<borrowed_iterator_t<_Range1>,
87 borrowed_iterator_t<_Range2>,
88 _OutIter>
89 operator()(
90 _Range1&& __range1,
91 _Range2&& __range2,
92 _OutIter __result,
93 _Comp __comp = {},
94 _Proj1 __proj1 = {},
95 _Proj2 __proj2 = {}) const {
96 auto __ret = std::__set_intersection<_RangeAlgPolicy>(
97 ranges::begin(__range1),
98 ranges::end(__range1),
99 ranges::begin(__range2),
100 ranges::end(__range2),
101 std::move(__result),
102 ranges::__make_projected_comp(__comp, __proj1, __proj2));
103 return {std::move(__ret.__in1_), std::move(__ret.__in2_), std::move(__ret.__out_)};
104 }
105};
106
107} // namespace __set_intersection
108
109inline namespace __cpo {
110 inline constexpr auto set_intersection = __set_intersection::__fn{};
111} // namespace __cpo
112} // namespace ranges
113
114_LIBCPP_END_NAMESPACE_STD
115
116#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
117#endif // _LIBCPP___ALGORITHM_RANGES_SET_INTERSECTION_H
lib/libcxx/include/__algorithm/ranges_set_symmetric_difference.h created+116
...@@ -0,0 +1,116 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_SET_SYMMETRIC_DIFFERENCE_H
10#define _LIBCPP___ALGORITHM_RANGES_SET_SYMMETRIC_DIFFERENCE_H
11
12#include <__algorithm/in_in_out_result.h>
13#include <__algorithm/make_projected.h>
14#include <__algorithm/set_symmetric_difference.h>
15#include <__config>
16#include <__functional/identity.h>
17#include <__functional/invoke.h>
18#include <__functional/ranges_operations.h>
19#include <__iterator/concepts.h>
20#include <__iterator/mergeable.h>
21#include <__ranges/access.h>
22#include <__ranges/concepts.h>
23#include <__ranges/dangling.h>
24#include <__utility/move.h>
25
26#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
27# pragma GCC system_header
28#endif
29
30#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
31
32_LIBCPP_BEGIN_NAMESPACE_STD
33
34namespace ranges {
35
36template <class _InIter1, class _InIter2, class _OutIter>
37using set_symmetric_difference_result = in_in_out_result<_InIter1, _InIter2, _OutIter>;
38
39namespace __set_symmetric_difference {
40
41struct __fn {
42 template <
43 input_iterator _InIter1,
44 sentinel_for<_InIter1> _Sent1,
45 input_iterator _InIter2,
46 sentinel_for<_InIter2> _Sent2,
47 weakly_incrementable _OutIter,
48 class _Comp = ranges::less,
49 class _Proj1 = identity,
50 class _Proj2 = identity>
51 requires mergeable<_InIter1, _InIter2, _OutIter, _Comp, _Proj1, _Proj2>
52 _LIBCPP_HIDE_FROM_ABI constexpr set_symmetric_difference_result<_InIter1, _InIter2, _OutIter> operator()(
53 _InIter1 __first1,
54 _Sent1 __last1,
55 _InIter2 __first2,
56 _Sent2 __last2,
57 _OutIter __result,
58 _Comp __comp = {},
59 _Proj1 __proj1 = {},
60 _Proj2 __proj2 = {}) const {
61 auto __ret = std::__set_symmetric_difference(
62 std::move(__first1),
63 std::move(__last1),
64 std::move(__first2),
65 std::move(__last2),
66 std::move(__result),
67 ranges::__make_projected_comp(__comp, __proj1, __proj2));
68 return {std::move(__ret.__in1_), std::move(__ret.__in2_), std::move(__ret.__out_)};
69 }
70
71 template <
72 input_range _Range1,
73 input_range _Range2,
74 weakly_incrementable _OutIter,
75 class _Comp = ranges::less,
76 class _Proj1 = identity,
77 class _Proj2 = identity>
78 requires mergeable<
79 iterator_t<_Range1>,
80 iterator_t<_Range2>,
81 _OutIter,
82 _Comp,
83 _Proj1,
84 _Proj2>
85 _LIBCPP_HIDE_FROM_ABI constexpr set_symmetric_difference_result<borrowed_iterator_t<_Range1>,
86 borrowed_iterator_t<_Range2>,
87 _OutIter>
88 operator()(
89 _Range1&& __range1,
90 _Range2&& __range2,
91 _OutIter __result,
92 _Comp __comp = {},
93 _Proj1 __proj1 = {},
94 _Proj2 __proj2 = {}) const {
95 auto __ret = std::__set_symmetric_difference(
96 ranges::begin(__range1),
97 ranges::end(__range1),
98 ranges::begin(__range2),
99 ranges::end(__range2),
100 std::move(__result),
101 ranges::__make_projected_comp(__comp, __proj1, __proj2));
102 return {std::move(__ret.__in1_), std::move(__ret.__in2_), std::move(__ret.__out_)};
103 }
104};
105
106} // namespace __set_symmetric_difference
107
108inline namespace __cpo {
109 inline constexpr auto set_symmetric_difference = __set_symmetric_difference::__fn{};
110} // namespace __cpo
111} // namespace ranges
112
113_LIBCPP_END_NAMESPACE_STD
114
115#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
116#endif // _LIBCPP___ALGORITHM_RANGES_SET_SYMMETRIC_DIFFERENCE_H
lib/libcxx/include/__algorithm/ranges_set_union.h created+120
...@@ -0,0 +1,120 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_SET_UNION_H
10#define _LIBCPP___ALGORITHM_RANGES_SET_UNION_H
11
12#include <__algorithm/in_in_out_result.h>
13#include <__algorithm/make_projected.h>
14#include <__algorithm/set_union.h>
15#include <__config>
16#include <__functional/identity.h>
17#include <__functional/invoke.h>
18#include <__functional/ranges_operations.h>
19#include <__iterator/concepts.h>
20#include <__iterator/iterator_traits.h>
21#include <__iterator/mergeable.h>
22#include <__iterator/projected.h>
23#include <__ranges/access.h>
24#include <__ranges/concepts.h>
25#include <__ranges/dangling.h>
26#include <__utility/forward.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#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
34
35_LIBCPP_BEGIN_NAMESPACE_STD
36
37namespace ranges {
38
39template <class _InIter1, class _InIter2, class _OutIter>
40using set_union_result = in_in_out_result<_InIter1, _InIter2, _OutIter>;
41
42namespace __set_union {
43
44struct __fn {
45 template <
46 input_iterator _InIter1,
47 sentinel_for<_InIter1> _Sent1,
48 input_iterator _InIter2,
49 sentinel_for<_InIter2> _Sent2,
50 weakly_incrementable _OutIter,
51 class _Comp = ranges::less,
52 class _Proj1 = identity,
53 class _Proj2 = identity>
54 requires mergeable<_InIter1, _InIter2, _OutIter, _Comp, _Proj1, _Proj2>
55 _LIBCPP_HIDE_FROM_ABI constexpr set_union_result<_InIter1, _InIter2, _OutIter> operator()(
56 _InIter1 __first1,
57 _Sent1 __last1,
58 _InIter2 __first2,
59 _Sent2 __last2,
60 _OutIter __result,
61 _Comp __comp = {},
62 _Proj1 __proj1 = {},
63 _Proj2 __proj2 = {}) const {
64 auto __ret = std::__set_union(
65 std::move(__first1),
66 std::move(__last1),
67 std::move(__first2),
68 std::move(__last2),
69 std::move(__result),
70 ranges::__make_projected_comp(__comp, __proj1, __proj2));
71 return {std::move(__ret.__in1_), std::move(__ret.__in2_), std::move(__ret.__out_)};
72 }
73
74 template <
75 input_range _Range1,
76 input_range _Range2,
77 weakly_incrementable _OutIter,
78 class _Comp = ranges::less,
79 class _Proj1 = identity,
80 class _Proj2 = identity>
81 requires mergeable<
82 iterator_t<_Range1>,
83 iterator_t<_Range2>,
84 _OutIter,
85 _Comp,
86 _Proj1,
87 _Proj2>
88 _LIBCPP_HIDE_FROM_ABI constexpr set_union_result<borrowed_iterator_t<_Range1>,
89 borrowed_iterator_t<_Range2>,
90 _OutIter>
91 operator()(
92 _Range1&& __range1,
93 _Range2&& __range2,
94 _OutIter __result,
95 _Comp __comp = {},
96 _Proj1 __proj1 = {},
97 _Proj2 __proj2 = {}) const {
98 auto __ret = std::__set_union(
99 ranges::begin(__range1),
100 ranges::end(__range1),
101 ranges::begin(__range2),
102 ranges::end(__range2),
103 std::move(__result),
104 ranges::__make_projected_comp(__comp, __proj1, __proj2));
105 return {std::move(__ret.__in1_), std::move(__ret.__in2_), std::move(__ret.__out_)};
106 }
107};
108
109} // namespace __set_union
110
111inline namespace __cpo {
112 inline constexpr auto set_union = __set_union::__fn{};
113} // namespace __cpo
114} // namespace ranges
115
116_LIBCPP_END_NAMESPACE_STD
117
118#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
119
120#endif // _LIBCPP___ALGORITHM_RANGES_SET_UNION_H
lib/libcxx/include/__algorithm/ranges_shuffle.h created+103
...@@ -0,0 +1,103 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_SHUFFLE_H
10#define _LIBCPP___ALGORITHM_RANGES_SHUFFLE_H
11
12#include <__algorithm/iterator_operations.h>
13#include <__algorithm/shuffle.h>
14#include <__config>
15#include <__functional/invoke.h>
16#include <__functional/ranges_operations.h>
17#include <__iterator/concepts.h>
18#include <__iterator/iterator_traits.h>
19#include <__iterator/next.h>
20#include <__iterator/permutable.h>
21#include <__random/uniform_random_bit_generator.h>
22#include <__ranges/access.h>
23#include <__ranges/concepts.h>
24#include <__ranges/dangling.h>
25#include <__utility/forward.h>
26#include <__utility/move.h>
27#include <type_traits>
28
29#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
30# pragma GCC system_header
31#endif
32
33#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
34
35_LIBCPP_PUSH_MACROS
36#include <__undef_macros>
37
38_LIBCPP_BEGIN_NAMESPACE_STD
39
40namespace ranges {
41namespace __shuffle {
42
43struct __fn {
44 // `std::shuffle` is more constrained than `std::ranges::shuffle`. `std::ranges::shuffle` only requires the given
45 // generator to satisfy the `std::uniform_random_bit_generator` concept. `std::shuffle` requires the given
46 // generator to meet the uniform random bit generator requirements; these requirements include satisfying
47 // `std::uniform_random_bit_generator` and add a requirement for the generator to provide a nested `result_type`
48 // typedef (see `[rand.req.urng]`).
49 //
50 // To reuse the implementation from `std::shuffle`, make the given generator meet the classic requirements by wrapping
51 // it into an adaptor type that forwards all of its interface and adds the required typedef.
52 template <class _Gen>
53 class _ClassicGenAdaptor {
54 private:
55 // The generator is not required to be copyable or movable, so it has to be stored as a reference.
56 _Gen& __gen;
57
58 public:
59 using result_type = invoke_result_t<_Gen&>;
60
61 _LIBCPP_HIDE_FROM_ABI
62 static constexpr auto min() { return __uncvref_t<_Gen>::min(); }
63 _LIBCPP_HIDE_FROM_ABI
64 static constexpr auto max() { return __uncvref_t<_Gen>::max(); }
65
66 _LIBCPP_HIDE_FROM_ABI
67 constexpr explicit _ClassicGenAdaptor(_Gen& __g) : __gen(__g) {}
68
69 _LIBCPP_HIDE_FROM_ABI
70 constexpr auto operator()() const { return __gen(); }
71 };
72
73 template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Gen>
74 requires permutable<_Iter> && uniform_random_bit_generator<remove_reference_t<_Gen>>
75 _LIBCPP_HIDE_FROM_ABI
76 _Iter operator()(_Iter __first, _Sent __last, _Gen&& __gen) const {
77 _ClassicGenAdaptor<_Gen> __adapted_gen(__gen);
78 return std::__shuffle<_RangeAlgPolicy>(std::move(__first), std::move(__last), __adapted_gen);
79 }
80
81 template<random_access_range _Range, class _Gen>
82 requires permutable<iterator_t<_Range>> && uniform_random_bit_generator<remove_reference_t<_Gen>>
83 _LIBCPP_HIDE_FROM_ABI
84 borrowed_iterator_t<_Range> operator()(_Range&& __range, _Gen&& __gen) const {
85 return (*this)(ranges::begin(__range), ranges::end(__range), std::forward<_Gen>(__gen));
86 }
87
88};
89
90} // namespace __shuffle
91
92inline namespace __cpo {
93 inline constexpr auto shuffle = __shuffle::__fn{};
94} // namespace __cpo
95} // namespace ranges
96
97_LIBCPP_END_NAMESPACE_STD
98
99_LIBCPP_POP_MACROS
100
101#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
102
103#endif // _LIBCPP___ALGORITHM_RANGES_SHUFFLE_H
lib/libcxx/include/__algorithm/ranges_sort.h created+79
...@@ -0,0 +1,79 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_SORT_H
10#define _LIBCPP___ALGORITHM_RANGES_SORT_H
11
12#include <__algorithm/iterator_operations.h>
13#include <__algorithm/make_projected.h>
14#include <__algorithm/sort.h>
15#include <__config>
16#include <__functional/identity.h>
17#include <__functional/invoke.h>
18#include <__functional/ranges_operations.h>
19#include <__iterator/concepts.h>
20#include <__iterator/iterator_traits.h>
21#include <__iterator/next.h>
22#include <__iterator/projected.h>
23#include <__iterator/sortable.h>
24#include <__ranges/access.h>
25#include <__ranges/concepts.h>
26#include <__ranges/dangling.h>
27#include <__utility/forward.h>
28#include <__utility/move.h>
29
30#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
31# pragma GCC system_header
32#endif
33
34#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
35
36_LIBCPP_BEGIN_NAMESPACE_STD
37
38namespace ranges {
39namespace __sort {
40
41struct __fn {
42 template <class _Iter, class _Sent, class _Comp, class _Proj>
43 _LIBCPP_HIDE_FROM_ABI constexpr static
44 _Iter __sort_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {
45 auto __last_iter = ranges::next(__first, __last);
46
47 auto&& __projected_comp = std::__make_projected(__comp, __proj);
48 std::__sort_impl<_RangeAlgPolicy>(std::move(__first), __last_iter, __projected_comp);
49
50 return __last_iter;
51 }
52
53 template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Comp = ranges::less, class _Proj = identity>
54 requires sortable<_Iter, _Comp, _Proj>
55 _LIBCPP_HIDE_FROM_ABI constexpr
56 _Iter operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
57 return __sort_fn_impl(std::move(__first), std::move(__last), __comp, __proj);
58 }
59
60 template <random_access_range _Range, class _Comp = ranges::less, class _Proj = identity>
61 requires sortable<iterator_t<_Range>, _Comp, _Proj>
62 _LIBCPP_HIDE_FROM_ABI constexpr
63 borrowed_iterator_t<_Range> operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
64 return __sort_fn_impl(ranges::begin(__r), ranges::end(__r), __comp, __proj);
65 }
66};
67
68} // namespace __sort
69
70inline namespace __cpo {
71 inline constexpr auto sort = __sort::__fn{};
72} // namespace __cpo
73} // namespace ranges
74
75_LIBCPP_END_NAMESPACE_STD
76
77#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
78
79#endif // _LIBCPP___ALGORITHM_RANGES_SORT_H
lib/libcxx/include/__algorithm/ranges_sort_heap.h created+80
...@@ -0,0 +1,80 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_SORT_HEAP_H
10#define _LIBCPP___ALGORITHM_RANGES_SORT_HEAP_H
11
12#include <__algorithm/iterator_operations.h>
13#include <__algorithm/make_projected.h>
14#include <__algorithm/sort_heap.h>
15#include <__concepts/same_as.h>
16#include <__config>
17#include <__functional/identity.h>
18#include <__functional/invoke.h>
19#include <__functional/ranges_operations.h>
20#include <__iterator/concepts.h>
21#include <__iterator/iterator_traits.h>
22#include <__iterator/next.h>
23#include <__iterator/projected.h>
24#include <__iterator/sortable.h>
25#include <__ranges/access.h>
26#include <__ranges/concepts.h>
27#include <__ranges/dangling.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#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
36
37_LIBCPP_BEGIN_NAMESPACE_STD
38
39namespace ranges {
40namespace __sort_heap {
41
42struct __fn {
43 template <class _Iter, class _Sent, class _Comp, class _Proj>
44 _LIBCPP_HIDE_FROM_ABI constexpr static
45 _Iter __sort_heap_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {
46 auto __last_iter = ranges::next(__first, __last);
47
48 auto&& __projected_comp = std::__make_projected(__comp, __proj);
49 std::__sort_heap<_RangeAlgPolicy>(std::move(__first), __last_iter, __projected_comp);
50
51 return __last_iter;
52 }
53
54 template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Comp = ranges::less, class _Proj = identity>
55 requires sortable<_Iter, _Comp, _Proj>
56 _LIBCPP_HIDE_FROM_ABI constexpr
57 _Iter operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
58 return __sort_heap_fn_impl(std::move(__first), std::move(__last), __comp, __proj);
59 }
60
61 template <random_access_range _Range, class _Comp = ranges::less, class _Proj = identity>
62 requires sortable<iterator_t<_Range>, _Comp, _Proj>
63 _LIBCPP_HIDE_FROM_ABI constexpr
64 borrowed_iterator_t<_Range> operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
65 return __sort_heap_fn_impl(ranges::begin(__r), ranges::end(__r), __comp, __proj);
66 }
67};
68
69} // namespace __sort_heap
70
71inline namespace __cpo {
72 inline constexpr auto sort_heap = __sort_heap::__fn{};
73} // namespace __cpo
74} // namespace ranges
75
76_LIBCPP_END_NAMESPACE_STD
77
78#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
79
80#endif // _LIBCPP___ALGORITHM_RANGES_SORT_HEAP_H
lib/libcxx/include/__algorithm/ranges_stable_partition.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___ALGORITHM_RANGES_STABLE_PARTITION_H
10#define _LIBCPP___ALGORITHM_RANGES_STABLE_PARTITION_H
11
12#include <__algorithm/iterator_operations.h>
13#include <__algorithm/make_projected.h>
14#include <__algorithm/ranges_iterator_concept.h>
15#include <__algorithm/stable_partition.h>
16#include <__config>
17#include <__functional/identity.h>
18#include <__functional/invoke.h>
19#include <__functional/ranges_operations.h>
20#include <__iterator/concepts.h>
21#include <__iterator/iterator_traits.h>
22#include <__iterator/next.h>
23#include <__iterator/permutable.h>
24#include <__iterator/projected.h>
25#include <__ranges/access.h>
26#include <__ranges/concepts.h>
27#include <__ranges/dangling.h>
28#include <__ranges/subrange.h>
29#include <__utility/forward.h>
30#include <__utility/move.h>
31#include <type_traits>
32
33#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
34# pragma GCC system_header
35#endif
36
37#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
38
39_LIBCPP_BEGIN_NAMESPACE_STD
40
41namespace ranges {
42namespace __stable_partition {
43
44struct __fn {
45
46 template <class _Iter, class _Sent, class _Proj, class _Pred>
47 _LIBCPP_HIDE_FROM_ABI static
48 subrange<__uncvref_t<_Iter>> __stable_partition_fn_impl(
49 _Iter&& __first, _Sent&& __last, _Pred&& __pred, _Proj&& __proj) {
50 auto __last_iter = ranges::next(__first, __last);
51
52 auto&& __projected_pred = std::__make_projected(__pred, __proj);
53 auto __result = std::__stable_partition<_RangeAlgPolicy>(
54 std::move(__first), __last_iter, __projected_pred, __iterator_concept<_Iter>());
55
56 return {std::move(__result), std::move(__last_iter)};
57 }
58
59 template <bidirectional_iterator _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity,
60 indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>
61 requires permutable<_Iter>
62 _LIBCPP_HIDE_FROM_ABI
63 subrange<_Iter> operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) const {
64 return __stable_partition_fn_impl(__first, __last, __pred, __proj);
65 }
66
67 template <bidirectional_range _Range, class _Proj = identity,
68 indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
69 requires permutable<iterator_t<_Range>>
70 _LIBCPP_HIDE_FROM_ABI
71 borrowed_subrange_t<_Range> operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const {
72 return __stable_partition_fn_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
73 }
74
75};
76
77} // namespace __stable_partition
78
79inline namespace __cpo {
80 inline constexpr auto stable_partition = __stable_partition::__fn{};
81} // namespace __cpo
82} // namespace ranges
83
84_LIBCPP_END_NAMESPACE_STD
85
86#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
87
88#endif // _LIBCPP___ALGORITHM_RANGES_STABLE_PARTITION_H
lib/libcxx/include/__algorithm/ranges_stable_sort.h created+79
...@@ -0,0 +1,79 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_STABLE_SORT_H
10#define _LIBCPP___ALGORITHM_RANGES_STABLE_SORT_H
11
12#include <__algorithm/iterator_operations.h>
13#include <__algorithm/make_projected.h>
14#include <__algorithm/stable_sort.h>
15#include <__config>
16#include <__functional/identity.h>
17#include <__functional/invoke.h>
18#include <__functional/ranges_operations.h>
19#include <__iterator/concepts.h>
20#include <__iterator/iterator_traits.h>
21#include <__iterator/next.h>
22#include <__iterator/projected.h>
23#include <__iterator/sortable.h>
24#include <__ranges/access.h>
25#include <__ranges/concepts.h>
26#include <__ranges/dangling.h>
27#include <__utility/forward.h>
28#include <__utility/move.h>
29
30#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
31# pragma GCC system_header
32#endif
33
34#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
35
36_LIBCPP_BEGIN_NAMESPACE_STD
37
38namespace ranges {
39namespace __stable_sort {
40
41struct __fn {
42 template <class _Iter, class _Sent, class _Comp, class _Proj>
43 _LIBCPP_HIDE_FROM_ABI
44 static _Iter __stable_sort_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {
45 auto __last_iter = ranges::next(__first, __last);
46
47 auto&& __projected_comp = std::__make_projected(__comp, __proj);
48 std::__stable_sort_impl<_RangeAlgPolicy>(std::move(__first), __last_iter, __projected_comp);
49
50 return __last_iter;
51 }
52
53 template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Comp = ranges::less, class _Proj = identity>
54 requires sortable<_Iter, _Comp, _Proj>
55 _LIBCPP_HIDE_FROM_ABI
56 _Iter operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
57 return __stable_sort_fn_impl(std::move(__first), std::move(__last), __comp, __proj);
58 }
59
60 template <random_access_range _Range, class _Comp = ranges::less, class _Proj = identity>
61 requires sortable<iterator_t<_Range>, _Comp, _Proj>
62 _LIBCPP_HIDE_FROM_ABI
63 borrowed_iterator_t<_Range> operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
64 return __stable_sort_fn_impl(ranges::begin(__r), ranges::end(__r), __comp, __proj);
65 }
66};
67
68} // namespace __stable_sort
69
70inline namespace __cpo {
71 inline constexpr auto stable_sort = __stable_sort::__fn{};
72} // namespace __cpo
73} // namespace ranges
74
75_LIBCPP_END_NAMESPACE_STD
76
77#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
78
79#endif // _LIBCPP___ALGORITHM_RANGES_STABLE_SORT_H
lib/libcxx/include/__algorithm/ranges_swap_ranges.h created+69
...@@ -0,0 +1,69 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_SWAP_RANGES_H
10#define _LIBCPP___ALGORITHM_RANGES_SWAP_RANGES_H
11
12#include <__algorithm/in_in_result.h>
13#include <__config>
14#include <__iterator/concepts.h>
15#include <__iterator/iter_swap.h>
16#include <__ranges/access.h>
17#include <__ranges/concepts.h>
18#include <__ranges/dangling.h>
19#include <__utility/move.h>
20
21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
22# pragma GCC system_header
23#endif
24
25#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
26
27_LIBCPP_BEGIN_NAMESPACE_STD
28
29namespace ranges {
30
31template <class _I1, class _I2>
32using swap_ranges_result = in_in_result<_I1, _I2>;
33
34namespace __swap_ranges {
35struct __fn {
36 template <input_iterator _I1, sentinel_for<_I1> _S1,
37 input_iterator _I2, sentinel_for<_I2> _S2>
38 requires indirectly_swappable<_I1, _I2>
39 _LIBCPP_HIDE_FROM_ABI constexpr swap_ranges_result<_I1, _I2>
40 operator()(_I1 __first1, _S1 __last1, _I2 __first2, _S2 __last2) const {
41 while (__first1 != __last1 && __first2 != __last2) {
42 ranges::iter_swap(__first1, __first2);
43 ++__first1;
44 ++__first2;
45 }
46 return {_VSTD::move(__first1), _VSTD::move(__first2)};
47 }
48
49 template <input_range _R1, input_range _R2>
50 requires indirectly_swappable<iterator_t<_R1>, iterator_t<_R2>>
51 _LIBCPP_HIDE_FROM_ABI constexpr
52 swap_ranges_result<borrowed_iterator_t<_R1>, borrowed_iterator_t<_R2>>
53 operator()(_R1&& __r1, _R2&& __r2) const {
54 return operator()(ranges::begin(__r1), ranges::end(__r1),
55 ranges::begin(__r2), ranges::end(__r2));
56 }
57};
58} // namespace __swap_ranges
59
60inline namespace __cpo {
61 inline constexpr auto swap_ranges = __swap_ranges::__fn{};
62} // namespace __cpo
63} // namespace ranges
64
65_LIBCPP_END_NAMESPACE_STD
66
67#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
68
69#endif // _LIBCPP___ALGORITHM_RANGES_SWAP_RANGES_H
lib/libcxx/include/__algorithm/ranges_transform.h created+170
...@@ -0,0 +1,170 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_TRANSFORM_H
10#define _LIBCPP___ALGORITHM_RANGES_TRANSFORM_H
11
12#include <__algorithm/in_in_out_result.h>
13#include <__algorithm/in_out_result.h>
14#include <__concepts/constructible.h>
15#include <__config>
16#include <__functional/identity.h>
17#include <__functional/invoke.h>
18#include <__iterator/concepts.h>
19#include <__iterator/projected.h>
20#include <__ranges/access.h>
21#include <__ranges/concepts.h>
22#include <__ranges/dangling.h>
23#include <__utility/move.h>
24
25#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
26# pragma GCC system_header
27#endif
28
29#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
30
31_LIBCPP_BEGIN_NAMESPACE_STD
32
33namespace ranges {
34
35template <class _Ip, class _Op>
36using unary_transform_result = in_out_result<_Ip, _Op>;
37
38template <class _I1, class _I2, class _O1>
39using binary_transform_result = in_in_out_result<_I1, _I2, _O1>;
40
41namespace __transform {
42struct __fn {
43private:
44 template <class _InIter, class _Sent,
45 class _OutIter,
46 class _Func,
47 class _Proj>
48 _LIBCPP_HIDE_FROM_ABI static constexpr
49 unary_transform_result<_InIter, _OutIter> __unary(_InIter __first, _Sent __last,
50 _OutIter __result,
51 _Func& __operation,
52 _Proj& __projection) {
53 while (__first != __last) {
54 *__result = std::invoke(__operation, std::invoke(__projection, *__first));
55 ++__first;
56 ++__result;
57 }
58
59 return {std::move(__first), std::move(__result)};
60 }
61
62 template <class _InIter1, class _Sent1,
63 class _InIter2, class _Sent2,
64 class _OutIter,
65 class _Func,
66 class _Proj1,
67 class _Proj2>
68 _LIBCPP_HIDE_FROM_ABI static constexpr binary_transform_result<_InIter1, _InIter2, _OutIter>
69 __binary(_InIter1 __first1, _Sent1 __last1,
70 _InIter2 __first2, _Sent2 __last2,
71 _OutIter __result,
72 _Func& __binary_operation,
73 _Proj1& __projection1,
74 _Proj2& __projection2) {
75 while (__first1 != __last1 && __first2 != __last2) {
76 *__result = std::invoke(__binary_operation, std::invoke(__projection1, *__first1),
77 std::invoke(__projection2, *__first2));
78 ++__first1;
79 ++__first2;
80 ++__result;
81 }
82 return {std::move(__first1), std::move(__first2), std::move(__result)};
83 }
84public:
85 template <input_iterator _InIter, sentinel_for<_InIter> _Sent,
86 weakly_incrementable _OutIter,
87 copy_constructible _Func,
88 class _Proj = identity>
89 requires indirectly_writable<_OutIter, indirect_result_t<_Func&, projected<_InIter, _Proj>>>
90 _LIBCPP_HIDE_FROM_ABI constexpr
91 unary_transform_result<_InIter, _OutIter> operator()(_InIter __first, _Sent __last,
92 _OutIter __result,
93 _Func __operation,
94 _Proj __proj = {}) const {
95 return __unary(std::move(__first), std::move(__last), std::move(__result), __operation, __proj);
96 }
97
98 template <input_range _Range,
99 weakly_incrementable _OutIter,
100 copy_constructible _Func,
101 class _Proj = identity>
102 requires indirectly_writable<_OutIter, indirect_result_t<_Func, projected<iterator_t<_Range>, _Proj>>>
103 _LIBCPP_HIDE_FROM_ABI constexpr
104 unary_transform_result<borrowed_iterator_t<_Range>, _OutIter> operator()(_Range&& __range,
105 _OutIter __result,
106 _Func __operation,
107 _Proj __projection = {}) const {
108 return __unary(ranges::begin(__range), ranges::end(__range), std::move(__result), __operation, __projection);
109 }
110
111 template <input_iterator _InIter1, sentinel_for<_InIter1> _Sent1,
112 input_iterator _InIter2, sentinel_for<_InIter2> _Sent2,
113 weakly_incrementable _OutIter,
114 copy_constructible _Func,
115 class _Proj1 = identity,
116 class _Proj2 = identity>
117 requires indirectly_writable<_OutIter, indirect_result_t<_Func&, projected<_InIter1, _Proj1>,
118 projected<_InIter2, _Proj2>>>
119 _LIBCPP_HIDE_FROM_ABI constexpr
120 binary_transform_result<_InIter1, _InIter2, _OutIter> operator()(_InIter1 __first1, _Sent1 __last1,
121 _InIter2 __first2, _Sent2 __last2,
122 _OutIter __result,
123 _Func __binary_operation,
124 _Proj1 __projection1 = {},
125 _Proj2 __projection2 = {}) const {
126 return __binary(std::move(__first1), std::move(__last1),
127 std::move(__first2), std::move(__last2),
128 std::move(__result),
129 __binary_operation,
130 __projection1,
131 __projection2);
132 }
133
134 template <input_range _Range1,
135 input_range _Range2,
136 weakly_incrementable _OutIter,
137 copy_constructible _Func,
138 class _Proj1 = identity,
139 class _Proj2 = identity>
140 requires indirectly_writable<_OutIter, indirect_result_t<_Func&, projected<iterator_t<_Range1>, _Proj1>,
141 projected<iterator_t<_Range2>, _Proj2>>>
142 _LIBCPP_HIDE_FROM_ABI constexpr
143 binary_transform_result<borrowed_iterator_t<_Range1>, borrowed_iterator_t<_Range2>, _OutIter>
144 operator()(_Range1&& __range1,
145 _Range2&& __range2,
146 _OutIter __result,
147 _Func __binary_operation,
148 _Proj1 __projection1 = {},
149 _Proj2 __projection2 = {}) const {
150 return __binary(ranges::begin(__range1), ranges::end(__range1),
151 ranges::begin(__range2), ranges::end(__range2),
152 std::move(__result),
153 __binary_operation,
154 __projection1,
155 __projection2);
156 }
157
158};
159} // namespace __transform
160
161inline namespace __cpo {
162 inline constexpr auto transform = __transform::__fn{};
163} // namespace __cpo
164} // namespace ranges
165
166_LIBCPP_END_NAMESPACE_STD
167
168#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
169
170#endif // _LIBCPP___ALGORITHM_RANGES_TRANSFORM_H
lib/libcxx/include/__algorithm/ranges_unique.h created+78
...@@ -0,0 +1,78 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_UNIQUE_H
10#define _LIBCPP___ALGORITHM_RANGES_UNIQUE_H
11
12#include <__algorithm/iterator_operations.h>
13#include <__algorithm/make_projected.h>
14#include <__algorithm/unique.h>
15#include <__config>
16#include <__functional/identity.h>
17#include <__functional/invoke.h>
18#include <__functional/ranges_operations.h>
19#include <__iterator/concepts.h>
20#include <__iterator/iterator_traits.h>
21#include <__iterator/permutable.h>
22#include <__iterator/projected.h>
23#include <__ranges/access.h>
24#include <__ranges/concepts.h>
25#include <__ranges/dangling.h>
26#include <__ranges/subrange.h>
27#include <__utility/forward.h>
28#include <__utility/move.h>
29
30#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
31# pragma GCC system_header
32#endif
33
34#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
35
36_LIBCPP_BEGIN_NAMESPACE_STD
37
38namespace ranges {
39namespace __unique {
40
41 struct __fn {
42 template <
43 permutable _Iter,
44 sentinel_for<_Iter> _Sent,
45 class _Proj = identity,
46 indirect_equivalence_relation<projected<_Iter, _Proj>> _Comp = ranges::equal_to>
47 _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter>
48 operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
49 auto __ret = std::__unique<_RangeAlgPolicy>(
50 std::move(__first), std::move(__last), std::__make_projected(__comp, __proj));
51 return {std::move(__ret.first), std::move(__ret.second)};
52 }
53
54 template <
55 forward_range _Range,
56 class _Proj = identity,
57 indirect_equivalence_relation<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::equal_to>
58 requires permutable<iterator_t<_Range>>
59 _LIBCPP_HIDE_FROM_ABI constexpr borrowed_subrange_t<_Range>
60 operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const {
61 auto __ret = std::__unique<_RangeAlgPolicy>(
62 ranges::begin(__range), ranges::end(__range), std::__make_projected(__comp, __proj));
63 return {std::move(__ret.first), std::move(__ret.second)};
64 }
65 };
66
67} // namespace __unique
68
69inline namespace __cpo {
70 inline constexpr auto unique = __unique::__fn{};
71} // namespace __cpo
72} // namespace ranges
73
74_LIBCPP_END_NAMESPACE_STD
75
76#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
77
78#endif // _LIBCPP___ALGORITHM_RANGES_UNIQUE_H
lib/libcxx/include/__algorithm/ranges_unique_copy.h created+115
...@@ -0,0 +1,115 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_UNIQUE_COPY_H
10#define _LIBCPP___ALGORITHM_RANGES_UNIQUE_COPY_H
11
12#include <__algorithm/in_out_result.h>
13#include <__algorithm/iterator_operations.h>
14#include <__algorithm/make_projected.h>
15#include <__algorithm/unique_copy.h>
16#include <__concepts/same_as.h>
17#include <__config>
18#include <__functional/identity.h>
19#include <__functional/invoke.h>
20#include <__functional/ranges_operations.h>
21#include <__iterator/concepts.h>
22#include <__iterator/iterator_traits.h>
23#include <__iterator/projected.h>
24#include <__iterator/readable_traits.h>
25#include <__ranges/access.h>
26#include <__ranges/concepts.h>
27#include <__ranges/dangling.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#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
36
37_LIBCPP_BEGIN_NAMESPACE_STD
38
39namespace ranges {
40
41template <class _InIter, class _OutIter>
42using unique_copy_result = in_out_result<_InIter, _OutIter>;
43
44namespace __unique_copy {
45
46template <class _InIter, class _OutIter>
47concept __can_reread_from_output = (input_iterator<_OutIter> && same_as<iter_value_t<_InIter>, iter_value_t<_OutIter>>);
48
49struct __fn {
50 template <class _InIter, class _OutIter>
51 static consteval auto __get_algo_tag() {
52 if constexpr (forward_iterator<_InIter>) {
53 return __unique_copy_tags::__reread_from_input_tag{};
54 } else if constexpr (__can_reread_from_output<_InIter, _OutIter>) {
55 return __unique_copy_tags::__reread_from_output_tag{};
56 } else if constexpr (indirectly_copyable_storable<_InIter, _OutIter>) {
57 return __unique_copy_tags::__read_from_tmp_value_tag{};
58 }
59 }
60
61 template <class _InIter, class _OutIter>
62 using __algo_tag_t = decltype(__get_algo_tag<_InIter, _OutIter>());
63
64 template <input_iterator _InIter,
65 sentinel_for<_InIter> _Sent,
66 weakly_incrementable _OutIter,
67 class _Proj = identity,
68 indirect_equivalence_relation<projected<_InIter, _Proj>> _Comp = ranges::equal_to>
69 requires indirectly_copyable<_InIter, _OutIter> &&
70 (forward_iterator<_InIter> ||
71 (input_iterator<_OutIter> && same_as<iter_value_t<_InIter>, iter_value_t<_OutIter>>) ||
72 indirectly_copyable_storable<_InIter, _OutIter>)
73 _LIBCPP_HIDE_FROM_ABI constexpr unique_copy_result<_InIter, _OutIter>
74 operator()(_InIter __first, _Sent __last, _OutIter __result, _Comp __comp = {}, _Proj __proj = {}) const {
75 auto __ret = std::__unique_copy<_RangeAlgPolicy>(
76 std::move(__first),
77 std::move(__last),
78 std::move(__result),
79 std::__make_projected(__comp, __proj),
80 __algo_tag_t<_InIter, _OutIter>());
81 return {std::move(__ret.first), std::move(__ret.second)};
82 }
83
84 template <input_range _Range,
85 weakly_incrementable _OutIter,
86 class _Proj = identity,
87 indirect_equivalence_relation<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::equal_to>
88 requires indirectly_copyable<iterator_t<_Range>, _OutIter> &&
89 (forward_iterator<iterator_t<_Range>> ||
90 (input_iterator<_OutIter> && same_as<range_value_t<_Range>, iter_value_t<_OutIter>>) ||
91 indirectly_copyable_storable<iterator_t<_Range>, _OutIter>)
92 _LIBCPP_HIDE_FROM_ABI constexpr unique_copy_result<borrowed_iterator_t<_Range>, _OutIter>
93 operator()(_Range&& __range, _OutIter __result, _Comp __comp = {}, _Proj __proj = {}) const {
94 auto __ret = std::__unique_copy<_RangeAlgPolicy>(
95 ranges::begin(__range),
96 ranges::end(__range),
97 std::move(__result),
98 std::__make_projected(__comp, __proj),
99 __algo_tag_t<iterator_t<_Range>, _OutIter>());
100 return {std::move(__ret.first), std::move(__ret.second)};
101 }
102};
103
104} // namespace __unique_copy
105
106inline namespace __cpo {
107inline constexpr auto unique_copy = __unique_copy::__fn{};
108} // namespace __cpo
109} // namespace ranges
110
111_LIBCPP_END_NAMESPACE_STD
112
113#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
114
115#endif // _LIBCPP___ALGORITHM_RANGES_UNIQUE_COPY_H
lib/libcxx/include/__algorithm/ranges_upper_bound.h created+75
...@@ -0,0 +1,75 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_UPPER_BOUND_H
10#define _LIBCPP___ALGORITHM_RANGES_UPPER_BOUND_H
11
12#include <__algorithm/iterator_operations.h>
13#include <__algorithm/lower_bound.h>
14#include <__config>
15#include <__functional/identity.h>
16#include <__functional/invoke.h>
17#include <__functional/ranges_operations.h>
18#include <__iterator/concepts.h>
19#include <__iterator/projected.h>
20#include <__ranges/access.h>
21#include <__ranges/concepts.h>
22#include <__ranges/dangling.h>
23
24#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
25# pragma GCC system_header
26#endif
27
28#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
29
30_LIBCPP_BEGIN_NAMESPACE_STD
31
32namespace ranges {
33namespace __upper_bound {
34struct __fn {
35 template <forward_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity,
36 indirect_strict_weak_order<const _Type*, projected<_Iter, _Proj>> _Comp = ranges::less>
37 _LIBCPP_HIDE_FROM_ABI constexpr
38 _Iter operator()(_Iter __first, _Sent __last, const _Type& __value, _Comp __comp = {}, _Proj __proj = {}) const {
39 auto __comp_lhs_rhs_swapped = [&](const auto& __lhs, const auto& __rhs) {
40 return !std::invoke(__comp, __rhs, __lhs);
41 };
42
43 return std::__lower_bound_impl<_RangeAlgPolicy>(__first, __last, __value, __comp_lhs_rhs_swapped, __proj);
44 }
45
46 template <forward_range _Range, class _Type, class _Proj = identity,
47 indirect_strict_weak_order<const _Type*, projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
48 _LIBCPP_HIDE_FROM_ABI constexpr
49 borrowed_iterator_t<_Range> operator()(_Range&& __r,
50 const _Type& __value,
51 _Comp __comp = {},
52 _Proj __proj = {}) const {
53 auto __comp_lhs_rhs_swapped = [&](const auto& __lhs, const auto& __rhs) {
54 return !std::invoke(__comp, __rhs, __lhs);
55 };
56
57 return std::__lower_bound_impl<_RangeAlgPolicy>(ranges::begin(__r),
58 ranges::end(__r),
59 __value,
60 __comp_lhs_rhs_swapped,
61 __proj);
62 }
63};
64} // namespace __upper_bound
65
66inline namespace __cpo {
67 inline constexpr auto upper_bound = __upper_bound::__fn{};
68} // namespace __cpo
69} // namespace ranges
70
71_LIBCPP_END_NAMESPACE_STD
72
73#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
74
75#endif // _LIBCPP___ALGORITHM_RANGES_UPPER_BOUND_H
lib/libcxx/include/__algorithm/remove.h+4-4
...@@ -15,22 +15,22 @@...@@ -15,22 +15,22 @@
15#include <__utility/move.h>15#include <__utility/move.h>
1616
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header18# pragma GCC system_header
19#endif19#endif
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
23template <class _ForwardIterator, class _Tp>23template <class _ForwardIterator, class _Tp>
24_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator24_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
25remove(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)25remove(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value)
26{26{
27 __first = _VSTD::find(__first, __last, __value_);27 __first = _VSTD::find(__first, __last, __value);
28 if (__first != __last)28 if (__first != __last)
29 {29 {
30 _ForwardIterator __i = __first;30 _ForwardIterator __i = __first;
31 while (++__i != __last)31 while (++__i != __last)
32 {32 {
33 if (!(*__i == __value_))33 if (!(*__i == __value))
34 {34 {
35 *__first = _VSTD::move(*__i);35 *__first = _VSTD::move(*__i);
36 ++__first;36 ++__first;
lib/libcxx/include/__algorithm/remove_copy.h+3-3
...@@ -12,7 +12,7 @@...@@ -12,7 +12,7 @@
12#include <__config>12#include <__config>
1313
14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
15#pragma GCC system_header15# pragma GCC system_header
16#endif16#endif
1717
18_LIBCPP_BEGIN_NAMESPACE_STD18_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -20,11 +20,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -20,11 +20,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD
20template <class _InputIterator, class _OutputIterator, class _Tp>20template <class _InputIterator, class _OutputIterator, class _Tp>
21inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1721inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
22_OutputIterator22_OutputIterator
23remove_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, const _Tp& __value_)23remove_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, const _Tp& __value)
24{24{
25 for (; __first != __last; ++__first)25 for (; __first != __last; ++__first)
26 {26 {
27 if (!(*__first == __value_))27 if (!(*__first == __value))
28 {28 {
29 *__result = *__first;29 *__result = *__first;
30 ++__result;30 ++__result;
lib/libcxx/include/__algorithm/remove_copy_if.h+1-1
...@@ -12,7 +12,7 @@...@@ -12,7 +12,7 @@
12#include <__config>12#include <__config>
1313
14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
15#pragma GCC system_header15# pragma GCC system_header
16#endif16#endif
1717
18_LIBCPP_BEGIN_NAMESPACE_STD18_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/remove_if.h+2-2
...@@ -11,10 +11,10 @@...@@ -11,10 +11,10 @@
1111
12#include <__algorithm/find_if.h>12#include <__algorithm/find_if.h>
13#include <__config>13#include <__config>
14#include <utility>14#include <__utility/move.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
18#endif18#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/replace.h+1-1
...@@ -12,7 +12,7 @@...@@ -12,7 +12,7 @@
12#include <__config>12#include <__config>
1313
14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
15#pragma GCC system_header15# pragma GCC system_header
16#endif16#endif
1717
18_LIBCPP_BEGIN_NAMESPACE_STD18_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/replace_copy.h+1-1
...@@ -12,7 +12,7 @@...@@ -12,7 +12,7 @@
12#include <__config>12#include <__config>
1313
14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
15#pragma GCC system_header15# pragma GCC system_header
16#endif16#endif
1717
18_LIBCPP_BEGIN_NAMESPACE_STD18_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/replace_copy_if.h+1-1
...@@ -12,7 +12,7 @@...@@ -12,7 +12,7 @@
12#include <__config>12#include <__config>
1313
14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
15#pragma GCC system_header15# pragma GCC system_header
16#endif16#endif
1717
18_LIBCPP_BEGIN_NAMESPACE_STD18_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/replace_if.h+1-1
...@@ -12,7 +12,7 @@...@@ -12,7 +12,7 @@
12#include <__config>12#include <__config>
1313
14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
15#pragma GCC system_header15# pragma GCC system_header
16#endif16#endif
1717
18_LIBCPP_BEGIN_NAMESPACE_STD18_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/reverse.h+1-1
...@@ -14,7 +14,7 @@...@@ -14,7 +14,7 @@
14#include <__iterator/iterator_traits.h>14#include <__iterator/iterator_traits.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
18#endif18#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/reverse_copy.h+1-1
...@@ -12,7 +12,7 @@...@@ -12,7 +12,7 @@
12#include <__config>12#include <__config>
1313
14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
15#pragma GCC system_header15# pragma GCC system_header
16#endif16#endif
1717
18_LIBCPP_BEGIN_NAMESPACE_STD18_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/rotate.h+52-38
...@@ -9,6 +9,7 @@...@@ -9,6 +9,7 @@
9#ifndef _LIBCPP___ALGORITHM_ROTATE_H9#ifndef _LIBCPP___ALGORITHM_ROTATE_H
10#define _LIBCPP___ALGORITHM_ROTATE_H10#define _LIBCPP___ALGORITHM_ROTATE_H
1111
12#include <__algorithm/iterator_operations.h>
12#include <__algorithm/move.h>13#include <__algorithm/move.h>
13#include <__algorithm/move_backward.h>14#include <__algorithm/move_backward.h>
14#include <__algorithm/swap_ranges.h>15#include <__algorithm/swap_ranges.h>
...@@ -16,46 +17,50 @@...@@ -16,46 +17,50 @@
16#include <__iterator/iterator_traits.h>17#include <__iterator/iterator_traits.h>
17#include <__iterator/next.h>18#include <__iterator/next.h>
18#include <__iterator/prev.h>19#include <__iterator/prev.h>
20#include <__utility/move.h>
19#include <__utility/swap.h>21#include <__utility/swap.h>
20#include <iterator>22#include <type_traits>
2123
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)24#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23#pragma GCC system_header25# pragma GCC system_header
24#endif26#endif
2527
26_LIBCPP_BEGIN_NAMESPACE_STD28_LIBCPP_BEGIN_NAMESPACE_STD
2729
28template <class _ForwardIterator>30template <class _AlgPolicy, class _ForwardIterator>
29_LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator31_LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator
30__rotate_left(_ForwardIterator __first, _ForwardIterator __last)32__rotate_left(_ForwardIterator __first, _ForwardIterator __last)
31{33{
32 typedef typename iterator_traits<_ForwardIterator>::value_type value_type;34 typedef typename iterator_traits<_ForwardIterator>::value_type value_type;
33 value_type __tmp = _VSTD::move(*__first);35 value_type __tmp = _IterOps<_AlgPolicy>::__iter_move(__first);
36 // TODO(ranges): pass `_AlgPolicy` to `move`.
34 _ForwardIterator __lm1 = _VSTD::move(_VSTD::next(__first), __last, __first);37 _ForwardIterator __lm1 = _VSTD::move(_VSTD::next(__first), __last, __first);
35 *__lm1 = _VSTD::move(__tmp);38 *__lm1 = _VSTD::move(__tmp);
36 return __lm1;39 return __lm1;
37}40}
3841
39template <class _BidirectionalIterator>42template <class _AlgPolicy, class _BidirectionalIterator>
40_LIBCPP_CONSTEXPR_AFTER_CXX11 _BidirectionalIterator43_LIBCPP_CONSTEXPR_AFTER_CXX11 _BidirectionalIterator
41__rotate_right(_BidirectionalIterator __first, _BidirectionalIterator __last)44__rotate_right(_BidirectionalIterator __first, _BidirectionalIterator __last)
42{45{
43 typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;46 typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
47 // TODO(ranges): pass `_AlgPolicy` to `prev`.
44 _BidirectionalIterator __lm1 = _VSTD::prev(__last);48 _BidirectionalIterator __lm1 = _VSTD::prev(__last);
45 value_type __tmp = _VSTD::move(*__lm1);49 value_type __tmp = _IterOps<_AlgPolicy>::__iter_move(__lm1);
50 // TODO(ranges): pass `_AlgPolicy` to `move_backward`.
46 _BidirectionalIterator __fp1 = _VSTD::move_backward(__first, __lm1, __last);51 _BidirectionalIterator __fp1 = _VSTD::move_backward(__first, __lm1, __last);
47 *__first = _VSTD::move(__tmp);52 *__first = _VSTD::move(__tmp);
48 return __fp1;53 return __fp1;
49}54}
5055
51template <class _ForwardIterator>56template <class _AlgPolicy, class _ForwardIterator>
52_LIBCPP_CONSTEXPR_AFTER_CXX14 _ForwardIterator57_LIBCPP_CONSTEXPR_AFTER_CXX14 _ForwardIterator
53__rotate_forward(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last)58__rotate_forward(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last)
54{59{
55 _ForwardIterator __i = __middle;60 _ForwardIterator __i = __middle;
56 while (true)61 while (true)
57 {62 {
58 swap(*__first, *__i);63 _IterOps<_AlgPolicy>::iter_swap(__first, __i);
59 ++__first;64 ++__first;
60 if (++__i == __last)65 if (++__i == __last)
61 break;66 break;
...@@ -68,7 +73,7 @@ __rotate_forward(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIt...@@ -68,7 +73,7 @@ __rotate_forward(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIt
68 __i = __middle;73 __i = __middle;
69 while (true)74 while (true)
70 {75 {
71 swap(*__first, *__i);76 _IterOps<_AlgPolicy>::iter_swap(__first, __i);
72 ++__first;77 ++__first;
73 if (++__i == __last)78 if (++__i == __last)
74 {79 {
...@@ -97,7 +102,7 @@ __algo_gcd(_Integral __x, _Integral __y)...@@ -97,7 +102,7 @@ __algo_gcd(_Integral __x, _Integral __y)
97 return __x;102 return __x;
98}103}
99104
100template<typename _RandomAccessIterator>105template <class _AlgPolicy, typename _RandomAccessIterator>
101_LIBCPP_CONSTEXPR_AFTER_CXX14 _RandomAccessIterator106_LIBCPP_CONSTEXPR_AFTER_CXX14 _RandomAccessIterator
102__rotate_gcd(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last)107__rotate_gcd(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last)
103{108{
...@@ -108,18 +113,19 @@ __rotate_gcd(_RandomAccessIterator __first, _RandomAccessIterator __middle, _Ran...@@ -108,18 +113,19 @@ __rotate_gcd(_RandomAccessIterator __first, _RandomAccessIterator __middle, _Ran
108 const difference_type __m2 = __last - __middle;113 const difference_type __m2 = __last - __middle;
109 if (__m1 == __m2)114 if (__m1 == __m2)
110 {115 {
116 // TODO(ranges): pass `_AlgPolicy` to `swap_ranges`.
111 _VSTD::swap_ranges(__first, __middle, __middle);117 _VSTD::swap_ranges(__first, __middle, __middle);
112 return __middle;118 return __middle;
113 }119 }
114 const difference_type __g = _VSTD::__algo_gcd(__m1, __m2);120 const difference_type __g = _VSTD::__algo_gcd(__m1, __m2);
115 for (_RandomAccessIterator __p = __first + __g; __p != __first;)121 for (_RandomAccessIterator __p = __first + __g; __p != __first;)
116 {122 {
117 value_type __t(_VSTD::move(*--__p));123 value_type __t(_IterOps<_AlgPolicy>::__iter_move(--__p));
118 _RandomAccessIterator __p1 = __p;124 _RandomAccessIterator __p1 = __p;
119 _RandomAccessIterator __p2 = __p1 + __m1;125 _RandomAccessIterator __p2 = __p1 + __m1;
120 do126 do
121 {127 {
122 *__p1 = _VSTD::move(*__p2);128 *__p1 = _IterOps<_AlgPolicy>::__iter_move(__p2);
123 __p1 = __p2;129 __p1 = __p2;
124 const difference_type __d = __last - __p2;130 const difference_type __d = __last - __p2;
125 if (__m1 < __d)131 if (__m1 < __d)
...@@ -132,54 +138,66 @@ __rotate_gcd(_RandomAccessIterator __first, _RandomAccessIterator __middle, _Ran...@@ -132,54 +138,66 @@ __rotate_gcd(_RandomAccessIterator __first, _RandomAccessIterator __middle, _Ran
132 return __first + __m2;138 return __first + __m2;
133}139}
134140
135template <class _ForwardIterator>141template <class _AlgPolicy, class _ForwardIterator>
136inline _LIBCPP_INLINE_VISIBILITY142inline _LIBCPP_INLINE_VISIBILITY
137_LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator143_LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator
138__rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last,144__rotate_impl(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last,
139 _VSTD::forward_iterator_tag)145 _VSTD::forward_iterator_tag)
140{146{
141 typedef typename iterator_traits<_ForwardIterator>::value_type value_type;147 typedef typename iterator_traits<_ForwardIterator>::value_type value_type;
142 if (is_trivially_move_assignable<value_type>::value)148 if (is_trivially_move_assignable<value_type>::value)
143 {149 {
144 if (_VSTD::next(__first) == __middle)150 if (_IterOps<_AlgPolicy>::next(__first) == __middle)
145 return _VSTD::__rotate_left(__first, __last);151 return std::__rotate_left<_AlgPolicy>(__first, __last);
146 }152 }
147 return _VSTD::__rotate_forward(__first, __middle, __last);153 return std::__rotate_forward<_AlgPolicy>(__first, __middle, __last);
148}154}
149155
150template <class _BidirectionalIterator>156template <class _AlgPolicy, class _BidirectionalIterator>
151inline _LIBCPP_INLINE_VISIBILITY157inline _LIBCPP_INLINE_VISIBILITY
152_LIBCPP_CONSTEXPR_AFTER_CXX11 _BidirectionalIterator158_LIBCPP_CONSTEXPR_AFTER_CXX11 _BidirectionalIterator
153__rotate(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last,159__rotate_impl(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last,
154 bidirectional_iterator_tag)160 bidirectional_iterator_tag)
155{161{
156 typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;162 typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
157 if (is_trivially_move_assignable<value_type>::value)163 if (is_trivially_move_assignable<value_type>::value)
158 {164 {
159 if (_VSTD::next(__first) == __middle)165 if (_IterOps<_AlgPolicy>::next(__first) == __middle)
160 return _VSTD::__rotate_left(__first, __last);166 return std::__rotate_left<_AlgPolicy>(__first, __last);
161 if (_VSTD::next(__middle) == __last)167 if (_IterOps<_AlgPolicy>::next(__middle) == __last)
162 return _VSTD::__rotate_right(__first, __last);168 return std::__rotate_right<_AlgPolicy>(__first, __last);
163 }169 }
164 return _VSTD::__rotate_forward(__first, __middle, __last);170 return std::__rotate_forward<_AlgPolicy>(__first, __middle, __last);
165}171}
166172
167template <class _RandomAccessIterator>173template <class _AlgPolicy, class _RandomAccessIterator>
168inline _LIBCPP_INLINE_VISIBILITY174inline _LIBCPP_INLINE_VISIBILITY
169_LIBCPP_CONSTEXPR_AFTER_CXX11 _RandomAccessIterator175_LIBCPP_CONSTEXPR_AFTER_CXX11 _RandomAccessIterator
170__rotate(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last,176__rotate_impl(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last,
171 random_access_iterator_tag)177 random_access_iterator_tag)
172{178{
173 typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;179 typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
174 if (is_trivially_move_assignable<value_type>::value)180 if (is_trivially_move_assignable<value_type>::value)
175 {181 {
176 if (_VSTD::next(__first) == __middle)182 if (_IterOps<_AlgPolicy>::next(__first) == __middle)
177 return _VSTD::__rotate_left(__first, __last);183 return std::__rotate_left<_AlgPolicy>(__first, __last);
178 if (_VSTD::next(__middle) == __last)184 if (_IterOps<_AlgPolicy>::next(__middle) == __last)
179 return _VSTD::__rotate_right(__first, __last);185 return std::__rotate_right<_AlgPolicy>(__first, __last);
180 return _VSTD::__rotate_gcd(__first, __middle, __last);186 return std::__rotate_gcd<_AlgPolicy>(__first, __middle, __last);
181 }187 }
182 return _VSTD::__rotate_forward(__first, __middle, __last);188 return std::__rotate_forward<_AlgPolicy>(__first, __middle, __last);
189}
190
191template <class _AlgPolicy, class _RandomAccessIterator, class _IterCategory>
192_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
193_RandomAccessIterator __rotate(_RandomAccessIterator __first, _RandomAccessIterator __middle,
194 _RandomAccessIterator __last, _IterCategory __iter_category) {
195 if (__first == __middle)
196 return __last;
197 if (__middle == __last)
198 return __first;
199
200 return std::__rotate_impl<_AlgPolicy>(std::move(__first), std::move(__middle), std::move(__last), __iter_category);
183}201}
184202
185template <class _ForwardIterator>203template <class _ForwardIterator>
...@@ -187,12 +205,8 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -187,12 +205,8 @@ inline _LIBCPP_INLINE_VISIBILITY
187_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator205_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
188rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last)206rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last)
189{207{
190 if (__first == __middle)208 return std::__rotate<_ClassicAlgPolicy>(__first, __middle, __last,
191 return __last;209 typename iterator_traits<_ForwardIterator>::iterator_category());
192 if (__middle == __last)
193 return __first;
194 return _VSTD::__rotate(__first, __middle, __last,
195 typename iterator_traits<_ForwardIterator>::iterator_category());
196}210}
197211
198_LIBCPP_END_NAMESPACE_STD212_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/rotate_copy.h+1-1
...@@ -13,7 +13,7 @@...@@ -13,7 +13,7 @@
13#include <__config>13#include <__config>
1414
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16#pragma GCC system_header16# pragma GCC system_header
17#endif17#endif
1818
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/sample.h+5-3
...@@ -10,13 +10,15 @@...@@ -10,13 +10,15 @@
10#define _LIBCPP___ALGORITHM_SAMPLE_H10#define _LIBCPP___ALGORITHM_SAMPLE_H
1111
12#include <__algorithm/min.h>12#include <__algorithm/min.h>
13#include <__assert>
13#include <__config>14#include <__config>
14#include <__debug>15#include <__iterator/distance.h>
16#include <__iterator/iterator_traits.h>
15#include <__random/uniform_int_distribution.h>17#include <__random/uniform_int_distribution.h>
16#include <iterator>18#include <type_traits>
1719
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19#pragma GCC system_header21# pragma GCC system_header
20#endif22#endif
2123
22_LIBCPP_PUSH_MACROS24_LIBCPP_PUSH_MACROS
lib/libcxx/include/__algorithm/search.h+129-51
...@@ -11,41 +11,59 @@...@@ -11,41 +11,59 @@
11#define _LIBCPP___ALGORITHM_SEARCH_H11#define _LIBCPP___ALGORITHM_SEARCH_H
1212
13#include <__algorithm/comp.h>13#include <__algorithm/comp.h>
14#include <__algorithm/iterator_operations.h>
14#include <__config>15#include <__config>
16#include <__functional/identity.h>
17#include <__iterator/advance.h>
18#include <__iterator/concepts.h>
15#include <__iterator/iterator_traits.h>19#include <__iterator/iterator_traits.h>
16#include <utility>20#include <__type_traits/is_callable.h>
21#include <__utility/pair.h>
22#include <type_traits>
1723
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)24#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19#pragma GCC system_header25# pragma GCC system_header
20#endif26#endif
2127
22_LIBCPP_BEGIN_NAMESPACE_STD28_LIBCPP_BEGIN_NAMESPACE_STD
2329
24template <class _BinaryPredicate, class _ForwardIterator1, class _ForwardIterator2>30template <class _AlgPolicy,
25pair<_ForwardIterator1, _ForwardIterator1>31 class _Iter1, class _Sent1,
26 _LIBCPP_CONSTEXPR_AFTER_CXX11 __search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,32 class _Iter2, class _Sent2,
27 _ForwardIterator2 __first2, _ForwardIterator2 __last2,33 class _Pred,
28 _BinaryPredicate __pred, forward_iterator_tag, forward_iterator_tag) {34 class _Proj1,
35 class _Proj2>
36_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
37pair<_Iter1, _Iter1> __search_forward_impl(_Iter1 __first1, _Sent1 __last1,
38 _Iter2 __first2, _Sent2 __last2,
39 _Pred& __pred,
40 _Proj1& __proj1,
41 _Proj2& __proj2) {
29 if (__first2 == __last2)42 if (__first2 == __last2)
30 return _VSTD::make_pair(__first1, __first1); // Everything matches an empty sequence43 return std::make_pair(__first1, __first1); // Everything matches an empty sequence
31 while (true) {44 while (true) {
32 // Find first element in sequence 1 that matchs *__first2, with a mininum of loop checks45 // Find first element in sequence 1 that matchs *__first2, with a mininum of loop checks
33 while (true) {46 while (true) {
34 if (__first1 == __last1) // return __last1 if no element matches *__first247 if (__first1 == __last1) { // return __last1 if no element matches *__first2
35 return _VSTD::make_pair(__last1, __last1);48 _IterOps<_AlgPolicy>::__advance_to(__first1, __last1);
36 if (__pred(*__first1, *__first2))49 return std::make_pair(__first1, __first1);
50 }
51 if (std::__invoke(__pred, std::__invoke(__proj1, *__first1), std::__invoke(__proj2, *__first2)))
37 break;52 break;
38 ++__first1;53 ++__first1;
39 }54 }
40 // *__first1 matches *__first2, now match elements after here55 // *__first1 matches *__first2, now match elements after here
41 _ForwardIterator1 __m1 = __first1;56 _Iter1 __m1 = __first1;
42 _ForwardIterator2 __m2 = __first2;57 _Iter2 __m2 = __first2;
43 while (true) {58 while (true) {
44 if (++__m2 == __last2) // If pattern exhausted, __first1 is the answer (works for 1 element pattern)59 if (++__m2 == __last2) // If pattern exhausted, __first1 is the answer (works for 1 element pattern)
45 return _VSTD::make_pair(__first1, __m1);60 return std::make_pair(__first1, ++__m1);
46 if (++__m1 == __last1) // Otherwise if source exhaused, pattern not found61 if (++__m1 == __last1) { // Otherwise if source exhaused, pattern not found
47 return _VSTD::make_pair(__last1, __last1);62 return std::make_pair(__m1, __m1);
48 if (!__pred(*__m1, *__m2)) // if there is a mismatch, restart with a new __first163 }
64
65 // if there is a mismatch, restart with a new __first1
66 if (!std::__invoke(__pred, std::__invoke(__proj1, *__m1), std::__invoke(__proj2, *__m2)))
49 {67 {
50 ++__first1;68 ++__first1;
51 break;69 break;
...@@ -54,38 +72,42 @@ pair<_ForwardIterator1, _ForwardIterator1>...@@ -54,38 +72,42 @@ pair<_ForwardIterator1, _ForwardIterator1>
54 }72 }
55}73}
5674
57template <class _BinaryPredicate, class _RandomAccessIterator1, class _RandomAccessIterator2>75template <class _AlgPolicy,
58_LIBCPP_CONSTEXPR_AFTER_CXX11 pair<_RandomAccessIterator1, _RandomAccessIterator1>76 class _Iter1, class _Sent1,
59__search(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, _RandomAccessIterator2 __first2,77 class _Iter2, class _Sent2,
60 _RandomAccessIterator2 __last2, _BinaryPredicate __pred, random_access_iterator_tag,78 class _Pred,
61 random_access_iterator_tag) {79 class _Proj1,
62 typedef typename iterator_traits<_RandomAccessIterator1>::difference_type _D1;80 class _Proj2,
63 typedef typename iterator_traits<_RandomAccessIterator2>::difference_type _D2;81 class _DiffT1,
64 // Take advantage of knowing source and pattern lengths. Stop short when source is smaller than pattern82 class _DiffT2>
65 const _D2 __len2 = __last2 - __first2;83_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
66 if (__len2 == 0)84pair<_Iter1, _Iter1> __search_random_access_impl(_Iter1 __first1, _Sent1 __last1,
67 return _VSTD::make_pair(__first1, __first1);85 _Iter2 __first2, _Sent2 __last2,
68 const _D1 __len1 = __last1 - __first1;86 _Pred& __pred,
69 if (__len1 < __len2)87 _Proj1& __proj1,
70 return _VSTD::make_pair(__last1, __last1);88 _Proj2& __proj2,
71 const _RandomAccessIterator1 __s = __last1 - _D1(__len2 - 1); // Start of pattern match can't go beyond here89 _DiffT1 __size1,
90 _DiffT2 __size2) {
91 const _Iter1 __s = __first1 + __size1 - _DiffT1(__size2 - 1); // Start of pattern match can't go beyond here
7292
73 while (true) {93 while (true) {
74 while (true) {94 while (true) {
75 if (__first1 == __s)95 if (__first1 == __s) {
76 return _VSTD::make_pair(__last1, __last1);96 _IterOps<_AlgPolicy>::__advance_to(__first1, __last1);
77 if (__pred(*__first1, *__first2))97 return std::make_pair(__first1, __first1);
98 }
99 if (std::__invoke(__pred, std::__invoke(__proj1, *__first1), std::__invoke(__proj2, *__first2)))
78 break;100 break;
79 ++__first1;101 ++__first1;
80 }102 }
81103
82 _RandomAccessIterator1 __m1 = __first1;104 _Iter1 __m1 = __first1;
83 _RandomAccessIterator2 __m2 = __first2;105 _Iter2 __m2 = __first2;
84 while (true) {106 while (true) {
85 if (++__m2 == __last2)107 if (++__m2 == __last2)
86 return _VSTD::make_pair(__first1, __first1 + _D1(__len2));108 return std::make_pair(__first1, __first1 + _DiffT1(__size2));
87 ++__m1; // no need to check range on __m1 because __s guarantees we have enough source109 ++__m1; // no need to check range on __m1 because __s guarantees we have enough source
88 if (!__pred(*__m1, *__m2)) {110 if (!std::__invoke(__pred, std::__invoke(__proj1, *__m1), std::__invoke(__proj2, *__m2))) {
89 ++__first1;111 ++__first1;
90 break;112 break;
91 }113 }
...@@ -93,22 +115,78 @@ __search(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, _Rando...@@ -93,22 +115,78 @@ __search(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, _Rando
93 }115 }
94}116}
95117
118template <class _Iter1, class _Sent1,
119 class _Iter2, class _Sent2,
120 class _Pred,
121 class _Proj1,
122 class _Proj2>
123_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
124pair<_Iter1, _Iter1> __search_impl(_Iter1 __first1, _Sent1 __last1,
125 _Iter2 __first2, _Sent2 __last2,
126 _Pred& __pred,
127 _Proj1& __proj1,
128 _Proj2& __proj2,
129 __enable_if_t<__is_cpp17_random_access_iterator<_Iter1>::value
130 && __is_cpp17_random_access_iterator<_Iter2>::value>* = nullptr) {
131
132 auto __size2 = __last2 - __first2;
133 if (__size2 == 0)
134 return std::make_pair(__first1, __first1);
135
136 auto __size1 = __last1 - __first1;
137 if (__size1 < __size2) {
138 return std::make_pair(__last1, __last1);
139 }
140
141 return std::__search_random_access_impl<_ClassicAlgPolicy>(__first1, __last1,
142 __first2, __last2,
143 __pred,
144 __proj1,
145 __proj2,
146 __size1,
147 __size2);
148}
149
150template <class _Iter1, class _Sent1,
151 class _Iter2, class _Sent2,
152 class _Pred,
153 class _Proj1,
154 class _Proj2>
155_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
156pair<_Iter1, _Iter1> __search_impl(_Iter1 __first1, _Sent1 __last1,
157 _Iter2 __first2, _Sent2 __last2,
158 _Pred& __pred,
159 _Proj1& __proj1,
160 _Proj2& __proj2,
161 __enable_if_t<__is_cpp17_forward_iterator<_Iter1>::value
162 && __is_cpp17_forward_iterator<_Iter2>::value
163 && !(__is_cpp17_random_access_iterator<_Iter1>::value
164 && __is_cpp17_random_access_iterator<_Iter2>::value)>* = nullptr) {
165 return std::__search_forward_impl<_ClassicAlgPolicy>(__first1, __last1,
166 __first2, __last2,
167 __pred,
168 __proj1,
169 __proj2);
170}
171
96template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>172template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
97_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator1173_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
98search(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2,174_ForwardIterator1 search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
99 _BinaryPredicate __pred) {175 _ForwardIterator2 __first2, _ForwardIterator2 __last2,
100 return _VSTD::__search<_BinaryPredicate&>(176 _BinaryPredicate __pred) {
101 __first1, __last1, __first2, __last2, __pred,177 static_assert(__is_callable<_BinaryPredicate, decltype(*__first1), decltype(*__first2)>::value,
102 typename iterator_traits<_ForwardIterator1>::iterator_category(),178 "BinaryPredicate has to be callable");
103 typename iterator_traits<_ForwardIterator2>::iterator_category()).first;179 auto __proj = __identity();
180 return std::__search_impl(__first1, __last1, __first2, __last2, __pred, __proj, __proj).first;
104}181}
105182
106template <class _ForwardIterator1, class _ForwardIterator2>183template <class _ForwardIterator1, class _ForwardIterator2>
107_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator1184_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
108search(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) {185_ForwardIterator1 search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
109 typedef typename iterator_traits<_ForwardIterator1>::value_type __v1;186 _ForwardIterator2 __first2, _ForwardIterator2 __last2) {
110 typedef typename iterator_traits<_ForwardIterator2>::value_type __v2;187 using __v1 = typename iterator_traits<_ForwardIterator1>::value_type;
111 return _VSTD::search(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>());188 using __v2 = typename iterator_traits<_ForwardIterator2>::value_type;
189 return std::search(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>());
112}190}
113191
114#if _LIBCPP_STD_VER > 14192#if _LIBCPP_STD_VER > 14
lib/libcxx/include/__algorithm/search_n.h+115-46
...@@ -11,40 +11,56 @@...@@ -11,40 +11,56 @@
11#define _LIBCPP___ALGORITHM_SEARCH_N_H11#define _LIBCPP___ALGORITHM_SEARCH_N_H
1212
13#include <__algorithm/comp.h>13#include <__algorithm/comp.h>
14#include <__algorithm/iterator_operations.h>
14#include <__config>15#include <__config>
16#include <__functional/identity.h>
17#include <__iterator/advance.h>
18#include <__iterator/concepts.h>
19#include <__iterator/distance.h>
15#include <__iterator/iterator_traits.h>20#include <__iterator/iterator_traits.h>
21#include <__ranges/concepts.h>
22#include <__utility/pair.h>
16#include <type_traits> // __convert_to_integral23#include <type_traits> // __convert_to_integral
1724
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)25#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19#pragma GCC system_header26# pragma GCC system_header
20#endif27#endif
2128
22_LIBCPP_BEGIN_NAMESPACE_STD29_LIBCPP_BEGIN_NAMESPACE_STD
2330
24template <class _BinaryPredicate, class _ForwardIterator, class _Size, class _Tp>31template <class _AlgPolicy, class _Pred, class _Iter, class _Sent, class _SizeT, class _Type, class _Proj>
25_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator __search_n(_ForwardIterator __first, _ForwardIterator __last,32_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
26 _Size __count, const _Tp& __value_, _BinaryPredicate __pred,33pair<_Iter, _Iter> __search_n_forward_impl(_Iter __first, _Sent __last,
27 forward_iterator_tag) {34 _SizeT __count,
35 const _Type& __value,
36 _Pred& __pred,
37 _Proj& __proj) {
28 if (__count <= 0)38 if (__count <= 0)
29 return __first;39 return std::make_pair(__first, __first);
30 while (true) {40 while (true) {
31 // Find first element in sequence that matchs __value_, with a mininum of loop checks41 // Find first element in sequence that matchs __value, with a mininum of loop checks
32 while (true) {42 while (true) {
33 if (__first == __last) // return __last if no element matches __value_43 if (__first == __last) { // return __last if no element matches __value
34 return __last;44 _IterOps<_AlgPolicy>::__advance_to(__first, __last);
35 if (__pred(*__first, __value_))45 return std::make_pair(__first, __first);
46 }
47 if (std::__invoke(__pred, std::__invoke(__proj, *__first), __value))
36 break;48 break;
37 ++__first;49 ++__first;
38 }50 }
39 // *__first matches __value_, now match elements after here51 // *__first matches __value, now match elements after here
40 _ForwardIterator __m = __first;52 _Iter __m = __first;
41 _Size __c(0);53 _SizeT __c(0);
42 while (true) {54 while (true) {
43 if (++__c == __count) // If pattern exhausted, __first is the answer (works for 1 element pattern)55 if (++__c == __count) // If pattern exhausted, __first is the answer (works for 1 element pattern)
44 return __first;56 return std::make_pair(__first, ++__m);
45 if (++__m == __last) // Otherwise if source exhaused, pattern not found57 if (++__m == __last) { // Otherwise if source exhaused, pattern not found
46 return __last;58 _IterOps<_AlgPolicy>::__advance_to(__first, __last);
47 if (!__pred(*__m, __value_)) // if there is a mismatch, restart with a new __first59 return std::make_pair(__first, __first);
60 }
61
62 // if there is a mismatch, restart with a new __first
63 if (!std::__invoke(__pred, std::__invoke(__proj, *__m), __value))
48 {64 {
49 __first = __m;65 __first = __m;
50 ++__first;66 ++__first;
...@@ -54,35 +70,44 @@ _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator __search_n(_ForwardIterator __fir...@@ -54,35 +70,44 @@ _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator __search_n(_ForwardIterator __fir
54 }70 }
55}71}
5672
57template <class _BinaryPredicate, class _RandomAccessIterator, class _Size, class _Tp>73template <class _AlgPolicy, class _Pred, class _Iter, class _Sent, class _SizeT, class _Type, class _Proj, class _DiffT>
58_LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator __search_n(_RandomAccessIterator __first,74_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
59 _RandomAccessIterator __last, _Size __count,75std::pair<_Iter, _Iter> __search_n_random_access_impl(_Iter __first, _Sent __last,
60 const _Tp& __value_, _BinaryPredicate __pred,76 _SizeT __count,
61 random_access_iterator_tag) {77 const _Type& __value,
62 typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;78 _Pred& __pred,
63 if (__count <= 0)79 _Proj& __proj,
64 return __first;80 _DiffT __size1) {
65 _Size __len = static_cast<_Size>(__last - __first);81 using difference_type = typename iterator_traits<_Iter>::difference_type;
66 if (__len < __count)82 if (__count == 0)
67 return __last;83 return std::make_pair(__first, __first);
68 const _RandomAccessIterator __s = __last - difference_type(__count - 1); // Start of pattern match can't go beyond here84 if (__size1 < static_cast<_DiffT>(__count)) {
85 _IterOps<_AlgPolicy>::__advance_to(__first, __last);
86 return std::make_pair(__first, __first);
87 }
88
89 const auto __s = __first + __size1 - difference_type(__count - 1); // Start of pattern match can't go beyond here
69 while (true) {90 while (true) {
70 // Find first element in sequence that matchs __value_, with a mininum of loop checks91 // Find first element in sequence that matchs __value, with a mininum of loop checks
71 while (true) {92 while (true) {
72 if (__first >= __s) // return __last if no element matches __value_93 if (__first >= __s) { // return __last if no element matches __value
73 return __last;94 _IterOps<_AlgPolicy>::__advance_to(__first, __last);
74 if (__pred(*__first, __value_))95 return std::make_pair(__first, __first);
96 }
97 if (std::__invoke(__pred, std::__invoke(__proj, *__first), __value))
75 break;98 break;
76 ++__first;99 ++__first;
77 }100 }
78 // *__first matches __value_, now match elements after here101 // *__first matches __value_, now match elements after here
79 _RandomAccessIterator __m = __first;102 auto __m = __first;
80 _Size __c(0);103 _SizeT __c(0);
81 while (true) {104 while (true) {
82 if (++__c == __count) // If pattern exhausted, __first is the answer (works for 1 element pattern)105 if (++__c == __count) // If pattern exhausted, __first is the answer (works for 1 element pattern)
83 return __first;106 return std::make_pair(__first, __first + _DiffT(__count));
84 ++__m; // no need to check range on __m because __s guarantees we have enough source107 ++__m; // no need to check range on __m because __s guarantees we have enough source
85 if (!__pred(*__m, __value_)) // if there is a mismatch, restart with a new __first108
109 // if there is a mismatch, restart with a new __first
110 if (!std::__invoke(__pred, std::__invoke(__proj, *__m), __value))
86 {111 {
87 __first = __m;112 __first = __m;
88 ++__first;113 ++__first;
...@@ -92,19 +117,63 @@ _LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator __search_n(_RandomAccessIter...@@ -92,19 +117,63 @@ _LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator __search_n(_RandomAccessIter
92 }117 }
93}118}
94119
120template <class _Iter, class _Sent,
121 class _DiffT,
122 class _Type,
123 class _Pred,
124 class _Proj>
125_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
126pair<_Iter, _Iter> __search_n_impl(_Iter __first, _Sent __last,
127 _DiffT __count,
128 const _Type& __value,
129 _Pred& __pred,
130 _Proj& __proj,
131 __enable_if_t<__is_cpp17_random_access_iterator<_Iter>::value>* = nullptr) {
132 return std::__search_n_random_access_impl<_ClassicAlgPolicy>(__first, __last,
133 __count,
134 __value,
135 __pred,
136 __proj,
137 __last - __first);
138}
139
140template <class _Iter1, class _Sent1,
141 class _DiffT,
142 class _Type,
143 class _Pred,
144 class _Proj>
145_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
146pair<_Iter1, _Iter1> __search_n_impl(_Iter1 __first, _Sent1 __last,
147 _DiffT __count,
148 const _Type& __value,
149 _Pred& __pred,
150 _Proj& __proj,
151 __enable_if_t<__is_cpp17_forward_iterator<_Iter1>::value
152 && !__is_cpp17_random_access_iterator<_Iter1>::value>* = nullptr) {
153 return std::__search_n_forward_impl<_ClassicAlgPolicy>(__first, __last,
154 __count,
155 __value,
156 __pred,
157 __proj);
158}
159
95template <class _ForwardIterator, class _Size, class _Tp, class _BinaryPredicate>160template <class _ForwardIterator, class _Size, class _Tp, class _BinaryPredicate>
96_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator search_n(161_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
97 _ForwardIterator __first, _ForwardIterator __last, _Size __count, const _Tp& __value_, _BinaryPredicate __pred) {162_ForwardIterator search_n(_ForwardIterator __first, _ForwardIterator __last,
98 return _VSTD::__search_n<_BinaryPredicate&>(163 _Size __count,
99 __first, __last, _VSTD::__convert_to_integral(__count), __value_, __pred,164 const _Tp& __value,
100 typename iterator_traits<_ForwardIterator>::iterator_category());165 _BinaryPredicate __pred) {
166 static_assert(__is_callable<_BinaryPredicate, decltype(*__first), const _Tp&>::value,
167 "BinaryPredicate has to be callable");
168 auto __proj = __identity();
169 return std::__search_n_impl(__first, __last, std::__convert_to_integral(__count), __value, __pred, __proj).first;
101}170}
102171
103template <class _ForwardIterator, class _Size, class _Tp>172template <class _ForwardIterator, class _Size, class _Tp>
104_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator173_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
105search_n(_ForwardIterator __first, _ForwardIterator __last, _Size __count, const _Tp& __value_) {174_ForwardIterator search_n(_ForwardIterator __first, _ForwardIterator __last, _Size __count, const _Tp& __value) {
106 typedef typename iterator_traits<_ForwardIterator>::value_type __v;175 typedef typename iterator_traits<_ForwardIterator>::value_type __v;
107 return _VSTD::search_n(__first, __last, _VSTD::__convert_to_integral(__count), __value_, __equal_to<__v, _Tp>());176 return std::search_n(__first, __last, std::__convert_to_integral(__count), __value, __equal_to<__v, _Tp>());
108}177}
109178
110_LIBCPP_END_NAMESPACE_STD179_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/set_difference.h+45-38
...@@ -13,58 +13,65 @@...@@ -13,58 +13,65 @@
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 <__functional/identity.h>
17#include <__functional/invoke.h>
16#include <__iterator/iterator_traits.h>18#include <__iterator/iterator_traits.h>
19#include <__utility/move.h>
20#include <__utility/pair.h>
21#include <type_traits>
1722
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19#pragma GCC system_header24# pragma GCC system_header
20#endif25#endif
2126
22_LIBCPP_BEGIN_NAMESPACE_STD27_LIBCPP_BEGIN_NAMESPACE_STD
2328
24template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>29template < class _Comp, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter>
25_LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator30_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<__uncvref_t<_InIter1>, __uncvref_t<_OutIter> >
26__set_difference(_InputIterator1 __first1, _InputIterator1 __last1,31__set_difference(
27 _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)32 _InIter1&& __first1, _Sent1&& __last1, _InIter2&& __first2, _Sent2&& __last2, _OutIter&& __result, _Comp&& __comp) {
28{33 while (__first1 != __last1 && __first2 != __last2) {
29 while (__first1 != __last1)34 if (__comp(*__first1, *__first2)) {
30 {35 *__result = *__first1;
31 if (__first2 == __last2)36 ++__first1;
32 return _VSTD::copy(__first1, __last1, __result);37 ++__result;
33 if (__comp(*__first1, *__first2))38 } else if (__comp(*__first2, *__first1)) {
34 {39 ++__first2;
35 *__result = *__first1;40 } else {
36 ++__result;41 ++__first1;
37 ++__first1;42 ++__first2;
38 }
39 else
40 {
41 if (!__comp(*__first2, *__first1))
42 ++__first1;
43 ++__first2;
44 }
45 }43 }
46 return __result;44 }
45 return std::__copy(std::move(__first1), std::move(__last1), std::move(__result));
47}46}
4847
49template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>48template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
50inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1749inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator set_difference(
51_OutputIterator50 _InputIterator1 __first1,
52set_difference(_InputIterator1 __first1, _InputIterator1 __last1,51 _InputIterator1 __last1,
53 _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)52 _InputIterator2 __first2,
54{53 _InputIterator2 __last2,
55 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;54 _OutputIterator __result,
56 return _VSTD::__set_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp);55 _Compare __comp) {
56 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
57 return std::__set_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp).second;
57}58}
5859
59template <class _InputIterator1, class _InputIterator2, class _OutputIterator>60template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
60inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1761inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator set_difference(
61_OutputIterator62 _InputIterator1 __first1,
62set_difference(_InputIterator1 __first1, _InputIterator1 __last1,63 _InputIterator1 __last1,
63 _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result)64 _InputIterator2 __first2,
64{65 _InputIterator2 __last2,
65 return _VSTD::set_difference(__first1, __last1, __first2, __last2, __result,66 _OutputIterator __result) {
66 __less<typename iterator_traits<_InputIterator1>::value_type,67 return std::__set_difference(
67 typename iterator_traits<_InputIterator2>::value_type>());68 __first1,
69 __last1,
70 __first2,
71 __last2,
72 __result,
73 __less<typename iterator_traits<_InputIterator1>::value_type,
74 typename iterator_traits<_InputIterator2>::value_type>()).second;
68}75}
6976
70_LIBCPP_END_NAMESPACE_STD77_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/set_intersection.h+67-36
...@@ -11,57 +11,88 @@...@@ -11,57 +11,88 @@
1111
12#include <__algorithm/comp.h>12#include <__algorithm/comp.h>
13#include <__algorithm/comp_ref_type.h>13#include <__algorithm/comp_ref_type.h>
14#include <__algorithm/iterator_operations.h>
14#include <__config>15#include <__config>
15#include <__iterator/iterator_traits.h>16#include <__iterator/iterator_traits.h>
17#include <__iterator/next.h>
18#include <__utility/move.h>
1619
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header21# pragma GCC system_header
19#endif22#endif
2023
21_LIBCPP_BEGIN_NAMESPACE_STD24_LIBCPP_BEGIN_NAMESPACE_STD
2225
23template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>26template <class _InIter1, class _InIter2, class _OutIter>
24_LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator27struct __set_intersection_result {
25__set_intersection(_InputIterator1 __first1, _InputIterator1 __last1,28 _InIter1 __in1_;
26 _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)29 _InIter2 __in2_;
27{30 _OutIter __out_;
28 while (__first1 != __last1 && __first2 != __last2)31
29 {32 // need a constructor as C++03 aggregate init is hard
30 if (__comp(*__first1, *__first2))33 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
31 ++__first1;34 __set_intersection_result(_InIter1&& __in_iter1, _InIter2&& __in_iter2, _OutIter&& __out_iter)
32 else35 : __in1_(std::move(__in_iter1)), __in2_(std::move(__in_iter2)), __out_(std::move(__out_iter)) {}
33 {36};
34 if (!__comp(*__first2, *__first1))37
35 {38template <class _AlgPolicy, class _Compare, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter>
36 *__result = *__first1;39_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 __set_intersection_result<_InIter1, _InIter2, _OutIter>
37 ++__result;40__set_intersection(
38 ++__first1;41 _InIter1 __first1, _Sent1 __last1, _InIter2 __first2, _Sent2 __last2, _OutIter __result, _Compare&& __comp) {
39 }42 while (__first1 != __last1 && __first2 != __last2) {
40 ++__first2;43 if (__comp(*__first1, *__first2))
41 }44 ++__first1;
45 else {
46 if (!__comp(*__first2, *__first1)) {
47 *__result = *__first1;
48 ++__result;
49 ++__first1;
50 }
51 ++__first2;
42 }52 }
43 return __result;53 }
54
55 return __set_intersection_result<_InIter1, _InIter2, _OutIter>(
56 _IterOps<_AlgPolicy>::next(std::move(__first1), std::move(__last1)),
57 _IterOps<_AlgPolicy>::next(std::move(__first2), std::move(__last2)),
58 std::move(__result));
44}59}
4560
46template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>61template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
47inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1762inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator set_intersection(
48_OutputIterator63 _InputIterator1 __first1,
49set_intersection(_InputIterator1 __first1, _InputIterator1 __last1,64 _InputIterator1 __last1,
50 _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)65 _InputIterator2 __first2,
51{66 _InputIterator2 __last2,
52 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;67 _OutputIterator __result,
53 return _VSTD::__set_intersection<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp);68 _Compare __comp) {
69 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
70 return std::__set_intersection<_ClassicAlgPolicy, _Comp_ref>(
71 std::move(__first1),
72 std::move(__last1),
73 std::move(__first2),
74 std::move(__last2),
75 std::move(__result),
76 __comp)
77 .__out_;
54}78}
5579
56template <class _InputIterator1, class _InputIterator2, class _OutputIterator>80template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
57inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1781inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator set_intersection(
58_OutputIterator82 _InputIterator1 __first1,
59set_intersection(_InputIterator1 __first1, _InputIterator1 __last1,83 _InputIterator1 __last1,
60 _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result)84 _InputIterator2 __first2,
61{85 _InputIterator2 __last2,
62 return _VSTD::set_intersection(__first1, __last1, __first2, __last2, __result,86 _OutputIterator __result) {
63 __less<typename iterator_traits<_InputIterator1>::value_type,87 return std::__set_intersection<_ClassicAlgPolicy>(
64 typename iterator_traits<_InputIterator2>::value_type>());88 std::move(__first1),
89 std::move(__last1),
90 std::move(__first2),
91 std::move(__last2),
92 std::move(__result),
93 __less<typename iterator_traits<_InputIterator1>::value_type,
94 typename iterator_traits<_InputIterator2>::value_type>())
95 .__out_;
65}96}
6697
67_LIBCPP_END_NAMESPACE_STD98_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/set_symmetric_difference.h+70-43
...@@ -14,62 +14,89 @@...@@ -14,62 +14,89 @@
14#include <__algorithm/copy.h>14#include <__algorithm/copy.h>
15#include <__config>15#include <__config>
16#include <__iterator/iterator_traits.h>16#include <__iterator/iterator_traits.h>
17#include <__utility/move.h>
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
20#endif21#endif
2122
22_LIBCPP_BEGIN_NAMESPACE_STD23_LIBCPP_BEGIN_NAMESPACE_STD
2324
24template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>25template <class _InIter1, class _InIter2, class _OutIter>
25_LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator26struct __set_symmetric_difference_result {
26__set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1,27 _InIter1 __in1_;
27 _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)28 _InIter2 __in2_;
28{29 _OutIter __out_;
29 while (__first1 != __last1)30
30 {31 // need a constructor as C++03 aggregate init is hard
31 if (__first2 == __last2)32 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
32 return _VSTD::copy(__first1, __last1, __result);33 __set_symmetric_difference_result(_InIter1&& __in_iter1, _InIter2&& __in_iter2, _OutIter&& __out_iter)
33 if (__comp(*__first1, *__first2))34 : __in1_(std::move(__in_iter1)), __in2_(std::move(__in_iter2)), __out_(std::move(__out_iter)) {}
34 {35};
35 *__result = *__first1;36
36 ++__result;37template <class _Compare, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter>
37 ++__first1;38_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 __set_symmetric_difference_result<_InIter1, _InIter2, _OutIter>
38 }39__set_symmetric_difference(
39 else40 _InIter1 __first1, _Sent1 __last1, _InIter2 __first2, _Sent2 __last2, _OutIter __result, _Compare&& __comp) {
40 {41 while (__first1 != __last1) {
41 if (__comp(*__first2, *__first1))42 if (__first2 == __last2) {
42 {43 auto __ret1 = std::__copy_impl(std::move(__first1), std::move(__last1), std::move(__result));
43 *__result = *__first2;44 return __set_symmetric_difference_result<_InIter1, _InIter2, _OutIter>(
44 ++__result;45 std::move(__ret1.first), std::move(__first2), std::move((__ret1.second)));
45 }46 }
46 else47 if (__comp(*__first1, *__first2)) {
47 ++__first1;48 *__result = *__first1;
48 ++__first2;49 ++__result;
49 }50 ++__first1;
51 } else {
52 if (__comp(*__first2, *__first1)) {
53 *__result = *__first2;
54 ++__result;
55 } else {
56 ++__first1;
57 }
58 ++__first2;
50 }59 }
51 return _VSTD::copy(__first2, __last2, __result);60 }
61 auto __ret2 = std::__copy_impl(std::move(__first2), std::move(__last2), std::move(__result));
62 return __set_symmetric_difference_result<_InIter1, _InIter2, _OutIter>(
63 std::move(__first1), std::move(__ret2.first), std::move((__ret2.second)));
52}64}
5365
54template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>66template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
55inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1767_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator set_symmetric_difference(
56_OutputIterator68 _InputIterator1 __first1,
57set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1,69 _InputIterator1 __last1,
58 _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)70 _InputIterator2 __first2,
59{71 _InputIterator2 __last2,
60 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;72 _OutputIterator __result,
61 return _VSTD::__set_symmetric_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp);73 _Compare __comp) {
74 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
75 return std::__set_symmetric_difference<_Comp_ref>(
76 std::move(__first1),
77 std::move(__last1),
78 std::move(__first2),
79 std::move(__last2),
80 std::move(__result),
81 __comp)
82 .__out_;
62}83}
6384
64template <class _InputIterator1, class _InputIterator2, class _OutputIterator>85template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
65inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1786_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator set_symmetric_difference(
66_OutputIterator87 _InputIterator1 __first1,
67set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1,88 _InputIterator1 __last1,
68 _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result)89 _InputIterator2 __first2,
69{90 _InputIterator2 __last2,
70 return _VSTD::set_symmetric_difference(__first1, __last1, __first2, __last2, __result,91 _OutputIterator __result) {
71 __less<typename iterator_traits<_InputIterator1>::value_type,92 return std::set_symmetric_difference(
72 typename iterator_traits<_InputIterator2>::value_type>());93 std::move(__first1),
94 std::move(__last1),
95 std::move(__first2),
96 std::move(__last2),
97 std::move(__result),
98 __less<typename iterator_traits<_InputIterator1>::value_type,
99 typename iterator_traits<_InputIterator2>::value_type>());
73}100}
74101
75_LIBCPP_END_NAMESPACE_STD102_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/set_union.h+66-38
...@@ -14,57 +14,85 @@...@@ -14,57 +14,85 @@
14#include <__algorithm/copy.h>14#include <__algorithm/copy.h>
15#include <__config>15#include <__config>
16#include <__iterator/iterator_traits.h>16#include <__iterator/iterator_traits.h>
17#include <__utility/move.h>
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
20#endif21#endif
2122
22_LIBCPP_BEGIN_NAMESPACE_STD23_LIBCPP_BEGIN_NAMESPACE_STD
2324
24template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>25template <class _InIter1, class _InIter2, class _OutIter>
25_LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator26struct __set_union_result {
26__set_union(_InputIterator1 __first1, _InputIterator1 __last1,27 _InIter1 __in1_;
27 _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)28 _InIter2 __in2_;
28{29 _OutIter __out_;
29 for (; __first1 != __last1; ++__result)30
30 {31 // need a constructor as C++03 aggregate init is hard
31 if (__first2 == __last2)32 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
32 return _VSTD::copy(__first1, __last1, __result);33 __set_union_result(_InIter1&& __in_iter1, _InIter2&& __in_iter2, _OutIter&& __out_iter)
33 if (__comp(*__first2, *__first1))34 : __in1_(std::move(__in_iter1)), __in2_(std::move(__in_iter2)), __out_(std::move(__out_iter)) {}
34 {35};
35 *__result = *__first2;36
36 ++__first2;37template <class _Compare, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter>
37 }38_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 __set_union_result<_InIter1, _InIter2, _OutIter> __set_union(
38 else39 _InIter1 __first1, _Sent1 __last1, _InIter2 __first2, _Sent2 __last2, _OutIter __result, _Compare&& __comp) {
39 {40 for (; __first1 != __last1; ++__result) {
40 if (!__comp(*__first1, *__first2))41 if (__first2 == __last2) {
41 ++__first2;42 auto __ret1 = std::__copy_impl(std::move(__first1), std::move(__last1), std::move(__result));
42 *__result = *__first1;43 return __set_union_result<_InIter1, _InIter2, _OutIter>(
43 ++__first1;44 std::move(__ret1.first), std::move(__first2), std::move((__ret1.second)));
44 }45 }
46 if (__comp(*__first2, *__first1)) {
47 *__result = *__first2;
48 ++__first2;
49 } else {
50 if (!__comp(*__first1, *__first2)) {
51 ++__first2;
52 }
53 *__result = *__first1;
54 ++__first1;
45 }55 }
46 return _VSTD::copy(__first2, __last2, __result);56 }
57 auto __ret2 = std::__copy_impl(std::move(__first2), std::move(__last2), std::move(__result));
58 return __set_union_result<_InIter1, _InIter2, _OutIter>(
59 std::move(__first1), std::move(__ret2.first), std::move((__ret2.second)));
47}60}
4861
49template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>62template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
50inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1763_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator set_union(
51_OutputIterator64 _InputIterator1 __first1,
52set_union(_InputIterator1 __first1, _InputIterator1 __last1,65 _InputIterator1 __last1,
53 _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)66 _InputIterator2 __first2,
54{67 _InputIterator2 __last2,
55 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;68 _OutputIterator __result,
56 return _VSTD::__set_union<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp);69 _Compare __comp) {
70 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
71 return std::__set_union<_Comp_ref>(
72 std::move(__first1),
73 std::move(__last1),
74 std::move(__first2),
75 std::move(__last2),
76 std::move(__result),
77 __comp)
78 .__out_;
57}79}
5880
59template <class _InputIterator1, class _InputIterator2, class _OutputIterator>81template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
60inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1782_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator set_union(
61_OutputIterator83 _InputIterator1 __first1,
62set_union(_InputIterator1 __first1, _InputIterator1 __last1,84 _InputIterator1 __last1,
63 _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result)85 _InputIterator2 __first2,
64{86 _InputIterator2 __last2,
65 return _VSTD::set_union(__first1, __last1, __first2, __last2, __result,87 _OutputIterator __result) {
66 __less<typename iterator_traits<_InputIterator1>::value_type,88 return std::set_union(
67 typename iterator_traits<_InputIterator2>::value_type>());89 std::move(__first1),
90 std::move(__last1),
91 std::move(__first2),
92 std::move(__last2),
93 std::move(__result),
94 __less<typename iterator_traits<_InputIterator1>::value_type,
95 typename iterator_traits<_InputIterator2>::value_type>());
68}96}
6997
70_LIBCPP_END_NAMESPACE_STD98_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/shift_left.h+1-1
...@@ -15,7 +15,7 @@...@@ -15,7 +15,7 @@
15#include <type_traits>15#include <type_traits>
1616
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header18# pragma GCC system_header
19#endif19#endif
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/shift_right.h+1-1
...@@ -18,7 +18,7 @@...@@ -18,7 +18,7 @@
18#include <type_traits>18#include <type_traits>
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
22#endif22#endif
2323
24_LIBCPP_BEGIN_NAMESPACE_STD24_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/shuffle.h+21-7
...@@ -9,15 +9,18 @@...@@ -9,15 +9,18 @@
9#ifndef _LIBCPP___ALGORITHM_SHUFFLE_H9#ifndef _LIBCPP___ALGORITHM_SHUFFLE_H
10#define _LIBCPP___ALGORITHM_SHUFFLE_H10#define _LIBCPP___ALGORITHM_SHUFFLE_H
1111
12#include <__algorithm/iterator_operations.h>
12#include <__config>13#include <__config>
14#include <__debug>
13#include <__iterator/iterator_traits.h>15#include <__iterator/iterator_traits.h>
14#include <__random/uniform_int_distribution.h>16#include <__random/uniform_int_distribution.h>
15#include <__utility/swap.h>17#include <__utility/forward.h>
18#include <__utility/move.h>
16#include <cstddef>19#include <cstddef>
17#include <cstdint>20#include <cstdint>
1821
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20#pragma GCC system_header23# pragma GCC system_header
21#endif24#endif
2225
23_LIBCPP_PUSH_MACROS26_LIBCPP_PUSH_MACROS
...@@ -133,13 +136,15 @@ random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,...@@ -133,13 +136,15 @@ random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
133}136}
134#endif137#endif
135138
136template<class _RandomAccessIterator, class _UniformRandomNumberGenerator>139template <class _AlgPolicy, class _RandomAccessIterator, class _Sentinel, class _UniformRandomNumberGenerator>
137 void shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,140_RandomAccessIterator __shuffle(
138 _UniformRandomNumberGenerator&& __g)141 _RandomAccessIterator __first, _Sentinel __last_sentinel, _UniformRandomNumberGenerator&& __g) {
139{
140 typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;142 typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
141 typedef uniform_int_distribution<ptrdiff_t> _Dp;143 typedef uniform_int_distribution<ptrdiff_t> _Dp;
142 typedef typename _Dp::param_type _Pp;144 typedef typename _Dp::param_type _Pp;
145
146 auto __original_last = _IterOps<_AlgPolicy>::next(__first, __last_sentinel);
147 auto __last = __original_last;
143 difference_type __d = __last - __first;148 difference_type __d = __last - __first;
144 if (__d > 1)149 if (__d > 1)
145 {150 {
...@@ -148,9 +153,18 @@ template<class _RandomAccessIterator, class _UniformRandomNumberGenerator>...@@ -148,9 +153,18 @@ template<class _RandomAccessIterator, class _UniformRandomNumberGenerator>
148 {153 {
149 difference_type __i = __uid(__g, _Pp(0, __d));154 difference_type __i = __uid(__g, _Pp(0, __d));
150 if (__i != difference_type(0))155 if (__i != difference_type(0))
151 swap(*__first, *(__first + __i));156 _IterOps<_AlgPolicy>::iter_swap(__first, __first + __i);
152 }157 }
153 }158 }
159
160 return __original_last;
161}
162
163template <class _RandomAccessIterator, class _UniformRandomNumberGenerator>
164void shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
165 _UniformRandomNumberGenerator&& __g) {
166 (void)std::__shuffle<_ClassicAlgPolicy>(
167 std::move(__first), std::move(__last), std::forward<_UniformRandomNumberGenerator>(__g));
154}168}
155169
156_LIBCPP_END_NAMESPACE_STD170_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/sift_down.h+41-5
...@@ -9,22 +9,26 @@...@@ -9,22 +9,26 @@
9#ifndef _LIBCPP___ALGORITHM_SIFT_DOWN_H9#ifndef _LIBCPP___ALGORITHM_SIFT_DOWN_H
10#define _LIBCPP___ALGORITHM_SIFT_DOWN_H10#define _LIBCPP___ALGORITHM_SIFT_DOWN_H
1111
12#include <__algorithm/iterator_operations.h>
13#include <__assert>
12#include <__config>14#include <__config>
13#include <__iterator/iterator_traits.h>15#include <__iterator/iterator_traits.h>
14#include <__utility/move.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
18#endif20#endif
1921
20_LIBCPP_BEGIN_NAMESPACE_STD22_LIBCPP_BEGIN_NAMESPACE_STD
2123
22template <class _Compare, class _RandomAccessIterator>24template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
23_LIBCPP_CONSTEXPR_AFTER_CXX11 void25_LIBCPP_CONSTEXPR_AFTER_CXX11 void
24__sift_down(_RandomAccessIterator __first, _Compare __comp,26__sift_down(_RandomAccessIterator __first, _Compare&& __comp,
25 typename iterator_traits<_RandomAccessIterator>::difference_type __len,27 typename iterator_traits<_RandomAccessIterator>::difference_type __len,
26 _RandomAccessIterator __start)28 _RandomAccessIterator __start)
27{29{
30 using _Ops = _IterOps<_AlgPolicy>;
31
28 typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;32 typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
29 typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;33 typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
30 // left-child of __start is at 2 * __start + 134 // left-child of __start is at 2 * __start + 1
...@@ -48,11 +52,11 @@ __sift_down(_RandomAccessIterator __first, _Compare __comp,...@@ -48,11 +52,11 @@ __sift_down(_RandomAccessIterator __first, _Compare __comp,
48 // we are, __start is larger than its largest child52 // we are, __start is larger than its largest child
49 return;53 return;
5054
51 value_type __top(_VSTD::move(*__start));55 value_type __top(_Ops::__iter_move(__start));
52 do56 do
53 {57 {
54 // we are not in heap-order, swap the parent with its largest child58 // we are not in heap-order, swap the parent with its largest child
55 *__start = _VSTD::move(*__child_i);59 *__start = _Ops::__iter_move(__child_i);
56 __start = __child_i;60 __start = __child_i;
5761
58 if ((__len - 2) / 2 < __child)62 if ((__len - 2) / 2 < __child)
...@@ -73,6 +77,38 @@ __sift_down(_RandomAccessIterator __first, _Compare __comp,...@@ -73,6 +77,38 @@ __sift_down(_RandomAccessIterator __first, _Compare __comp,
73 *__start = _VSTD::move(__top);77 *__start = _VSTD::move(__top);
74}78}
7579
80template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
81_LIBCPP_CONSTEXPR_AFTER_CXX11 _RandomAccessIterator
82__floyd_sift_down(_RandomAccessIterator __first, _Compare&& __comp,
83 typename iterator_traits<_RandomAccessIterator>::difference_type __len)
84{
85 using difference_type = typename iterator_traits<_RandomAccessIterator>::difference_type;
86 _LIBCPP_ASSERT(__len >= 2, "shouldn't be called unless __len >= 2");
87
88 _RandomAccessIterator __hole = __first;
89 _RandomAccessIterator __child_i = __first;
90 difference_type __child = 0;
91
92 while (true) {
93 __child_i += difference_type(__child + 1);
94 __child = 2 * __child + 1;
95
96 if ((__child + 1) < __len && __comp(*__child_i, *(__child_i + difference_type(1)))) {
97 // right-child exists and is greater than left-child
98 ++__child_i;
99 ++__child;
100 }
101
102 // swap __hole with its largest child
103 *__hole = _IterOps<_AlgPolicy>::__iter_move(__child_i);
104 __hole = __child_i;
105
106 // if __hole is now a leaf, we're done
107 if (__child > (__len - 2) / 2)
108 return __hole;
109 }
110}
111
76_LIBCPP_END_NAMESPACE_STD112_LIBCPP_END_NAMESPACE_STD
77113
78#endif // _LIBCPP___ALGORITHM_SIFT_DOWN_H114#endif // _LIBCPP___ALGORITHM_SIFT_DOWN_H
lib/libcxx/include/__algorithm/sort.h+598-449
...@@ -11,462 +11,602 @@...@@ -11,462 +11,602 @@
1111
12#include <__algorithm/comp.h>12#include <__algorithm/comp.h>
13#include <__algorithm/comp_ref_type.h>13#include <__algorithm/comp_ref_type.h>
14#include <__algorithm/iterator_operations.h>
14#include <__algorithm/min_element.h>15#include <__algorithm/min_element.h>
15#include <__algorithm/partial_sort.h>16#include <__algorithm/partial_sort.h>
16#include <__algorithm/unwrap_iter.h>17#include <__algorithm/unwrap_iter.h>
18#include <__bits>
17#include <__config>19#include <__config>
18#include <__utility/swap.h>20#include <__debug>
21#include <__debug_utils/randomize_range.h>
22#include <__functional/operations.h>
23#include <__functional/ranges_operations.h>
24#include <__iterator/iterator_traits.h>
25#include <climits>
19#include <memory>26#include <memory>
2027
21#if defined(_LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY)
22# include <__algorithm/shuffle.h>
23#endif
24
25#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)28#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
26#pragma GCC system_header29# pragma GCC system_header
27#endif30#endif
2831
29_LIBCPP_BEGIN_NAMESPACE_STD32_LIBCPP_BEGIN_NAMESPACE_STD
3033
34// Wraps an algorithm policy tag and a comparator in a single struct, used to pass the policy tag around without
35// changing the number of template arguments (to keep the ABI stable). This is only used for the "range" policy tag.
36//
37// To create an object of this type, use `_WrapAlgPolicy<T, C>::type` -- see the specialization below for the rationale.
38template <class _PolicyT, class _CompT, class = void>
39struct _WrapAlgPolicy {
40 using type = _WrapAlgPolicy;
41
42 using _AlgPolicy = _PolicyT;
43 using _Comp = _CompT;
44 _Comp& __comp;
45
46 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
47 _WrapAlgPolicy(_Comp& __c) : __comp(__c) {}
48};
49
50// Specialization for the "classic" policy tag that avoids creating a struct and simply defines an alias for the
51// comparator. When unwrapping, a pristine comparator is always considered to have the "classic" tag attached. Passing
52// the pristine comparator where possible allows using template instantiations from the dylib.
53template <class _PolicyT, class _CompT>
54struct _WrapAlgPolicy<_PolicyT, _CompT, __enable_if_t<std::is_same<_PolicyT, _ClassicAlgPolicy>::value> > {
55 using type = _CompT;
56};
57
58// Unwraps a pristine functor (e.g. `std::less`) as if it were wrapped using `_WrapAlgPolicy`. The policy tag is always
59// set to "classic".
60template <class _CompT>
61struct _UnwrapAlgPolicy {
62 using _AlgPolicy = _ClassicAlgPolicy;
63 using _Comp = _CompT;
64
65 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 static
66 _Comp __get_comp(_Comp __comp) { return __comp; }
67};
68
69// Unwraps a `_WrapAlgPolicy` struct.
70template <class... _Ts>
71struct _UnwrapAlgPolicy<_WrapAlgPolicy<_Ts...> > {
72 using _Wrapped = _WrapAlgPolicy<_Ts...>;
73 using _AlgPolicy = typename _Wrapped::_AlgPolicy;
74 using _Comp = typename _Wrapped::_Comp;
75
76 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 static
77 _Comp __get_comp(_Wrapped& __w) { return __w.__comp; }
78};
79
31// stable, 2-3 compares, 0-2 swaps80// stable, 2-3 compares, 0-2 swaps
3281
33template <class _Compare, class _ForwardIterator>82template <class _AlgPolicy, class _Compare, class _ForwardIterator>
34_LIBCPP_CONSTEXPR_AFTER_CXX11 unsigned83_LIBCPP_CONSTEXPR_AFTER_CXX11 unsigned __sort3(_ForwardIterator __x, _ForwardIterator __y, _ForwardIterator __z,
35__sort3(_ForwardIterator __x, _ForwardIterator __y, _ForwardIterator __z, _Compare __c)84 _Compare __c) {
36{85 using _Ops = _IterOps<_AlgPolicy>;
37 unsigned __r = 0;86
38 if (!__c(*__y, *__x)) // if x <= y87 unsigned __r = 0;
39 {88 if (!__c(*__y, *__x)) // if x <= y
40 if (!__c(*__z, *__y)) // if y <= z89 {
41 return __r; // x <= y && y <= z90 if (!__c(*__z, *__y)) // if y <= z
42 // x <= y && y > z91 return __r; // x <= y && y <= z
43 swap(*__y, *__z); // x <= z && y < z92 // x <= y && y > z
44 __r = 1;93 _Ops::iter_swap(__y, __z); // x <= z && y < z
45 if (__c(*__y, *__x)) // if x > y94 __r = 1;
46 {95 if (__c(*__y, *__x)) // if x > y
47 swap(*__x, *__y); // x < y && y <= z
48 __r = 2;
49 }
50 return __r; // x <= y && y < z
51 }
52 if (__c(*__z, *__y)) // x > y, if y > z
53 {
54 swap(*__x, *__z); // x < y && y < z
55 __r = 1;
56 return __r;
57 }
58 swap(*__x, *__y); // x > y && y <= z
59 __r = 1; // x < y && x <= z
60 if (__c(*__z, *__y)) // if y > z
61 {96 {
62 swap(*__y, *__z); // x <= y && y < z97 _Ops::iter_swap(__x, __y); // x < y && y <= z
63 __r = 2;98 __r = 2;
64 }99 }
100 return __r; // x <= y && y < z
101 }
102 if (__c(*__z, *__y)) // x > y, if y > z
103 {
104 _Ops::iter_swap(__x, __z); // x < y && y < z
105 __r = 1;
65 return __r;106 return __r;
66} // x <= y && y <= z107 }
108 _Ops::iter_swap(__x, __y); // x > y && y <= z
109 __r = 1; // x < y && x <= z
110 if (__c(*__z, *__y)) // if y > z
111 {
112 _Ops::iter_swap(__y, __z); // x <= y && y < z
113 __r = 2;
114 }
115 return __r;
116} // x <= y && y <= z
67117
68// stable, 3-6 compares, 0-5 swaps118// stable, 3-6 compares, 0-5 swaps
69119
70template <class _Compare, class _ForwardIterator>120template <class _AlgPolicy, class _Compare, class _ForwardIterator>
71unsigned121unsigned __sort4(_ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3, _ForwardIterator __x4,
72__sort4(_ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3,122 _Compare __c) {
73 _ForwardIterator __x4, _Compare __c)123 using _Ops = _IterOps<_AlgPolicy>;
74{124
75 unsigned __r = _VSTD::__sort3<_Compare>(__x1, __x2, __x3, __c);125 unsigned __r = std::__sort3<_AlgPolicy, _Compare>(__x1, __x2, __x3, __c);
76 if (__c(*__x4, *__x3))126 if (__c(*__x4, *__x3)) {
77 {127 _Ops::iter_swap(__x3, __x4);
78 swap(*__x3, *__x4);128 ++__r;
129 if (__c(*__x3, *__x2)) {
130 _Ops::iter_swap(__x2, __x3);
131 ++__r;
132 if (__c(*__x2, *__x1)) {
133 _Ops::iter_swap(__x1, __x2);
79 ++__r;134 ++__r;
80 if (__c(*__x3, *__x2))135 }
81 {
82 swap(*__x2, *__x3);
83 ++__r;
84 if (__c(*__x2, *__x1))
85 {
86 swap(*__x1, *__x2);
87 ++__r;
88 }
89 }
90 }136 }
91 return __r;137 }
138 return __r;
92}139}
93140
94// stable, 4-10 compares, 0-9 swaps141// stable, 4-10 compares, 0-9 swaps
95142
96template <class _Compare, class _ForwardIterator>143template <class _WrappedComp, class _ForwardIterator>
97_LIBCPP_HIDDEN144_LIBCPP_HIDDEN unsigned __sort5(_ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3,
98unsigned145 _ForwardIterator __x4, _ForwardIterator __x5, _WrappedComp __wrapped_comp) {
99__sort5(_ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3,146 using _Unwrap = _UnwrapAlgPolicy<_WrappedComp>;
100 _ForwardIterator __x4, _ForwardIterator __x5, _Compare __c)147 using _AlgPolicy = typename _Unwrap::_AlgPolicy;
101{148 using _Ops = _IterOps<_AlgPolicy>;
102 unsigned __r = _VSTD::__sort4<_Compare>(__x1, __x2, __x3, __x4, __c);149
103 if (__c(*__x5, *__x4))150 using _Compare = typename _Unwrap::_Comp;
104 {151 _Compare __c = _Unwrap::__get_comp(__wrapped_comp);
105 swap(*__x4, *__x5);152
153 unsigned __r = std::__sort4<_AlgPolicy, _Compare>(__x1, __x2, __x3, __x4, __c);
154 if (__c(*__x5, *__x4)) {
155 _Ops::iter_swap(__x4, __x5);
156 ++__r;
157 if (__c(*__x4, *__x3)) {
158 _Ops::iter_swap(__x3, __x4);
159 ++__r;
160 if (__c(*__x3, *__x2)) {
161 _Ops::iter_swap(__x2, __x3);
106 ++__r;162 ++__r;
107 if (__c(*__x4, *__x3))163 if (__c(*__x2, *__x1)) {
108 {164 _Ops::iter_swap(__x1, __x2);
109 swap(*__x3, *__x4);165 ++__r;
110 ++__r;
111 if (__c(*__x3, *__x2))
112 {
113 swap(*__x2, *__x3);
114 ++__r;
115 if (__c(*__x2, *__x1))
116 {
117 swap(*__x1, *__x2);
118 ++__r;
119 }
120 }
121 }166 }
167 }
122 }168 }
123 return __r;169 }
170 return __r;
171}
172
173template <class _AlgPolicy, class _Compare, class _ForwardIterator>
174_LIBCPP_HIDDEN unsigned __sort5_wrap_policy(
175 _ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3, _ForwardIterator __x4, _ForwardIterator __x5,
176 _Compare __c) {
177 using _WrappedComp = typename _WrapAlgPolicy<_AlgPolicy, _Compare>::type;
178 _WrappedComp __wrapped_comp(__c);
179 return std::__sort5<_WrappedComp>(
180 std::move(__x1), std::move(__x2), std::move(__x3), std::move(__x4), std::move(__x5), __wrapped_comp);
181}
182
183// The comparator being simple is a prerequisite for using the branchless optimization.
184template <class _Tp>
185struct __is_simple_comparator : false_type {};
186template <class _Tp>
187struct __is_simple_comparator<__less<_Tp>&> : true_type {};
188template <class _Tp>
189struct __is_simple_comparator<less<_Tp>&> : true_type {};
190template <class _Tp>
191struct __is_simple_comparator<greater<_Tp>&> : true_type {};
192#if _LIBCPP_STD_VER > 17
193template <>
194struct __is_simple_comparator<ranges::less&> : true_type {};
195template <>
196struct __is_simple_comparator<ranges::greater&> : true_type {};
197#endif
198
199template <class _Compare, class _Iter, class _Tp = typename iterator_traits<_Iter>::value_type>
200using __use_branchless_sort =
201 integral_constant<bool, __is_cpp17_contiguous_iterator<_Iter>::value && sizeof(_Tp) <= sizeof(void*) &&
202 is_arithmetic<_Tp>::value && __is_simple_comparator<_Compare>::value>;
203
204// Ensures that __c(*__x, *__y) is true by swapping *__x and *__y if necessary.
205template <class _Compare, class _RandomAccessIterator>
206inline _LIBCPP_HIDE_FROM_ABI void __cond_swap(_RandomAccessIterator __x, _RandomAccessIterator __y, _Compare __c) {
207 // Note: this function behaves correctly even with proxy iterators (because it relies on `value_type`).
208 using value_type = typename iterator_traits<_RandomAccessIterator>::value_type;
209 bool __r = __c(*__x, *__y);
210 value_type __tmp = __r ? *__x : *__y;
211 *__y = __r ? *__y : *__x;
212 *__x = __tmp;
213}
214
215// Ensures that *__x, *__y and *__z are ordered according to the comparator __c,
216// under the assumption that *__y and *__z are already ordered.
217template <class _Compare, class _RandomAccessIterator>
218inline _LIBCPP_HIDE_FROM_ABI void __partially_sorted_swap(_RandomAccessIterator __x, _RandomAccessIterator __y,
219 _RandomAccessIterator __z, _Compare __c) {
220 // Note: this function behaves correctly even with proxy iterators (because it relies on `value_type`).
221 using value_type = typename iterator_traits<_RandomAccessIterator>::value_type;
222 bool __r = __c(*__z, *__x);
223 value_type __tmp = __r ? *__z : *__x;
224 *__z = __r ? *__x : *__z;
225 __r = __c(__tmp, *__y);
226 *__x = __r ? *__x : *__y;
227 *__y = __r ? *__y : __tmp;
228}
229
230template <class, class _Compare, class _RandomAccessIterator>
231inline _LIBCPP_HIDE_FROM_ABI __enable_if_t<__use_branchless_sort<_Compare, _RandomAccessIterator>::value, void>
232__sort3_maybe_branchless(_RandomAccessIterator __x1, _RandomAccessIterator __x2, _RandomAccessIterator __x3,
233 _Compare __c) {
234 _VSTD::__cond_swap<_Compare>(__x2, __x3, __c);
235 _VSTD::__partially_sorted_swap<_Compare>(__x1, __x2, __x3, __c);
236}
237
238template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
239inline _LIBCPP_HIDE_FROM_ABI __enable_if_t<!__use_branchless_sort<_Compare, _RandomAccessIterator>::value, void>
240__sort3_maybe_branchless(_RandomAccessIterator __x1, _RandomAccessIterator __x2, _RandomAccessIterator __x3,
241 _Compare __c) {
242 std::__sort3<_AlgPolicy, _Compare>(__x1, __x2, __x3, __c);
243}
244
245template <class, class _Compare, class _RandomAccessIterator>
246inline _LIBCPP_HIDE_FROM_ABI __enable_if_t<__use_branchless_sort<_Compare, _RandomAccessIterator>::value, void>
247__sort4_maybe_branchless(_RandomAccessIterator __x1, _RandomAccessIterator __x2, _RandomAccessIterator __x3,
248 _RandomAccessIterator __x4, _Compare __c) {
249 _VSTD::__cond_swap<_Compare>(__x1, __x3, __c);
250 _VSTD::__cond_swap<_Compare>(__x2, __x4, __c);
251 _VSTD::__cond_swap<_Compare>(__x1, __x2, __c);
252 _VSTD::__cond_swap<_Compare>(__x3, __x4, __c);
253 _VSTD::__cond_swap<_Compare>(__x2, __x3, __c);
254}
255
256template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
257inline _LIBCPP_HIDE_FROM_ABI __enable_if_t<!__use_branchless_sort<_Compare, _RandomAccessIterator>::value, void>
258__sort4_maybe_branchless(_RandomAccessIterator __x1, _RandomAccessIterator __x2, _RandomAccessIterator __x3,
259 _RandomAccessIterator __x4, _Compare __c) {
260 std::__sort4<_AlgPolicy, _Compare>(__x1, __x2, __x3, __x4, __c);
261}
262
263template <class, class _Compare, class _RandomAccessIterator>
264inline _LIBCPP_HIDE_FROM_ABI __enable_if_t<__use_branchless_sort<_Compare, _RandomAccessIterator>::value, void>
265__sort5_maybe_branchless(_RandomAccessIterator __x1, _RandomAccessIterator __x2, _RandomAccessIterator __x3,
266 _RandomAccessIterator __x4, _RandomAccessIterator __x5, _Compare __c) {
267 _VSTD::__cond_swap<_Compare>(__x1, __x2, __c);
268 _VSTD::__cond_swap<_Compare>(__x4, __x5, __c);
269 _VSTD::__partially_sorted_swap<_Compare>(__x3, __x4, __x5, __c);
270 _VSTD::__cond_swap<_Compare>(__x2, __x5, __c);
271 _VSTD::__partially_sorted_swap<_Compare>(__x1, __x3, __x4, __c);
272 _VSTD::__partially_sorted_swap<_Compare>(__x2, __x3, __x4, __c);
273}
274
275template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
276inline _LIBCPP_HIDE_FROM_ABI __enable_if_t<!__use_branchless_sort<_Compare, _RandomAccessIterator>::value, void>
277__sort5_maybe_branchless(_RandomAccessIterator __x1, _RandomAccessIterator __x2, _RandomAccessIterator __x3,
278 _RandomAccessIterator __x4, _RandomAccessIterator __x5, _Compare __c) {
279 std::__sort5_wrap_policy<_AlgPolicy, _Compare>(__x1, __x2, __x3, __x4, __x5, __c);
124}280}
125281
126// Assumes size > 0282// Assumes size > 0
127template <class _Compare, class _BidirectionalIterator>283template <class _AlgPolicy, class _Compare, class _BidirectionalIterator>
128_LIBCPP_CONSTEXPR_AFTER_CXX11 void284_LIBCPP_CONSTEXPR_AFTER_CXX11 void __selection_sort(_BidirectionalIterator __first, _BidirectionalIterator __last,
129__selection_sort(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)285 _Compare __comp) {
130{286 _BidirectionalIterator __lm1 = __last;
131 _BidirectionalIterator __lm1 = __last;287 for (--__lm1; __first != __lm1; ++__first) {
132 for (--__lm1; __first != __lm1; ++__first)288 _BidirectionalIterator __i = std::__min_element<_Compare>(__first, __last, __comp);
133 {289 if (__i != __first)
134 _BidirectionalIterator __i = _VSTD::min_element(__first, __last, __comp);290 _IterOps<_AlgPolicy>::iter_swap(__first, __i);
135 if (__i != __first)291 }
136 swap(*__first, *__i);292}
293
294template <class _AlgPolicy, class _Compare, class _BidirectionalIterator>
295void __insertion_sort(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp) {
296 using _Ops = _IterOps<_AlgPolicy>;
297
298 typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
299 if (__first != __last) {
300 _BidirectionalIterator __i = __first;
301 for (++__i; __i != __last; ++__i) {
302 _BidirectionalIterator __j = __i;
303 value_type __t(_Ops::__iter_move(__j));
304 for (_BidirectionalIterator __k = __i; __k != __first && __comp(__t, *--__k); --__j)
305 *__j = _Ops::__iter_move(__k);
306 *__j = _VSTD::move(__t);
137 }307 }
308 }
138}309}
139310
140template <class _Compare, class _BidirectionalIterator>311template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
141void312void __insertion_sort_3(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {
142__insertion_sort(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)313 using _Ops = _IterOps<_AlgPolicy>;
143{314
144 typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;315 typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
145 if (__first != __last)316 typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
146 {317 _RandomAccessIterator __j = __first + difference_type(2);
147 _BidirectionalIterator __i = __first;318 std::__sort3_maybe_branchless<_AlgPolicy, _Compare>(__first, __first + difference_type(1), __j, __comp);
148 for (++__i; __i != __last; ++__i)319 for (_RandomAccessIterator __i = __j + difference_type(1); __i != __last; ++__i) {
149 {320 if (__comp(*__i, *__j)) {
150 _BidirectionalIterator __j = __i;321 value_type __t(_Ops::__iter_move(__i));
151 value_type __t(_VSTD::move(*__j));322 _RandomAccessIterator __k = __j;
152 for (_BidirectionalIterator __k = __i; __k != __first && __comp(__t, *--__k); --__j)323 __j = __i;
153 *__j = _VSTD::move(*__k);324 do {
154 *__j = _VSTD::move(__t);325 *__j = _Ops::__iter_move(__k);
155 }326 __j = __k;
327 } while (__j != __first && __comp(__t, *--__k));
328 *__j = _VSTD::move(__t);
156 }329 }
330 __j = __i;
331 }
157}332}
158333
159template <class _Compare, class _RandomAccessIterator>334template <class _WrappedComp, class _RandomAccessIterator>
160void335bool __insertion_sort_incomplete(
161__insertion_sort_3(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)336 _RandomAccessIterator __first, _RandomAccessIterator __last, _WrappedComp __wrapped_comp) {
162{337 using _Unwrap = _UnwrapAlgPolicy<_WrappedComp>;
163 typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;338 using _AlgPolicy = typename _Unwrap::_AlgPolicy;
164 typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;339 using _Ops = _IterOps<_AlgPolicy>;
165 _RandomAccessIterator __j = __first+difference_type(2);340
166 _VSTD::__sort3<_Compare>(__first, __first+difference_type(1), __j, __comp);341 using _Compare = typename _Unwrap::_Comp;
167 for (_RandomAccessIterator __i = __j+difference_type(1); __i != __last; ++__i)342 _Compare __comp = _Unwrap::__get_comp(__wrapped_comp);
168 {343
169 if (__comp(*__i, *__j))344 typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
170 {345 switch (__last - __first) {
171 value_type __t(_VSTD::move(*__i));346 case 0:
172 _RandomAccessIterator __k = __j;347 case 1:
173 __j = __i;348 return true;
174 do349 case 2:
175 {350 if (__comp(*--__last, *__first))
176 *__j = _VSTD::move(*__k);351 _IterOps<_AlgPolicy>::iter_swap(__first, __last);
177 __j = __k;352 return true;
178 } while (__j != __first && __comp(__t, *--__k));353 case 3:
179 *__j = _VSTD::move(__t);354 std::__sort3_maybe_branchless<_AlgPolicy, _Compare>(__first, __first + difference_type(1), --__last, __comp);
180 }355 return true;
181 __j = __i;356 case 4:
357 std::__sort4_maybe_branchless<_AlgPolicy, _Compare>(
358 __first, __first + difference_type(1), __first + difference_type(2), --__last, __comp);
359 return true;
360 case 5:
361 std::__sort5_maybe_branchless<_AlgPolicy, _Compare>(
362 __first, __first + difference_type(1), __first + difference_type(2), __first + difference_type(3),
363 --__last, __comp);
364 return true;
365 }
366 typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
367 _RandomAccessIterator __j = __first + difference_type(2);
368 std::__sort3_maybe_branchless<_AlgPolicy, _Compare>(__first, __first + difference_type(1), __j, __comp);
369 const unsigned __limit = 8;
370 unsigned __count = 0;
371 for (_RandomAccessIterator __i = __j + difference_type(1); __i != __last; ++__i) {
372 if (__comp(*__i, *__j)) {
373 value_type __t(_Ops::__iter_move(__i));
374 _RandomAccessIterator __k = __j;
375 __j = __i;
376 do {
377 *__j = _Ops::__iter_move(__k);
378 __j = __k;
379 } while (__j != __first && __comp(__t, *--__k));
380 *__j = _VSTD::move(__t);
381 if (++__count == __limit)
382 return ++__i == __last;
182 }383 }
384 __j = __i;
385 }
386 return true;
183}387}
184388
185template <class _Compare, class _RandomAccessIterator>389template <class _AlgPolicy, class _Compare, class _BidirectionalIterator>
186bool390void __insertion_sort_move(_BidirectionalIterator __first1, _BidirectionalIterator __last1,
187__insertion_sort_incomplete(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)391 typename iterator_traits<_BidirectionalIterator>::value_type* __first2, _Compare __comp) {
188{392 using _Ops = _IterOps<_AlgPolicy>;
189 typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;393
190 switch (__last - __first)394 typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
191 {395 if (__first1 != __last1) {
396 __destruct_n __d(0);
397 unique_ptr<value_type, __destruct_n&> __h(__first2, __d);
398 value_type* __last2 = __first2;
399 ::new ((void*)__last2) value_type(_Ops::__iter_move(__first1));
400 __d.template __incr<value_type>();
401 for (++__last2; ++__first1 != __last1; ++__last2) {
402 value_type* __j2 = __last2;
403 value_type* __i2 = __j2;
404 if (__comp(*__first1, *--__i2)) {
405 ::new ((void*)__j2) value_type(std::move(*__i2));
406 __d.template __incr<value_type>();
407 for (--__j2; __i2 != __first2 && __comp(*__first1, *--__i2); --__j2)
408 *__j2 = std::move(*__i2);
409 *__j2 = _Ops::__iter_move(__first1);
410 } else {
411 ::new ((void*)__j2) value_type(_Ops::__iter_move(__first1));
412 __d.template __incr<value_type>();
413 }
414 }
415 __h.release();
416 }
417}
418
419template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
420void __introsort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp,
421 typename iterator_traits<_RandomAccessIterator>::difference_type __depth) {
422 using _Ops = _IterOps<_AlgPolicy>;
423
424 typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
425 typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
426 const difference_type __limit =
427 is_trivially_copy_constructible<value_type>::value && is_trivially_copy_assignable<value_type>::value ? 30 : 6;
428 while (true) {
429 __restart:
430 difference_type __len = __last - __first;
431 switch (__len) {
192 case 0:432 case 0:
193 case 1:433 case 1:
194 return true;434 return;
195 case 2:435 case 2:
196 if (__comp(*--__last, *__first))436 if (__comp(*--__last, *__first))
197 swap(*__first, *__last);437 _IterOps<_AlgPolicy>::iter_swap(__first, __last);
198 return true;438 return;
199 case 3:439 case 3:
200 _VSTD::__sort3<_Compare>(__first, __first+difference_type(1), --__last, __comp);440 std::__sort3_maybe_branchless<_AlgPolicy, _Compare>(__first, __first + difference_type(1), --__last, __comp);
201 return true;441 return;
202 case 4:442 case 4:
203 _VSTD::__sort4<_Compare>(__first, __first+difference_type(1), __first+difference_type(2), --__last, __comp);443 std::__sort4_maybe_branchless<_AlgPolicy, _Compare>(
204 return true;444 __first, __first + difference_type(1), __first + difference_type(2), --__last, __comp);
445 return;
205 case 5:446 case 5:
206 _VSTD::__sort5<_Compare>(__first, __first+difference_type(1), __first+difference_type(2), __first+difference_type(3), --__last, __comp);447 std::__sort5_maybe_branchless<_AlgPolicy, _Compare>(
207 return true;448 __first, __first + difference_type(1), __first + difference_type(2), __first + difference_type(3),
449 --__last, __comp);
450 return;
208 }451 }
209 typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;452 if (__len <= __limit) {
210 _RandomAccessIterator __j = __first+difference_type(2);453 std::__insertion_sort_3<_AlgPolicy, _Compare>(__first, __last, __comp);
211 _VSTD::__sort3<_Compare>(__first, __first+difference_type(1), __j, __comp);454 return;
212 const unsigned __limit = 8;
213 unsigned __count = 0;
214 for (_RandomAccessIterator __i = __j+difference_type(1); __i != __last; ++__i)
215 {
216 if (__comp(*__i, *__j))
217 {
218 value_type __t(_VSTD::move(*__i));
219 _RandomAccessIterator __k = __j;
220 __j = __i;
221 do
222 {
223 *__j = _VSTD::move(*__k);
224 __j = __k;
225 } while (__j != __first && __comp(__t, *--__k));
226 *__j = _VSTD::move(__t);
227 if (++__count == __limit)
228 return ++__i == __last;
229 }
230 __j = __i;
231 }455 }
232 return true;456 // __len > 5
233}457 if (__depth == 0) {
234458 // Fallback to heap sort as Introsort suggests.
235template <class _Compare, class _BidirectionalIterator>459 std::__partial_sort<_AlgPolicy, _Compare>(__first, __last, __last, __comp);
236void460 return;
237__insertion_sort_move(_BidirectionalIterator __first1, _BidirectionalIterator __last1,461 }
238 typename iterator_traits<_BidirectionalIterator>::value_type* __first2, _Compare __comp)462 --__depth;
239{463 _RandomAccessIterator __m = __first;
240 typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;464 _RandomAccessIterator __lm1 = __last;
241 if (__first1 != __last1)465 --__lm1;
466 unsigned __n_swaps;
242 {467 {
243 __destruct_n __d(0);468 difference_type __delta;
244 unique_ptr<value_type, __destruct_n&> __h(__first2, __d);469 if (__len >= 1000) {
245 value_type* __last2 = __first2;470 __delta = __len / 2;
246 ::new ((void*)__last2) value_type(_VSTD::move(*__first1));471 __m += __delta;
247 __d.template __incr<value_type>();472 __delta /= 2;
248 for (++__last2; ++__first1 != __last1; ++__last2)473 __n_swaps = std::__sort5_wrap_policy<_AlgPolicy, _Compare>(
249 {474 __first, __first + __delta, __m, __m + __delta, __lm1, __comp);
250 value_type* __j2 = __last2;475 } else {
251 value_type* __i2 = __j2;476 __delta = __len / 2;
252 if (__comp(*__first1, *--__i2))477 __m += __delta;
253 {478 __n_swaps = std::__sort3<_AlgPolicy, _Compare>(__first, __m, __lm1, __comp);
254 ::new ((void*)__j2) value_type(_VSTD::move(*__i2));479 }
255 __d.template __incr<value_type>();
256 for (--__j2; __i2 != __first2 && __comp(*__first1, *--__i2); --__j2)
257 *__j2 = _VSTD::move(*__i2);
258 *__j2 = _VSTD::move(*__first1);
259 }
260 else
261 {
262 ::new ((void*)__j2) value_type(_VSTD::move(*__first1));
263 __d.template __incr<value_type>();
264 }
265 }
266 __h.release();
267 }480 }
268}481 // *__m is median
269482 // partition [__first, __m) < *__m and *__m <= [__m, __last)
270template <class _Compare, class _RandomAccessIterator>483 // (this inhibits tossing elements equivalent to __m around unnecessarily)
271void484 _RandomAccessIterator __i = __first;
272__introsort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp,485 _RandomAccessIterator __j = __lm1;
273 typename iterator_traits<_RandomAccessIterator>::difference_type __depth)486 // j points beyond range to be tested, *__m is known to be <= *__lm1
274{487 // The search going up is known to be guarded but the search coming down isn't.
275 typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;488 // Prime the downward search with a guard.
276 typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;489 if (!__comp(*__i, *__m)) // if *__first == *__m
277 const difference_type __limit = is_trivially_copy_constructible<value_type>::value &&
278 is_trivially_copy_assignable<value_type>::value ? 30 : 6;
279 while (true)
280 {490 {
281 __restart:491 // *__first == *__m, *__first doesn't go in first part
282 difference_type __len = __last - __first;492 // manually guard downward moving __j against __i
283 switch (__len)493 while (true) {
284 {494 if (__i == --__j) {
285 case 0:495 // *__first == *__m, *__m <= all other elements
286 case 1:496 // Parition instead into [__first, __i) == *__first and *__first < [__i, __last)
287 return;497 ++__i; // __first + 1
288 case 2:498 __j = __last;
289 if (__comp(*--__last, *__first))499 if (!__comp(*__first, *--__j)) // we need a guard if *__first == *(__last-1)
290 swap(*__first, *__last);500 {
291 return;501 while (true) {
292 case 3:502 if (__i == __j)
293 _VSTD::__sort3<_Compare>(__first, __first+difference_type(1), --__last, __comp);503 return; // [__first, __last) all equivalent elements
294 return;504 if (__comp(*__first, *__i)) {
295 case 4:505 _Ops::iter_swap(__i, __j);
296 _VSTD::__sort4<_Compare>(__first, __first+difference_type(1), __first+difference_type(2), --__last, __comp);
297 return;
298 case 5:
299 _VSTD::__sort5<_Compare>(__first, __first+difference_type(1), __first+difference_type(2), __first+difference_type(3), --__last, __comp);
300 return;
301 }
302 if (__len <= __limit)
303 {
304 _VSTD::__insertion_sort_3<_Compare>(__first, __last, __comp);
305 return;
306 }
307 // __len > 5
308 if (__depth == 0)
309 {
310 // Fallback to heap sort as Introsort suggests.
311 _VSTD::__partial_sort<_Compare>(__first, __last, __last, __comp);
312 return;
313 }
314 --__depth;
315 _RandomAccessIterator __m = __first;
316 _RandomAccessIterator __lm1 = __last;
317 --__lm1;
318 unsigned __n_swaps;
319 {
320 difference_type __delta;
321 if (__len >= 1000)
322 {
323 __delta = __len/2;
324 __m += __delta;
325 __delta /= 2;
326 __n_swaps = _VSTD::__sort5<_Compare>(__first, __first + __delta, __m, __m+__delta, __lm1, __comp);
327 }
328 else
329 {
330 __delta = __len/2;
331 __m += __delta;
332 __n_swaps = _VSTD::__sort3<_Compare>(__first, __m, __lm1, __comp);
333 }
334 }
335 // *__m is median
336 // partition [__first, __m) < *__m and *__m <= [__m, __last)
337 // (this inhibits tossing elements equivalent to __m around unnecessarily)
338 _RandomAccessIterator __i = __first;
339 _RandomAccessIterator __j = __lm1;
340 // j points beyond range to be tested, *__m is known to be <= *__lm1
341 // The search going up is known to be guarded but the search coming down isn't.
342 // Prime the downward search with a guard.
343 if (!__comp(*__i, *__m)) // if *__first == *__m
344 {
345 // *__first == *__m, *__first doesn't go in first part
346 // manually guard downward moving __j against __i
347 while (true)
348 {
349 if (__i == --__j)
350 {
351 // *__first == *__m, *__m <= all other elements
352 // Parition instead into [__first, __i) == *__first and *__first < [__i, __last)
353 ++__i; // __first + 1
354 __j = __last;
355 if (!__comp(*__first, *--__j)) // we need a guard if *__first == *(__last-1)
356 {
357 while (true)
358 {
359 if (__i == __j)
360 return; // [__first, __last) all equivalent elements
361 if (__comp(*__first, *__i))
362 {
363 swap(*__i, *__j);
364 ++__n_swaps;
365 ++__i;
366 break;
367 }
368 ++__i;
369 }
370 }
371 // [__first, __i) == *__first and *__first < [__j, __last) and __j == __last - 1
372 if (__i == __j)
373 return;
374 while (true)
375 {
376 while (!__comp(*__first, *__i))
377 ++__i;
378 while (__comp(*__first, *--__j))
379 ;
380 if (__i >= __j)
381 break;
382 swap(*__i, *__j);
383 ++__n_swaps;
384 ++__i;
385 }
386 // [__first, __i) == *__first and *__first < [__i, __last)
387 // The first part is sorted, sort the second part
388 // _VSTD::__sort<_Compare>(__i, __last, __comp);
389 __first = __i;
390 goto __restart;
391 }
392 if (__comp(*__j, *__m))
393 {
394 swap(*__i, *__j);
395 ++__n_swaps;
396 break; // found guard for downward moving __j, now use unguarded partition
397 }
398 }
399 }
400 // It is known that *__i < *__m
401 ++__i;
402 // j points beyond range to be tested, *__m is known to be <= *__lm1
403 // if not yet partitioned...
404 if (__i < __j)
405 {
406 // known that *(__i - 1) < *__m
407 // known that __i <= __m
408 while (true)
409 {
410 // __m still guards upward moving __i
411 while (__comp(*__i, *__m))
412 ++__i;
413 // It is now known that a guard exists for downward moving __j
414 while (!__comp(*--__j, *__m))
415 ;
416 if (__i > __j)
417 break;
418 swap(*__i, *__j);
419 ++__n_swaps;506 ++__n_swaps;
420 // It is known that __m != __j
421 // If __m just moved, follow it
422 if (__m == __i)
423 __m = __j;
424 ++__i;507 ++__i;
508 break;
509 }
510 ++__i;
425 }511 }
426 }512 }
427 // [__first, __i) < *__m and *__m <= [__i, __last)513 // [__first, __i) == *__first and *__first < [__j, __last) and __j == __last - 1
428 if (__i != __m && __comp(*__m, *__i))514 if (__i == __j)
429 {515 return;
430 swap(*__i, *__m);516 while (true) {
517 while (!__comp(*__first, *__i))
518 ++__i;
519 while (__comp(*__first, *--__j))
520 ;
521 if (__i >= __j)
522 break;
523 _Ops::iter_swap(__i, __j);
431 ++__n_swaps;524 ++__n_swaps;
525 ++__i;
526 }
527 // [__first, __i) == *__first and *__first < [__i, __last)
528 // The first part is sorted, sort the second part
529 // _VSTD::__sort<_Compare>(__i, __last, __comp);
530 __first = __i;
531 goto __restart;
432 }532 }
433 // [__first, __i) < *__i and *__i <= [__i+1, __last)533 if (__comp(*__j, *__m)) {
434 // If we were given a perfect partition, see if insertion sort is quick...534 _Ops::iter_swap(__i, __j);
435 if (__n_swaps == 0)535 ++__n_swaps;
436 {536 break; // found guard for downward moving __j, now use unguarded partition
437 bool __fs = _VSTD::__insertion_sort_incomplete<_Compare>(__first, __i, __comp);
438 if (_VSTD::__insertion_sort_incomplete<_Compare>(__i+difference_type(1), __last, __comp))
439 {
440 if (__fs)
441 return;
442 __last = __i;
443 continue;
444 }
445 else
446 {
447 if (__fs)
448 {
449 __first = ++__i;
450 continue;
451 }
452 }
453 }537 }
454 // sort smaller range with recursive call and larger with tail recursion elimination538 }
455 if (__i - __first < __last - __i)539 }
456 {540 // It is known that *__i < *__m
457 _VSTD::__introsort<_Compare>(__first, __i, __comp, __depth);541 ++__i;
542 // j points beyond range to be tested, *__m is known to be <= *__lm1
543 // if not yet partitioned...
544 if (__i < __j) {
545 // known that *(__i - 1) < *__m
546 // known that __i <= __m
547 while (true) {
548 // __m still guards upward moving __i
549 while (__comp(*__i, *__m))
550 ++__i;
551 // It is now known that a guard exists for downward moving __j
552 while (!__comp(*--__j, *__m))
553 ;
554 if (__i > __j)
555 break;
556 _Ops::iter_swap(__i, __j);
557 ++__n_swaps;
558 // It is known that __m != __j
559 // If __m just moved, follow it
560 if (__m == __i)
561 __m = __j;
562 ++__i;
563 }
564 }
565 // [__first, __i) < *__m and *__m <= [__i, __last)
566 if (__i != __m && __comp(*__m, *__i)) {
567 _Ops::iter_swap(__i, __m);
568 ++__n_swaps;
569 }
570 // [__first, __i) < *__i and *__i <= [__i+1, __last)
571 // If we were given a perfect partition, see if insertion sort is quick...
572 if (__n_swaps == 0) {
573 using _WrappedComp = typename _WrapAlgPolicy<_AlgPolicy, _Compare>::type;
574 _WrappedComp __wrapped_comp(__comp);
575 bool __fs = std::__insertion_sort_incomplete<_WrappedComp>(__first, __i, __wrapped_comp);
576 if (std::__insertion_sort_incomplete<_WrappedComp>(__i + difference_type(1), __last, __wrapped_comp)) {
577 if (__fs)
578 return;
579 __last = __i;
580 continue;
581 } else {
582 if (__fs) {
458 __first = ++__i;583 __first = ++__i;
584 continue;
459 }585 }
460 else586 }
461 {
462 _VSTD::__introsort<_Compare>(__i + difference_type(1), __last, __comp, __depth);
463 __last = __i;
464 }
465 }587 }
588 // sort smaller range with recursive call and larger with tail recursion elimination
589 if (__i - __first < __last - __i) {
590 std::__introsort<_AlgPolicy, _Compare>(__first, __i, __comp, __depth);
591 __first = ++__i;
592 } else {
593 std::__introsort<_AlgPolicy, _Compare>(__i + difference_type(1), __last, __comp, __depth);
594 __last = __i;
595 }
596 }
466}597}
467598
468template <typename _Number>599template <typename _Number>
469inline _LIBCPP_HIDE_FROM_ABI _Number __log2i(_Number __n) {600inline _LIBCPP_HIDE_FROM_ABI _Number __log2i(_Number __n) {
601 if (__n == 0)
602 return 0;
603 if (sizeof(__n) <= sizeof(unsigned))
604 return sizeof(unsigned) * CHAR_BIT - 1 - __libcpp_clz(static_cast<unsigned>(__n));
605 if (sizeof(__n) <= sizeof(unsigned long))
606 return sizeof(unsigned long) * CHAR_BIT - 1 - __libcpp_clz(static_cast<unsigned long>(__n));
607 if (sizeof(__n) <= sizeof(unsigned long long))
608 return sizeof(unsigned long long) * CHAR_BIT - 1 - __libcpp_clz(static_cast<unsigned long long>(__n));
609
470 _Number __log2 = 0;610 _Number __log2 = 0;
471 while (__n > 1) {611 while (__n > 1) {
472 __log2++;612 __log2++;
...@@ -475,80 +615,89 @@ inline _LIBCPP_HIDE_FROM_ABI _Number __log2i(_Number __n) {...@@ -475,80 +615,89 @@ inline _LIBCPP_HIDE_FROM_ABI _Number __log2i(_Number __n) {
475 return __log2;615 return __log2;
476}616}
477617
478template <class _Compare, class _RandomAccessIterator>618template <class _WrappedComp, class _RandomAccessIterator>
479void __sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {619void __sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _WrappedComp __wrapped_comp) {
480 typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;620 typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
481 difference_type __depth_limit = 2 * __log2i(__last - __first);621 difference_type __depth_limit = 2 * __log2i(__last - __first);
482 _VSTD::__introsort<_Compare>(__first, __last, __comp, __depth_limit);622
623 using _Unwrap = _UnwrapAlgPolicy<_WrappedComp>;
624 using _AlgPolicy = typename _Unwrap::_AlgPolicy;
625 using _Compare = typename _Unwrap::_Comp;
626 _Compare __comp = _Unwrap::__get_comp(__wrapped_comp);
627 std::__introsort<_AlgPolicy, _Compare>(__first, __last, __comp, __depth_limit);
483}628}
484629
485template <class _Compare, class _Tp>630template <class _Compare, class _Tp>
486inline _LIBCPP_INLINE_VISIBILITY631inline _LIBCPP_INLINE_VISIBILITY void __sort(_Tp** __first, _Tp** __last, __less<_Tp*>&) {
487void632 __less<uintptr_t> __comp;
488__sort(_Tp** __first, _Tp** __last, __less<_Tp*>&)633 std::__sort<__less<uintptr_t>&, uintptr_t*>((uintptr_t*)__first, (uintptr_t*)__last, __comp);
489{
490 __less<uintptr_t> __comp;
491 _VSTD::__sort<__less<uintptr_t>&, uintptr_t*>((uintptr_t*)__first, (uintptr_t*)__last, __comp);
492}634}
493635
494_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<char>&, char*>(char*, char*, __less<char>&))636extern template _LIBCPP_FUNC_VIS void __sort<__less<char>&, char*>(char*, char*, __less<char>&);
495#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS637#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
496_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&))638extern template _LIBCPP_FUNC_VIS void __sort<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&);
497#endif639#endif
498_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&))640extern template _LIBCPP_FUNC_VIS void __sort<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&);
499_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&))641extern template _LIBCPP_FUNC_VIS void __sort<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&);
500_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<short>&, short*>(short*, short*, __less<short>&))642extern template _LIBCPP_FUNC_VIS void __sort<__less<short>&, short*>(short*, short*, __less<short>&);
501_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&))643extern template _LIBCPP_FUNC_VIS void __sort<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&);
502_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<int>&, int*>(int*, int*, __less<int>&))644extern template _LIBCPP_FUNC_VIS void __sort<__less<int>&, int*>(int*, int*, __less<int>&);
503_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<unsigned>&, unsigned*>(unsigned*, unsigned*, __less<unsigned>&))645extern template _LIBCPP_FUNC_VIS void __sort<__less<unsigned>&, unsigned*>(unsigned*, unsigned*, __less<unsigned>&);
504_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<long>&, long*>(long*, long*, __less<long>&))646extern template _LIBCPP_FUNC_VIS void __sort<__less<long>&, long*>(long*, long*, __less<long>&);
505_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<unsigned long>&, unsigned long*>(unsigned long*, unsigned long*, __less<unsigned long>&))647extern template _LIBCPP_FUNC_VIS void __sort<__less<unsigned long>&, unsigned long*>(unsigned long*, unsigned long*, __less<unsigned long>&);
506_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<long long>&, long long*>(long long*, long long*, __less<long long>&))648extern template _LIBCPP_FUNC_VIS void __sort<__less<long long>&, long long*>(long long*, long long*, __less<long long>&);
507_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<unsigned long long>&, unsigned long long*>(unsigned long long*, unsigned long long*, __less<unsigned long long>&))649extern template _LIBCPP_FUNC_VIS void __sort<__less<unsigned long long>&, unsigned long long*>(unsigned long long*, unsigned long long*, __less<unsigned long long>&);
508_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<float>&, float*>(float*, float*, __less<float>&))650extern template _LIBCPP_FUNC_VIS void __sort<__less<float>&, float*>(float*, float*, __less<float>&);
509_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<double>&, double*>(double*, double*, __less<double>&))651extern template _LIBCPP_FUNC_VIS void __sort<__less<double>&, double*>(double*, double*, __less<double>&);
510_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<long double>&, long double*>(long double*, long double*, __less<long double>&))652extern template _LIBCPP_FUNC_VIS void __sort<__less<long double>&, long double*>(long double*, long double*, __less<long double>&);
511653
512_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<char>&, char*>(char*, char*, __less<char>&))654extern template _LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<char>&, char*>(char*, char*, __less<char>&);
513#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS655#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
514_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&))656extern template _LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&);
515#endif657#endif
516_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&))658extern template _LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&);
517_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&))659extern template _LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&);
518_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<short>&, short*>(short*, short*, __less<short>&))660extern template _LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<short>&, short*>(short*, short*, __less<short>&);
519_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&))661extern template _LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&);
520_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<int>&, int*>(int*, int*, __less<int>&))662extern template _LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<int>&, int*>(int*, int*, __less<int>&);
521_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned>&, unsigned*>(unsigned*, unsigned*, __less<unsigned>&))663extern template _LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned>&, unsigned*>(unsigned*, unsigned*, __less<unsigned>&);
522_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<long>&, long*>(long*, long*, __less<long>&))664extern template _LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<long>&, long*>(long*, long*, __less<long>&);
523_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned long>&, unsigned long*>(unsigned long*, unsigned long*, __less<unsigned long>&))665extern template _LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned long>&, unsigned long*>(unsigned long*, unsigned long*, __less<unsigned long>&);
524_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<long long>&, long long*>(long long*, long long*, __less<long long>&))666extern template _LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<long long>&, long long*>(long long*, long long*, __less<long long>&);
525_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned long long>&, unsigned long long*>(unsigned long long*, unsigned long long*, __less<unsigned long long>&))667extern template _LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned long long>&, unsigned long long*>(unsigned long long*, unsigned long long*, __less<unsigned long long>&);
526_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<float>&, float*>(float*, float*, __less<float>&))668extern template _LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<float>&, float*>(float*, float*, __less<float>&);
527_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<double>&, double*>(double*, double*, __less<double>&))669extern template _LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<double>&, double*>(double*, double*, __less<double>&);
528_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<long double>&, long double*>(long double*, long double*, __less<long double>&))670extern template _LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<long double>&, long double*>(long double*, long double*, __less<long double>&);
529671
530_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS unsigned __sort5<__less<long double>&, long double*>(long double*, long double*, long double*, long double*, long double*, __less<long double>&))672extern template _LIBCPP_FUNC_VIS unsigned __sort5<__less<long double>&, long double*>(long double*, long double*, long double*, long double*, long double*, __less<long double>&);
531673
532template <class _RandomAccessIterator, class _Compare>674template <class _AlgPolicy, class _RandomAccessIterator, class _Comp>
533inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17675inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
534void676void __sort_impl(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp& __comp) {
535sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)677 std::__debug_randomize_range<_AlgPolicy>(__first, __last);
536{678
537 _LIBCPP_DEBUG_RANDOMIZE_RANGE(__first, __last);679 using _Comp_ref = typename __comp_ref_type<_Comp>::type;
538 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
539 if (__libcpp_is_constant_evaluated()) {680 if (__libcpp_is_constant_evaluated()) {
540 _VSTD::__partial_sort<_Comp_ref>(__first, __last, __last, _Comp_ref(__comp));681 std::__partial_sort<_AlgPolicy>(__first, __last, __last, __comp);
682
541 } else {683 } else {
542 _VSTD::__sort<_Comp_ref>(_VSTD::__unwrap_iter(__first), _VSTD::__unwrap_iter(__last), _Comp_ref(__comp));684 using _WrappedComp = typename _WrapAlgPolicy<_AlgPolicy, _Comp_ref>::type;
685 _Comp_ref __comp_ref(__comp);
686 _WrappedComp __wrapped_comp(__comp_ref);
687 std::__sort<_WrappedComp>(std::__unwrap_iter(__first), std::__unwrap_iter(__last), __wrapped_comp);
543 }688 }
544}689}
545690
691template <class _RandomAccessIterator, class _Comp>
692inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
693void sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp) {
694 std::__sort_impl<_ClassicAlgPolicy>(std::move(__first), std::move(__last), __comp);
695}
696
546template <class _RandomAccessIterator>697template <class _RandomAccessIterator>
547inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17698inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
548void699void sort(_RandomAccessIterator __first, _RandomAccessIterator __last) {
549sort(_RandomAccessIterator __first, _RandomAccessIterator __last)700 std::sort(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
550{
551 _VSTD::sort(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
552}701}
553702
554_LIBCPP_END_NAMESPACE_STD703_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/sort_heap.h+23-20
...@@ -11,41 +11,44 @@...@@ -11,41 +11,44 @@
1111
12#include <__algorithm/comp.h>12#include <__algorithm/comp.h>
13#include <__algorithm/comp_ref_type.h>13#include <__algorithm/comp_ref_type.h>
14#include <__algorithm/iterator_operations.h>
14#include <__algorithm/pop_heap.h>15#include <__algorithm/pop_heap.h>
15#include <__config>16#include <__config>
16#include <__iterator/iterator_traits.h>17#include <__iterator/iterator_traits.h>
17#include <type_traits> // swap18#include <__utility/move.h>
19#include <type_traits>
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
21#endif23#endif
2224
23_LIBCPP_BEGIN_NAMESPACE_STD25_LIBCPP_BEGIN_NAMESPACE_STD
2426
25template <class _Compare, class _RandomAccessIterator>27template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
26_LIBCPP_CONSTEXPR_AFTER_CXX17 void28inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
27__sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)29void __sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare&& __comp) {
28{30 using _CompRef = typename __comp_ref_type<_Compare>::type;
29 typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;31 _CompRef __comp_ref = __comp;
30 for (difference_type __n = __last - __first; __n > 1; --__last, (void) --__n)32
31 _VSTD::__pop_heap<_Compare>(__first, __last, __comp, __n);33 using difference_type = typename iterator_traits<_RandomAccessIterator>::difference_type;
34 for (difference_type __n = __last - __first; __n > 1; --__last, (void) --__n)
35 std::__pop_heap<_AlgPolicy>(__first, __last, __comp_ref, __n);
32}36}
3337
34template <class _RandomAccessIterator, class _Compare>38template <class _RandomAccessIterator, class _Compare>
35inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1739inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
36void40void sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {
37sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)41 static_assert(std::is_copy_constructible<_RandomAccessIterator>::value, "Iterators must be copy constructible.");
38{42 static_assert(std::is_copy_assignable<_RandomAccessIterator>::value, "Iterators must be copy assignable.");
39 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;43
40 _VSTD::__sort_heap<_Comp_ref>(__first, __last, __comp);44 std::__sort_heap<_ClassicAlgPolicy>(std::move(__first), std::move(__last), __comp);
41}45}
4246
43template <class _RandomAccessIterator>47template <class _RandomAccessIterator>
44inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1748inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
45void49void sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) {
46sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)50 std::sort_heap(std::move(__first), std::move(__last),
47{51 __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
48 _VSTD::sort_heap(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
49}52}
5053
51_LIBCPP_END_NAMESPACE_STD54_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/stable_partition.h+67-38
...@@ -9,23 +9,28 @@...@@ -9,23 +9,28 @@
9#ifndef _LIBCPP___ALGORITHM_STABLE_PARTITION_H9#ifndef _LIBCPP___ALGORITHM_STABLE_PARTITION_H
10#define _LIBCPP___ALGORITHM_STABLE_PARTITION_H10#define _LIBCPP___ALGORITHM_STABLE_PARTITION_H
1111
12#include <__algorithm/iterator_operations.h>
12#include <__algorithm/rotate.h>13#include <__algorithm/rotate.h>
13#include <__config>14#include <__config>
15#include <__iterator/advance.h>
16#include <__iterator/distance.h>
14#include <__iterator/iterator_traits.h>17#include <__iterator/iterator_traits.h>
15#include <__utility/swap.h>
16#include <memory>18#include <memory>
19#include <type_traits>
1720
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19#pragma GCC system_header22# pragma GCC system_header
20#endif23#endif
2124
22_LIBCPP_BEGIN_NAMESPACE_STD25_LIBCPP_BEGIN_NAMESPACE_STD
2326
24template <class _Predicate, class _ForwardIterator, class _Distance, class _Pair>27template <class _AlgPolicy, class _Predicate, class _ForwardIterator, class _Distance, class _Pair>
25_ForwardIterator28_ForwardIterator
26__stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred,29__stable_partition_impl(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred,
27 _Distance __len, _Pair __p, forward_iterator_tag __fit)30 _Distance __len, _Pair __p, forward_iterator_tag __fit)
28{31{
32 using _Ops = _IterOps<_AlgPolicy>;
33
29 // *__first is known to be false34 // *__first is known to be false
30 // __len >= 135 // __len >= 1
31 if (__len == 1)36 if (__len == 1)
...@@ -35,7 +40,7 @@ __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate...@@ -35,7 +40,7 @@ __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate
35 _ForwardIterator __m = __first;40 _ForwardIterator __m = __first;
36 if (__pred(*++__m))41 if (__pred(*++__m))
37 {42 {
38 swap(*__first, *__m);43 _Ops::iter_swap(__first, __m);
39 return __m;44 return __m;
40 }45 }
41 return __first;46 return __first;
...@@ -48,7 +53,7 @@ __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate...@@ -48,7 +53,7 @@ __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate
48 // Move the falses into the temporary buffer, and the trues to the front of the line53 // Move the falses into the temporary buffer, and the trues to the front of the line
49 // Update __first to always point to the end of the trues54 // Update __first to always point to the end of the trues
50 value_type* __t = __p.first;55 value_type* __t = __p.first;
51 ::new ((void*)__t) value_type(_VSTD::move(*__first));56 ::new ((void*)__t) value_type(_Ops::__iter_move(__first));
52 __d.template __incr<value_type>();57 __d.template __incr<value_type>();
53 ++__t;58 ++__t;
54 _ForwardIterator __i = __first;59 _ForwardIterator __i = __first;
...@@ -56,12 +61,12 @@ __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate...@@ -56,12 +61,12 @@ __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate
56 {61 {
57 if (__pred(*__i))62 if (__pred(*__i))
58 {63 {
59 *__first = _VSTD::move(*__i);64 *__first = _Ops::__iter_move(__i);
60 ++__first;65 ++__first;
61 }66 }
62 else67 else
63 {68 {
64 ::new ((void*)__t) value_type(_VSTD::move(*__i));69 ::new ((void*)__t) value_type(_Ops::__iter_move(__i));
65 __d.template __incr<value_type>();70 __d.template __incr<value_type>();
66 ++__t;71 ++__t;
67 }72 }
...@@ -70,7 +75,7 @@ __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate...@@ -70,7 +75,7 @@ __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate
70 // Move falses back into range, but don't mess up __first which points to first false75 // Move falses back into range, but don't mess up __first which points to first false
71 __i = __first;76 __i = __first;
72 for (value_type* __t2 = __p.first; __t2 < __t; ++__t2, (void) ++__i)77 for (value_type* __t2 = __p.first; __t2 < __t; ++__t2, (void) ++__i)
73 *__i = _VSTD::move(*__t2);78 *__i = _Ops::__iter_move(__t2);
74 // __h destructs moved-from values out of the temp buffer, but doesn't deallocate buffer79 // __h destructs moved-from values out of the temp buffer, but doesn't deallocate buffer
75 return __first;80 return __first;
76 }81 }
...@@ -78,11 +83,12 @@ __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate...@@ -78,11 +83,12 @@ __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate
78 // __len >= 383 // __len >= 3
79 _ForwardIterator __m = __first;84 _ForwardIterator __m = __first;
80 _Distance __len2 = __len / 2; // __len2 >= 285 _Distance __len2 = __len / 2; // __len2 >= 2
81 _VSTD::advance(__m, __len2);86 _Ops::advance(__m, __len2);
82 // recurse on [__first, __m), *__first know to be false87 // recurse on [__first, __m), *__first know to be false
83 // F?????????????????88 // F?????????????????
84 // f m l89 // f m l
85 _ForwardIterator __first_false = _VSTD::__stable_partition<_Predicate&>(__first, __m, __pred, __len2, __p, __fit);90 _ForwardIterator __first_false = std::__stable_partition_impl<_AlgPolicy, _Predicate&>(
91 __first, __m, __pred, __len2, __p, __fit);
86 // TTTFFFFF??????????92 // TTTFFFFF??????????
87 // f ff m l93 // f ff m l
88 // recurse on [__m, __last], except increase __m until *(__m) is false, *__last know to be true94 // recurse on [__m, __last], except increase __m until *(__m) is false, *__last know to be true
...@@ -97,18 +103,19 @@ __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate...@@ -97,18 +103,19 @@ __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate
97 }103 }
98 // TTTFFFFFTTTF??????104 // TTTFFFFFTTTF??????
99 // f ff m m1 l105 // f ff m m1 l
100 __second_false = _VSTD::__stable_partition<_Predicate&>(__m1, __last, __pred, __len_half, __p, __fit);106 __second_false = std::__stable_partition_impl<_AlgPolicy, _Predicate&>(
107 __m1, __last, __pred, __len_half, __p, __fit);
101__second_half_done:108__second_half_done:
102 // TTTFFFFFTTTTTFFFFF109 // TTTFFFFFTTTTTFFFFF
103 // f ff m sf l110 // f ff m sf l
104 return _VSTD::rotate(__first_false, __m, __second_false);111 return std::__rotate<_AlgPolicy>(__first_false, __m, __second_false, __fit);
105 // TTTTTTTTFFFFFFFFFF112 // TTTTTTTTFFFFFFFFFF
106 // |113 // |
107}114}
108115
109template <class _Predicate, class _ForwardIterator>116template <class _AlgPolicy, class _Predicate, class _ForwardIterator>
110_ForwardIterator117_ForwardIterator
111__stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred,118__stable_partition_impl(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred,
112 forward_iterator_tag)119 forward_iterator_tag)
113{120{
114 const unsigned __alloc_limit = 3; // might want to make this a function of trivial assignment121 const unsigned __alloc_limit = 3; // might want to make this a function of trivial assignment
...@@ -125,28 +132,34 @@ __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate...@@ -125,28 +132,34 @@ __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate
125 // *__first is known to be false132 // *__first is known to be false
126 typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type;133 typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type;
127 typedef typename iterator_traits<_ForwardIterator>::value_type value_type;134 typedef typename iterator_traits<_ForwardIterator>::value_type value_type;
128 difference_type __len = _VSTD::distance(__first, __last);135 difference_type __len = _IterOps<_AlgPolicy>::distance(__first, __last);
129 pair<value_type*, ptrdiff_t> __p(0, 0);136 pair<value_type*, ptrdiff_t> __p(0, 0);
130 unique_ptr<value_type, __return_temporary_buffer> __h;137 unique_ptr<value_type, __return_temporary_buffer> __h;
131 if (__len >= __alloc_limit)138 if (__len >= __alloc_limit)
132 {139 {
140// TODO: Remove the use of std::get_temporary_buffer
141_LIBCPP_SUPPRESS_DEPRECATED_PUSH
133 __p = _VSTD::get_temporary_buffer<value_type>(__len);142 __p = _VSTD::get_temporary_buffer<value_type>(__len);
143_LIBCPP_SUPPRESS_DEPRECATED_POP
134 __h.reset(__p.first);144 __h.reset(__p.first);
135 }145 }
136 return _VSTD::__stable_partition<_Predicate&>(__first, __last, __pred, __len, __p, forward_iterator_tag());146 return std::__stable_partition_impl<_AlgPolicy, _Predicate&>(
147 std::move(__first), std::move(__last), __pred, __len, __p, forward_iterator_tag());
137}148}
138149
139template <class _Predicate, class _BidirectionalIterator, class _Distance, class _Pair>150template <class _AlgPolicy, class _Predicate, class _BidirectionalIterator, class _Distance, class _Pair>
140_BidirectionalIterator151_BidirectionalIterator
141__stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last, _Predicate __pred,152__stable_partition_impl(_BidirectionalIterator __first, _BidirectionalIterator __last, _Predicate __pred,
142 _Distance __len, _Pair __p, bidirectional_iterator_tag __bit)153 _Distance __len, _Pair __p, bidirectional_iterator_tag __bit)
143{154{
155 using _Ops = _IterOps<_AlgPolicy>;
156
144 // *__first is known to be false157 // *__first is known to be false
145 // *__last is known to be true158 // *__last is known to be true
146 // __len >= 2159 // __len >= 2
147 if (__len == 2)160 if (__len == 2)
148 {161 {
149 swap(*__first, *__last);162 _Ops::iter_swap(__first, __last);
150 return __last;163 return __last;
151 }164 }
152 if (__len == 3)165 if (__len == 3)
...@@ -154,12 +167,12 @@ __stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last...@@ -154,12 +167,12 @@ __stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last
154 _BidirectionalIterator __m = __first;167 _BidirectionalIterator __m = __first;
155 if (__pred(*++__m))168 if (__pred(*++__m))
156 {169 {
157 swap(*__first, *__m);170 _Ops::iter_swap(__first, __m);
158 swap(*__m, *__last);171 _Ops::iter_swap(__m, __last);
159 return __last;172 return __last;
160 }173 }
161 swap(*__m, *__last);174 _Ops::iter_swap(__m, __last);
162 swap(*__first, *__m);175 _Ops::iter_swap(__first, __m);
163 return __m;176 return __m;
164 }177 }
165 if (__len <= __p.second)178 if (__len <= __p.second)
...@@ -170,7 +183,7 @@ __stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last...@@ -170,7 +183,7 @@ __stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last
170 // Move the falses into the temporary buffer, and the trues to the front of the line183 // Move the falses into the temporary buffer, and the trues to the front of the line
171 // Update __first to always point to the end of the trues184 // Update __first to always point to the end of the trues
172 value_type* __t = __p.first;185 value_type* __t = __p.first;
173 ::new ((void*)__t) value_type(_VSTD::move(*__first));186 ::new ((void*)__t) value_type(_Ops::__iter_move(__first));
174 __d.template __incr<value_type>();187 __d.template __incr<value_type>();
175 ++__t;188 ++__t;
176 _BidirectionalIterator __i = __first;189 _BidirectionalIterator __i = __first;
...@@ -178,23 +191,23 @@ __stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last...@@ -178,23 +191,23 @@ __stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last
178 {191 {
179 if (__pred(*__i))192 if (__pred(*__i))
180 {193 {
181 *__first = _VSTD::move(*__i);194 *__first = _Ops::__iter_move(__i);
182 ++__first;195 ++__first;
183 }196 }
184 else197 else
185 {198 {
186 ::new ((void*)__t) value_type(_VSTD::move(*__i));199 ::new ((void*)__t) value_type(_Ops::__iter_move(__i));
187 __d.template __incr<value_type>();200 __d.template __incr<value_type>();
188 ++__t;201 ++__t;
189 }202 }
190 }203 }
191 // move *__last, known to be true204 // move *__last, known to be true
192 *__first = _VSTD::move(*__i);205 *__first = _Ops::__iter_move(__i);
193 __i = ++__first;206 __i = ++__first;
194 // All trues now at start of range, all falses in buffer207 // All trues now at start of range, all falses in buffer
195 // Move falses back into range, but don't mess up __first which points to first false208 // Move falses back into range, but don't mess up __first which points to first false
196 for (value_type* __t2 = __p.first; __t2 < __t; ++__t2, (void) ++__i)209 for (value_type* __t2 = __p.first; __t2 < __t; ++__t2, (void) ++__i)
197 *__i = _VSTD::move(*__t2);210 *__i = _Ops::__iter_move(__t2);
198 // __h destructs moved-from values out of the temp buffer, but doesn't deallocate buffer211 // __h destructs moved-from values out of the temp buffer, but doesn't deallocate buffer
199 return __first;212 return __first;
200 }213 }
...@@ -202,7 +215,7 @@ __stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last...@@ -202,7 +215,7 @@ __stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last
202 // __len >= 4215 // __len >= 4
203 _BidirectionalIterator __m = __first;216 _BidirectionalIterator __m = __first;
204 _Distance __len2 = __len / 2; // __len2 >= 2217 _Distance __len2 = __len / 2; // __len2 >= 2
205 _VSTD::advance(__m, __len2);218 _Ops::advance(__m, __len2);
206 // recurse on [__first, __m-1], except reduce __m-1 until *(__m-1) is true, *__first know to be false219 // recurse on [__first, __m-1], except reduce __m-1 until *(__m-1) is true, *__first know to be false
207 // F????????????????T220 // F????????????????T
208 // f m l221 // f m l
...@@ -217,7 +230,8 @@ __stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last...@@ -217,7 +230,8 @@ __stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last
217 }230 }
218 // F???TFFF?????????T231 // F???TFFF?????????T
219 // f m1 m l232 // f m1 m l
220 __first_false = _VSTD::__stable_partition<_Predicate&>(__first, __m1, __pred, __len_half, __p, __bit);233 __first_false = std::__stable_partition_impl<_AlgPolicy, _Predicate&>(
234 __first, __m1, __pred, __len_half, __p, __bit);
221__first_half_done:235__first_half_done:
222 // TTTFFFFF?????????T236 // TTTFFFFF?????????T
223 // f ff m l237 // f ff m l
...@@ -234,18 +248,19 @@ __first_half_done:...@@ -234,18 +248,19 @@ __first_half_done:
234 }248 }
235 // TTTFFFFFTTTF?????T249 // TTTFFFFFTTTF?????T
236 // f ff m m1 l250 // f ff m m1 l
237 __second_false = _VSTD::__stable_partition<_Predicate&>(__m1, __last, __pred, __len_half, __p, __bit);251 __second_false = std::__stable_partition_impl<_AlgPolicy, _Predicate&>(
252 __m1, __last, __pred, __len_half, __p, __bit);
238__second_half_done:253__second_half_done:
239 // TTTFFFFFTTTTTFFFFF254 // TTTFFFFFTTTTTFFFFF
240 // f ff m sf l255 // f ff m sf l
241 return _VSTD::rotate(__first_false, __m, __second_false);256 return std::__rotate<_AlgPolicy>(__first_false, __m, __second_false, __bit);
242 // TTTTTTTTFFFFFFFFFF257 // TTTTTTTTFFFFFFFFFF
243 // |258 // |
244}259}
245260
246template <class _Predicate, class _BidirectionalIterator>261template <class _AlgPolicy, class _Predicate, class _BidirectionalIterator>
247_BidirectionalIterator262_BidirectionalIterator
248__stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last, _Predicate __pred,263__stable_partition_impl(_BidirectionalIterator __first, _BidirectionalIterator __last, _Predicate __pred,
249 bidirectional_iterator_tag)264 bidirectional_iterator_tag)
250{265{
251 typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type;266 typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type;
...@@ -271,15 +286,27 @@ __stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last...@@ -271,15 +286,27 @@ __stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last
271 // *__first is known to be false286 // *__first is known to be false
272 // *__last is known to be true287 // *__last is known to be true
273 // __len >= 2288 // __len >= 2
274 difference_type __len = _VSTD::distance(__first, __last) + 1;289 difference_type __len = _IterOps<_AlgPolicy>::distance(__first, __last) + 1;
275 pair<value_type*, ptrdiff_t> __p(0, 0);290 pair<value_type*, ptrdiff_t> __p(0, 0);
276 unique_ptr<value_type, __return_temporary_buffer> __h;291 unique_ptr<value_type, __return_temporary_buffer> __h;
277 if (__len >= __alloc_limit)292 if (__len >= __alloc_limit)
278 {293 {
294// TODO: Remove the use of std::get_temporary_buffer
295_LIBCPP_SUPPRESS_DEPRECATED_PUSH
279 __p = _VSTD::get_temporary_buffer<value_type>(__len);296 __p = _VSTD::get_temporary_buffer<value_type>(__len);
297_LIBCPP_SUPPRESS_DEPRECATED_POP
280 __h.reset(__p.first);298 __h.reset(__p.first);
281 }299 }
282 return _VSTD::__stable_partition<_Predicate&>(__first, __last, __pred, __len, __p, bidirectional_iterator_tag());300 return std::__stable_partition_impl<_AlgPolicy, _Predicate&>(
301 std::move(__first), std::move(__last), __pred, __len, __p, bidirectional_iterator_tag());
302}
303
304template <class _AlgPolicy, class _Predicate, class _ForwardIterator, class _IterCategory>
305_LIBCPP_HIDE_FROM_ABI
306_ForwardIterator __stable_partition(
307 _ForwardIterator __first, _ForwardIterator __last, _Predicate&& __pred, _IterCategory __iter_category) {
308 return std::__stable_partition_impl<_AlgPolicy, __uncvref_t<_Predicate>&>(
309 std::move(__first), std::move(__last), __pred, __iter_category);
283}310}
284311
285template <class _ForwardIterator, class _Predicate>312template <class _ForwardIterator, class _Predicate>
...@@ -287,7 +314,9 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -287,7 +314,9 @@ inline _LIBCPP_INLINE_VISIBILITY
287_ForwardIterator314_ForwardIterator
288stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)315stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)
289{316{
290 return _VSTD::__stable_partition<_Predicate&>(__first, __last, __pred, typename iterator_traits<_ForwardIterator>::iterator_category());317 using _IterCategory = typename iterator_traits<_ForwardIterator>::iterator_category;
318 return std::__stable_partition<_ClassicAlgPolicy, _Predicate&>(
319 std::move(__first), std::move(__last), __pred, _IterCategory());
291}320}
292321
293_LIBCPP_END_NAMESPACE_STD322_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/stable_sort.h+67-53
...@@ -12,25 +12,28 @@...@@ -12,25 +12,28 @@
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/inplace_merge.h>14#include <__algorithm/inplace_merge.h>
15#include <__algorithm/iterator_operations.h>
15#include <__algorithm/sort.h>16#include <__algorithm/sort.h>
16#include <__config>17#include <__config>
17#include <__iterator/iterator_traits.h>18#include <__iterator/iterator_traits.h>
18#include <__utility/swap.h>19#include <__utility/move.h>
19#include <memory>20#include <memory>
20#include <type_traits>21#include <type_traits>
2122
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23#pragma GCC system_header24# pragma GCC system_header
24#endif25#endif
2526
26_LIBCPP_BEGIN_NAMESPACE_STD27_LIBCPP_BEGIN_NAMESPACE_STD
2728
28template <class _Compare, class _InputIterator1, class _InputIterator2>29template <class _AlgPolicy, class _Compare, class _InputIterator1, class _InputIterator2>
29void30void
30__merge_move_construct(_InputIterator1 __first1, _InputIterator1 __last1,31__merge_move_construct(_InputIterator1 __first1, _InputIterator1 __last1,
31 _InputIterator2 __first2, _InputIterator2 __last2,32 _InputIterator2 __first2, _InputIterator2 __last2,
32 typename iterator_traits<_InputIterator1>::value_type* __result, _Compare __comp)33 typename iterator_traits<_InputIterator1>::value_type* __result, _Compare __comp)
33{34{
35 using _Ops = _IterOps<_AlgPolicy>;
36
34 typedef typename iterator_traits<_InputIterator1>::value_type value_type;37 typedef typename iterator_traits<_InputIterator1>::value_type value_type;
35 __destruct_n __d(0);38 __destruct_n __d(0);
36 unique_ptr<value_type, __destruct_n&> __h(__result, __d);39 unique_ptr<value_type, __destruct_n&> __h(__result, __d);
...@@ -39,111 +42,115 @@ __merge_move_construct(_InputIterator1 __first1, _InputIterator1 __last1,...@@ -39,111 +42,115 @@ __merge_move_construct(_InputIterator1 __first1, _InputIterator1 __last1,
39 if (__first1 == __last1)42 if (__first1 == __last1)
40 {43 {
41 for (; __first2 != __last2; ++__first2, (void) ++__result, __d.template __incr<value_type>())44 for (; __first2 != __last2; ++__first2, (void) ++__result, __d.template __incr<value_type>())
42 ::new ((void*)__result) value_type(_VSTD::move(*__first2));45 ::new ((void*)__result) value_type(_Ops::__iter_move(__first2));
43 __h.release();46 __h.release();
44 return;47 return;
45 }48 }
46 if (__first2 == __last2)49 if (__first2 == __last2)
47 {50 {
48 for (; __first1 != __last1; ++__first1, (void) ++__result, __d.template __incr<value_type>())51 for (; __first1 != __last1; ++__first1, (void) ++__result, __d.template __incr<value_type>())
49 ::new ((void*)__result) value_type(_VSTD::move(*__first1));52 ::new ((void*)__result) value_type(_Ops::__iter_move(__first1));
50 __h.release();53 __h.release();
51 return;54 return;
52 }55 }
53 if (__comp(*__first2, *__first1))56 if (__comp(*__first2, *__first1))
54 {57 {
55 ::new ((void*)__result) value_type(_VSTD::move(*__first2));58 ::new ((void*)__result) value_type(_Ops::__iter_move(__first2));
56 __d.template __incr<value_type>();59 __d.template __incr<value_type>();
57 ++__first2;60 ++__first2;
58 }61 }
59 else62 else
60 {63 {
61 ::new ((void*)__result) value_type(_VSTD::move(*__first1));64 ::new ((void*)__result) value_type(_Ops::__iter_move(__first1));
62 __d.template __incr<value_type>();65 __d.template __incr<value_type>();
63 ++__first1;66 ++__first1;
64 }67 }
65 }68 }
66}69}
6770
68template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>71template <class _AlgPolicy, class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>
69void72void
70__merge_move_assign(_InputIterator1 __first1, _InputIterator1 __last1,73__merge_move_assign(_InputIterator1 __first1, _InputIterator1 __last1,
71 _InputIterator2 __first2, _InputIterator2 __last2,74 _InputIterator2 __first2, _InputIterator2 __last2,
72 _OutputIterator __result, _Compare __comp)75 _OutputIterator __result, _Compare __comp)
73{76{
77 using _Ops = _IterOps<_AlgPolicy>;
78
74 for (; __first1 != __last1; ++__result)79 for (; __first1 != __last1; ++__result)
75 {80 {
76 if (__first2 == __last2)81 if (__first2 == __last2)
77 {82 {
78 for (; __first1 != __last1; ++__first1, (void) ++__result)83 for (; __first1 != __last1; ++__first1, (void) ++__result)
79 *__result = _VSTD::move(*__first1);84 *__result = _Ops::__iter_move(__first1);
80 return;85 return;
81 }86 }
82 if (__comp(*__first2, *__first1))87 if (__comp(*__first2, *__first1))
83 {88 {
84 *__result = _VSTD::move(*__first2);89 *__result = _Ops::__iter_move(__first2);
85 ++__first2;90 ++__first2;
86 }91 }
87 else92 else
88 {93 {
89 *__result = _VSTD::move(*__first1);94 *__result = _Ops::__iter_move(__first1);
90 ++__first1;95 ++__first1;
91 }96 }
92 }97 }
93 for (; __first2 != __last2; ++__first2, (void) ++__result)98 for (; __first2 != __last2; ++__first2, (void) ++__result)
94 *__result = _VSTD::move(*__first2);99 *__result = _Ops::__iter_move(__first2);
95}100}
96101
97template <class _Compare, class _RandomAccessIterator>102template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
98void103void
99__stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp,104__stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp,
100 typename iterator_traits<_RandomAccessIterator>::difference_type __len,105 typename iterator_traits<_RandomAccessIterator>::difference_type __len,
101 typename iterator_traits<_RandomAccessIterator>::value_type* __buff, ptrdiff_t __buff_size);106 typename iterator_traits<_RandomAccessIterator>::value_type* __buff, ptrdiff_t __buff_size);
102107
103template <class _Compare, class _RandomAccessIterator>108template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
104void109void
105__stable_sort_move(_RandomAccessIterator __first1, _RandomAccessIterator __last1, _Compare __comp,110__stable_sort_move(_RandomAccessIterator __first1, _RandomAccessIterator __last1, _Compare __comp,
106 typename iterator_traits<_RandomAccessIterator>::difference_type __len,111 typename iterator_traits<_RandomAccessIterator>::difference_type __len,
107 typename iterator_traits<_RandomAccessIterator>::value_type* __first2)112 typename iterator_traits<_RandomAccessIterator>::value_type* __first2)
108{113{
114 using _Ops = _IterOps<_AlgPolicy>;
115
109 typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;116 typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
110 switch (__len)117 switch (__len)
111 {118 {
112 case 0:119 case 0:
113 return;120 return;
114 case 1:121 case 1:
115 ::new ((void*)__first2) value_type(_VSTD::move(*__first1));122 ::new ((void*)__first2) value_type(_Ops::__iter_move(__first1));
116 return;123 return;
117 case 2:124 case 2:
118 __destruct_n __d(0);125 __destruct_n __d(0);
119 unique_ptr<value_type, __destruct_n&> __h2(__first2, __d);126 unique_ptr<value_type, __destruct_n&> __h2(__first2, __d);
120 if (__comp(*--__last1, *__first1))127 if (__comp(*--__last1, *__first1))
121 {128 {
122 ::new ((void*)__first2) value_type(_VSTD::move(*__last1));129 ::new ((void*)__first2) value_type(_Ops::__iter_move(__last1));
123 __d.template __incr<value_type>();130 __d.template __incr<value_type>();
124 ++__first2;131 ++__first2;
125 ::new ((void*)__first2) value_type(_VSTD::move(*__first1));132 ::new ((void*)__first2) value_type(_Ops::__iter_move(__first1));
126 }133 }
127 else134 else
128 {135 {
129 ::new ((void*)__first2) value_type(_VSTD::move(*__first1));136 ::new ((void*)__first2) value_type(_Ops::__iter_move(__first1));
130 __d.template __incr<value_type>();137 __d.template __incr<value_type>();
131 ++__first2;138 ++__first2;
132 ::new ((void*)__first2) value_type(_VSTD::move(*__last1));139 ::new ((void*)__first2) value_type(_Ops::__iter_move(__last1));
133 }140 }
134 __h2.release();141 __h2.release();
135 return;142 return;
136 }143 }
137 if (__len <= 8)144 if (__len <= 8)
138 {145 {
139 _VSTD::__insertion_sort_move<_Compare>(__first1, __last1, __first2, __comp);146 std::__insertion_sort_move<_AlgPolicy, _Compare>(__first1, __last1, __first2, __comp);
140 return;147 return;
141 }148 }
142 typename iterator_traits<_RandomAccessIterator>::difference_type __l2 = __len / 2;149 typename iterator_traits<_RandomAccessIterator>::difference_type __l2 = __len / 2;
143 _RandomAccessIterator __m = __first1 + __l2;150 _RandomAccessIterator __m = __first1 + __l2;
144 _VSTD::__stable_sort<_Compare>(__first1, __m, __comp, __l2, __first2, __l2);151 std::__stable_sort<_AlgPolicy, _Compare>(__first1, __m, __comp, __l2, __first2, __l2);
145 _VSTD::__stable_sort<_Compare>(__m, __last1, __comp, __len - __l2, __first2 + __l2, __len - __l2);152 std::__stable_sort<_AlgPolicy, _Compare>(__m, __last1, __comp, __len - __l2, __first2 + __l2, __len - __l2);
146 _VSTD::__merge_move_construct<_Compare>(__first1, __m, __m, __last1, __first2, __comp);153 std::__merge_move_construct<_AlgPolicy, _Compare>(__first1, __m, __m, __last1, __first2, __comp);
147}154}
148155
149template <class _Tp>156template <class _Tp>
...@@ -152,7 +159,7 @@ struct __stable_sort_switch...@@ -152,7 +159,7 @@ struct __stable_sort_switch
152 static const unsigned value = 128*is_trivially_copy_assignable<_Tp>::value;159 static const unsigned value = 128*is_trivially_copy_assignable<_Tp>::value;
153};160};
154161
155template <class _Compare, class _RandomAccessIterator>162template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
156void163void
157__stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp,164__stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp,
158 typename iterator_traits<_RandomAccessIterator>::difference_type __len,165 typename iterator_traits<_RandomAccessIterator>::difference_type __len,
...@@ -167,12 +174,12 @@ __stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp...@@ -167,12 +174,12 @@ __stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp
167 return;174 return;
168 case 2:175 case 2:
169 if (__comp(*--__last, *__first))176 if (__comp(*--__last, *__first))
170 swap(*__first, *__last);177 _IterOps<_AlgPolicy>::iter_swap(__first, __last);
171 return;178 return;
172 }179 }
173 if (__len <= static_cast<difference_type>(__stable_sort_switch<value_type>::value))180 if (__len <= static_cast<difference_type>(__stable_sort_switch<value_type>::value))
174 {181 {
175 _VSTD::__insertion_sort<_Compare>(__first, __last, __comp);182 std::__insertion_sort<_AlgPolicy, _Compare>(__first, __last, __comp);
176 return;183 return;
177 }184 }
178 typename iterator_traits<_RandomAccessIterator>::difference_type __l2 = __len / 2;185 typename iterator_traits<_RandomAccessIterator>::difference_type __l2 = __len / 2;
...@@ -181,11 +188,12 @@ __stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp...@@ -181,11 +188,12 @@ __stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp
181 {188 {
182 __destruct_n __d(0);189 __destruct_n __d(0);
183 unique_ptr<value_type, __destruct_n&> __h2(__buff, __d);190 unique_ptr<value_type, __destruct_n&> __h2(__buff, __d);
184 _VSTD::__stable_sort_move<_Compare>(__first, __m, __comp, __l2, __buff);191 std::__stable_sort_move<_AlgPolicy, _Compare>(__first, __m, __comp, __l2, __buff);
185 __d.__set(__l2, (value_type*)nullptr);192 __d.__set(__l2, (value_type*)nullptr);
186 _VSTD::__stable_sort_move<_Compare>(__m, __last, __comp, __len - __l2, __buff + __l2);193 std::__stable_sort_move<_AlgPolicy, _Compare>(__m, __last, __comp, __len - __l2, __buff + __l2);
187 __d.__set(__len, (value_type*)nullptr);194 __d.__set(__len, (value_type*)nullptr);
188 _VSTD::__merge_move_assign<_Compare>(__buff, __buff + __l2, __buff + __l2, __buff + __len, __first, __comp);195 std::__merge_move_assign<_AlgPolicy, _Compare>(
196 __buff, __buff + __l2, __buff + __l2, __buff + __len, __first, __comp);
189// _VSTD::__merge<_Compare>(move_iterator<value_type*>(__buff),197// _VSTD::__merge<_Compare>(move_iterator<value_type*>(__buff),
190// move_iterator<value_type*>(__buff + __l2),198// move_iterator<value_type*>(__buff + __l2),
191// move_iterator<_RandomAccessIterator>(__buff + __l2),199// move_iterator<_RandomAccessIterator>(__buff + __l2),
...@@ -193,36 +201,42 @@ __stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp...@@ -193,36 +201,42 @@ __stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp
193// __first, __comp);201// __first, __comp);
194 return;202 return;
195 }203 }
196 _VSTD::__stable_sort<_Compare>(__first, __m, __comp, __l2, __buff, __buff_size);204 std::__stable_sort<_AlgPolicy, _Compare>(__first, __m, __comp, __l2, __buff, __buff_size);
197 _VSTD::__stable_sort<_Compare>(__m, __last, __comp, __len - __l2, __buff, __buff_size);205 std::__stable_sort<_AlgPolicy, _Compare>(__m, __last, __comp, __len - __l2, __buff, __buff_size);
198 _VSTD::__inplace_merge<_Compare>(__first, __m, __last, __comp, __l2, __len - __l2, __buff, __buff_size);206 std::__inplace_merge<_AlgPolicy>(__first, __m, __last, __comp, __l2, __len - __l2, __buff, __buff_size);
207}
208
209template <class _AlgPolicy, class _RandomAccessIterator, class _Compare>
210inline _LIBCPP_HIDE_FROM_ABI
211void __stable_sort_impl(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare& __comp) {
212 using value_type = typename iterator_traits<_RandomAccessIterator>::value_type;
213 using difference_type = typename iterator_traits<_RandomAccessIterator>::difference_type;
214
215 difference_type __len = __last - __first;
216 pair<value_type*, ptrdiff_t> __buf(0, 0);
217 unique_ptr<value_type, __return_temporary_buffer> __h;
218 if (__len > static_cast<difference_type>(__stable_sort_switch<value_type>::value)) {
219// TODO: Remove the use of std::get_temporary_buffer
220_LIBCPP_SUPPRESS_DEPRECATED_PUSH
221 __buf = std::get_temporary_buffer<value_type>(__len);
222_LIBCPP_SUPPRESS_DEPRECATED_POP
223 __h.reset(__buf.first);
224 }
225
226 using _Comp_ref = typename __comp_ref_type<_Compare>::type;
227 std::__stable_sort<_AlgPolicy, _Comp_ref>(__first, __last, __comp, __len, __buf.first, __buf.second);
199}228}
200229
201template <class _RandomAccessIterator, class _Compare>230template <class _RandomAccessIterator, class _Compare>
202inline _LIBCPP_INLINE_VISIBILITY231inline _LIBCPP_HIDE_FROM_ABI
203void232void stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {
204stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)233 std::__stable_sort_impl<_ClassicAlgPolicy>(std::move(__first), std::move(__last), __comp);
205{
206 typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
207 typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
208 difference_type __len = __last - __first;
209 pair<value_type*, ptrdiff_t> __buf(0, 0);
210 unique_ptr<value_type, __return_temporary_buffer> __h;
211 if (__len > static_cast<difference_type>(__stable_sort_switch<value_type>::value))
212 {
213 __buf = _VSTD::get_temporary_buffer<value_type>(__len);
214 __h.reset(__buf.first);
215 }
216 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
217 _VSTD::__stable_sort<_Comp_ref>(__first, __last, __comp, __len, __buf.first, __buf.second);
218}234}
219235
220template <class _RandomAccessIterator>236template <class _RandomAccessIterator>
221inline _LIBCPP_INLINE_VISIBILITY237inline _LIBCPP_HIDE_FROM_ABI
222void238void stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last) {
223stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last)239 std::stable_sort(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
224{
225 _VSTD::stable_sort(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
226}240}
227241
228_LIBCPP_END_NAMESPACE_STD242_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/swap_ranges.h+1-2
...@@ -11,10 +11,9 @@...@@ -11,10 +11,9 @@
1111
12#include <__config>12#include <__config>
13#include <__utility/swap.h>13#include <__utility/swap.h>
14#include <type_traits>
1514
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17#pragma GCC system_header16# pragma GCC system_header
18#endif17#endif
1918
20_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/transform.h+1-1
...@@ -12,7 +12,7 @@...@@ -12,7 +12,7 @@
12#include <__config>12#include <__config>
1313
14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
15#pragma GCC system_header15# pragma GCC system_header
16#endif16#endif
1717
18_LIBCPP_BEGIN_NAMESPACE_STD18_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/unique.h+27-23
...@@ -11,44 +11,48 @@...@@ -11,44 +11,48 @@
1111
12#include <__algorithm/adjacent_find.h>12#include <__algorithm/adjacent_find.h>
13#include <__algorithm/comp.h>13#include <__algorithm/comp.h>
14#include <__algorithm/iterator_operations.h>
14#include <__config>15#include <__config>
15#include <__iterator/iterator_traits.h>16#include <__iterator/iterator_traits.h>
16#include <__utility/move.h>17#include <__utility/move.h>
18#include <__utility/pair.h>
1719
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19#pragma GCC system_header21# pragma GCC system_header
20#endif22#endif
2123
22_LIBCPP_BEGIN_NAMESPACE_STD24_LIBCPP_BEGIN_NAMESPACE_STD
2325
24// unique26// unique
2527
28template <class _AlgPolicy, class _Iter, class _Sent, class _BinaryPredicate>
29_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 std::pair<_Iter, _Iter>
30__unique(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) {
31 __first = std::__adjacent_find(__first, __last, __pred);
32 if (__first != __last) {
33 // ... a a ? ...
34 // f i
35 _Iter __i = __first;
36 for (++__i; ++__i != __last;)
37 if (!__pred(*__first, *__i))
38 *++__first = _IterOps<_AlgPolicy>::__iter_move(__i);
39 ++__first;
40 return std::pair<_Iter, _Iter>(std::move(__first), std::move(__i));
41 }
42 return std::pair<_Iter, _Iter>(__first, __first);
43}
44
26template <class _ForwardIterator, class _BinaryPredicate>45template <class _ForwardIterator, class _BinaryPredicate>
27_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator46_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
28unique(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred)47unique(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred) {
29{48 return std::__unique<_ClassicAlgPolicy>(std::move(__first), std::move(__last), __pred).first;
30 __first = _VSTD::adjacent_find<_ForwardIterator, _BinaryPredicate&>(__first, __last, __pred);
31 if (__first != __last)
32 {
33 // ... a a ? ...
34 // f i
35 _ForwardIterator __i = __first;
36 for (++__i; ++__i != __last;)
37 if (!__pred(*__first, *__i))
38 *++__first = _VSTD::move(*__i);
39 ++__first;
40 }
41 return __first;
42}49}
4350
44template <class _ForwardIterator>51template <class _ForwardIterator>
45_LIBCPP_NODISCARD_EXT inline52_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
46_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1753unique(_ForwardIterator __first, _ForwardIterator __last) {
47_ForwardIterator54 typedef typename iterator_traits<_ForwardIterator>::value_type __v;
48unique(_ForwardIterator __first, _ForwardIterator __last)55 return std::unique(__first, __last, __equal_to<__v>());
49{
50 typedef typename iterator_traits<_ForwardIterator>::value_type __v;
51 return _VSTD::unique(__first, __last, __equal_to<__v>());
52}56}
5357
54_LIBCPP_END_NAMESPACE_STD58_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/unique_copy.h+83-67
...@@ -10,98 +10,114 @@...@@ -10,98 +10,114 @@
10#define _LIBCPP___ALGORITHM_UNIQUE_COPY_H10#define _LIBCPP___ALGORITHM_UNIQUE_COPY_H
1111
12#include <__algorithm/comp.h>12#include <__algorithm/comp.h>
13#include <__algorithm/iterator_operations.h>
13#include <__config>14#include <__config>
14#include <__iterator/iterator_traits.h>15#include <__iterator/iterator_traits.h>
15#include <utility>16#include <__type_traits/conditional.h>
17#include <__type_traits/is_base_of.h>
18#include <__type_traits/is_same.h>
19#include <__utility/move.h>
20#include <__utility/pair.h>
1621
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header23# pragma GCC system_header
19#endif24#endif
2025
21_LIBCPP_BEGIN_NAMESPACE_STD26_LIBCPP_BEGIN_NAMESPACE_STD
2227
23template <class _BinaryPredicate, class _InputIterator, class _OutputIterator>28namespace __unique_copy_tags {
24_LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator29
25__unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryPredicate __pred,30struct __reread_from_input_tag {};
26 input_iterator_tag, output_iterator_tag)31struct __reread_from_output_tag {};
27{32struct __read_from_tmp_value_tag {};
28 if (__first != __last)33
29 {34} // namespace __unique_copy_tags
30 typename iterator_traits<_InputIterator>::value_type __t(*__first);35
36template <class _AlgPolicy, class _BinaryPredicate, class _InputIterator, class _Sent, class _OutputIterator>
37_LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _OutputIterator>
38__unique_copy(_InputIterator __first,
39 _Sent __last,
40 _OutputIterator __result,
41 _BinaryPredicate&& __pred,
42 __unique_copy_tags::__read_from_tmp_value_tag) {
43 if (__first != __last) {
44 typename _IterOps<_AlgPolicy>::template __value_type<_InputIterator> __t(*__first);
45 *__result = __t;
46 ++__result;
47 while (++__first != __last) {
48 if (!__pred(__t, *__first)) {
49 __t = *__first;
31 *__result = __t;50 *__result = __t;
32 ++__result;51 ++__result;
33 while (++__first != __last)52 }
34 {
35 if (!__pred(__t, *__first))
36 {
37 __t = *__first;
38 *__result = __t;
39 ++__result;
40 }
41 }
42 }53 }
43 return __result;54 }
55 return pair<_InputIterator, _OutputIterator>(std::move(__first), std::move(__result));
44}56}
4557
46template <class _BinaryPredicate, class _ForwardIterator, class _OutputIterator>58template <class _AlgPolicy, class _BinaryPredicate, class _ForwardIterator, class _Sent, class _OutputIterator>
47_LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator59_LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI pair<_ForwardIterator, _OutputIterator>
48__unique_copy(_ForwardIterator __first, _ForwardIterator __last, _OutputIterator __result, _BinaryPredicate __pred,60__unique_copy(_ForwardIterator __first,
49 forward_iterator_tag, output_iterator_tag)61 _Sent __last,
50{62 _OutputIterator __result,
51 if (__first != __last)63 _BinaryPredicate&& __pred,
52 {64 __unique_copy_tags::__reread_from_input_tag) {
53 _ForwardIterator __i = __first;65 if (__first != __last) {
54 *__result = *__i;66 _ForwardIterator __i = __first;
67 *__result = *__i;
68 ++__result;
69 while (++__first != __last) {
70 if (!__pred(*__i, *__first)) {
71 *__result = *__first;
55 ++__result;72 ++__result;
56 while (++__first != __last)73 __i = __first;
57 {74 }
58 if (!__pred(*__i, *__first))
59 {
60 *__result = *__first;
61 ++__result;
62 __i = __first;
63 }
64 }
65 }75 }
66 return __result;76 }
77 return pair<_ForwardIterator, _OutputIterator>(std::move(__first), std::move(__result));
67}78}
6879
69template <class _BinaryPredicate, class _InputIterator, class _ForwardIterator>80template <class _AlgPolicy, class _BinaryPredicate, class _InputIterator, class _Sent, class _InputAndOutputIterator>
70_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator81_LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _InputAndOutputIterator>
71__unique_copy(_InputIterator __first, _InputIterator __last, _ForwardIterator __result, _BinaryPredicate __pred,82__unique_copy(_InputIterator __first,
72 input_iterator_tag, forward_iterator_tag)83 _Sent __last,
73{84 _InputAndOutputIterator __result,
74 if (__first != __last)85 _BinaryPredicate&& __pred,
75 {86 __unique_copy_tags::__reread_from_output_tag) {
76 *__result = *__first;87 if (__first != __last) {
77 while (++__first != __last)88 *__result = *__first;
78 if (!__pred(*__result, *__first))89 while (++__first != __last)
79 *++__result = *__first;90 if (!__pred(*__result, *__first))
80 ++__result;91 *++__result = *__first;
81 }92 ++__result;
82 return __result;93 }
94 return pair<_InputIterator, _InputAndOutputIterator>(std::move(__first), std::move(__result));
83}95}
8496
85template <class _InputIterator, class _OutputIterator, class _BinaryPredicate>97template <class _InputIterator, class _OutputIterator, class _BinaryPredicate>
86inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1798inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator
87_OutputIterator99unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryPredicate __pred) {
88unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryPredicate __pred)100 using __algo_tag = typename conditional<
89{101 is_base_of<forward_iterator_tag, typename iterator_traits<_InputIterator>::iterator_category>::value,
90 return _VSTD::__unique_copy<_BinaryPredicate&>(__first, __last, __result, __pred,102 __unique_copy_tags::__reread_from_input_tag,
91 typename iterator_traits<_InputIterator>::iterator_category(),103 typename conditional<
92 typename iterator_traits<_OutputIterator>::iterator_category());104 is_base_of<forward_iterator_tag, typename iterator_traits<_OutputIterator>::iterator_category>::value &&
105 is_same< typename iterator_traits<_InputIterator>::value_type,
106 typename iterator_traits<_OutputIterator>::value_type>::value,
107 __unique_copy_tags::__reread_from_output_tag,
108 __unique_copy_tags::__read_from_tmp_value_tag>::type >::type;
109 return std::__unique_copy<_ClassicAlgPolicy>(
110 std::move(__first), std::move(__last), std::move(__result), __pred, __algo_tag())
111 .second;
93}112}
94113
95template <class _InputIterator, class _OutputIterator>114template <class _InputIterator, class _OutputIterator>
96inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17115inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator
97_OutputIterator116unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result) {
98unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result)117 typedef typename iterator_traits<_InputIterator>::value_type __v;
99{118 return std::unique_copy(std::move(__first), std::move(__last), std::move(__result), __equal_to<__v>());
100 typedef typename iterator_traits<_InputIterator>::value_type __v;
101 return _VSTD::unique_copy(__first, __last, __result, __equal_to<__v>());
102}119}
103120
104
105_LIBCPP_END_NAMESPACE_STD121_LIBCPP_END_NAMESPACE_STD
106122
107#endif // _LIBCPP___ALGORITHM_UNIQUE_COPY_H123#endif // _LIBCPP___ALGORITHM_UNIQUE_COPY_H
lib/libcxx/include/__algorithm/unwrap_iter.h+31-43
...@@ -10,73 +10,61 @@...@@ -10,73 +10,61 @@
10#define _LIBCPP___ALGORITHM_UNWRAP_ITER_H10#define _LIBCPP___ALGORITHM_UNWRAP_ITER_H
1111
12#include <__config>12#include <__config>
13#include <__iterator/iterator_traits.h>
13#include <__memory/pointer_traits.h>14#include <__memory/pointer_traits.h>
14#include <iterator>15#include <__utility/move.h>
15#include <type_traits>16#include <type_traits>
1617
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header19# pragma GCC system_header
19#endif20#endif
2021
21_LIBCPP_BEGIN_NAMESPACE_STD22_LIBCPP_BEGIN_NAMESPACE_STD
2223
23// The job of __unwrap_iter is to lower contiguous iterators (such as24// TODO: Change the name of __unwrap_iter_impl to something more appropriate
24// vector<T>::iterator) into pointers, to reduce the number of template25// The job of __unwrap_iter is to remove iterator wrappers (like reverse_iterator or __wrap_iter),
25// instantiations and to enable pointer-based optimizations e.g. in std::copy.26// to reduce the number of template instantiations and to enable pointer-based optimizations e.g. in std::copy.
26// For iterators that are not contiguous, it must be a no-op.
27// In debug mode, we don't do this.27// In debug mode, we don't do this.
28//28//
29// __unwrap_iter is non-constexpr for user-defined iterators whose
30// `to_address` and/or `operator->` is non-constexpr. This is okay; but we
31// try to avoid doing __unwrap_iter in constant-evaluated contexts anyway.
32//
33// Some algorithms (e.g. std::copy, but not std::sort) need to convert an29// Some algorithms (e.g. std::copy, but not std::sort) need to convert an
34// "unwrapped" result back into a contiguous iterator. Since contiguous iterators30// "unwrapped" result back into the original iterator type. Doing that is the job of __rewrap_iter.
35// are random-access, we can do this portably using iterator arithmetic; this
36// is the job of __rewrap_iter.
3731
32// Default case - we can't unwrap anything
38template <class _Iter, bool = __is_cpp17_contiguous_iterator<_Iter>::value>33template <class _Iter, bool = __is_cpp17_contiguous_iterator<_Iter>::value>
39struct __unwrap_iter_impl {34struct __unwrap_iter_impl {
40 static _LIBCPP_CONSTEXPR _Iter35 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Iter __rewrap(_Iter, _Iter __iter) { return __iter; }
41 __apply(_Iter __i) _NOEXCEPT {36 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Iter __unwrap(_Iter __i) _NOEXCEPT { return __i; }
42 return __i;
43 }
44};37};
4538
46#if _LIBCPP_DEBUG_LEVEL < 239#ifndef _LIBCPP_ENABLE_DEBUG_MODE
4740
41// It's a contiguous iterator, so we can use a raw pointer instead
48template <class _Iter>42template <class _Iter>
49struct __unwrap_iter_impl<_Iter, true> {43struct __unwrap_iter_impl<_Iter, true> {
50 static _LIBCPP_CONSTEXPR decltype(_VSTD::__to_address(declval<_Iter>()))44 using _ToAddressT = decltype(std::__to_address(std::declval<_Iter>()));
51 __apply(_Iter __i) _NOEXCEPT {
52 return _VSTD::__to_address(__i);
53 }
54};
5545
56#endif // _LIBCPP_DEBUG_LEVEL < 246 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Iter __rewrap(_Iter __orig_iter, _ToAddressT __unwrapped_iter) {
47 return __orig_iter + (__unwrapped_iter - std::__to_address(__orig_iter));
48 }
5749
58template<class _Iter, class _Impl = __unwrap_iter_impl<_Iter> >50 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToAddressT __unwrap(_Iter __i) _NOEXCEPT {
59inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR51 return std::__to_address(__i);
60decltype(_Impl::__apply(declval<_Iter>()))52 }
61__unwrap_iter(_Iter __i) _NOEXCEPT53};
62{54
63 return _Impl::__apply(__i);55#endif // !_LIBCPP_ENABLE_DEBUG_MODE
64}
6556
66template<class _OrigIter>57template<class _Iter,
67_LIBCPP_HIDE_FROM_ABI58 class _Impl = __unwrap_iter_impl<_Iter>,
68_OrigIter __rewrap_iter(_OrigIter, _OrigIter __result)59 __enable_if_t<is_copy_constructible<_Iter>::value, int> = 0>
69{60inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
70 return __result;61decltype(_Impl::__unwrap(std::declval<_Iter>())) __unwrap_iter(_Iter __i) _NOEXCEPT {
62 return _Impl::__unwrap(__i);
71}63}
7264
73template<class _OrigIter, class _UnwrappedIter>65template <class _OrigIter, class _Iter, class _Impl = __unwrap_iter_impl<_OrigIter> >
74_LIBCPP_HIDE_FROM_ABI66_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _OrigIter __rewrap_iter(_OrigIter __orig_iter, _Iter __iter) _NOEXCEPT {
75_OrigIter __rewrap_iter(_OrigIter __first, _UnwrappedIter __result)67 return _Impl::__rewrap(std::move(__orig_iter), std::move(__iter));
76{
77 // Precondition: __result is reachable from __first
78 // Precondition: _OrigIter is a contiguous iterator
79 return __first + (__result - _VSTD::__unwrap_iter(__first));
80}68}
8169
82_LIBCPP_END_NAMESPACE_STD70_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/unwrap_range.h created+97
...@@ -0,0 +1,97 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_UNWRAP_RANGE_H
10#define _LIBCPP___ALGORITHM_UNWRAP_RANGE_H
11
12#include <__algorithm/unwrap_iter.h>
13#include <__concepts/constructible.h>
14#include <__config>
15#include <__iterator/concepts.h>
16#include <__iterator/next.h>
17#include <__utility/declval.h>
18#include <__utility/move.h>
19#include <__utility/pair.h>
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// __unwrap_range and __rewrap_range are used to unwrap ranges which may have different iterator and sentinel types.
28// __unwrap_iter and __rewrap_iter don't work for this, because they assume that the iterator and sentinel have
29// the same type. __unwrap_range tries to get two iterators and then forward to __unwrap_iter.
30
31#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
32template <class _Iter, class _Sent>
33struct __unwrap_range_impl {
34 _LIBCPP_HIDE_FROM_ABI static constexpr auto __unwrap(_Iter __first, _Sent __sent)
35 requires random_access_iterator<_Iter> && sized_sentinel_for<_Sent, _Iter>
36 {
37 auto __last = ranges::next(__first, __sent);
38 return pair{std::__unwrap_iter(std::move(__first)), std::__unwrap_iter(std::move(__last))};
39 }
40
41 _LIBCPP_HIDE_FROM_ABI static constexpr auto __unwrap(_Iter __first, _Sent __last) {
42 return pair{std::move(__first), std::move(__last)};
43 }
44
45 _LIBCPP_HIDE_FROM_ABI static constexpr auto
46 __rewrap(_Iter __orig_iter, decltype(std::__unwrap_iter(__orig_iter)) __iter)
47 requires random_access_iterator<_Iter> && sized_sentinel_for<_Sent, _Iter>
48 {
49 return std::__rewrap_iter(std::move(__orig_iter), std::move(__iter));
50 }
51
52 _LIBCPP_HIDE_FROM_ABI static constexpr auto __rewrap(const _Iter&, _Iter __iter)
53 requires (!(random_access_iterator<_Iter> && sized_sentinel_for<_Sent, _Iter>))
54 {
55 return __iter;
56 }
57};
58
59template <class _Iter>
60struct __unwrap_range_impl<_Iter, _Iter> {
61 _LIBCPP_HIDE_FROM_ABI static constexpr auto __unwrap(_Iter __first, _Iter __last) {
62 return pair{std::__unwrap_iter(std::move(__first)), std::__unwrap_iter(std::move(__last))};
63 }
64
65 _LIBCPP_HIDE_FROM_ABI static constexpr auto
66 __rewrap(_Iter __orig_iter, decltype(std::__unwrap_iter(__orig_iter)) __iter) {
67 return std::__rewrap_iter(std::move(__orig_iter), std::move(__iter));
68 }
69};
70
71template <class _Iter, class _Sent>
72_LIBCPP_HIDE_FROM_ABI constexpr auto __unwrap_range(_Iter __first, _Sent __last) {
73 return __unwrap_range_impl<_Iter, _Sent>::__unwrap(std::move(__first), std::move(__last));
74}
75
76template <
77 class _Sent,
78 class _Iter,
79 class _Unwrapped = decltype(std::__unwrap_range(std::declval<_Iter>(), std::declval<_Sent>()))>
80_LIBCPP_HIDE_FROM_ABI constexpr _Iter __rewrap_range(_Iter __orig_iter, _Unwrapped __iter) {
81 return __unwrap_range_impl<_Iter, _Sent>::__rewrap(std::move(__orig_iter), std::move(__iter));
82}
83#else // _LIBCPP_STD_VER > 17
84template <class _Iter, class _Unwrapped = decltype(std::__unwrap_iter(std::declval<_Iter>()))>
85_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR pair<_Unwrapped, _Unwrapped> __unwrap_range(_Iter __first, _Iter __last) {
86 return std::make_pair(std::__unwrap_iter(std::move(__first)), std::__unwrap_iter(std::move(__last)));
87}
88
89template <class _Iter, class _Unwrapped = decltype(std::__unwrap_iter(std::declval<_Iter>()))>
90_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Iter __rewrap_range(_Iter __orig_iter, _Unwrapped __iter) {
91 return std::__rewrap_iter(std::move(__orig_iter), std::move(__iter));
92}
93#endif // _LIBCPP_STD_VER > 17
94
95_LIBCPP_END_NAMESPACE_STD
96
97#endif // _LIBCPP___ALGORITHM_UNWRAP_RANGE_H
lib/libcxx/include/__algorithm/upper_bound.h+36-34
...@@ -11,54 +11,56 @@...@@ -11,54 +11,56 @@
1111
12#include <__algorithm/comp.h>12#include <__algorithm/comp.h>
13#include <__algorithm/half_positive.h>13#include <__algorithm/half_positive.h>
14#include <__algorithm/iterator_operations.h>
14#include <__config>15#include <__config>
15#include <iterator>16#include <__functional/identity.h>
17#include <__functional/invoke.h>
18#include <__iterator/advance.h>
19#include <__iterator/distance.h>
20#include <__iterator/iterator_traits.h>
21#include <__type_traits/is_copy_constructible.h>
22#include <__utility/move.h>
1623
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)24#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header25# pragma GCC system_header
19#endif26#endif
2027
21_LIBCPP_BEGIN_NAMESPACE_STD28_LIBCPP_BEGIN_NAMESPACE_STD
2229
23template <class _Compare, class _ForwardIterator, class _Tp>30template <class _AlgPolicy, class _Compare, class _Iter, class _Sent, class _Tp, class _Proj>
24_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator31_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _Iter
25__upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)32__upper_bound(_Iter __first, _Sent __last, const _Tp& __value, _Compare&& __comp, _Proj&& __proj) {
26{33 auto __len = _IterOps<_AlgPolicy>::distance(__first, __last);
27 typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type;34 while (__len != 0) {
28 difference_type __len = _VSTD::distance(__first, __last);35 auto __half_len = std::__half_positive(__len);
29 while (__len != 0)36 auto __mid = _IterOps<_AlgPolicy>::next(__first, __half_len);
30 {37 if (std::__invoke(__comp, __value, std::__invoke(__proj, *__mid)))
31 difference_type __l2 = _VSTD::__half_positive(__len);38 __len = __half_len;
32 _ForwardIterator __m = __first;39 else {
33 _VSTD::advance(__m, __l2);40 __first = ++__mid;
34 if (__comp(__value_, *__m))41 __len -= __half_len + 1;
35 __len = __l2;
36 else
37 {
38 __first = ++__m;
39 __len -= __l2 + 1;
40 }
41 }42 }
42 return __first;43 }
44 return __first;
43}45}
4446
45template <class _ForwardIterator, class _Tp, class _Compare>47template <class _ForwardIterator, class _Tp, class _Compare>
46_LIBCPP_NODISCARD_EXT inline48_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
47_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1749upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) {
48_ForwardIterator50 static_assert(is_copy_constructible<_ForwardIterator>::value,
49upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)51 "Iterator has to be copy constructible");
50{52 return std::__upper_bound<_ClassicAlgPolicy>(
51 return _VSTD::__upper_bound<_Compare&>(__first, __last, __value_, __comp);53 std::move(__first), std::move(__last), __value, std::move(__comp), std::__identity());
52}54}
5355
54template <class _ForwardIterator, class _Tp>56template <class _ForwardIterator, class _Tp>
55_LIBCPP_NODISCARD_EXT inline57_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
56_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1758upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {
57_ForwardIterator59 return std::upper_bound(
58upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)60 std::move(__first),
59{61 std::move(__last),
60 return _VSTD::upper_bound(__first, __last, __value_,62 __value,
61 __less<_Tp, typename iterator_traits<_ForwardIterator>::value_type>());63 __less<_Tp, typename iterator_traits<_ForwardIterator>::value_type>());
62}64}
6365
64_LIBCPP_END_NAMESPACE_STD66_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__assert 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___ASSERT
11#define _LIBCPP___ASSERT
12
13#include <__config>
14#include <__verbose_abort>
15
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header
18#endif
19
20// This is for backwards compatibility with code that might have been enabling
21// assertions through the Debug mode previously.
22// TODO: In LLVM 16, make it an error to define _LIBCPP_DEBUG
23#if defined(_LIBCPP_DEBUG)
24# ifndef _LIBCPP_ENABLE_ASSERTIONS
25# define _LIBCPP_ENABLE_ASSERTIONS 1
26# endif
27#endif
28
29// Automatically enable assertions when the debug mode is enabled.
30#if defined(_LIBCPP_ENABLE_DEBUG_MODE)
31# ifndef _LIBCPP_ENABLE_ASSERTIONS
32# define _LIBCPP_ENABLE_ASSERTIONS 1
33# endif
34#endif
35
36#ifndef _LIBCPP_ENABLE_ASSERTIONS
37# define _LIBCPP_ENABLE_ASSERTIONS _LIBCPP_ENABLE_ASSERTIONS_DEFAULT
38#endif
39
40#if _LIBCPP_ENABLE_ASSERTIONS != 0 && _LIBCPP_ENABLE_ASSERTIONS != 1
41# error "_LIBCPP_ENABLE_ASSERTIONS must be set to 0 or 1"
42#endif
43
44#if _LIBCPP_ENABLE_ASSERTIONS
45# define _LIBCPP_ASSERT(expression, message) \
46 (__builtin_expect(static_cast<bool>(expression), 1) ? \
47 (void)0 : \
48 ::std::__libcpp_verbose_abort("%s:%d: assertion %s failed: %s", __FILE__, __LINE__, #expression, message))
49#elif !defined(_LIBCPP_ASSERTIONS_DISABLE_ASSUME) && __has_builtin(__builtin_assume)
50# define _LIBCPP_ASSERT(expression, message) \
51 (_LIBCPP_DIAGNOSTIC_PUSH \
52 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wassume") \
53 __builtin_assume(static_cast<bool>(expression)) \
54 _LIBCPP_DIAGNOSTIC_POP)
55#else
56# define _LIBCPP_ASSERT(expression, message) ((void)0)
57#endif
58
59#endif // _LIBCPP___ASSERT
lib/libcxx/include/__availability+60-28
...@@ -13,7 +13,7 @@...@@ -13,7 +13,7 @@
13#include <__config>13#include <__config>
1414
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header16# pragma GCC system_header
17#endif17#endif
1818
19// Libc++ is shipped by various vendors. In particular, it is used as a system19// Libc++ is shipped by various vendors. In particular, it is used as a system
...@@ -91,6 +91,10 @@...@@ -91,6 +91,10 @@
91 // other exception types. These were put in the shared library to prevent91 // other exception types. These were put in the shared library to prevent
92 // code bloat from every user program defining the vtable for these exception92 // code bloat from every user program defining the vtable for these exception
93 // types.93 // types.
94 //
95 // Note that when exceptions are disabled, the methods that normally throw
96 // these exceptions can be used even on older deployment targets, but those
97 // methods will abort instead of throwing.
94# define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS98# define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
95# define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS99# define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS
96# define _LIBCPP_AVAILABILITY_BAD_ANY_CAST100# define _LIBCPP_AVAILABILITY_BAD_ANY_CAST
...@@ -99,10 +103,15 @@...@@ -99,10 +103,15 @@
99# define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS103# define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS
100104
101 // This controls the availability of the sized version of ::operator delete,105 // This controls the availability of the sized version of ::operator delete,
102 // which was added to the dylib later.106 // ::operator delete[], and their align_val_t variants, which were all added
107 // in C++17, and hence not present in early dylibs.
103# define _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE108# define _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE
104109
105 // This controls the availability of the std::future_error exception.110 // This controls the availability of the std::future_error exception.
111 //
112 // Note that when exceptions are disabled, the methods that normally throw
113 // std::future_error can be used even on older deployment targets, but those
114 // methods will abort instead of throwing.
106# define _LIBCPP_AVAILABILITY_FUTURE_ERROR115# define _LIBCPP_AVAILABILITY_FUTURE_ERROR
107116
108 // This controls the availability of std::type_info's vtable.117 // This controls the availability of std::type_info's vtable.
...@@ -126,16 +135,14 @@...@@ -126,16 +135,14 @@
126# define _LIBCPP_AVAILABILITY_FILESYSTEM_POP135# define _LIBCPP_AVAILABILITY_FILESYSTEM_POP
127// # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_filesystem136// # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_filesystem
128137
129 // This controls the availability of std::to_chars.
130# define _LIBCPP_AVAILABILITY_TO_CHARS
131
132 // This controls the availability of floating-point std::to_chars functions.138 // This controls the availability of floating-point std::to_chars functions.
133 // These overloads were added later than the integer overloads.139 // These overloads were added later than the integer overloads.
134# define _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT140# define _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT
135141
136 // This controls the availability of the C++20 synchronization library,142 // This controls the availability of the C++20 synchronization library,
137 // which requires shared library support for various operations143 // which requires shared library support for various operations
138 // (see libcxx/src/atomic.cpp).144 // (see libcxx/src/atomic.cpp). This includes <barier>, <latch>,
145 // <semaphore>, and notification functions on std::atomic.
139# define _LIBCPP_AVAILABILITY_SYNC146# define _LIBCPP_AVAILABILITY_SYNC
140// # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_atomic_wait147// # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_atomic_wait
141// # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_barrier148// # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_barrier
...@@ -149,10 +156,26 @@...@@ -149,10 +156,26 @@
149# define _LIBCPP_AVAILABILITY_FORMAT156# define _LIBCPP_AVAILABILITY_FORMAT
150// # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format157// # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format
151158
159 // This controls whether the default verbose termination function is
160 // provided by the library.
161 //
162 // Note that when users provide their own custom function, it doesn't
163 // matter whether the dylib provides a default function, and the
164 // availability markup can actually give a false positive diagnostic
165 // (it will think that no function is provided, when in reality the
166 // user has provided their own).
167 //
168 // Users can pass -D_LIBCPP_AVAILABILITY_CUSTOM_VERBOSE_ABORT_PROVIDED
169 // to the compiler to tell the library to ignore the fact that the
170 // default function isn't available on their deployment target. Note that
171 // defining this macro but failing to define a custom function will lead to
172 // a load-time error on back-deployment targets, so it should be avoided.
173# define _LIBCPP_AVAILABILITY_DEFAULT_VERBOSE_ABORT
174
152#elif defined(__APPLE__)175#elif defined(__APPLE__)
153176
154# define _LIBCPP_AVAILABILITY_SHARED_MUTEX \177# define _LIBCPP_AVAILABILITY_SHARED_MUTEX \
155 __attribute__((availability(macosx,strict,introduced=10.12))) \178 __attribute__((availability(macos,strict,introduced=10.12))) \
156 __attribute__((availability(ios,strict,introduced=10.0))) \179 __attribute__((availability(ios,strict,introduced=10.0))) \
157 __attribute__((availability(tvos,strict,introduced=10.0))) \180 __attribute__((availability(tvos,strict,introduced=10.0))) \
158 __attribute__((availability(watchos,strict,introduced=3.0)))181 __attribute__((availability(watchos,strict,introduced=3.0)))
...@@ -164,24 +187,27 @@...@@ -164,24 +187,27 @@
164# define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_shared_timed_mutex187# define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_shared_timed_mutex
165# endif188# endif
166189
190 // Note: bad_optional_access & friends were not introduced in the matching
191 // macOS and iOS versions, so the version mismatch between macOS and others
192 // is intended.
167# define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS \193# define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS \
168 __attribute__((availability(macosx,strict,introduced=10.13))) \194 __attribute__((availability(macos,strict,introduced=10.13))) \
169 __attribute__((availability(ios,strict,introduced=11.0))) \195 __attribute__((availability(ios,strict,introduced=12.0))) \
170 __attribute__((availability(tvos,strict,introduced=11.0))) \196 __attribute__((availability(tvos,strict,introduced=12.0))) \
171 __attribute__((availability(watchos,strict,introduced=4.0)))197 __attribute__((availability(watchos,strict,introduced=5.0)))
172# define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS \198# define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS \
173 _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS199 _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
174# define _LIBCPP_AVAILABILITY_BAD_ANY_CAST \200# define _LIBCPP_AVAILABILITY_BAD_ANY_CAST \
175 _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS201 _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
176202
177# define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS \203# define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS \
178 __attribute__((availability(macosx,strict,introduced=10.12))) \204 __attribute__((availability(macos,strict,introduced=10.12))) \
179 __attribute__((availability(ios,strict,introduced=10.0))) \205 __attribute__((availability(ios,strict,introduced=10.0))) \
180 __attribute__((availability(tvos,strict,introduced=10.0))) \206 __attribute__((availability(tvos,strict,introduced=10.0))) \
181 __attribute__((availability(watchos,strict,introduced=3.0)))207 __attribute__((availability(watchos,strict,introduced=3.0)))
182208
183# define _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE \209# define _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE \
184 __attribute__((availability(macosx,strict,introduced=10.12))) \210 __attribute__((availability(macos,strict,introduced=10.12))) \
185 __attribute__((availability(ios,strict,introduced=10.0))) \211 __attribute__((availability(ios,strict,introduced=10.0))) \
186 __attribute__((availability(tvos,strict,introduced=10.0))) \212 __attribute__((availability(tvos,strict,introduced=10.0))) \
187 __attribute__((availability(watchos,strict,introduced=3.0)))213 __attribute__((availability(watchos,strict,introduced=3.0)))
...@@ -190,26 +216,26 @@...@@ -190,26 +216,26 @@
190 __attribute__((availability(ios,strict,introduced=6.0)))216 __attribute__((availability(ios,strict,introduced=6.0)))
191217
192# define _LIBCPP_AVAILABILITY_TYPEINFO_VTABLE \218# define _LIBCPP_AVAILABILITY_TYPEINFO_VTABLE \
193 __attribute__((availability(macosx,strict,introduced=10.9))) \219 __attribute__((availability(macos,strict,introduced=10.9))) \
194 __attribute__((availability(ios,strict,introduced=7.0)))220 __attribute__((availability(ios,strict,introduced=7.0)))
195221
196# define _LIBCPP_AVAILABILITY_LOCALE_CATEGORY \222# define _LIBCPP_AVAILABILITY_LOCALE_CATEGORY \
197 __attribute__((availability(macosx,strict,introduced=10.9))) \223 __attribute__((availability(macos,strict,introduced=10.9))) \
198 __attribute__((availability(ios,strict,introduced=7.0)))224 __attribute__((availability(ios,strict,introduced=7.0)))
199225
200# define _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR \226# define _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR \
201 __attribute__((availability(macosx,strict,introduced=10.9))) \227 __attribute__((availability(macos,strict,introduced=10.9))) \
202 __attribute__((availability(ios,strict,introduced=7.0)))228 __attribute__((availability(ios,strict,introduced=7.0)))
203229
204# define _LIBCPP_AVAILABILITY_FILESYSTEM \230# define _LIBCPP_AVAILABILITY_FILESYSTEM \
205 __attribute__((availability(macosx,strict,introduced=10.15))) \231 __attribute__((availability(macos,strict,introduced=10.15))) \
206 __attribute__((availability(ios,strict,introduced=13.0))) \232 __attribute__((availability(ios,strict,introduced=13.0))) \
207 __attribute__((availability(tvos,strict,introduced=13.0))) \233 __attribute__((availability(tvos,strict,introduced=13.0))) \
208 __attribute__((availability(watchos,strict,introduced=6.0)))234 __attribute__((availability(watchos,strict,introduced=6.0)))
209# define _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH \235# define _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH \
210 _Pragma("clang attribute push(__attribute__((availability(macosx,strict,introduced=10.15))), apply_to=any(function,record))") \236 _Pragma("clang attribute push(__attribute__((availability(macos,strict,introduced=10.15))), apply_to=any(function,record))") \
211 _Pragma("clang attribute push(__attribute__((availability(ios,strict,introduced=13.0))), apply_to=any(function,record))") \237 _Pragma("clang attribute push(__attribute__((availability(ios,strict,introduced=13.0))), apply_to=any(function,record))") \
212 _Pragma("clang attribute push(__attribute__((availability(tvos,strict,introduced=13.0))), apply_to=any(function,record))") \238 _Pragma("clang attribute push(__attribute__((availability(tvos,strict,introduced=13.0))), apply_to=any(function,record))") \
213 _Pragma("clang attribute push(__attribute__((availability(watchos,strict,introduced=6.0))), apply_to=any(function,record))")239 _Pragma("clang attribute push(__attribute__((availability(watchos,strict,introduced=6.0))), apply_to=any(function,record))")
214# define _LIBCPP_AVAILABILITY_FILESYSTEM_POP \240# define _LIBCPP_AVAILABILITY_FILESYSTEM_POP \
215 _Pragma("clang attribute pop") \241 _Pragma("clang attribute pop") \
...@@ -223,14 +249,11 @@...@@ -223,14 +249,11 @@
223# define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_filesystem249# define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_filesystem
224# endif250# endif
225251
226# define _LIBCPP_AVAILABILITY_TO_CHARS \
227 _LIBCPP_AVAILABILITY_FILESYSTEM
228
229# define _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT \252# define _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT \
230 __attribute__((unavailable))253 __attribute__((unavailable))
231254
232# define _LIBCPP_AVAILABILITY_SYNC \255# define _LIBCPP_AVAILABILITY_SYNC \
233 __attribute__((availability(macosx,strict,introduced=11.0))) \256 __attribute__((availability(macos,strict,introduced=11.0))) \
234 __attribute__((availability(ios,strict,introduced=14.0))) \257 __attribute__((availability(ios,strict,introduced=14.0))) \
235 __attribute__((availability(tvos,strict,introduced=14.0))) \258 __attribute__((availability(tvos,strict,introduced=14.0))) \
236 __attribute__((availability(watchos,strict,introduced=7.0)))259 __attribute__((availability(watchos,strict,introduced=7.0)))
...@@ -244,13 +267,12 @@...@@ -244,13 +267,12 @@
244# define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_semaphore267# define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_semaphore
245# endif268# endif
246269
247 // This controls the availability of the C++20 format library.
248 // The library is in development and not ABI stable yet. P2216 is
249 // retroactively accepted in C++20. This paper contains ABI breaking
250 // changes.
251# define _LIBCPP_AVAILABILITY_FORMAT \270# define _LIBCPP_AVAILABILITY_FORMAT \
252 __attribute__((unavailable))271 __attribute__((unavailable))
253# define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format272# define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format
273
274# define _LIBCPP_AVAILABILITY_DEFAULT_VERBOSE_ABORT \
275 __attribute__((unavailable))
254#else276#else
255277
256// ...New vendors can add availability markup here...278// ...New vendors can add availability markup here...
...@@ -274,4 +296,14 @@...@@ -274,4 +296,14 @@
274# define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS296# define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS
275#endif297#endif
276298
299// Define the special verbose termination function availability attribute, which can be silenced by
300// users if they provide their own custom function. The rest of the code should not use the
301// *_DEFAULT_* macro directly, since that would make it ignore the fact that the user provided
302// a custom function.
303#if defined(_LIBCPP_AVAILABILITY_CUSTOM_VERBOSE_ABORT_PROVIDED)
304# define _LIBCPP_AVAILABILITY_VERBOSE_ABORT /* nothing */
305#else
306# define _LIBCPP_AVAILABILITY_VERBOSE_ABORT _LIBCPP_AVAILABILITY_DEFAULT_VERBOSE_ABORT
307#endif
308
277#endif // _LIBCPP___AVAILABILITY309#endif // _LIBCPP___AVAILABILITY
lib/libcxx/include/__bit/bit_cast.h+7-9
...@@ -14,21 +14,19 @@...@@ -14,21 +14,19 @@
14#include <type_traits>14#include <type_traits>
1515
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17#pragma GCC system_header17# pragma GCC system_header
18#endif18#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
2121
22#if _LIBCPP_STD_VER > 1722#if _LIBCPP_STD_VER > 17
2323
24template<class _ToType, class _FromType, class = enable_if_t<24template <class _ToType, class _FromType>
25 sizeof(_ToType) == sizeof(_FromType) &&25 requires(sizeof(_ToType) == sizeof(_FromType) &&
26 is_trivially_copyable_v<_ToType> &&26 is_trivially_copyable_v<_ToType> &&
27 is_trivially_copyable_v<_FromType>27 is_trivially_copyable_v<_FromType>)
28>>28_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _ToType bit_cast(const _FromType& __from) noexcept {
29_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI29 return __builtin_bit_cast(_ToType, __from);
30constexpr _ToType bit_cast(_FromType const& __from) noexcept {
31 return __builtin_bit_cast(_ToType, __from);
32}30}
3331
34#endif // _LIBCPP_STD_VER > 1732#endif // _LIBCPP_STD_VER > 17
lib/libcxx/include/__bit/byteswap.h+2-2
...@@ -21,7 +21,7 @@...@@ -21,7 +21,7 @@
2121
22_LIBCPP_BEGIN_NAMESPACE_STD22_LIBCPP_BEGIN_NAMESPACE_STD
2323
24#if _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_CONCEPTS)24#if _LIBCPP_STD_VER > 20
2525
26template <integral _Tp>26template <integral _Tp>
27_LIBCPP_HIDE_FROM_ABI constexpr _Tp byteswap(_Tp __val) noexcept {27_LIBCPP_HIDE_FROM_ABI constexpr _Tp byteswap(_Tp __val) noexcept {
...@@ -48,7 +48,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp byteswap(_Tp __val) noexcept {...@@ -48,7 +48,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp byteswap(_Tp __val) noexcept {
48 }48 }
49}49}
5050
51#endif // _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_CONCEPTS)51#endif // _LIBCPP_STD_VER > 20
5252
53_LIBCPP_END_NAMESPACE_STD53_LIBCPP_END_NAMESPACE_STD
5454
lib/libcxx/include/__bit_reference+172-117
...@@ -10,12 +10,19 @@...@@ -10,12 +10,19 @@
10#ifndef _LIBCPP___BIT_REFERENCE10#ifndef _LIBCPP___BIT_REFERENCE
11#define _LIBCPP___BIT_REFERENCE11#define _LIBCPP___BIT_REFERENCE
1212
13#include <__algorithm/copy_n.h>
14#include <__algorithm/fill_n.h>
15#include <__algorithm/min.h>
13#include <__bits>16#include <__bits>
14#include <__config>17#include <__config>
15#include <algorithm>18#include <__iterator/iterator_traits.h>
19#include <__memory/construct_at.h>
20#include <__memory/pointer_traits.h>
21#include <cstring>
22#include <type_traits>
1623
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)24#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header25# pragma GCC system_header
19#endif26#endif
2027
21_LIBCPP_PUSH_MACROS28_LIBCPP_PUSH_MACROS
...@@ -47,15 +54,15 @@ class __bit_reference...@@ -47,15 +54,15 @@ class __bit_reference
47 friend class __bit_const_reference<_Cp>;54 friend class __bit_const_reference<_Cp>;
48 friend class __bit_iterator<_Cp, false>;55 friend class __bit_iterator<_Cp, false>;
49public:56public:
50 _LIBCPP_INLINE_VISIBILITY57 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
51 __bit_reference(const __bit_reference&) = default;58 __bit_reference(const __bit_reference&) = default;
5259
53 _LIBCPP_INLINE_VISIBILITY operator bool() const _NOEXCEPT60 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 operator bool() const _NOEXCEPT
54 {return static_cast<bool>(*__seg_ & __mask_);}61 {return static_cast<bool>(*__seg_ & __mask_);}
55 _LIBCPP_INLINE_VISIBILITY bool operator ~() const _NOEXCEPT62 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool operator ~() const _NOEXCEPT
56 {return !static_cast<bool>(*this);}63 {return !static_cast<bool>(*this);}
5764
58 _LIBCPP_INLINE_VISIBILITY65 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
59 __bit_reference& operator=(bool __x) _NOEXCEPT66 __bit_reference& operator=(bool __x) _NOEXCEPT
60 {67 {
61 if (__x)68 if (__x)
...@@ -65,16 +72,26 @@ public:...@@ -65,16 +72,26 @@ public:
65 return *this;72 return *this;
66 }73 }
6774
68 _LIBCPP_INLINE_VISIBILITY75#if _LIBCPP_STD_VER > 20
76 _LIBCPP_HIDE_FROM_ABI constexpr const __bit_reference& operator=(bool __x) const noexcept {
77 if (__x)
78 *__seg_ |= __mask_;
79 else
80 *__seg_ &= ~__mask_;
81 return *this;
82 }
83#endif
84
85 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
69 __bit_reference& operator=(const __bit_reference& __x) _NOEXCEPT86 __bit_reference& operator=(const __bit_reference& __x) _NOEXCEPT
70 {return operator=(static_cast<bool>(__x));}87 {return operator=(static_cast<bool>(__x));}
7188
72 _LIBCPP_INLINE_VISIBILITY void flip() _NOEXCEPT {*__seg_ ^= __mask_;}89 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void flip() _NOEXCEPT {*__seg_ ^= __mask_;}
73 _LIBCPP_INLINE_VISIBILITY __bit_iterator<_Cp, false> operator&() const _NOEXCEPT90 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, false> operator&() const _NOEXCEPT
74 {return __bit_iterator<_Cp, false>(__seg_, static_cast<unsigned>(__libcpp_ctz(__mask_)));}91 {return __bit_iterator<_Cp, false>(__seg_, static_cast<unsigned>(__libcpp_ctz(__mask_)));}
75private:92private:
76 _LIBCPP_INLINE_VISIBILITY93 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
77 __bit_reference(__storage_pointer __s, __storage_type __m) _NOEXCEPT94 explicit __bit_reference(__storage_pointer __s, __storage_type __m) _NOEXCEPT
78 : __seg_(__s), __mask_(__m) {}95 : __seg_(__s), __mask_(__m) {}
79};96};
8097
...@@ -84,7 +101,7 @@ class __bit_reference<_Cp, false>...@@ -84,7 +101,7 @@ class __bit_reference<_Cp, false>
84};101};
85102
86template <class _Cp>103template <class _Cp>
87inline _LIBCPP_INLINE_VISIBILITY104inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
88void105void
89swap(__bit_reference<_Cp> __x, __bit_reference<_Cp> __y) _NOEXCEPT106swap(__bit_reference<_Cp> __x, __bit_reference<_Cp> __y) _NOEXCEPT
90{107{
...@@ -94,7 +111,7 @@ swap(__bit_reference<_Cp> __x, __bit_reference<_Cp> __y) _NOEXCEPT...@@ -94,7 +111,7 @@ swap(__bit_reference<_Cp> __x, __bit_reference<_Cp> __y) _NOEXCEPT
94}111}
95112
96template <class _Cp, class _Dp>113template <class _Cp, class _Dp>
97inline _LIBCPP_INLINE_VISIBILITY114inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
98void115void
99swap(__bit_reference<_Cp> __x, __bit_reference<_Dp> __y) _NOEXCEPT116swap(__bit_reference<_Cp> __x, __bit_reference<_Dp> __y) _NOEXCEPT
100{117{
...@@ -104,7 +121,7 @@ swap(__bit_reference<_Cp> __x, __bit_reference<_Dp> __y) _NOEXCEPT...@@ -104,7 +121,7 @@ swap(__bit_reference<_Cp> __x, __bit_reference<_Dp> __y) _NOEXCEPT
104}121}
105122
106template <class _Cp>123template <class _Cp>
107inline _LIBCPP_INLINE_VISIBILITY124inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
108void125void
109swap(__bit_reference<_Cp> __x, bool& __y) _NOEXCEPT126swap(__bit_reference<_Cp> __x, bool& __y) _NOEXCEPT
110{127{
...@@ -114,7 +131,7 @@ swap(__bit_reference<_Cp> __x, bool& __y) _NOEXCEPT...@@ -114,7 +131,7 @@ swap(__bit_reference<_Cp> __x, bool& __y) _NOEXCEPT
114}131}
115132
116template <class _Cp>133template <class _Cp>
117inline _LIBCPP_INLINE_VISIBILITY134inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
118void135void
119swap(bool& __x, __bit_reference<_Cp> __y) _NOEXCEPT136swap(bool& __x, __bit_reference<_Cp> __y) _NOEXCEPT
120{137{
...@@ -138,19 +155,19 @@ public:...@@ -138,19 +155,19 @@ public:
138 _LIBCPP_INLINE_VISIBILITY155 _LIBCPP_INLINE_VISIBILITY
139 __bit_const_reference(const __bit_const_reference&) = default;156 __bit_const_reference(const __bit_const_reference&) = default;
140157
141 _LIBCPP_INLINE_VISIBILITY158 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
142 __bit_const_reference(const __bit_reference<_Cp>& __x) _NOEXCEPT159 __bit_const_reference(const __bit_reference<_Cp>& __x) _NOEXCEPT
143 : __seg_(__x.__seg_), __mask_(__x.__mask_) {}160 : __seg_(__x.__seg_), __mask_(__x.__mask_) {}
144161
145 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR operator bool() const _NOEXCEPT162 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR operator bool() const _NOEXCEPT
146 {return static_cast<bool>(*__seg_ & __mask_);}163 {return static_cast<bool>(*__seg_ & __mask_);}
147164
148 _LIBCPP_INLINE_VISIBILITY __bit_iterator<_Cp, true> operator&() const _NOEXCEPT165 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, true> operator&() const _NOEXCEPT
149 {return __bit_iterator<_Cp, true>(__seg_, static_cast<unsigned>(__libcpp_ctz(__mask_)));}166 {return __bit_iterator<_Cp, true>(__seg_, static_cast<unsigned>(__libcpp_ctz(__mask_)));}
150private:167private:
151 _LIBCPP_INLINE_VISIBILITY168 _LIBCPP_INLINE_VISIBILITY
152 _LIBCPP_CONSTEXPR169 _LIBCPP_CONSTEXPR
153 __bit_const_reference(__storage_pointer __s, __storage_type __m) _NOEXCEPT170 explicit __bit_const_reference(__storage_pointer __s, __storage_type __m) _NOEXCEPT
154 : __seg_(__s), __mask_(__m) {}171 : __seg_(__s), __mask_(__m) {}
155172
156 __bit_const_reference& operator=(const __bit_const_reference&) = delete;173 __bit_const_reference& operator=(const __bit_const_reference&) = delete;
...@@ -159,12 +176,12 @@ private:...@@ -159,12 +176,12 @@ private:
159// find176// find
160177
161template <class _Cp, bool _IsConst>178template <class _Cp, bool _IsConst>
162__bit_iterator<_Cp, _IsConst>179_LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, _IsConst>
163__find_bool_true(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n)180__find_bool_true(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n)
164{181{
165 typedef __bit_iterator<_Cp, _IsConst> _It;182 typedef __bit_iterator<_Cp, _IsConst> _It;
166 typedef typename _It::__storage_type __storage_type;183 typedef typename _It::__storage_type __storage_type;
167 static const int __bits_per_word = _It::__bits_per_word;184 const int __bits_per_word = _It::__bits_per_word;
168 // do first partial word185 // do first partial word
169 if (__first.__ctz_ != 0)186 if (__first.__ctz_ != 0)
170 {187 {
...@@ -195,7 +212,7 @@ __find_bool_true(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type...@@ -195,7 +212,7 @@ __find_bool_true(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type
195}212}
196213
197template <class _Cp, bool _IsConst>214template <class _Cp, bool _IsConst>
198__bit_iterator<_Cp, _IsConst>215_LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, _IsConst>
199__find_bool_false(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n)216__find_bool_false(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n)
200{217{
201 typedef __bit_iterator<_Cp, _IsConst> _It;218 typedef __bit_iterator<_Cp, _IsConst> _It;
...@@ -234,11 +251,11 @@ __find_bool_false(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type...@@ -234,11 +251,11 @@ __find_bool_false(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type
234}251}
235252
236template <class _Cp, bool _IsConst, class _Tp>253template <class _Cp, bool _IsConst, class _Tp>
237inline _LIBCPP_INLINE_VISIBILITY254inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
238__bit_iterator<_Cp, _IsConst>255__bit_iterator<_Cp, _IsConst>
239find(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, const _Tp& __value_)256find(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, const _Tp& __value)
240{257{
241 if (static_cast<bool>(__value_))258 if (static_cast<bool>(__value))
242 return _VSTD::__find_bool_true(__first, static_cast<typename _Cp::size_type>(__last - __first));259 return _VSTD::__find_bool_true(__first, static_cast<typename _Cp::size_type>(__last - __first));
243 return _VSTD::__find_bool_false(__first, static_cast<typename _Cp::size_type>(__last - __first));260 return _VSTD::__find_bool_false(__first, static_cast<typename _Cp::size_type>(__last - __first));
244}261}
...@@ -310,9 +327,9 @@ __count_bool_false(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_typ...@@ -310,9 +327,9 @@ __count_bool_false(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_typ
310template <class _Cp, bool _IsConst, class _Tp>327template <class _Cp, bool _IsConst, class _Tp>
311inline _LIBCPP_INLINE_VISIBILITY328inline _LIBCPP_INLINE_VISIBILITY
312typename __bit_iterator<_Cp, _IsConst>::difference_type329typename __bit_iterator<_Cp, _IsConst>::difference_type
313count(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, const _Tp& __value_)330count(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, const _Tp& __value)
314{331{
315 if (static_cast<bool>(__value_))332 if (static_cast<bool>(__value))
316 return _VSTD::__count_bool_true(__first, static_cast<typename _Cp::size_type>(__last - __first));333 return _VSTD::__count_bool_true(__first, static_cast<typename _Cp::size_type>(__last - __first));
317 return _VSTD::__count_bool_false(__first, static_cast<typename _Cp::size_type>(__last - __first));334 return _VSTD::__count_bool_false(__first, static_cast<typename _Cp::size_type>(__last - __first));
318}335}
...@@ -320,7 +337,7 @@ count(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __las...@@ -320,7 +337,7 @@ count(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __las
320// fill_n337// fill_n
321338
322template <class _Cp>339template <class _Cp>
323void340_LIBCPP_CONSTEXPR_AFTER_CXX17 void
324__fill_n_false(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)341__fill_n_false(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
325{342{
326 typedef __bit_iterator<_Cp, false> _It;343 typedef __bit_iterator<_Cp, false> _It;
...@@ -338,7 +355,7 @@ __fill_n_false(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)...@@ -338,7 +355,7 @@ __fill_n_false(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
338 }355 }
339 // do middle whole words356 // do middle whole words
340 __storage_type __nw = __n / __bits_per_word;357 __storage_type __nw = __n / __bits_per_word;
341 _VSTD::memset(_VSTD::__to_address(__first.__seg_), 0, __nw * sizeof(__storage_type));358 std::fill_n(std::__to_address(__first.__seg_), __nw, 0);
342 __n -= __nw * __bits_per_word;359 __n -= __nw * __bits_per_word;
343 // do last partial word360 // do last partial word
344 if (__n > 0)361 if (__n > 0)
...@@ -350,7 +367,7 @@ __fill_n_false(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)...@@ -350,7 +367,7 @@ __fill_n_false(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
350}367}
351368
352template <class _Cp>369template <class _Cp>
353void370_LIBCPP_CONSTEXPR_AFTER_CXX17 void
354__fill_n_true(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)371__fill_n_true(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
355{372{
356 typedef __bit_iterator<_Cp, false> _It;373 typedef __bit_iterator<_Cp, false> _It;
...@@ -368,7 +385,8 @@ __fill_n_true(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)...@@ -368,7 +385,8 @@ __fill_n_true(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
368 }385 }
369 // do middle whole words386 // do middle whole words
370 __storage_type __nw = __n / __bits_per_word;387 __storage_type __nw = __n / __bits_per_word;
371 _VSTD::memset(_VSTD::__to_address(__first.__seg_), -1, __nw * sizeof(__storage_type));388 // __storage_type is always an unsigned type, so -1 sets all bits
389 std::fill_n(std::__to_address(__first.__seg_), __nw, static_cast<__storage_type>(-1));
372 __n -= __nw * __bits_per_word;390 __n -= __nw * __bits_per_word;
373 // do last partial word391 // do last partial word
374 if (__n > 0)392 if (__n > 0)
...@@ -380,13 +398,13 @@ __fill_n_true(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)...@@ -380,13 +398,13 @@ __fill_n_true(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
380}398}
381399
382template <class _Cp>400template <class _Cp>
383inline _LIBCPP_INLINE_VISIBILITY401inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
384void402void
385fill_n(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n, bool __value_)403fill_n(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n, bool __value)
386{404{
387 if (__n > 0)405 if (__n > 0)
388 {406 {
389 if (__value_)407 if (__value)
390 _VSTD::__fill_n_true(__first, __n);408 _VSTD::__fill_n_true(__first, __n);
391 else409 else
392 _VSTD::__fill_n_false(__first, __n);410 _VSTD::__fill_n_false(__first, __n);
...@@ -396,16 +414,17 @@ fill_n(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n, bool __v...@@ -396,16 +414,17 @@ fill_n(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n, bool __v
396// fill414// fill
397415
398template <class _Cp>416template <class _Cp>
399inline _LIBCPP_INLINE_VISIBILITY417inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
400void418void
401fill(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __last, bool __value_)419fill(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __last, bool __value)
402{420{
403 _VSTD::fill_n(__first, static_cast<typename _Cp::size_type>(__last - __first), __value_);421 _VSTD::fill_n(__first, static_cast<typename _Cp::size_type>(__last - __first), __value);
404}422}
405423
406// copy424// copy
407425
408template <class _Cp, bool _IsConst>426template <class _Cp, bool _IsConst>
427_LIBCPP_CONSTEXPR_AFTER_CXX17
409__bit_iterator<_Cp, false>428__bit_iterator<_Cp, false>
410__copy_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last,429__copy_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last,
411 __bit_iterator<_Cp, false> __result)430 __bit_iterator<_Cp, false> __result)
...@@ -435,9 +454,7 @@ __copy_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsCon...@@ -435,9 +454,7 @@ __copy_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsCon
435 // __first.__ctz_ == 0;454 // __first.__ctz_ == 0;
436 // do middle words455 // do middle words
437 __storage_type __nw = __n / __bits_per_word;456 __storage_type __nw = __n / __bits_per_word;
438 _VSTD::memmove(_VSTD::__to_address(__result.__seg_),457 std::copy_n(std::__to_address(__first.__seg_), __nw, std::__to_address(__result.__seg_));
439 _VSTD::__to_address(__first.__seg_),
440 __nw * sizeof(__storage_type));
441 __n -= __nw * __bits_per_word;458 __n -= __nw * __bits_per_word;
442 __result.__seg_ += __nw;459 __result.__seg_ += __nw;
443 // do last word460 // do last word
...@@ -455,6 +472,7 @@ __copy_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsCon...@@ -455,6 +472,7 @@ __copy_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsCon
455}472}
456473
457template <class _Cp, bool _IsConst>474template <class _Cp, bool _IsConst>
475_LIBCPP_CONSTEXPR_AFTER_CXX17
458__bit_iterator<_Cp, false>476__bit_iterator<_Cp, false>
459__copy_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last,477__copy_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last,
460 __bit_iterator<_Cp, false> __result)478 __bit_iterator<_Cp, false> __result)
...@@ -462,7 +480,7 @@ __copy_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsC...@@ -462,7 +480,7 @@ __copy_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsC
462 typedef __bit_iterator<_Cp, _IsConst> _In;480 typedef __bit_iterator<_Cp, _IsConst> _In;
463 typedef typename _In::difference_type difference_type;481 typedef typename _In::difference_type difference_type;
464 typedef typename _In::__storage_type __storage_type;482 typedef typename _In::__storage_type __storage_type;
465 static const int __bits_per_word = _In::__bits_per_word;483 const int __bits_per_word = _In::__bits_per_word;
466 difference_type __n = __last - __first;484 difference_type __n = __last - __first;
467 if (__n > 0)485 if (__n > 0)
468 {486 {
...@@ -533,7 +551,7 @@ __copy_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsC...@@ -533,7 +551,7 @@ __copy_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsC
533}551}
534552
535template <class _Cp, bool _IsConst>553template <class _Cp, bool _IsConst>
536inline _LIBCPP_INLINE_VISIBILITY554inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
537__bit_iterator<_Cp, false>555__bit_iterator<_Cp, false>
538copy(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result)556copy(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result)
539{557{
...@@ -545,7 +563,7 @@ copy(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last...@@ -545,7 +563,7 @@ copy(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last
545// copy_backward563// copy_backward
546564
547template <class _Cp, bool _IsConst>565template <class _Cp, bool _IsConst>
548__bit_iterator<_Cp, false>566_LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, false>
549__copy_backward_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last,567__copy_backward_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last,
550 __bit_iterator<_Cp, false> __result)568 __bit_iterator<_Cp, false> __result)
551{569{
...@@ -576,9 +594,7 @@ __copy_backward_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_C...@@ -576,9 +594,7 @@ __copy_backward_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_C
576 __storage_type __nw = __n / __bits_per_word;594 __storage_type __nw = __n / __bits_per_word;
577 __result.__seg_ -= __nw;595 __result.__seg_ -= __nw;
578 __last.__seg_ -= __nw;596 __last.__seg_ -= __nw;
579 _VSTD::memmove(_VSTD::__to_address(__result.__seg_),597 std::copy_n(std::__to_address(__last.__seg_), __nw, std::__to_address(__result.__seg_));
580 _VSTD::__to_address(__last.__seg_),
581 __nw * sizeof(__storage_type));
582 __n -= __nw * __bits_per_word;598 __n -= __nw * __bits_per_word;
583 // do last word599 // do last word
584 if (__n > 0)600 if (__n > 0)
...@@ -594,7 +610,7 @@ __copy_backward_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_C...@@ -594,7 +610,7 @@ __copy_backward_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_C
594}610}
595611
596template <class _Cp, bool _IsConst>612template <class _Cp, bool _IsConst>
597__bit_iterator<_Cp, false>613_LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, false>
598__copy_backward_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last,614__copy_backward_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last,
599 __bit_iterator<_Cp, false> __result)615 __bit_iterator<_Cp, false> __result)
600{616{
...@@ -680,7 +696,7 @@ __copy_backward_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<...@@ -680,7 +696,7 @@ __copy_backward_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<
680}696}
681697
682template <class _Cp, bool _IsConst>698template <class _Cp, bool _IsConst>
683inline _LIBCPP_INLINE_VISIBILITY699inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
684__bit_iterator<_Cp, false>700__bit_iterator<_Cp, false>
685copy_backward(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result)701copy_backward(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result)
686{702{
...@@ -887,14 +903,19 @@ struct __bit_array...@@ -887,14 +903,19 @@ struct __bit_array
887 difference_type __size_;903 difference_type __size_;
888 __storage_type __word_[_Np];904 __storage_type __word_[_Np];
889905
890 _LIBCPP_INLINE_VISIBILITY static difference_type capacity()906 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 static difference_type capacity()
891 {return static_cast<difference_type>(_Np * __bits_per_word);}907 {return static_cast<difference_type>(_Np * __bits_per_word);}
892 _LIBCPP_INLINE_VISIBILITY explicit __bit_array(difference_type __s) : __size_(__s) {}908 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit __bit_array(difference_type __s) : __size_(__s) {
893 _LIBCPP_INLINE_VISIBILITY iterator begin()909 if (__libcpp_is_constant_evaluated()) {
910 for (size_t __i = 0; __i != __bit_array<_Cp>::_Np; ++__i)
911 std::__construct_at(__word_ + __i, 0);
912 }
913 }
914 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator begin()
894 {915 {
895 return iterator(pointer_traits<__storage_pointer>::pointer_to(__word_[0]), 0);916 return iterator(pointer_traits<__storage_pointer>::pointer_to(__word_[0]), 0);
896 }917 }
897 _LIBCPP_INLINE_VISIBILITY iterator end()918 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator end()
898 {919 {
899 return iterator(pointer_traits<__storage_pointer>::pointer_to(__word_[0]) + __size_ / __bits_per_word,920 return iterator(pointer_traits<__storage_pointer>::pointer_to(__word_[0]) + __size_ / __bits_per_word,
900 static_cast<unsigned>(__size_ % __bits_per_word));921 static_cast<unsigned>(__size_ % __bits_per_word));
...@@ -902,7 +923,7 @@ struct __bit_array...@@ -902,7 +923,7 @@ struct __bit_array
902};923};
903924
904template <class _Cp>925template <class _Cp>
905__bit_iterator<_Cp, false>926_LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, false>
906rotate(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __middle, __bit_iterator<_Cp, false> __last)927rotate(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __middle, __bit_iterator<_Cp, false> __last)
907{928{
908 typedef __bit_iterator<_Cp, false> _I1;929 typedef __bit_iterator<_Cp, false> _I1;
...@@ -953,14 +974,14 @@ rotate(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __middle,...@@ -953,14 +974,14 @@ rotate(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __middle,
953// equal974// equal
954975
955template <class _Cp, bool _IC1, bool _IC2>976template <class _Cp, bool _IC1, bool _IC2>
956bool977_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
957__equal_unaligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1,978__equal_unaligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1,
958 __bit_iterator<_Cp, _IC2> __first2)979 __bit_iterator<_Cp, _IC2> __first2)
959{980{
960 typedef __bit_iterator<_Cp, _IC1> _It;981 typedef __bit_iterator<_Cp, _IC1> _It;
961 typedef typename _It::difference_type difference_type;982 typedef typename _It::difference_type difference_type;
962 typedef typename _It::__storage_type __storage_type;983 typedef typename _It::__storage_type __storage_type;
963 static const int __bits_per_word = _It::__bits_per_word;984 const int __bits_per_word = _It::__bits_per_word;
964 difference_type __n = __last1 - __first1;985 difference_type __n = __last1 - __first1;
965 if (__n > 0)986 if (__n > 0)
966 {987 {
...@@ -1035,14 +1056,14 @@ __equal_unaligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1>...@@ -1035,14 +1056,14 @@ __equal_unaligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1>
1035}1056}
10361057
1037template <class _Cp, bool _IC1, bool _IC2>1058template <class _Cp, bool _IC1, bool _IC2>
1038bool1059_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
1039__equal_aligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1,1060__equal_aligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1,
1040 __bit_iterator<_Cp, _IC2> __first2)1061 __bit_iterator<_Cp, _IC2> __first2)
1041{1062{
1042 typedef __bit_iterator<_Cp, _IC1> _It;1063 typedef __bit_iterator<_Cp, _IC1> _It;
1043 typedef typename _It::difference_type difference_type;1064 typedef typename _It::difference_type difference_type;
1044 typedef typename _It::__storage_type __storage_type;1065 typedef typename _It::__storage_type __storage_type;
1045 static const int __bits_per_word = _It::__bits_per_word;1066 const int __bits_per_word = _It::__bits_per_word;
1046 difference_type __n = __last1 - __first1;1067 difference_type __n = __last1 - __first1;
1047 if (__n > 0)1068 if (__n > 0)
1048 {1069 {
...@@ -1078,7 +1099,7 @@ __equal_aligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __...@@ -1078,7 +1099,7 @@ __equal_aligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __
1078}1099}
10791100
1080template <class _Cp, bool _IC1, bool _IC2>1101template <class _Cp, bool _IC1, bool _IC2>
1081inline _LIBCPP_INLINE_VISIBILITY1102inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1082bool1103bool
1083equal(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1, __bit_iterator<_Cp, _IC2> __first2)1104equal(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1, __bit_iterator<_Cp, _IC2> __first2)
1084{1105{
...@@ -1095,7 +1116,11 @@ public:...@@ -1095,7 +1116,11 @@ public:
1095 typedef typename _Cp::difference_type difference_type;1116 typedef typename _Cp::difference_type difference_type;
1096 typedef bool value_type;1117 typedef bool value_type;
1097 typedef __bit_iterator pointer;1118 typedef __bit_iterator pointer;
1119#ifndef _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL
1098 typedef typename conditional<_IsConst, __bit_const_reference<_Cp>, __bit_reference<_Cp> >::type reference;1120 typedef typename conditional<_IsConst, __bit_const_reference<_Cp>, __bit_reference<_Cp> >::type reference;
1121#else
1122 using reference = typename conditional<_IsConst, bool, __bit_reference<_Cp> >::type;
1123#endif
1099 typedef random_access_iterator_tag iterator_category;1124 typedef random_access_iterator_tag iterator_category;
11001125
1101private:1126private:
...@@ -1108,7 +1133,7 @@ private:...@@ -1108,7 +1133,7 @@ private:
1108 unsigned __ctz_;1133 unsigned __ctz_;
11091134
1110public:1135public:
1111 _LIBCPP_INLINE_VISIBILITY __bit_iterator() _NOEXCEPT1136 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator() _NOEXCEPT
1112#if _LIBCPP_STD_VER > 111137#if _LIBCPP_STD_VER > 11
1113 : __seg_(nullptr), __ctz_(0)1138 : __seg_(nullptr), __ctz_(0)
1114#endif1139#endif
...@@ -1119,7 +1144,7 @@ public:...@@ -1119,7 +1144,7 @@ public:
1119 // When _IsConst=true, this is a converting constructor;1144 // When _IsConst=true, this is a converting constructor;
1120 // the copy and move constructors are implicitly generated1145 // the copy and move constructors are implicitly generated
1121 // and trivial.1146 // and trivial.
1122 _LIBCPP_INLINE_VISIBILITY1147 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1123 __bit_iterator(const __bit_iterator<_Cp, false>& __it) _NOEXCEPT1148 __bit_iterator(const __bit_iterator<_Cp, false>& __it) _NOEXCEPT
1124 : __seg_(__it.__seg_), __ctz_(__it.__ctz_) {}1149 : __seg_(__it.__seg_), __ctz_(__it.__ctz_) {}
11251150
...@@ -1128,17 +1153,19 @@ public:...@@ -1128,17 +1153,19 @@ public:
1128 // the implicit generation of a defaulted one is deprecated.1153 // the implicit generation of a defaulted one is deprecated.
1129 // When _IsConst=true, the assignment operators are1154 // When _IsConst=true, the assignment operators are
1130 // implicitly generated and trivial.1155 // implicitly generated and trivial.
1131 _LIBCPP_INLINE_VISIBILITY1156 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1132 __bit_iterator& operator=(const _If<_IsConst, struct __private_nat, __bit_iterator>& __it) {1157 __bit_iterator& operator=(const _If<_IsConst, struct __private_nat, __bit_iterator>& __it) {
1133 __seg_ = __it.__seg_;1158 __seg_ = __it.__seg_;
1134 __ctz_ = __it.__ctz_;1159 __ctz_ = __it.__ctz_;
1135 return *this;1160 return *this;
1136 }1161 }
11371162
1138 _LIBCPP_INLINE_VISIBILITY reference operator*() const _NOEXCEPT1163 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 reference operator*() const _NOEXCEPT {
1139 {return reference(__seg_, __storage_type(1) << __ctz_);}1164 return typename conditional<_IsConst, __bit_const_reference<_Cp>, __bit_reference<_Cp> >
1165 ::type(__seg_, __storage_type(1) << __ctz_);
1166 }
11401167
1141 _LIBCPP_INLINE_VISIBILITY __bit_iterator& operator++()1168 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator& operator++()
1142 {1169 {
1143 if (__ctz_ != __bits_per_word-1)1170 if (__ctz_ != __bits_per_word-1)
1144 ++__ctz_;1171 ++__ctz_;
...@@ -1150,14 +1177,14 @@ public:...@@ -1150,14 +1177,14 @@ public:
1150 return *this;1177 return *this;
1151 }1178 }
11521179
1153 _LIBCPP_INLINE_VISIBILITY __bit_iterator operator++(int)1180 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator operator++(int)
1154 {1181 {
1155 __bit_iterator __tmp = *this;1182 __bit_iterator __tmp = *this;
1156 ++(*this);1183 ++(*this);
1157 return __tmp;1184 return __tmp;
1158 }1185 }
11591186
1160 _LIBCPP_INLINE_VISIBILITY __bit_iterator& operator--()1187 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator& operator--()
1161 {1188 {
1162 if (__ctz_ != 0)1189 if (__ctz_ != 0)
1163 --__ctz_;1190 --__ctz_;
...@@ -1169,14 +1196,14 @@ public:...@@ -1169,14 +1196,14 @@ public:
1169 return *this;1196 return *this;
1170 }1197 }
11711198
1172 _LIBCPP_INLINE_VISIBILITY __bit_iterator operator--(int)1199 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator operator--(int)
1173 {1200 {
1174 __bit_iterator __tmp = *this;1201 __bit_iterator __tmp = *this;
1175 --(*this);1202 --(*this);
1176 return __tmp;1203 return __tmp;
1177 }1204 }
11781205
1179 _LIBCPP_INLINE_VISIBILITY __bit_iterator& operator+=(difference_type __n)1206 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator& operator+=(difference_type __n)
1180 {1207 {
1181 if (__n >= 0)1208 if (__n >= 0)
1182 __seg_ += (__n + __ctz_) / __bits_per_word;1209 __seg_ += (__n + __ctz_) / __bits_per_word;
...@@ -1188,55 +1215,55 @@ public:...@@ -1188,55 +1215,55 @@ public:
1188 return *this;1215 return *this;
1189 }1216 }
11901217
1191 _LIBCPP_INLINE_VISIBILITY __bit_iterator& operator-=(difference_type __n)1218 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator& operator-=(difference_type __n)
1192 {1219 {
1193 return *this += -__n;1220 return *this += -__n;
1194 }1221 }
11951222
1196 _LIBCPP_INLINE_VISIBILITY __bit_iterator operator+(difference_type __n) const1223 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator operator+(difference_type __n) const
1197 {1224 {
1198 __bit_iterator __t(*this);1225 __bit_iterator __t(*this);
1199 __t += __n;1226 __t += __n;
1200 return __t;1227 return __t;
1201 }1228 }
12021229
1203 _LIBCPP_INLINE_VISIBILITY __bit_iterator operator-(difference_type __n) const1230 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator operator-(difference_type __n) const
1204 {1231 {
1205 __bit_iterator __t(*this);1232 __bit_iterator __t(*this);
1206 __t -= __n;1233 __t -= __n;
1207 return __t;1234 return __t;
1208 }1235 }
12091236
1210 _LIBCPP_INLINE_VISIBILITY1237 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1211 friend __bit_iterator operator+(difference_type __n, const __bit_iterator& __it) {return __it + __n;}1238 friend __bit_iterator operator+(difference_type __n, const __bit_iterator& __it) {return __it + __n;}
12121239
1213 _LIBCPP_INLINE_VISIBILITY1240 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1214 friend difference_type operator-(const __bit_iterator& __x, const __bit_iterator& __y)1241 friend difference_type operator-(const __bit_iterator& __x, const __bit_iterator& __y)
1215 {return (__x.__seg_ - __y.__seg_) * __bits_per_word + __x.__ctz_ - __y.__ctz_;}1242 {return (__x.__seg_ - __y.__seg_) * __bits_per_word + __x.__ctz_ - __y.__ctz_;}
12161243
1217 _LIBCPP_INLINE_VISIBILITY reference operator[](difference_type __n) const {return *(*this + __n);}1244 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 reference operator[](difference_type __n) const {return *(*this + __n);}
12181245
1219 _LIBCPP_INLINE_VISIBILITY friend bool operator==(const __bit_iterator& __x, const __bit_iterator& __y)1246 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 friend bool operator==(const __bit_iterator& __x, const __bit_iterator& __y)
1220 {return __x.__seg_ == __y.__seg_ && __x.__ctz_ == __y.__ctz_;}1247 {return __x.__seg_ == __y.__seg_ && __x.__ctz_ == __y.__ctz_;}
12211248
1222 _LIBCPP_INLINE_VISIBILITY friend bool operator!=(const __bit_iterator& __x, const __bit_iterator& __y)1249 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 friend bool operator!=(const __bit_iterator& __x, const __bit_iterator& __y)
1223 {return !(__x == __y);}1250 {return !(__x == __y);}
12241251
1225 _LIBCPP_INLINE_VISIBILITY friend bool operator<(const __bit_iterator& __x, const __bit_iterator& __y)1252 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 friend bool operator<(const __bit_iterator& __x, const __bit_iterator& __y)
1226 {return __x.__seg_ < __y.__seg_ || (__x.__seg_ == __y.__seg_ && __x.__ctz_ < __y.__ctz_);}1253 {return __x.__seg_ < __y.__seg_ || (__x.__seg_ == __y.__seg_ && __x.__ctz_ < __y.__ctz_);}
12271254
1228 _LIBCPP_INLINE_VISIBILITY friend bool operator>(const __bit_iterator& __x, const __bit_iterator& __y)1255 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 friend bool operator>(const __bit_iterator& __x, const __bit_iterator& __y)
1229 {return __y < __x;}1256 {return __y < __x;}
12301257
1231 _LIBCPP_INLINE_VISIBILITY friend bool operator<=(const __bit_iterator& __x, const __bit_iterator& __y)1258 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 friend bool operator<=(const __bit_iterator& __x, const __bit_iterator& __y)
1232 {return !(__y < __x);}1259 {return !(__y < __x);}
12331260
1234 _LIBCPP_INLINE_VISIBILITY friend bool operator>=(const __bit_iterator& __x, const __bit_iterator& __y)1261 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 friend bool operator>=(const __bit_iterator& __x, const __bit_iterator& __y)
1235 {return !(__x < __y);}1262 {return !(__x < __y);}
12361263
1237private:1264private:
1238 _LIBCPP_INLINE_VISIBILITY1265 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1239 __bit_iterator(__storage_pointer __s, unsigned __ctz) _NOEXCEPT1266 explicit __bit_iterator(__storage_pointer __s, unsigned __ctz) _NOEXCEPT
1240 : __seg_(__s), __ctz_(__ctz) {}1267 : __seg_(__s), __ctz_(__ctz) {}
12411268
1242 friend typename _Cp::__self;1269 friend typename _Cp::__self;
...@@ -1245,26 +1272,44 @@ private:...@@ -1245,26 +1272,44 @@ private:
1245 friend class __bit_const_reference<_Cp>;1272 friend class __bit_const_reference<_Cp>;
1246 friend class __bit_iterator<_Cp, true>;1273 friend class __bit_iterator<_Cp, true>;
1247 template <class _Dp> friend struct __bit_array;1274 template <class _Dp> friend struct __bit_array;
1248 template <class _Dp> friend void __fill_n_false(__bit_iterator<_Dp, false> __first, typename _Dp::size_type __n);1275 template <class _Dp>
1249 template <class _Dp> friend void __fill_n_true(__bit_iterator<_Dp, false> __first, typename _Dp::size_type __n);1276 _LIBCPP_CONSTEXPR_AFTER_CXX17
1250 template <class _Dp, bool _IC> friend __bit_iterator<_Dp, false> __copy_aligned(__bit_iterator<_Dp, _IC> __first,1277 friend void __fill_n_false(__bit_iterator<_Dp, false> __first, typename _Dp::size_type __n);
1251 __bit_iterator<_Dp, _IC> __last,1278
1252 __bit_iterator<_Dp, false> __result);1279 template <class _Dp>
1253 template <class _Dp, bool _IC> friend __bit_iterator<_Dp, false> __copy_unaligned(__bit_iterator<_Dp, _IC> __first,1280 _LIBCPP_CONSTEXPR_AFTER_CXX17
1254 __bit_iterator<_Dp, _IC> __last,1281 friend void __fill_n_true(__bit_iterator<_Dp, false> __first, typename _Dp::size_type __n);
1255 __bit_iterator<_Dp, false> __result);1282
1256 template <class _Dp, bool _IC> friend __bit_iterator<_Dp, false> copy(__bit_iterator<_Dp, _IC> __first,1283 template <class _Dp, bool _IC>
1257 __bit_iterator<_Dp, _IC> __last,1284 _LIBCPP_CONSTEXPR_AFTER_CXX17
1258 __bit_iterator<_Dp, false> __result);1285 friend __bit_iterator<_Dp, false> __copy_aligned(__bit_iterator<_Dp, _IC> __first,
1259 template <class _Dp, bool _IC> friend __bit_iterator<_Dp, false> __copy_backward_aligned(__bit_iterator<_Dp, _IC> __first,1286 __bit_iterator<_Dp, _IC> __last,
1260 __bit_iterator<_Dp, _IC> __last,1287 __bit_iterator<_Dp, false> __result);
1261 __bit_iterator<_Dp, false> __result);1288 template <class _Dp, bool _IC>
1262 template <class _Dp, bool _IC> friend __bit_iterator<_Dp, false> __copy_backward_unaligned(__bit_iterator<_Dp, _IC> __first,1289 _LIBCPP_CONSTEXPR_AFTER_CXX17
1263 __bit_iterator<_Dp, _IC> __last,1290 friend __bit_iterator<_Dp, false> __copy_unaligned(__bit_iterator<_Dp, _IC> __first,
1264 __bit_iterator<_Dp, false> __result);1291 __bit_iterator<_Dp, _IC> __last,
1265 template <class _Dp, bool _IC> friend __bit_iterator<_Dp, false> copy_backward(__bit_iterator<_Dp, _IC> __first,1292 __bit_iterator<_Dp, false> __result);
1266 __bit_iterator<_Dp, _IC> __last,1293 template <class _Dp, bool _IC>
1267 __bit_iterator<_Dp, false> __result);1294 _LIBCPP_CONSTEXPR_AFTER_CXX17
1295 friend __bit_iterator<_Dp, false> copy(__bit_iterator<_Dp, _IC> __first,
1296 __bit_iterator<_Dp, _IC> __last,
1297 __bit_iterator<_Dp, false> __result);
1298 template <class _Dp, bool _IC>
1299 _LIBCPP_CONSTEXPR_AFTER_CXX17
1300 friend __bit_iterator<_Dp, false> __copy_backward_aligned(__bit_iterator<_Dp, _IC> __first,
1301 __bit_iterator<_Dp, _IC> __last,
1302 __bit_iterator<_Dp, false> __result);
1303 template <class _Dp, bool _IC>
1304 _LIBCPP_CONSTEXPR_AFTER_CXX17
1305 friend __bit_iterator<_Dp, false> __copy_backward_unaligned(__bit_iterator<_Dp, _IC> __first,
1306 __bit_iterator<_Dp, _IC> __last,
1307 __bit_iterator<_Dp, false> __result);
1308 template <class _Dp, bool _IC>
1309 _LIBCPP_CONSTEXPR_AFTER_CXX17
1310 friend __bit_iterator<_Dp, false> copy_backward(__bit_iterator<_Dp, _IC> __first,
1311 __bit_iterator<_Dp, _IC> __last,
1312 __bit_iterator<_Dp, false> __result);
1268 template <class __C1, class __C2>friend __bit_iterator<__C2, false> __swap_ranges_aligned(__bit_iterator<__C1, false>,1313 template <class __C1, class __C2>friend __bit_iterator<__C2, false> __swap_ranges_aligned(__bit_iterator<__C1, false>,
1269 __bit_iterator<__C1, false>,1314 __bit_iterator<__C1, false>,
1270 __bit_iterator<__C2, false>);1315 __bit_iterator<__C2, false>);
...@@ -1274,22 +1319,32 @@ private:...@@ -1274,22 +1319,32 @@ private:
1274 template <class __C1, class __C2>friend __bit_iterator<__C2, false> swap_ranges(__bit_iterator<__C1, false>,1319 template <class __C1, class __C2>friend __bit_iterator<__C2, false> swap_ranges(__bit_iterator<__C1, false>,
1275 __bit_iterator<__C1, false>,1320 __bit_iterator<__C1, false>,
1276 __bit_iterator<__C2, false>);1321 __bit_iterator<__C2, false>);
1277 template <class _Dp> friend __bit_iterator<_Dp, false> rotate(__bit_iterator<_Dp, false>,1322 template <class _Dp>
1278 __bit_iterator<_Dp, false>,1323 _LIBCPP_CONSTEXPR_AFTER_CXX17
1279 __bit_iterator<_Dp, false>);1324 friend __bit_iterator<_Dp, false> rotate(__bit_iterator<_Dp, false>,
1280 template <class _Dp, bool _IC1, bool _IC2> friend bool __equal_aligned(__bit_iterator<_Dp, _IC1>,1325 __bit_iterator<_Dp, false>,
1281 __bit_iterator<_Dp, _IC1>,1326 __bit_iterator<_Dp, false>);
1282 __bit_iterator<_Dp, _IC2>);1327 template <class _Dp, bool _IC1, bool _IC2>
1283 template <class _Dp, bool _IC1, bool _IC2> friend bool __equal_unaligned(__bit_iterator<_Dp, _IC1>,1328 _LIBCPP_CONSTEXPR_AFTER_CXX17
1284 __bit_iterator<_Dp, _IC1>,1329 friend bool __equal_aligned(__bit_iterator<_Dp, _IC1>,
1285 __bit_iterator<_Dp, _IC2>);1330 __bit_iterator<_Dp, _IC1>,
1286 template <class _Dp, bool _IC1, bool _IC2> friend bool equal(__bit_iterator<_Dp, _IC1>,1331 __bit_iterator<_Dp, _IC2>);
1287 __bit_iterator<_Dp, _IC1>,1332 template <class _Dp, bool _IC1, bool _IC2>
1288 __bit_iterator<_Dp, _IC2>);1333 _LIBCPP_CONSTEXPR_AFTER_CXX17
1289 template <class _Dp, bool _IC> friend __bit_iterator<_Dp, _IC> __find_bool_true(__bit_iterator<_Dp, _IC>,1334 friend bool __equal_unaligned(__bit_iterator<_Dp, _IC1>,
1290 typename _Dp::size_type);1335 __bit_iterator<_Dp, _IC1>,
1291 template <class _Dp, bool _IC> friend __bit_iterator<_Dp, _IC> __find_bool_false(__bit_iterator<_Dp, _IC>,1336 __bit_iterator<_Dp, _IC2>);
1292 typename _Dp::size_type);1337 template <class _Dp, bool _IC1, bool _IC2>
1338 _LIBCPP_CONSTEXPR_AFTER_CXX17
1339 friend bool equal(__bit_iterator<_Dp, _IC1>,
1340 __bit_iterator<_Dp, _IC1>,
1341 __bit_iterator<_Dp, _IC2>);
1342 template <class _Dp, bool _IC>
1343 _LIBCPP_CONSTEXPR_AFTER_CXX17
1344 friend __bit_iterator<_Dp, _IC> __find_bool_true(__bit_iterator<_Dp, _IC>, typename _Dp::size_type);
1345 template <class _Dp, bool _IC>
1346 _LIBCPP_CONSTEXPR_AFTER_CXX17
1347 friend __bit_iterator<_Dp, _IC> __find_bool_false(__bit_iterator<_Dp, _IC>, typename _Dp::size_type);
1293 template <class _Dp, bool _IC> friend typename __bit_iterator<_Dp, _IC>::difference_type1348 template <class _Dp, bool _IC> friend typename __bit_iterator<_Dp, _IC>::difference_type
1294 __count_bool_true(__bit_iterator<_Dp, _IC>, typename _Dp::size_type);1349 __count_bool_true(__bit_iterator<_Dp, _IC>, typename _Dp::size_type);
1295 template <class _Dp, bool _IC> friend typename __bit_iterator<_Dp, _IC>::difference_type1350 template <class _Dp, bool _IC> friend typename __bit_iterator<_Dp, _IC>::difference_type
lib/libcxx/include/__bits+18-1
...@@ -13,7 +13,7 @@...@@ -13,7 +13,7 @@
13#include <__config>13#include <__config>
1414
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16#pragma GCC system_header16# pragma GCC system_header
17#endif17#endif
1818
19_LIBCPP_PUSH_MACROS19_LIBCPP_PUSH_MACROS
...@@ -43,6 +43,23 @@ int __libcpp_clz(unsigned long __x) _NOEXCEPT { return __builtin_clzl(__x);...@@ -43,6 +43,23 @@ int __libcpp_clz(unsigned long __x) _NOEXCEPT { return __builtin_clzl(__x);
43inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR43inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
44int __libcpp_clz(unsigned long long __x) _NOEXCEPT { return __builtin_clzll(__x); }44int __libcpp_clz(unsigned long long __x) _NOEXCEPT { return __builtin_clzll(__x); }
4545
46# ifndef _LIBCPP_HAS_NO_INT128
47inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
48int __libcpp_clz(__uint128_t __x) _NOEXCEPT {
49 // The function is written in this form due to C++ constexpr limitations.
50 // The algorithm:
51 // - Test whether any bit in the high 64-bits is set
52 // - No bits set:
53 // - The high 64-bits contain 64 leading zeros,
54 // - Add the result of the low 64-bits.
55 // - Any bits set:
56 // - The number of leading zeros of the input is the number of leading
57 // zeros in the high 64-bits.
58 return ((__x >> 64) == 0)
59 ? (64 + __builtin_clzll(static_cast<unsigned long long>(__x)))
60 : __builtin_clzll(static_cast<unsigned long long>(__x >> 64));
61}
62# endif
4663
47inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR64inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
48int __libcpp_popcount(unsigned __x) _NOEXCEPT { return __builtin_popcount(__x); }65int __libcpp_popcount(unsigned __x) _NOEXCEPT { return __builtin_popcount(__x); }
lib/libcxx/include/__bsd_locale_defaults.h+4-4
...@@ -11,11 +11,11 @@...@@ -11,11 +11,11 @@
11// we will define the mapping from an internal macro to the real BSD symbol.11// we will define the mapping from an internal macro to the real BSD symbol.
12//===----------------------------------------------------------------------===//12//===----------------------------------------------------------------------===//
1313
14#ifndef _LIBCPP_BSD_LOCALE_DEFAULTS_H14#ifndef _LIBCPP___BSD_LOCALE_DEFAULTS_H
15#define _LIBCPP_BSD_LOCALE_DEFAULTS_H15#define _LIBCPP___BSD_LOCALE_DEFAULTS_H
1616
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header18# pragma GCC system_header
19#endif19#endif
2020
21#define __libcpp_mb_cur_max_l(loc) MB_CUR_MAX_L(loc)21#define __libcpp_mb_cur_max_l(loc) MB_CUR_MAX_L(loc)
...@@ -33,4 +33,4 @@...@@ -33,4 +33,4 @@
33#define __libcpp_asprintf_l(...) asprintf_l(__VA_ARGS__)33#define __libcpp_asprintf_l(...) asprintf_l(__VA_ARGS__)
34#define __libcpp_sscanf_l(...) sscanf_l(__VA_ARGS__)34#define __libcpp_sscanf_l(...) sscanf_l(__VA_ARGS__)
3535
36#endif // _LIBCPP_BSD_LOCALE_DEFAULTS_H36#endif // _LIBCPP___BSD_LOCALE_DEFAULTS_H
lib/libcxx/include/__bsd_locale_fallbacks.h+4-4
...@@ -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_BSD_LOCALE_FALLBACKS_DEFAULTS_H13#ifndef _LIBCPP___BSD_LOCALE_FALLBACKS_H
14#define _LIBCPP_BSD_LOCALE_FALLBACKS_DEFAULTS_H14#define _LIBCPP___BSD_LOCALE_FALLBACKS_H
1515
16#include <memory>16#include <memory>
17#include <stdarg.h>17#include <stdarg.h>
18#include <stdlib.h>18#include <stdlib.h>
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
22#endif22#endif
2323
24_LIBCPP_BEGIN_NAMESPACE_STD24_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -140,4 +140,4 @@ int __libcpp_sscanf_l(const char *__s, locale_t __l, const char *__format, ...)...@@ -140,4 +140,4 @@ int __libcpp_sscanf_l(const char *__s, locale_t __l, const char *__format, ...)
140140
141_LIBCPP_END_NAMESPACE_STD141_LIBCPP_END_NAMESPACE_STD
142142
143#endif // _LIBCPP_BSD_LOCALE_FALLBACKS_DEFAULTS_H143#endif // _LIBCPP___BSD_LOCALE_FALLBACKS_H
lib/libcxx/include/__charconv/chars_format.h+1-1
...@@ -14,7 +14,7 @@...@@ -14,7 +14,7 @@
14#include <__utility/to_underlying.h>14#include <__utility/to_underlying.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
18#endif18#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__charconv/from_chars_result.h+1-1
...@@ -14,7 +14,7 @@...@@ -14,7 +14,7 @@
14#include <__errc>14#include <__errc>
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
18#endif18#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__charconv/tables.h created+180
...@@ -0,0 +1,180 @@
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_TABLES
11#define _LIBCPP___CHARCONV_TABLES
12
13#include <__config>
14#include <cstdint>
15
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header
18#endif
19
20_LIBCPP_BEGIN_NAMESPACE_STD
21
22#ifndef _LIBCPP_CXX03_LANG
23
24namespace __itoa {
25
26/// Contains the charconv helper tables.
27///
28/// In C++17 these could be inline constexpr variable, but libc++ supports
29/// charconv for integrals in C++11 mode.
30template <class = void>
31struct __table {
32 static const char __base_2_lut[64];
33 static const char __base_8_lut[128];
34 static const char __base_16_lut[512];
35
36 static const uint32_t __pow10_32[10];
37 static const uint64_t __pow10_64[20];
38# ifndef _LIBCPP_HAS_NO_INT128
39 // TODO FMT Reduce the number of entries in this table.
40 static const __uint128_t __pow10_128[40];
41 static const int __pow10_128_offset = 0;
42# endif
43 static const char __digits_base_10[200];
44};
45
46template <class _Tp>
47const char __table<_Tp>::__base_2_lut[64] = {
48 '0', '0', '0', '0', '0', '0', '0', '1', '0', '0', '1', '0', '0', '0', '1', '1', '0', '1', '0', '0', '0', '1',
49 '0', '1', '0', '1', '1', '0', '0', '1', '1', '1', '1', '0', '0', '0', '1', '0', '0', '1', '1', '0', '1', '0',
50 '1', '0', '1', '1', '1', '1', '0', '0', '1', '1', '0', '1', '1', '1', '1', '0', '1', '1', '1', '1'};
51
52template <class _Tp>
53const char __table<_Tp>::__base_8_lut[128] = {
54 '0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '1', '0', '1', '1', '1', '2',
55 '1', '3', '1', '4', '1', '5', '1', '6', '1', '7', '2', '0', '2', '1', '2', '2', '2', '3', '2', '4', '2', '5',
56 '2', '6', '2', '7', '3', '0', '3', '1', '3', '2', '3', '3', '3', '4', '3', '5', '3', '6', '3', '7', '4', '0',
57 '4', '1', '4', '2', '4', '3', '4', '4', '4', '5', '4', '6', '4', '7', '5', '0', '5', '1', '5', '2', '5', '3',
58 '5', '4', '5', '5', '5', '6', '5', '7', '6', '0', '6', '1', '6', '2', '6', '3', '6', '4', '6', '5', '6', '6',
59 '6', '7', '7', '0', '7', '1', '7', '2', '7', '3', '7', '4', '7', '5', '7', '6', '7', '7'};
60
61template <class _Tp>
62const char __table<_Tp>::__base_16_lut[512] = {
63 '0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '0', '8', '0', '9', '0', 'a', '0',
64 'b', '0', 'c', '0', 'd', '0', 'e', '0', 'f', '1', '0', '1', '1', '1', '2', '1', '3', '1', '4', '1', '5', '1', '6',
65 '1', '7', '1', '8', '1', '9', '1', 'a', '1', 'b', '1', 'c', '1', 'd', '1', 'e', '1', 'f', '2', '0', '2', '1', '2',
66 '2', '2', '3', '2', '4', '2', '5', '2', '6', '2', '7', '2', '8', '2', '9', '2', 'a', '2', 'b', '2', 'c', '2', 'd',
67 '2', 'e', '2', 'f', '3', '0', '3', '1', '3', '2', '3', '3', '3', '4', '3', '5', '3', '6', '3', '7', '3', '8', '3',
68 '9', '3', 'a', '3', 'b', '3', 'c', '3', 'd', '3', 'e', '3', 'f', '4', '0', '4', '1', '4', '2', '4', '3', '4', '4',
69 '4', '5', '4', '6', '4', '7', '4', '8', '4', '9', '4', 'a', '4', 'b', '4', 'c', '4', 'd', '4', 'e', '4', 'f', '5',
70 '0', '5', '1', '5', '2', '5', '3', '5', '4', '5', '5', '5', '6', '5', '7', '5', '8', '5', '9', '5', 'a', '5', 'b',
71 '5', 'c', '5', 'd', '5', 'e', '5', 'f', '6', '0', '6', '1', '6', '2', '6', '3', '6', '4', '6', '5', '6', '6', '6',
72 '7', '6', '8', '6', '9', '6', 'a', '6', 'b', '6', 'c', '6', 'd', '6', 'e', '6', 'f', '7', '0', '7', '1', '7', '2',
73 '7', '3', '7', '4', '7', '5', '7', '6', '7', '7', '7', '8', '7', '9', '7', 'a', '7', 'b', '7', 'c', '7', 'd', '7',
74 'e', '7', 'f', '8', '0', '8', '1', '8', '2', '8', '3', '8', '4', '8', '5', '8', '6', '8', '7', '8', '8', '8', '9',
75 '8', 'a', '8', 'b', '8', 'c', '8', 'd', '8', 'e', '8', 'f', '9', '0', '9', '1', '9', '2', '9', '3', '9', '4', '9',
76 '5', '9', '6', '9', '7', '9', '8', '9', '9', '9', 'a', '9', 'b', '9', 'c', '9', 'd', '9', 'e', '9', 'f', 'a', '0',
77 'a', '1', 'a', '2', 'a', '3', 'a', '4', 'a', '5', 'a', '6', 'a', '7', 'a', '8', 'a', '9', 'a', 'a', 'a', 'b', 'a',
78 'c', 'a', 'd', 'a', 'e', 'a', 'f', 'b', '0', 'b', '1', 'b', '2', 'b', '3', 'b', '4', 'b', '5', 'b', '6', 'b', '7',
79 'b', '8', 'b', '9', 'b', 'a', 'b', 'b', 'b', 'c', 'b', 'd', 'b', 'e', 'b', 'f', 'c', '0', 'c', '1', 'c', '2', 'c',
80 '3', 'c', '4', 'c', '5', 'c', '6', 'c', '7', 'c', '8', 'c', '9', 'c', 'a', 'c', 'b', 'c', 'c', 'c', 'd', 'c', 'e',
81 'c', 'f', 'd', '0', 'd', '1', 'd', '2', 'd', '3', 'd', '4', 'd', '5', 'd', '6', 'd', '7', 'd', '8', 'd', '9', 'd',
82 'a', 'd', 'b', 'd', 'c', 'd', 'd', 'd', 'e', 'd', 'f', 'e', '0', 'e', '1', 'e', '2', 'e', '3', 'e', '4', 'e', '5',
83 'e', '6', 'e', '7', 'e', '8', 'e', '9', 'e', 'a', 'e', 'b', 'e', 'c', 'e', 'd', 'e', 'e', 'e', 'f', 'f', '0', 'f',
84 '1', 'f', '2', 'f', '3', 'f', '4', 'f', '5', 'f', '6', 'f', '7', 'f', '8', 'f', '9', 'f', 'a', 'f', 'b', 'f', 'c',
85 'f', 'd', 'f', 'e', 'f', 'f'};
86
87template <class _Tp>
88const uint32_t __table<_Tp>::__pow10_32[10] = {
89 UINT32_C(0), UINT32_C(10), UINT32_C(100), UINT32_C(1000), UINT32_C(10000),
90 UINT32_C(100000), UINT32_C(1000000), UINT32_C(10000000), UINT32_C(100000000), UINT32_C(1000000000)};
91
92template <class _Tp>
93const uint64_t __table<_Tp>::__pow10_64[20] = {UINT64_C(0),
94 UINT64_C(10),
95 UINT64_C(100),
96 UINT64_C(1000),
97 UINT64_C(10000),
98 UINT64_C(100000),
99 UINT64_C(1000000),
100 UINT64_C(10000000),
101 UINT64_C(100000000),
102 UINT64_C(1000000000),
103 UINT64_C(10000000000),
104 UINT64_C(100000000000),
105 UINT64_C(1000000000000),
106 UINT64_C(10000000000000),
107 UINT64_C(100000000000000),
108 UINT64_C(1000000000000000),
109 UINT64_C(10000000000000000),
110 UINT64_C(100000000000000000),
111 UINT64_C(1000000000000000000),
112 UINT64_C(10000000000000000000)};
113
114# ifndef _LIBCPP_HAS_NO_INT128
115template <class _Tp>
116const __uint128_t __table<_Tp>::__pow10_128[40] = {
117 UINT64_C(0),
118 UINT64_C(10),
119 UINT64_C(100),
120 UINT64_C(1000),
121 UINT64_C(10000),
122 UINT64_C(100000),
123 UINT64_C(1000000),
124 UINT64_C(10000000),
125 UINT64_C(100000000),
126 UINT64_C(1000000000),
127 UINT64_C(10000000000),
128 UINT64_C(100000000000),
129 UINT64_C(1000000000000),
130 UINT64_C(10000000000000),
131 UINT64_C(100000000000000),
132 UINT64_C(1000000000000000),
133 UINT64_C(10000000000000000),
134 UINT64_C(100000000000000000),
135 UINT64_C(1000000000000000000),
136 UINT64_C(10000000000000000000),
137 __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10),
138 __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(100),
139 __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(1000),
140 __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10000),
141 __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(100000),
142 __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(1000000),
143 __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10000000),
144 __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(100000000),
145 __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(1000000000),
146 __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10000000000),
147 __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(100000000000),
148 __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(1000000000000),
149 __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10000000000000),
150 __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(100000000000000),
151 __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(1000000000000000),
152 __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10000000000000000),
153 __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(100000000000000000),
154 __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(1000000000000000000),
155 __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10000000000000000000),
156 (__uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10000000000000000000)) * 10};
157# endif
158
159template <class _Tp>
160const char __table<_Tp>::__digits_base_10[200] = {
161 // clang-format off
162 '0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '0', '8', '0', '9',
163 '1', '0', '1', '1', '1', '2', '1', '3', '1', '4', '1', '5', '1', '6', '1', '7', '1', '8', '1', '9',
164 '2', '0', '2', '1', '2', '2', '2', '3', '2', '4', '2', '5', '2', '6', '2', '7', '2', '8', '2', '9',
165 '3', '0', '3', '1', '3', '2', '3', '3', '3', '4', '3', '5', '3', '6', '3', '7', '3', '8', '3', '9',
166 '4', '0', '4', '1', '4', '2', '4', '3', '4', '4', '4', '5', '4', '6', '4', '7', '4', '8', '4', '9',
167 '5', '0', '5', '1', '5', '2', '5', '3', '5', '4', '5', '5', '5', '6', '5', '7', '5', '8', '5', '9',
168 '6', '0', '6', '1', '6', '2', '6', '3', '6', '4', '6', '5', '6', '6', '6', '7', '6', '8', '6', '9',
169 '7', '0', '7', '1', '7', '2', '7', '3', '7', '4', '7', '5', '7', '6', '7', '7', '7', '8', '7', '9',
170 '8', '0', '8', '1', '8', '2', '8', '3', '8', '4', '8', '5', '8', '6', '8', '7', '8', '8', '8', '9',
171 '9', '0', '9', '1', '9', '2', '9', '3', '9', '4', '9', '5', '9', '6', '9', '7', '9', '8', '9', '9'};
172// clang-format on
173
174} // namespace __itoa
175
176#endif // _LIBCPP_CXX03_LANG
177
178_LIBCPP_END_NAMESPACE_STD
179
180#endif // _LIBCPP___CHARCONV_TABLES
lib/libcxx/include/__charconv/to_chars_base_10.h created+185
...@@ -0,0 +1,185 @@
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_TO_CHARS_BASE_10_H
11#define _LIBCPP___CHARCONV_TO_CHARS_BASE_10_H
12
13#include <__algorithm/copy_n.h>
14#include <__charconv/tables.h>
15#include <__config>
16#include <cstdint>
17#include <limits>
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_LIBCPP_BEGIN_NAMESPACE_STD
27
28#ifndef _LIBCPP_CXX03_LANG
29
30namespace __itoa {
31
32_LIBCPP_HIDE_FROM_ABI inline char* __append1(char* __first, uint32_t __value) noexcept {
33 *__first = '0' + static_cast<char>(__value);
34 return __first + 1;
35}
36
37_LIBCPP_HIDE_FROM_ABI inline char* __append2(char* __first, uint32_t __value) noexcept {
38 return std::copy_n(&__table<>::__digits_base_10[__value * 2], 2, __first);
39}
40
41_LIBCPP_HIDE_FROM_ABI inline char* __append3(char* __first, uint32_t __value) noexcept {
42 return __itoa::__append2(__itoa::__append1(__first, __value / 100), __value % 100);
43}
44
45_LIBCPP_HIDE_FROM_ABI inline char* __append4(char* __first, uint32_t __value) noexcept {
46 return __itoa::__append2(__itoa::__append2(__first, __value / 100), __value % 100);
47}
48
49_LIBCPP_HIDE_FROM_ABI inline char* __append5(char* __first, uint32_t __value) noexcept {
50 return __itoa::__append4(__itoa::__append1(__first, __value / 10000), __value % 10000);
51}
52
53_LIBCPP_HIDE_FROM_ABI inline char* __append6(char* __first, uint32_t __value) noexcept {
54 return __itoa::__append4(__itoa::__append2(__first, __value / 10000), __value % 10000);
55}
56
57_LIBCPP_HIDE_FROM_ABI inline char* __append7(char* __first, uint32_t __value) noexcept {
58 return __itoa::__append6(__itoa::__append1(__first, __value / 1000000), __value % 1000000);
59}
60
61_LIBCPP_HIDE_FROM_ABI inline char* __append8(char* __first, uint32_t __value) noexcept {
62 return __itoa::__append6(__itoa::__append2(__first, __value / 1000000), __value % 1000000);
63}
64
65_LIBCPP_HIDE_FROM_ABI inline char* __append9(char* __first, uint32_t __value) noexcept {
66 return __itoa::__append8(__itoa::__append1(__first, __value / 100000000), __value % 100000000);
67}
68
69template <class _Tp>
70_LIBCPP_HIDE_FROM_ABI char* __append10(char* __first, _Tp __value) noexcept {
71 return __itoa::__append8(__itoa::__append2(__first, static_cast<uint32_t>(__value / 100000000)),
72 static_cast<uint32_t>(__value % 100000000));
73}
74
75_LIBCPP_HIDE_FROM_ABI inline char* __base_10_u32(char* __first, uint32_t __value) noexcept {
76 if (__value < 1000000) {
77 if (__value < 10000) {
78 if (__value < 100) {
79 // 0 <= __value < 100
80 if (__value < 10)
81 return __itoa::__append1(__first, __value);
82 return __itoa::__append2(__first, __value);
83 }
84 // 100 <= __value < 10'000
85 if (__value < 1000)
86 return __itoa::__append3(__first, __value);
87 return __itoa::__append4(__first, __value);
88 }
89
90 // 10'000 <= __value < 1'000'000
91 if (__value < 100000)
92 return __itoa::__append5(__first, __value);
93 return __itoa::__append6(__first, __value);
94 }
95
96 // __value => 1'000'000
97 if (__value < 100000000) {
98 // 1'000'000 <= __value < 100'000'000
99 if (__value < 10000000)
100 return __itoa::__append7(__first, __value);
101 return __itoa::__append8(__first, __value);
102 }
103
104 // 100'000'000 <= __value < max
105 if (__value < 1000000000)
106 return __itoa::__append9(__first, __value);
107 return __itoa::__append10(__first, __value);
108}
109
110_LIBCPP_HIDE_FROM_ABI inline char* __base_10_u64(char* __buffer, uint64_t __value) noexcept {
111 if (__value <= UINT32_MAX)
112 return __itoa::__base_10_u32(__buffer, static_cast<uint32_t>(__value));
113
114 // Numbers in the range UINT32_MAX <= val < 10'000'000'000 always contain 10
115 // digits and are outputted after this if statement.
116 if (__value >= 10000000000) {
117 // This function properly deterimines the first non-zero leading digit.
118 __buffer = __itoa::__base_10_u32(__buffer, static_cast<uint32_t>(__value / 10000000000));
119 __value %= 10000000000;
120 }
121 return __itoa::__append10(__buffer, __value);
122}
123
124# ifndef _LIBCPP_HAS_NO_INT128
125/// \returns 10^\a exp
126///
127/// \pre \a exp [19, 39]
128///
129/// \note The lookup table contains a partial set of exponents limiting the
130/// range that can be used. However the range is sufficient for
131/// \ref __base_10_u128.
132_LIBCPP_HIDE_FROM_ABI inline __uint128_t __pow_10(int __exp) noexcept {
133 _LIBCPP_ASSERT(__exp >= __table<>::__pow10_128_offset, "Index out of bounds");
134 return __table<>::__pow10_128[__exp - __table<>::__pow10_128_offset];
135}
136
137_LIBCPP_HIDE_FROM_ABI inline char* __base_10_u128(char* __buffer, __uint128_t __value) noexcept {
138 _LIBCPP_ASSERT(
139 __value > numeric_limits<uint64_t>::max(), "The optimizations for this algorithm fail when this isn't true.");
140
141 // Unlike the 64 to 32 bit case the 128 bit case the "upper half" can't be
142 // stored in the "lower half". Instead we first need to handle the top most
143 // digits separately.
144 //
145 // Maximum unsigned values
146 // 64 bit 18'446'744'073'709'551'615 (20 digits)
147 // 128 bit 340'282'366'920'938'463'463'374'607'431'768'211'455 (39 digits)
148 // step 1 ^ ([0-1] digits)
149 // step 2 ^^^^^^^^^^^^^^^^^^^^^^^^^ ([0-19] digits)
150 // step 3 ^^^^^^^^^^^^^^^^^^^^^^^^^ (19 digits)
151 if (__value >= __itoa::__pow_10(38)) {
152 // step 1
153 __buffer = __itoa::__append1(__buffer, static_cast<uint32_t>(__value / __itoa::__pow_10(38)));
154 __value %= __itoa::__pow_10(38);
155
156 // step 2 always 19 digits.
157 // They are handled here since leading zeros need to be appended to the buffer,
158 __buffer = __itoa::__append9(__buffer, static_cast<uint32_t>(__value / __itoa::__pow_10(29)));
159 __value %= __itoa::__pow_10(29);
160 __buffer = __itoa::__append10(__buffer, static_cast<uint64_t>(__value / __itoa::__pow_10(19)));
161 __value %= __itoa::__pow_10(19);
162 }
163 else {
164 // step 2
165 // This version needs to determine the position of the leading non-zero digit.
166 __buffer = __base_10_u64(__buffer, static_cast<uint64_t>(__value / __itoa::__pow_10(19)));
167 __value %= __itoa::__pow_10(19);
168 }
169
170 // Step 3
171 __buffer = __itoa::__append9(__buffer, static_cast<uint32_t>(__value / 10000000000));
172 __buffer = __itoa::__append10(__buffer, static_cast<uint64_t>(__value % 10000000000));
173
174 return __buffer;
175}
176# endif
177} // namespace __itoa
178
179#endif // _LIBCPP_CXX03_LANG
180
181_LIBCPP_END_NAMESPACE_STD
182
183_LIBCPP_POP_MACROS
184
185#endif // _LIBCPP___CHARCONV_TO_CHARS_BASE_10_H
lib/libcxx/include/__charconv/to_chars_result.h+1-1
...@@ -14,7 +14,7 @@...@@ -14,7 +14,7 @@
14#include <__errc>14#include <__errc>
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
18#endif18#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__chrono/calendar.h+2-1234
...@@ -11,20 +11,13 @@...@@ -11,20 +11,13 @@
11#define _LIBCPP___CHRONO_CALENDAR_H11#define _LIBCPP___CHRONO_CALENDAR_H
1212
13#include <__chrono/duration.h>13#include <__chrono/duration.h>
14#include <__chrono/system_clock.h>
15#include <__chrono/time_point.h>14#include <__chrono/time_point.h>
16#include <__config>15#include <__config>
17#include <limits>
18#include <ratio>
19#include <type_traits>
2016
21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
22#pragma GCC system_header18# pragma GCC system_header
23#endif19#endif
2420
25_LIBCPP_PUSH_MACROS
26#include <__undef_macros>
27
28#if _LIBCPP_STD_VER > 1721#if _LIBCPP_STD_VER > 17
2922
30_LIBCPP_BEGIN_NAMESPACE_STD23_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -38,1239 +31,14 @@ using local_time = time_point<local_t, Duration>;...@@ -38,1239 +31,14 @@ using local_time = time_point<local_t, Duration>;
38using local_seconds = local_time<seconds>;31using local_seconds = local_time<seconds>;
39using local_days = local_time<days>;32using local_days = local_time<days>;
4033
41struct last_spec { explicit last_spec() = default; };34struct last_spec { _LIBCPP_HIDE_FROM_ABI explicit last_spec() = default; };
42
43class day {
44private:
45 unsigned char __d;
46public:
47 day() = default;
48 explicit inline constexpr day(unsigned __val) noexcept : __d(static_cast<unsigned char>(__val)) {}
49 inline constexpr day& operator++() noexcept { ++__d; return *this; }
50 inline constexpr day operator++(int) noexcept { day __tmp = *this; ++(*this); return __tmp; }
51 inline constexpr day& operator--() noexcept { --__d; return *this; }
52 inline constexpr day operator--(int) noexcept { day __tmp = *this; --(*this); return __tmp; }
53 constexpr day& operator+=(const days& __dd) noexcept;
54 constexpr day& operator-=(const days& __dd) noexcept;
55 explicit inline constexpr operator unsigned() const noexcept { return __d; }
56 inline constexpr bool ok() const noexcept { return __d >= 1 && __d <= 31; }
57 };
58
59
60inline constexpr
61bool operator==(const day& __lhs, const day& __rhs) noexcept
62{ return static_cast<unsigned>(__lhs) == static_cast<unsigned>(__rhs); }
63
64inline constexpr
65bool operator!=(const day& __lhs, const day& __rhs) noexcept
66{ return !(__lhs == __rhs); }
67
68inline constexpr
69bool operator< (const day& __lhs, const day& __rhs) noexcept
70{ return static_cast<unsigned>(__lhs) < static_cast<unsigned>(__rhs); }
71
72inline constexpr
73bool operator> (const day& __lhs, const day& __rhs) noexcept
74{ return __rhs < __lhs; }
75
76inline constexpr
77bool operator<=(const day& __lhs, const day& __rhs) noexcept
78{ return !(__rhs < __lhs);}
79
80inline constexpr
81bool operator>=(const day& __lhs, const day& __rhs) noexcept
82{ return !(__lhs < __rhs); }
83
84inline constexpr
85day operator+ (const day& __lhs, const days& __rhs) noexcept
86{ return day(static_cast<unsigned>(__lhs) + __rhs.count()); }
87
88inline constexpr
89day operator+ (const days& __lhs, const day& __rhs) noexcept
90{ return __rhs + __lhs; }
91
92inline constexpr
93day operator- (const day& __lhs, const days& __rhs) noexcept
94{ return __lhs + -__rhs; }
95
96inline constexpr
97days operator-(const day& __lhs, const day& __rhs) noexcept
98{ return days(static_cast<int>(static_cast<unsigned>(__lhs)) -
99 static_cast<int>(static_cast<unsigned>(__rhs))); }
100
101inline constexpr day& day::operator+=(const days& __dd) noexcept
102{ *this = *this + __dd; return *this; }
103
104inline constexpr day& day::operator-=(const days& __dd) noexcept
105{ *this = *this - __dd; return *this; }
106
107
108class month {
109private:
110 unsigned char __m;
111public:
112 month() = default;
113 explicit inline constexpr month(unsigned __val) noexcept : __m(static_cast<unsigned char>(__val)) {}
114 inline constexpr month& operator++() noexcept { ++__m; return *this; }
115 inline constexpr month operator++(int) noexcept { month __tmp = *this; ++(*this); return __tmp; }
116 inline constexpr month& operator--() noexcept { --__m; return *this; }
117 inline constexpr month operator--(int) noexcept { month __tmp = *this; --(*this); return __tmp; }
118 constexpr month& operator+=(const months& __m1) noexcept;
119 constexpr month& operator-=(const months& __m1) noexcept;
120 explicit inline constexpr operator unsigned() const noexcept { return __m; }
121 inline constexpr bool ok() const noexcept { return __m >= 1 && __m <= 12; }
122};
123
124
125inline constexpr
126bool operator==(const month& __lhs, const month& __rhs) noexcept
127{ return static_cast<unsigned>(__lhs) == static_cast<unsigned>(__rhs); }
128
129inline constexpr
130bool operator!=(const month& __lhs, const month& __rhs) noexcept
131{ return !(__lhs == __rhs); }
132
133inline constexpr
134bool operator< (const month& __lhs, const month& __rhs) noexcept
135{ return static_cast<unsigned>(__lhs) < static_cast<unsigned>(__rhs); }
136
137inline constexpr
138bool operator> (const month& __lhs, const month& __rhs) noexcept
139{ return __rhs < __lhs; }
140
141inline constexpr
142bool operator<=(const month& __lhs, const month& __rhs) noexcept
143{ return !(__rhs < __lhs); }
144
145inline constexpr
146bool operator>=(const month& __lhs, const month& __rhs) noexcept
147{ return !(__lhs < __rhs); }
148
149inline constexpr
150month operator+ (const month& __lhs, const months& __rhs) noexcept
151{
152 auto const __mu = static_cast<long long>(static_cast<unsigned>(__lhs)) + (__rhs.count() - 1);
153 auto const __yr = (__mu >= 0 ? __mu : __mu - 11) / 12;
154 return month{static_cast<unsigned>(__mu - __yr * 12 + 1)};
155}
156
157inline constexpr
158month operator+ (const months& __lhs, const month& __rhs) noexcept
159{ return __rhs + __lhs; }
160
161inline constexpr
162month operator- (const month& __lhs, const months& __rhs) noexcept
163{ return __lhs + -__rhs; }
164
165inline constexpr
166months operator-(const month& __lhs, const month& __rhs) noexcept
167{
168 auto const __dm = static_cast<unsigned>(__lhs) - static_cast<unsigned>(__rhs);
169 return months(__dm <= 11 ? __dm : __dm + 12);
170}
171
172inline constexpr month& month::operator+=(const months& __dm) noexcept
173{ *this = *this + __dm; return *this; }
174
175inline constexpr month& month::operator-=(const months& __dm) noexcept
176{ *this = *this - __dm; return *this; }
177
178
179class year {
180private:
181 short __y;
182public:
183 year() = default;
184 explicit inline constexpr year(int __val) noexcept : __y(static_cast<short>(__val)) {}
185
186 inline constexpr year& operator++() noexcept { ++__y; return *this; }
187 inline constexpr year operator++(int) noexcept { year __tmp = *this; ++(*this); return __tmp; }
188 inline constexpr year& operator--() noexcept { --__y; return *this; }
189 inline constexpr year operator--(int) noexcept { year __tmp = *this; --(*this); return __tmp; }
190 constexpr year& operator+=(const years& __dy) noexcept;
191 constexpr year& operator-=(const years& __dy) noexcept;
192 inline constexpr year operator+() const noexcept { return *this; }
193 inline constexpr year operator-() const noexcept { return year{-__y}; }
194
195 inline constexpr bool is_leap() const noexcept { return __y % 4 == 0 && (__y % 100 != 0 || __y % 400 == 0); }
196 explicit inline constexpr operator int() const noexcept { return __y; }
197 constexpr bool ok() const noexcept;
198 static inline constexpr year min() noexcept { return year{-32767}; }
199 static inline constexpr year max() noexcept { return year{ 32767}; }
200};
201
202
203inline constexpr
204bool operator==(const year& __lhs, const year& __rhs) noexcept
205{ return static_cast<int>(__lhs) == static_cast<int>(__rhs); }
206
207inline constexpr
208bool operator!=(const year& __lhs, const year& __rhs) noexcept
209{ return !(__lhs == __rhs); }
210
211inline constexpr
212bool operator< (const year& __lhs, const year& __rhs) noexcept
213{ return static_cast<int>(__lhs) < static_cast<int>(__rhs); }
214
215inline constexpr
216bool operator> (const year& __lhs, const year& __rhs) noexcept
217{ return __rhs < __lhs; }
218
219inline constexpr
220bool operator<=(const year& __lhs, const year& __rhs) noexcept
221{ return !(__rhs < __lhs); }
222
223inline constexpr
224bool operator>=(const year& __lhs, const year& __rhs) noexcept
225{ return !(__lhs < __rhs); }
226
227inline constexpr
228year operator+ (const year& __lhs, const years& __rhs) noexcept
229{ return year(static_cast<int>(__lhs) + __rhs.count()); }
230
231inline constexpr
232year operator+ (const years& __lhs, const year& __rhs) noexcept
233{ return __rhs + __lhs; }
234
235inline constexpr
236year operator- (const year& __lhs, const years& __rhs) noexcept
237{ return __lhs + -__rhs; }
238
239inline constexpr
240years operator-(const year& __lhs, const year& __rhs) noexcept
241{ return years{static_cast<int>(__lhs) - static_cast<int>(__rhs)}; }
242
243
244inline constexpr year& year::operator+=(const years& __dy) noexcept
245{ *this = *this + __dy; return *this; }
246
247inline constexpr year& year::operator-=(const years& __dy) noexcept
248{ *this = *this - __dy; return *this; }
249
250inline constexpr bool year::ok() const noexcept
251{ return static_cast<int>(min()) <= __y && __y <= static_cast<int>(max()); }
252
253class weekday_indexed;
254class weekday_last;
255
256class weekday {
257private:
258 unsigned char __wd;
259 static constexpr unsigned char __weekday_from_days(int __days) noexcept;
260public:
261 weekday() = default;
262 inline explicit constexpr weekday(unsigned __val) noexcept : __wd(static_cast<unsigned char>(__val == 7 ? 0 : __val)) {}
263 inline constexpr weekday(const sys_days& __sysd) noexcept
264 : __wd(__weekday_from_days(__sysd.time_since_epoch().count())) {}
265 inline explicit constexpr weekday(const local_days& __locd) noexcept
266 : __wd(__weekday_from_days(__locd.time_since_epoch().count())) {}
267
268 inline constexpr weekday& operator++() noexcept { __wd = (__wd == 6 ? 0 : __wd + 1); return *this; }
269 inline constexpr weekday operator++(int) noexcept { weekday __tmp = *this; ++(*this); return __tmp; }
270 inline constexpr weekday& operator--() noexcept { __wd = (__wd == 0 ? 6 : __wd - 1); return *this; }
271 inline constexpr weekday operator--(int) noexcept { weekday __tmp = *this; --(*this); return __tmp; }
272 constexpr weekday& operator+=(const days& __dd) noexcept;
273 constexpr weekday& operator-=(const days& __dd) noexcept;
274 inline constexpr unsigned c_encoding() const noexcept { return __wd; }
275 inline constexpr unsigned iso_encoding() const noexcept { return __wd == 0u ? 7 : __wd; }
276 inline constexpr bool ok() const noexcept { return __wd <= 6; }
277 constexpr weekday_indexed operator[](unsigned __index) const noexcept;
278 constexpr weekday_last operator[](last_spec) const noexcept;
279};
280
281
282// https://howardhinnant.github.io/date_algorithms.html#weekday_from_days
283inline constexpr
284unsigned char weekday::__weekday_from_days(int __days) noexcept
285{
286 return static_cast<unsigned char>(
287 static_cast<unsigned>(__days >= -4 ? (__days+4) % 7 : (__days+5) % 7 + 6)
288 );
289}
290
291inline constexpr
292bool operator==(const weekday& __lhs, const weekday& __rhs) noexcept
293{ return __lhs.c_encoding() == __rhs.c_encoding(); }
294
295inline constexpr
296bool operator!=(const weekday& __lhs, const weekday& __rhs) noexcept
297{ return !(__lhs == __rhs); }
298
299inline constexpr
300bool operator< (const weekday& __lhs, const weekday& __rhs) noexcept
301{ return __lhs.c_encoding() < __rhs.c_encoding(); }
302
303inline constexpr
304bool operator> (const weekday& __lhs, const weekday& __rhs) noexcept
305{ return __rhs < __lhs; }
306
307inline constexpr
308bool operator<=(const weekday& __lhs, const weekday& __rhs) noexcept
309{ return !(__rhs < __lhs);}
310
311inline constexpr
312bool operator>=(const weekday& __lhs, const weekday& __rhs) noexcept
313{ return !(__lhs < __rhs); }
314
315constexpr weekday operator+(const weekday& __lhs, const days& __rhs) noexcept
316{
317 auto const __mu = static_cast<long long>(__lhs.c_encoding()) + __rhs.count();
318 auto const __yr = (__mu >= 0 ? __mu : __mu - 6) / 7;
319 return weekday{static_cast<unsigned>(__mu - __yr * 7)};
320}
321
322constexpr weekday operator+(const days& __lhs, const weekday& __rhs) noexcept
323{ return __rhs + __lhs; }
324
325constexpr weekday operator-(const weekday& __lhs, const days& __rhs) noexcept
326{ return __lhs + -__rhs; }
327
328constexpr days operator-(const weekday& __lhs, const weekday& __rhs) noexcept
329{
330 const int __wdu = __lhs.c_encoding() - __rhs.c_encoding();
331 const int __wk = (__wdu >= 0 ? __wdu : __wdu-6) / 7;
332 return days{__wdu - __wk * 7};
333}
334
335inline constexpr weekday& weekday::operator+=(const days& __dd) noexcept
336{ *this = *this + __dd; return *this; }
337
338inline constexpr weekday& weekday::operator-=(const days& __dd) noexcept
339{ *this = *this - __dd; return *this; }
340
341
342class weekday_indexed {
343private:
344 chrono::weekday __wd;
345 unsigned char __idx;
346public:
347 weekday_indexed() = default;
348 inline constexpr weekday_indexed(const chrono::weekday& __wdval, unsigned __idxval) noexcept
349 : __wd{__wdval}, __idx(__idxval) {}
350 inline constexpr chrono::weekday weekday() const noexcept { return __wd; }
351 inline constexpr unsigned index() const noexcept { return __idx; }
352 inline constexpr bool ok() const noexcept { return __wd.ok() && __idx >= 1 && __idx <= 5; }
353};
354
355inline constexpr
356bool operator==(const weekday_indexed& __lhs, const weekday_indexed& __rhs) noexcept
357{ return __lhs.weekday() == __rhs.weekday() && __lhs.index() == __rhs.index(); }
358
359inline constexpr
360bool operator!=(const weekday_indexed& __lhs, const weekday_indexed& __rhs) noexcept
361{ return !(__lhs == __rhs); }
362
363
364class weekday_last {
365private:
366 chrono::weekday __wd;
367public:
368 explicit constexpr weekday_last(const chrono::weekday& __val) noexcept
369 : __wd{__val} {}
370 constexpr chrono::weekday weekday() const noexcept { return __wd; }
371 constexpr bool ok() const noexcept { return __wd.ok(); }
372};
373
374inline constexpr
375bool operator==(const weekday_last& __lhs, const weekday_last& __rhs) noexcept
376{ return __lhs.weekday() == __rhs.weekday(); }
377
378inline constexpr
379bool operator!=(const weekday_last& __lhs, const weekday_last& __rhs) noexcept
380{ return !(__lhs == __rhs); }
381
382inline constexpr
383weekday_indexed weekday::operator[](unsigned __index) const noexcept { return weekday_indexed{*this, __index}; }
384
385inline constexpr
386weekday_last weekday::operator[](last_spec) const noexcept { return weekday_last{*this}; }
387
388
389inline constexpr last_spec last{};35inline constexpr last_spec last{};
390inline constexpr weekday Sunday{0};
391inline constexpr weekday Monday{1};
392inline constexpr weekday Tuesday{2};
393inline constexpr weekday Wednesday{3};
394inline constexpr weekday Thursday{4};
395inline constexpr weekday Friday{5};
396inline constexpr weekday Saturday{6};
397
398inline constexpr month January{1};
399inline constexpr month February{2};
400inline constexpr month March{3};
401inline constexpr month April{4};
402inline constexpr month May{5};
403inline constexpr month June{6};
404inline constexpr month July{7};
405inline constexpr month August{8};
406inline constexpr month September{9};
407inline constexpr month October{10};
408inline constexpr month November{11};
409inline constexpr month December{12};
410
411
412class month_day {
413private:
414 chrono::month __m;
415 chrono::day __d;
416public:
417 month_day() = default;
418 constexpr month_day(const chrono::month& __mval, const chrono::day& __dval) noexcept
419 : __m{__mval}, __d{__dval} {}
420 inline constexpr chrono::month month() const noexcept { return __m; }
421 inline constexpr chrono::day day() const noexcept { return __d; }
422 constexpr bool ok() const noexcept;
423};
424
425inline constexpr
426bool month_day::ok() const noexcept
427{
428 if (!__m.ok()) return false;
429 const unsigned __dval = static_cast<unsigned>(__d);
430 if (__dval < 1 || __dval > 31) return false;
431 if (__dval <= 29) return true;
432// Now we've got either 30 or 31
433 const unsigned __mval = static_cast<unsigned>(__m);
434 if (__mval == 2) return false;
435 if (__mval == 4 || __mval == 6 || __mval == 9 || __mval == 11)
436 return __dval == 30;
437 return true;
438}
439
440inline constexpr
441bool operator==(const month_day& __lhs, const month_day& __rhs) noexcept
442{ return __lhs.month() == __rhs.month() && __lhs.day() == __rhs.day(); }
443
444inline constexpr
445bool operator!=(const month_day& __lhs, const month_day& __rhs) noexcept
446{ return !(__lhs == __rhs); }
447
448inline constexpr
449month_day operator/(const month& __lhs, const day& __rhs) noexcept
450{ return month_day{__lhs, __rhs}; }
451
452constexpr
453month_day operator/(const day& __lhs, const month& __rhs) noexcept
454{ return __rhs / __lhs; }
455
456inline constexpr
457month_day operator/(const month& __lhs, int __rhs) noexcept
458{ return __lhs / day(__rhs); }
459
460constexpr
461month_day operator/(int __lhs, const day& __rhs) noexcept
462{ return month(__lhs) / __rhs; }
463
464constexpr
465month_day operator/(const day& __lhs, int __rhs) noexcept
466{ return month(__rhs) / __lhs; }
467
468
469inline constexpr
470bool operator< (const month_day& __lhs, const month_day& __rhs) noexcept
471{ return __lhs.month() != __rhs.month() ? __lhs.month() < __rhs.month() : __lhs.day() < __rhs.day(); }
472
473inline constexpr
474bool operator> (const month_day& __lhs, const month_day& __rhs) noexcept
475{ return __rhs < __lhs; }
476
477inline constexpr
478bool operator<=(const month_day& __lhs, const month_day& __rhs) noexcept
479{ return !(__rhs < __lhs);}
480
481inline constexpr
482bool operator>=(const month_day& __lhs, const month_day& __rhs) noexcept
483{ return !(__lhs < __rhs); }
484
485
486
487class month_day_last {
488private:
489 chrono::month __m;
490public:
491 explicit constexpr month_day_last(const chrono::month& __val) noexcept
492 : __m{__val} {}
493 inline constexpr chrono::month month() const noexcept { return __m; }
494 inline constexpr bool ok() const noexcept { return __m.ok(); }
495};
496
497inline constexpr
498bool operator==(const month_day_last& __lhs, const month_day_last& __rhs) noexcept
499{ return __lhs.month() == __rhs.month(); }
500
501inline constexpr
502bool operator!=(const month_day_last& __lhs, const month_day_last& __rhs) noexcept
503{ return !(__lhs == __rhs); }
50436
505inline constexpr
506bool operator< (const month_day_last& __lhs, const month_day_last& __rhs) noexcept
507{ return __lhs.month() < __rhs.month(); }
50837
509inline constexpr
510bool operator> (const month_day_last& __lhs, const month_day_last& __rhs) noexcept
511{ return __rhs < __lhs; }
512
513inline constexpr
514bool operator<=(const month_day_last& __lhs, const month_day_last& __rhs) noexcept
515{ return !(__rhs < __lhs);}
516
517inline constexpr
518bool operator>=(const month_day_last& __lhs, const month_day_last& __rhs) noexcept
519{ return !(__lhs < __rhs); }
520
521inline constexpr
522month_day_last operator/(const month& __lhs, last_spec) noexcept
523{ return month_day_last{__lhs}; }
524
525inline constexpr
526month_day_last operator/(last_spec, const month& __rhs) noexcept
527{ return month_day_last{__rhs}; }
528
529inline constexpr
530month_day_last operator/(int __lhs, last_spec) noexcept
531{ return month_day_last{month(__lhs)}; }
532
533inline constexpr
534month_day_last operator/(last_spec, int __rhs) noexcept
535{ return month_day_last{month(__rhs)}; }
536
537
538class month_weekday {
539private:
540 chrono::month __m;
541 chrono::weekday_indexed __wdi;
542public:
543 constexpr month_weekday(const chrono::month& __mval, const chrono::weekday_indexed& __wdival) noexcept
544 : __m{__mval}, __wdi{__wdival} {}
545 inline constexpr chrono::month month() const noexcept { return __m; }
546 inline constexpr chrono::weekday_indexed weekday_indexed() const noexcept { return __wdi; }
547 inline constexpr bool ok() const noexcept { return __m.ok() && __wdi.ok(); }
548};
549
550inline constexpr
551bool operator==(const month_weekday& __lhs, const month_weekday& __rhs) noexcept
552{ return __lhs.month() == __rhs.month() && __lhs.weekday_indexed() == __rhs.weekday_indexed(); }
553
554inline constexpr
555bool operator!=(const month_weekday& __lhs, const month_weekday& __rhs) noexcept
556{ return !(__lhs == __rhs); }
557
558inline constexpr
559month_weekday operator/(const month& __lhs, const weekday_indexed& __rhs) noexcept
560{ return month_weekday{__lhs, __rhs}; }
561
562inline constexpr
563month_weekday operator/(int __lhs, const weekday_indexed& __rhs) noexcept
564{ return month_weekday{month(__lhs), __rhs}; }
565
566inline constexpr
567month_weekday operator/(const weekday_indexed& __lhs, const month& __rhs) noexcept
568{ return month_weekday{__rhs, __lhs}; }
569
570inline constexpr
571month_weekday operator/(const weekday_indexed& __lhs, int __rhs) noexcept
572{ return month_weekday{month(__rhs), __lhs}; }
573
574
575class month_weekday_last {
576 chrono::month __m;
577 chrono::weekday_last __wdl;
578 public:
579 constexpr month_weekday_last(const chrono::month& __mval, const chrono::weekday_last& __wdlval) noexcept
580 : __m{__mval}, __wdl{__wdlval} {}
581 inline constexpr chrono::month month() const noexcept { return __m; }
582 inline constexpr chrono::weekday_last weekday_last() const noexcept { return __wdl; }
583 inline constexpr bool ok() const noexcept { return __m.ok() && __wdl.ok(); }
584};
585
586inline constexpr
587bool operator==(const month_weekday_last& __lhs, const month_weekday_last& __rhs) noexcept
588{ return __lhs.month() == __rhs.month() && __lhs.weekday_last() == __rhs.weekday_last(); }
589
590inline constexpr
591bool operator!=(const month_weekday_last& __lhs, const month_weekday_last& __rhs) noexcept
592{ return !(__lhs == __rhs); }
593
594
595inline constexpr
596month_weekday_last operator/(const month& __lhs, const weekday_last& __rhs) noexcept
597{ return month_weekday_last{__lhs, __rhs}; }
598
599inline constexpr
600month_weekday_last operator/(int __lhs, const weekday_last& __rhs) noexcept
601{ return month_weekday_last{month(__lhs), __rhs}; }
602
603inline constexpr
604month_weekday_last operator/(const weekday_last& __lhs, const month& __rhs) noexcept
605{ return month_weekday_last{__rhs, __lhs}; }
606
607inline constexpr
608month_weekday_last operator/(const weekday_last& __lhs, int __rhs) noexcept
609{ return month_weekday_last{month(__rhs), __lhs}; }
610
611
612class year_month {
613 chrono::year __y;
614 chrono::month __m;
615public:
616 year_month() = default;
617 constexpr year_month(const chrono::year& __yval, const chrono::month& __mval) noexcept
618 : __y{__yval}, __m{__mval} {}
619 inline constexpr chrono::year year() const noexcept { return __y; }
620 inline constexpr chrono::month month() const noexcept { return __m; }
621 inline constexpr year_month& operator+=(const months& __dm) noexcept { this->__m += __dm; return *this; }
622 inline constexpr year_month& operator-=(const months& __dm) noexcept { this->__m -= __dm; return *this; }
623 inline constexpr year_month& operator+=(const years& __dy) noexcept { this->__y += __dy; return *this; }
624 inline constexpr year_month& operator-=(const years& __dy) noexcept { this->__y -= __dy; return *this; }
625 inline constexpr bool ok() const noexcept { return __y.ok() && __m.ok(); }
626};
627
628inline constexpr
629year_month operator/(const year& __y, const month& __m) noexcept { return year_month{__y, __m}; }
630
631inline constexpr
632year_month operator/(const year& __y, int __m) noexcept { return year_month{__y, month(__m)}; }
633
634inline constexpr
635bool operator==(const year_month& __lhs, const year_month& __rhs) noexcept
636{ return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month(); }
637
638inline constexpr
639bool operator!=(const year_month& __lhs, const year_month& __rhs) noexcept
640{ return !(__lhs == __rhs); }
641
642inline constexpr
643bool operator< (const year_month& __lhs, const year_month& __rhs) noexcept
644{ return __lhs.year() != __rhs.year() ? __lhs.year() < __rhs.year() : __lhs.month() < __rhs.month(); }
645
646inline constexpr
647bool operator> (const year_month& __lhs, const year_month& __rhs) noexcept
648{ return __rhs < __lhs; }
649
650inline constexpr
651bool operator<=(const year_month& __lhs, const year_month& __rhs) noexcept
652{ return !(__rhs < __lhs);}
653
654inline constexpr
655bool operator>=(const year_month& __lhs, const year_month& __rhs) noexcept
656{ return !(__lhs < __rhs); }
657
658constexpr year_month operator+(const year_month& __lhs, const months& __rhs) noexcept
659{
660 int __dmi = static_cast<int>(static_cast<unsigned>(__lhs.month())) - 1 + __rhs.count();
661 const int __dy = (__dmi >= 0 ? __dmi : __dmi-11) / 12;
662 __dmi = __dmi - __dy * 12 + 1;
663 return (__lhs.year() + years(__dy)) / month(static_cast<unsigned>(__dmi));
664}
665
666constexpr year_month operator+(const months& __lhs, const year_month& __rhs) noexcept
667{ return __rhs + __lhs; }
668
669constexpr year_month operator+(const year_month& __lhs, const years& __rhs) noexcept
670{ return (__lhs.year() + __rhs) / __lhs.month(); }
671
672constexpr year_month operator+(const years& __lhs, const year_month& __rhs) noexcept
673{ return __rhs + __lhs; }
674
675constexpr months operator-(const year_month& __lhs, const year_month& __rhs) noexcept
676{ return (__lhs.year() - __rhs.year()) + months(static_cast<unsigned>(__lhs.month()) - static_cast<unsigned>(__rhs.month())); }
677
678constexpr year_month operator-(const year_month& __lhs, const months& __rhs) noexcept
679{ return __lhs + -__rhs; }
680
681constexpr year_month operator-(const year_month& __lhs, const years& __rhs) noexcept
682{ return __lhs + -__rhs; }
683
684class year_month_day_last;
685
686class year_month_day {
687private:
688 chrono::year __y;
689 chrono::month __m;
690 chrono::day __d;
691public:
692 year_month_day() = default;
693 inline constexpr year_month_day(
694 const chrono::year& __yval, const chrono::month& __mval, const chrono::day& __dval) noexcept
695 : __y{__yval}, __m{__mval}, __d{__dval} {}
696 constexpr year_month_day(const year_month_day_last& __ymdl) noexcept;
697 inline constexpr year_month_day(const sys_days& __sysd) noexcept
698 : year_month_day(__from_days(__sysd.time_since_epoch())) {}
699 inline explicit constexpr year_month_day(const local_days& __locd) noexcept
700 : year_month_day(__from_days(__locd.time_since_epoch())) {}
701
702 constexpr year_month_day& operator+=(const months& __dm) noexcept;
703 constexpr year_month_day& operator-=(const months& __dm) noexcept;
704 constexpr year_month_day& operator+=(const years& __dy) noexcept;
705 constexpr year_month_day& operator-=(const years& __dy) noexcept;
706
707 inline constexpr chrono::year year() const noexcept { return __y; }
708 inline constexpr chrono::month month() const noexcept { return __m; }
709 inline constexpr chrono::day day() const noexcept { return __d; }
710 inline constexpr operator sys_days() const noexcept { return sys_days{__to_days()}; }
711 inline explicit constexpr operator local_days() const noexcept { return local_days{__to_days()}; }
712
713 constexpr bool ok() const noexcept;
714
715 static constexpr year_month_day __from_days(days __d) noexcept;
716 constexpr days __to_days() const noexcept;
717};
718
719
720// https://howardhinnant.github.io/date_algorithms.html#civil_from_days
721inline constexpr
722year_month_day
723year_month_day::__from_days(days __d) noexcept
724{
725 static_assert(numeric_limits<unsigned>::digits >= 18, "");
726 static_assert(numeric_limits<int>::digits >= 20 , "");
727 const int __z = __d.count() + 719468;
728 const int __era = (__z >= 0 ? __z : __z - 146096) / 146097;
729 const unsigned __doe = static_cast<unsigned>(__z - __era * 146097); // [0, 146096]
730 const unsigned __yoe = (__doe - __doe/1460 + __doe/36524 - __doe/146096) / 365; // [0, 399]
731 const int __yr = static_cast<int>(__yoe) + __era * 400;
732 const unsigned __doy = __doe - (365 * __yoe + __yoe/4 - __yoe/100); // [0, 365]
733 const unsigned __mp = (5 * __doy + 2)/153; // [0, 11]
734 const unsigned __dy = __doy - (153 * __mp + 2)/5 + 1; // [1, 31]
735 const unsigned __mth = __mp + (__mp < 10 ? 3 : -9); // [1, 12]
736 return year_month_day{chrono::year{__yr + (__mth <= 2)}, chrono::month{__mth}, chrono::day{__dy}};
737}
738
739// https://howardhinnant.github.io/date_algorithms.html#days_from_civil
740inline constexpr days year_month_day::__to_days() const noexcept
741{
742 static_assert(numeric_limits<unsigned>::digits >= 18, "");
743 static_assert(numeric_limits<int>::digits >= 20 , "");
744
745 const int __yr = static_cast<int>(__y) - (__m <= February);
746 const unsigned __mth = static_cast<unsigned>(__m);
747 const unsigned __dy = static_cast<unsigned>(__d);
748
749 const int __era = (__yr >= 0 ? __yr : __yr - 399) / 400;
750 const unsigned __yoe = static_cast<unsigned>(__yr - __era * 400); // [0, 399]
751 const unsigned __doy = (153 * (__mth + (__mth > 2 ? -3 : 9)) + 2) / 5 + __dy-1; // [0, 365]
752 const unsigned __doe = __yoe * 365 + __yoe/4 - __yoe/100 + __doy; // [0, 146096]
753 return days{__era * 146097 + static_cast<int>(__doe) - 719468};
754}
755
756inline constexpr
757bool operator==(const year_month_day& __lhs, const year_month_day& __rhs) noexcept
758{ return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month() && __lhs.day() == __rhs.day(); }
759
760inline constexpr
761bool operator!=(const year_month_day& __lhs, const year_month_day& __rhs) noexcept
762{ return !(__lhs == __rhs); }
763
764inline constexpr
765bool operator< (const year_month_day& __lhs, const year_month_day& __rhs) noexcept
766{
767 if (__lhs.year() < __rhs.year()) return true;
768 if (__lhs.year() > __rhs.year()) return false;
769 if (__lhs.month() < __rhs.month()) return true;
770 if (__lhs.month() > __rhs.month()) return false;
771 return __lhs.day() < __rhs.day();
772}
773
774inline constexpr
775bool operator> (const year_month_day& __lhs, const year_month_day& __rhs) noexcept
776{ return __rhs < __lhs; }
777
778inline constexpr
779bool operator<=(const year_month_day& __lhs, const year_month_day& __rhs) noexcept
780{ return !(__rhs < __lhs);}
781
782inline constexpr
783bool operator>=(const year_month_day& __lhs, const year_month_day& __rhs) noexcept
784{ return !(__lhs < __rhs); }
785
786inline constexpr
787year_month_day operator/(const year_month& __lhs, const day& __rhs) noexcept
788{ return year_month_day{__lhs.year(), __lhs.month(), __rhs}; }
789
790inline constexpr
791year_month_day operator/(const year_month& __lhs, int __rhs) noexcept
792{ return __lhs / day(__rhs); }
793
794inline constexpr
795year_month_day operator/(const year& __lhs, const month_day& __rhs) noexcept
796{ return __lhs / __rhs.month() / __rhs.day(); }
797
798inline constexpr
799year_month_day operator/(int __lhs, const month_day& __rhs) noexcept
800{ return year(__lhs) / __rhs; }
801
802inline constexpr
803year_month_day operator/(const month_day& __lhs, const year& __rhs) noexcept
804{ return __rhs / __lhs; }
805
806inline constexpr
807year_month_day operator/(const month_day& __lhs, int __rhs) noexcept
808{ return year(__rhs) / __lhs; }
809
810
811inline constexpr
812year_month_day operator+(const year_month_day& __lhs, const months& __rhs) noexcept
813{ return (__lhs.year()/__lhs.month() + __rhs)/__lhs.day(); }
814
815inline constexpr
816year_month_day operator+(const months& __lhs, const year_month_day& __rhs) noexcept
817{ return __rhs + __lhs; }
818
819inline constexpr
820year_month_day operator-(const year_month_day& __lhs, const months& __rhs) noexcept
821{ return __lhs + -__rhs; }
822
823inline constexpr
824year_month_day operator+(const year_month_day& __lhs, const years& __rhs) noexcept
825{ return (__lhs.year() + __rhs) / __lhs.month() / __lhs.day(); }
826
827inline constexpr
828year_month_day operator+(const years& __lhs, const year_month_day& __rhs) noexcept
829{ return __rhs + __lhs; }
830
831inline constexpr
832year_month_day operator-(const year_month_day& __lhs, const years& __rhs) noexcept
833{ return __lhs + -__rhs; }
834
835inline constexpr year_month_day& year_month_day::operator+=(const months& __dm) noexcept { *this = *this + __dm; return *this; }
836inline constexpr year_month_day& year_month_day::operator-=(const months& __dm) noexcept { *this = *this - __dm; return *this; }
837inline constexpr year_month_day& year_month_day::operator+=(const years& __dy) noexcept { *this = *this + __dy; return *this; }
838inline constexpr year_month_day& year_month_day::operator-=(const years& __dy) noexcept { *this = *this - __dy; return *this; }
839
840class year_month_day_last {
841private:
842 chrono::year __y;
843 chrono::month_day_last __mdl;
844public:
845 constexpr year_month_day_last(const year& __yval, const month_day_last& __mdlval) noexcept
846 : __y{__yval}, __mdl{__mdlval} {}
847
848 constexpr year_month_day_last& operator+=(const months& __m) noexcept;
849 constexpr year_month_day_last& operator-=(const months& __m) noexcept;
850 constexpr year_month_day_last& operator+=(const years& __y) noexcept;
851 constexpr year_month_day_last& operator-=(const years& __y) noexcept;
852
853 inline constexpr chrono::year year() const noexcept { return __y; }
854 inline constexpr chrono::month month() const noexcept { return __mdl.month(); }
855 inline constexpr chrono::month_day_last month_day_last() const noexcept { return __mdl; }
856 constexpr chrono::day day() const noexcept;
857 inline constexpr operator sys_days() const noexcept { return sys_days{year()/month()/day()}; }
858 inline explicit constexpr operator local_days() const noexcept { return local_days{year()/month()/day()}; }
859 inline constexpr bool ok() const noexcept { return __y.ok() && __mdl.ok(); }
860};
861
862inline constexpr
863chrono::day year_month_day_last::day() const noexcept
864{
865 constexpr chrono::day __d[] =
866 {
867 chrono::day(31), chrono::day(28), chrono::day(31),
868 chrono::day(30), chrono::day(31), chrono::day(30),
869 chrono::day(31), chrono::day(31), chrono::day(30),
870 chrono::day(31), chrono::day(30), chrono::day(31)
871 };
872 return (month() != February || !__y.is_leap()) && month().ok() ?
873 __d[static_cast<unsigned>(month()) - 1] : chrono::day{29};
874}
875
876inline constexpr
877bool operator==(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept
878{ return __lhs.year() == __rhs.year() && __lhs.month_day_last() == __rhs.month_day_last(); }
879
880inline constexpr
881bool operator!=(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept
882{ return !(__lhs == __rhs); }
883
884inline constexpr
885bool operator< (const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept
886{
887 if (__lhs.year() < __rhs.year()) return true;
888 if (__lhs.year() > __rhs.year()) return false;
889 return __lhs.month_day_last() < __rhs.month_day_last();
890}
891
892inline constexpr
893bool operator> (const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept
894{ return __rhs < __lhs; }
895
896inline constexpr
897bool operator<=(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept
898{ return !(__rhs < __lhs);}
899
900inline constexpr
901bool operator>=(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept
902{ return !(__lhs < __rhs); }
903
904inline constexpr year_month_day_last operator/(const year_month& __lhs, last_spec) noexcept
905{ return year_month_day_last{__lhs.year(), month_day_last{__lhs.month()}}; }
906
907inline constexpr year_month_day_last operator/(const year& __lhs, const month_day_last& __rhs) noexcept
908{ return year_month_day_last{__lhs, __rhs}; }
909
910inline constexpr year_month_day_last operator/(int __lhs, const month_day_last& __rhs) noexcept
911{ return year_month_day_last{year{__lhs}, __rhs}; }
912
913inline constexpr year_month_day_last operator/(const month_day_last& __lhs, const year& __rhs) noexcept
914{ return __rhs / __lhs; }
915
916inline constexpr year_month_day_last operator/(const month_day_last& __lhs, int __rhs) noexcept
917{ return year{__rhs} / __lhs; }
918
919
920inline constexpr
921year_month_day_last operator+(const year_month_day_last& __lhs, const months& __rhs) noexcept
922{ return (__lhs.year() / __lhs.month() + __rhs) / last; }
923
924inline constexpr
925year_month_day_last operator+(const months& __lhs, const year_month_day_last& __rhs) noexcept
926{ return __rhs + __lhs; }
927
928inline constexpr
929year_month_day_last operator-(const year_month_day_last& __lhs, const months& __rhs) noexcept
930{ return __lhs + (-__rhs); }
931
932inline constexpr
933year_month_day_last operator+(const year_month_day_last& __lhs, const years& __rhs) noexcept
934{ return year_month_day_last{__lhs.year() + __rhs, __lhs.month_day_last()}; }
935
936inline constexpr
937year_month_day_last operator+(const years& __lhs, const year_month_day_last& __rhs) noexcept
938{ return __rhs + __lhs; }
939
940inline constexpr
941year_month_day_last operator-(const year_month_day_last& __lhs, const years& __rhs) noexcept
942{ return __lhs + (-__rhs); }
943
944inline constexpr year_month_day_last& year_month_day_last::operator+=(const months& __dm) noexcept { *this = *this + __dm; return *this; }
945inline constexpr year_month_day_last& year_month_day_last::operator-=(const months& __dm) noexcept { *this = *this - __dm; return *this; }
946inline constexpr year_month_day_last& year_month_day_last::operator+=(const years& __dy) noexcept { *this = *this + __dy; return *this; }
947inline constexpr year_month_day_last& year_month_day_last::operator-=(const years& __dy) noexcept { *this = *this - __dy; return *this; }
948
949inline constexpr year_month_day::year_month_day(const year_month_day_last& __ymdl) noexcept
950 : __y{__ymdl.year()}, __m{__ymdl.month()}, __d{__ymdl.day()} {}
951
952inline constexpr bool year_month_day::ok() const noexcept
953{
954 if (!__y.ok() || !__m.ok()) return false;
955 return chrono::day{1} <= __d && __d <= (__y / __m / last).day();
956}
957
958class year_month_weekday {
959 chrono::year __y;
960 chrono::month __m;
961 chrono::weekday_indexed __wdi;
962public:
963 year_month_weekday() = default;
964 constexpr year_month_weekday(const chrono::year& __yval, const chrono::month& __mval,
965 const chrono::weekday_indexed& __wdival) noexcept
966 : __y{__yval}, __m{__mval}, __wdi{__wdival} {}
967 constexpr year_month_weekday(const sys_days& __sysd) noexcept
968 : year_month_weekday(__from_days(__sysd.time_since_epoch())) {}
969 inline explicit constexpr year_month_weekday(const local_days& __locd) noexcept
970 : year_month_weekday(__from_days(__locd.time_since_epoch())) {}
971 constexpr year_month_weekday& operator+=(const months& m) noexcept;
972 constexpr year_month_weekday& operator-=(const months& m) noexcept;
973 constexpr year_month_weekday& operator+=(const years& y) noexcept;
974 constexpr year_month_weekday& operator-=(const years& y) noexcept;
975
976 inline constexpr chrono::year year() const noexcept { return __y; }
977 inline constexpr chrono::month month() const noexcept { return __m; }
978 inline constexpr chrono::weekday weekday() const noexcept { return __wdi.weekday(); }
979 inline constexpr unsigned index() const noexcept { return __wdi.index(); }
980 inline constexpr chrono::weekday_indexed weekday_indexed() const noexcept { return __wdi; }
981
982 inline constexpr operator sys_days() const noexcept { return sys_days{__to_days()}; }
983 inline explicit constexpr operator local_days() const noexcept { return local_days{__to_days()}; }
984 inline constexpr bool ok() const noexcept
985 {
986 if (!__y.ok() || !__m.ok() || !__wdi.ok()) return false;
987 if (__wdi.index() <= 4) return true;
988 auto __nth_weekday_day =
989 __wdi.weekday() -
990 chrono::weekday{static_cast<sys_days>(__y / __m / 1)} +
991 days{(__wdi.index() - 1) * 7 + 1};
992 return static_cast<unsigned>(__nth_weekday_day.count()) <=
993 static_cast<unsigned>((__y / __m / last).day());
994 }
995
996 static constexpr year_month_weekday __from_days(days __d) noexcept;
997 constexpr days __to_days() const noexcept;
998};
999
1000inline constexpr
1001year_month_weekday year_month_weekday::__from_days(days __d) noexcept
1002{
1003 const sys_days __sysd{__d};
1004 const chrono::weekday __wd = chrono::weekday(__sysd);
1005 const year_month_day __ymd = year_month_day(__sysd);
1006 return year_month_weekday{__ymd.year(), __ymd.month(),
1007 __wd[(static_cast<unsigned>(__ymd.day())-1)/7+1]};
1008}
1009
1010inline constexpr
1011days year_month_weekday::__to_days() const noexcept
1012{
1013 const sys_days __sysd = sys_days(__y/__m/1);
1014 return (__sysd + (__wdi.weekday() - chrono::weekday(__sysd) + days{(__wdi.index()-1)*7}))
1015 .time_since_epoch();
1016}
1017
1018inline constexpr
1019bool operator==(const year_month_weekday& __lhs, const year_month_weekday& __rhs) noexcept
1020{ return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month() && __lhs.weekday_indexed() == __rhs.weekday_indexed(); }
1021
1022inline constexpr
1023bool operator!=(const year_month_weekday& __lhs, const year_month_weekday& __rhs) noexcept
1024{ return !(__lhs == __rhs); }
1025
1026inline constexpr
1027year_month_weekday operator/(const year_month& __lhs, const weekday_indexed& __rhs) noexcept
1028{ return year_month_weekday{__lhs.year(), __lhs.month(), __rhs}; }
1029
1030inline constexpr
1031year_month_weekday operator/(const year& __lhs, const month_weekday& __rhs) noexcept
1032{ return year_month_weekday{__lhs, __rhs.month(), __rhs.weekday_indexed()}; }
1033
1034inline constexpr
1035year_month_weekday operator/(int __lhs, const month_weekday& __rhs) noexcept
1036{ return year(__lhs) / __rhs; }
1037
1038inline constexpr
1039year_month_weekday operator/(const month_weekday& __lhs, const year& __rhs) noexcept
1040{ return __rhs / __lhs; }
1041
1042inline constexpr
1043year_month_weekday operator/(const month_weekday& __lhs, int __rhs) noexcept
1044{ return year(__rhs) / __lhs; }
1045
1046
1047inline constexpr
1048year_month_weekday operator+(const year_month_weekday& __lhs, const months& __rhs) noexcept
1049{ return (__lhs.year() / __lhs.month() + __rhs) / __lhs.weekday_indexed(); }
1050
1051inline constexpr
1052year_month_weekday operator+(const months& __lhs, const year_month_weekday& __rhs) noexcept
1053{ return __rhs + __lhs; }
1054
1055inline constexpr
1056year_month_weekday operator-(const year_month_weekday& __lhs, const months& __rhs) noexcept
1057{ return __lhs + (-__rhs); }
1058
1059inline constexpr
1060year_month_weekday operator+(const year_month_weekday& __lhs, const years& __rhs) noexcept
1061{ return year_month_weekday{__lhs.year() + __rhs, __lhs.month(), __lhs.weekday_indexed()}; }
1062
1063inline constexpr
1064year_month_weekday operator+(const years& __lhs, const year_month_weekday& __rhs) noexcept
1065{ return __rhs + __lhs; }
1066
1067inline constexpr
1068year_month_weekday operator-(const year_month_weekday& __lhs, const years& __rhs) noexcept
1069{ return __lhs + (-__rhs); }
1070
1071
1072inline constexpr year_month_weekday& year_month_weekday::operator+=(const months& __dm) noexcept { *this = *this + __dm; return *this; }
1073inline constexpr year_month_weekday& year_month_weekday::operator-=(const months& __dm) noexcept { *this = *this - __dm; return *this; }
1074inline constexpr year_month_weekday& year_month_weekday::operator+=(const years& __dy) noexcept { *this = *this + __dy; return *this; }
1075inline constexpr year_month_weekday& year_month_weekday::operator-=(const years& __dy) noexcept { *this = *this - __dy; return *this; }
1076
1077class year_month_weekday_last {
1078private:
1079 chrono::year __y;
1080 chrono::month __m;
1081 chrono::weekday_last __wdl;
1082public:
1083 constexpr year_month_weekday_last(const chrono::year& __yval, const chrono::month& __mval,
1084 const chrono::weekday_last& __wdlval) noexcept
1085 : __y{__yval}, __m{__mval}, __wdl{__wdlval} {}
1086 constexpr year_month_weekday_last& operator+=(const months& __dm) noexcept;
1087 constexpr year_month_weekday_last& operator-=(const months& __dm) noexcept;
1088 constexpr year_month_weekday_last& operator+=(const years& __dy) noexcept;
1089 constexpr year_month_weekday_last& operator-=(const years& __dy) noexcept;
1090
1091 inline constexpr chrono::year year() const noexcept { return __y; }
1092 inline constexpr chrono::month month() const noexcept { return __m; }
1093 inline constexpr chrono::weekday weekday() const noexcept { return __wdl.weekday(); }
1094 inline constexpr chrono::weekday_last weekday_last() const noexcept { return __wdl; }
1095 inline constexpr operator sys_days() const noexcept { return sys_days{__to_days()}; }
1096 inline explicit constexpr operator local_days() const noexcept { return local_days{__to_days()}; }
1097 inline constexpr bool ok() const noexcept { return __y.ok() && __m.ok() && __wdl.ok(); }
1098
1099 constexpr days __to_days() const noexcept;
1100
1101};
1102
1103inline constexpr
1104days year_month_weekday_last::__to_days() const noexcept
1105{
1106 const sys_days __last = sys_days{__y/__m/last};
1107 return (__last - (chrono::weekday{__last} - __wdl.weekday())).time_since_epoch();
1108
1109}
1110
1111inline constexpr
1112bool operator==(const year_month_weekday_last& __lhs, const year_month_weekday_last& __rhs) noexcept
1113{ return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month() && __lhs.weekday_last() == __rhs.weekday_last(); }
1114
1115inline constexpr
1116bool operator!=(const year_month_weekday_last& __lhs, const year_month_weekday_last& __rhs) noexcept
1117{ return !(__lhs == __rhs); }
1118
1119
1120inline constexpr
1121year_month_weekday_last operator/(const year_month& __lhs, const weekday_last& __rhs) noexcept
1122{ return year_month_weekday_last{__lhs.year(), __lhs.month(), __rhs}; }
1123
1124inline constexpr
1125year_month_weekday_last operator/(const year& __lhs, const month_weekday_last& __rhs) noexcept
1126{ return year_month_weekday_last{__lhs, __rhs.month(), __rhs.weekday_last()}; }
1127
1128inline constexpr
1129year_month_weekday_last operator/(int __lhs, const month_weekday_last& __rhs) noexcept
1130{ return year(__lhs) / __rhs; }
1131
1132inline constexpr
1133year_month_weekday_last operator/(const month_weekday_last& __lhs, const year& __rhs) noexcept
1134{ return __rhs / __lhs; }
1135
1136inline constexpr
1137year_month_weekday_last operator/(const month_weekday_last& __lhs, int __rhs) noexcept
1138{ return year(__rhs) / __lhs; }
1139
1140
1141inline constexpr
1142year_month_weekday_last operator+(const year_month_weekday_last& __lhs, const months& __rhs) noexcept
1143{ return (__lhs.year() / __lhs.month() + __rhs) / __lhs.weekday_last(); }
1144
1145inline constexpr
1146year_month_weekday_last operator+(const months& __lhs, const year_month_weekday_last& __rhs) noexcept
1147{ return __rhs + __lhs; }
1148
1149inline constexpr
1150year_month_weekday_last operator-(const year_month_weekday_last& __lhs, const months& __rhs) noexcept
1151{ return __lhs + (-__rhs); }
1152
1153inline constexpr
1154year_month_weekday_last operator+(const year_month_weekday_last& __lhs, const years& __rhs) noexcept
1155{ return year_month_weekday_last{__lhs.year() + __rhs, __lhs.month(), __lhs.weekday_last()}; }
1156
1157inline constexpr
1158year_month_weekday_last operator+(const years& __lhs, const year_month_weekday_last& __rhs) noexcept
1159{ return __rhs + __lhs; }
1160
1161inline constexpr
1162year_month_weekday_last operator-(const year_month_weekday_last& __lhs, const years& __rhs) noexcept
1163{ return __lhs + (-__rhs); }
1164
1165inline constexpr year_month_weekday_last& year_month_weekday_last::operator+=(const months& __dm) noexcept { *this = *this + __dm; return *this; }
1166inline constexpr year_month_weekday_last& year_month_weekday_last::operator-=(const months& __dm) noexcept { *this = *this - __dm; return *this; }
1167inline constexpr year_month_weekday_last& year_month_weekday_last::operator+=(const years& __dy) noexcept { *this = *this + __dy; return *this; }
1168inline constexpr year_month_weekday_last& year_month_weekday_last::operator-=(const years& __dy) noexcept { *this = *this - __dy; return *this; }
1169
1170
1171template <class _Duration>
1172class hh_mm_ss
1173{
1174private:
1175 static_assert(__is_duration<_Duration>::value, "template parameter of hh_mm_ss must be a std::chrono::duration");
1176 using __CommonType = common_type_t<_Duration, chrono::seconds>;
1177
1178 static constexpr uint64_t __pow10(unsigned __exp)
1179 {
1180 uint64_t __ret = 1;
1181 for (unsigned __i = 0; __i < __exp; ++__i)
1182 __ret *= 10U;
1183 return __ret;
1184 }
1185
1186 static constexpr unsigned __width(uint64_t __n, uint64_t __d = 10, unsigned __w = 0)
1187 {
1188 if (__n >= 2 && __d != 0 && __w < 19)
1189 return 1 + __width(__n, __d % __n * 10, __w+1);
1190 return 0;
1191 }
1192
1193public:
1194 static unsigned constexpr fractional_width = __width(__CommonType::period::den) < 19 ?
1195 __width(__CommonType::period::den) : 6u;
1196 using precision = duration<typename __CommonType::rep, ratio<1, __pow10(fractional_width)>>;
1197
1198 constexpr hh_mm_ss() noexcept : hh_mm_ss{_Duration::zero()} {}
1199
1200 constexpr explicit hh_mm_ss(_Duration __d) noexcept :
1201 __is_neg(__d < _Duration(0)),
1202 __h(duration_cast<chrono::hours> (abs(__d))),
1203 __m(duration_cast<chrono::minutes>(abs(__d) - hours())),
1204 __s(duration_cast<chrono::seconds>(abs(__d) - hours() - minutes())),
1205 __f(duration_cast<precision> (abs(__d) - hours() - minutes() - seconds()))
1206 {}
1207
1208 constexpr bool is_negative() const noexcept { return __is_neg; }
1209 constexpr chrono::hours hours() const noexcept { return __h; }
1210 constexpr chrono::minutes minutes() const noexcept { return __m; }
1211 constexpr chrono::seconds seconds() const noexcept { return __s; }
1212 constexpr precision subseconds() const noexcept { return __f; }
1213
1214 constexpr precision to_duration() const noexcept
1215 {
1216 auto __dur = __h + __m + __s + __f;
1217 return __is_neg ? -__dur : __dur;
1218 }
1219
1220 constexpr explicit operator precision() const noexcept { return to_duration(); }
1221
1222private:
1223 bool __is_neg;
1224 chrono::hours __h;
1225 chrono::minutes __m;
1226 chrono::seconds __s;
1227 precision __f;
1228};
1229
1230constexpr bool is_am(const hours& __h) noexcept { return __h >= hours( 0) && __h < hours(12); }
1231constexpr bool is_pm(const hours& __h) noexcept { return __h >= hours(12) && __h < hours(24); }
1232
1233constexpr hours make12(const hours& __h) noexcept
1234{
1235 if (__h == hours( 0)) return hours(12);
1236 else if (__h <= hours(12)) return __h;
1237 else return __h - hours(12);
1238}
1239
1240constexpr hours make24(const hours& __h, bool __is_pm) noexcept
1241{
1242 if (__is_pm)
1243 return __h == hours(12) ? __h : __h + hours(12);
1244 else
1245 return __h == hours(12) ? hours(0) : __h;
1246}
1247
1248} // namespace chrono
1249
1250inline namespace literals
1251{
1252 inline namespace chrono_literals
1253 {
1254 constexpr chrono::day operator ""d(unsigned long long __d) noexcept
1255 {
1256 return chrono::day(static_cast<unsigned>(__d));
1257 }
1258
1259 constexpr chrono::year operator ""y(unsigned long long __y) noexcept
1260 {
1261 return chrono::year(static_cast<int>(__y));
1262 }
1263} // namespace chrono_literals
1264} // namespace literals
1265
1266namespace chrono { // hoist the literals into namespace std::chrono
1267 using namespace literals::chrono_literals;
1268} // namespace chrono38} // namespace chrono
126939
1270_LIBCPP_END_NAMESPACE_STD40_LIBCPP_END_NAMESPACE_STD
127141
1272#endif // _LIBCPP_STD_VER > 1742#endif // _LIBCPP_STD_VER > 17
127343
1274_LIBCPP_POP_MACROS
1275
1276#endif // _LIBCPP___CHRONO_CALENDAR_H44#endif // _LIBCPP___CHRONO_CALENDAR_H
lib/libcxx/include/__chrono/convert_to_timespec.h+1-1
...@@ -14,7 +14,7 @@...@@ -14,7 +14,7 @@
14#include <limits>14#include <limits>
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
18#endif18#endif
1919
20_LIBCPP_PUSH_MACROS20_LIBCPP_PUSH_MACROS
lib/libcxx/include/__chrono/day.h created+84
...@@ -0,0 +1,84 @@
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_DAY_H
11#define _LIBCPP___CHRONO_DAY_H
12
13#include <__chrono/duration.h>
14#include <__config>
15#include <compare>
16
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header
19#endif
20
21#if _LIBCPP_STD_VER > 17
22
23_LIBCPP_BEGIN_NAMESPACE_STD
24
25namespace chrono
26{
27
28class day {
29private:
30 unsigned char __d;
31public:
32 _LIBCPP_HIDE_FROM_ABI day() = default;
33 _LIBCPP_HIDE_FROM_ABI explicit inline constexpr day(unsigned __val) noexcept : __d(static_cast<unsigned char>(__val)) {}
34 _LIBCPP_HIDE_FROM_ABI inline constexpr day& operator++() noexcept { ++__d; return *this; }
35 _LIBCPP_HIDE_FROM_ABI inline constexpr day operator++(int) noexcept { day __tmp = *this; ++(*this); return __tmp; }
36 _LIBCPP_HIDE_FROM_ABI inline constexpr day& operator--() noexcept { --__d; return *this; }
37 _LIBCPP_HIDE_FROM_ABI inline constexpr day operator--(int) noexcept { day __tmp = *this; --(*this); return __tmp; }
38 _LIBCPP_HIDE_FROM_ABI constexpr day& operator+=(const days& __dd) noexcept;
39 _LIBCPP_HIDE_FROM_ABI constexpr day& operator-=(const days& __dd) noexcept;
40 _LIBCPP_HIDE_FROM_ABI explicit inline constexpr operator unsigned() const noexcept { return __d; }
41 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __d >= 1 && __d <= 31; }
42 };
43
44
45_LIBCPP_HIDE_FROM_ABI inline constexpr
46bool operator==(const day& __lhs, const day& __rhs) noexcept
47{ return static_cast<unsigned>(__lhs) == static_cast<unsigned>(__rhs); }
48
49_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering operator<=>(const day& __lhs, const day& __rhs) noexcept {
50 return static_cast<unsigned>(__lhs) <=> static_cast<unsigned>(__rhs);
51}
52
53_LIBCPP_HIDE_FROM_ABI inline constexpr
54day operator+ (const day& __lhs, const days& __rhs) noexcept
55{ return day(static_cast<unsigned>(__lhs) + __rhs.count()); }
56
57_LIBCPP_HIDE_FROM_ABI inline constexpr
58day operator+ (const days& __lhs, const day& __rhs) noexcept
59{ return __rhs + __lhs; }
60
61_LIBCPP_HIDE_FROM_ABI inline constexpr
62day operator- (const day& __lhs, const days& __rhs) noexcept
63{ return __lhs + -__rhs; }
64
65_LIBCPP_HIDE_FROM_ABI inline constexpr
66days operator-(const day& __lhs, const day& __rhs) noexcept
67{ return days(static_cast<int>(static_cast<unsigned>(__lhs)) -
68 static_cast<int>(static_cast<unsigned>(__rhs))); }
69
70_LIBCPP_HIDE_FROM_ABI inline constexpr
71day& day::operator+=(const days& __dd) noexcept
72{ *this = *this + __dd; return *this; }
73
74_LIBCPP_HIDE_FROM_ABI inline constexpr
75day& day::operator-=(const days& __dd) noexcept
76{ *this = *this - __dd; return *this; }
77
78} // namespace chrono
79
80_LIBCPP_END_NAMESPACE_STD
81
82#endif // _LIBCPP_STD_VER > 17
83
84#endif // _LIBCPP___CHRONO_DAY_H
lib/libcxx/include/__chrono/duration.h+5-5
...@@ -16,7 +16,7 @@...@@ -16,7 +16,7 @@
16#include <type_traits>16#include <type_traits>
1717
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19#pragma GCC system_header19# pragma GCC system_header
20#endif20#endif
2121
22_LIBCPP_PUSH_MACROS22_LIBCPP_PUSH_MACROS
...@@ -286,10 +286,10 @@ public:...@@ -286,10 +286,10 @@ public:
286 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator+=(const duration& __d) {__rep_ += __d.count(); return *this;}286 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator+=(const duration& __d) {__rep_ += __d.count(); return *this;}
287 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator-=(const duration& __d) {__rep_ -= __d.count(); return *this;}287 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator-=(const duration& __d) {__rep_ -= __d.count(); return *this;}
288288
289 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator*=(const rep& rhs) {__rep_ *= rhs; return *this;}289 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator*=(const rep& __rhs) {__rep_ *= __rhs; return *this;}
290 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator/=(const rep& rhs) {__rep_ /= rhs; return *this;}290 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator/=(const rep& __rhs) {__rep_ /= __rhs; return *this;}
291 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator%=(const rep& rhs) {__rep_ %= rhs; return *this;}291 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator%=(const rep& __rhs) {__rep_ %= __rhs; return *this;}
292 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator%=(const duration& rhs) {__rep_ %= rhs.count(); return *this;}292 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator%=(const duration& __rhs) {__rep_ %= __rhs.count(); return *this;}
293293
294 // special values294 // special values
295295
lib/libcxx/include/__chrono/file_clock.h+1-1
...@@ -18,7 +18,7 @@...@@ -18,7 +18,7 @@
18#include <ratio>18#include <ratio>
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
22#endif22#endif
2323
24#ifndef _LIBCPP_CXX03_LANG24#ifndef _LIBCPP_CXX03_LANG
lib/libcxx/include/__chrono/hh_mm_ss.h created+112
...@@ -0,0 +1,112 @@
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_HH_MM_SS_H
11#define _LIBCPP___CHRONO_HH_MM_SS_H
12
13#include <__chrono/duration.h>
14#include <__chrono/time_point.h>
15#include <__config>
16#include <ratio>
17#include <type_traits>
18
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20# pragma GCC system_header
21#endif
22
23#if _LIBCPP_STD_VER > 17
24
25_LIBCPP_BEGIN_NAMESPACE_STD
26
27namespace chrono
28{
29
30template <class _Duration>
31class hh_mm_ss
32{
33private:
34 static_assert(__is_duration<_Duration>::value, "template parameter of hh_mm_ss must be a std::chrono::duration");
35 using __CommonType = common_type_t<_Duration, chrono::seconds>;
36
37 _LIBCPP_HIDE_FROM_ABI static constexpr uint64_t __pow10(unsigned __exp)
38 {
39 uint64_t __ret = 1;
40 for (unsigned __i = 0; __i < __exp; ++__i)
41 __ret *= 10U;
42 return __ret;
43 }
44
45 _LIBCPP_HIDE_FROM_ABI static constexpr unsigned __width(uint64_t __n, uint64_t __d = 10, unsigned __w = 0)
46 {
47 if (__n >= 2 && __d != 0 && __w < 19)
48 return 1 + __width(__n, __d % __n * 10, __w+1);
49 return 0;
50 }
51
52public:
53 _LIBCPP_HIDE_FROM_ABI static unsigned constexpr fractional_width = __width(__CommonType::period::den) < 19 ?
54 __width(__CommonType::period::den) : 6u;
55 using precision = duration<typename __CommonType::rep, ratio<1, __pow10(fractional_width)>>;
56
57 _LIBCPP_HIDE_FROM_ABI constexpr hh_mm_ss() noexcept : hh_mm_ss{_Duration::zero()} {}
58
59 _LIBCPP_HIDE_FROM_ABI constexpr explicit hh_mm_ss(_Duration __d) noexcept :
60 __is_neg(__d < _Duration(0)),
61 __h(duration_cast<chrono::hours> (abs(__d))),
62 __m(duration_cast<chrono::minutes>(abs(__d) - hours())),
63 __s(duration_cast<chrono::seconds>(abs(__d) - hours() - minutes())),
64 __f(duration_cast<precision> (abs(__d) - hours() - minutes() - seconds()))
65 {}
66
67 _LIBCPP_HIDE_FROM_ABI constexpr bool is_negative() const noexcept { return __is_neg; }
68 _LIBCPP_HIDE_FROM_ABI constexpr chrono::hours hours() const noexcept { return __h; }
69 _LIBCPP_HIDE_FROM_ABI constexpr chrono::minutes minutes() const noexcept { return __m; }
70 _LIBCPP_HIDE_FROM_ABI constexpr chrono::seconds seconds() const noexcept { return __s; }
71 _LIBCPP_HIDE_FROM_ABI constexpr precision subseconds() const noexcept { return __f; }
72
73 _LIBCPP_HIDE_FROM_ABI constexpr precision to_duration() const noexcept
74 {
75 auto __dur = __h + __m + __s + __f;
76 return __is_neg ? -__dur : __dur;
77 }
78
79 _LIBCPP_HIDE_FROM_ABI constexpr explicit operator precision() const noexcept { return to_duration(); }
80
81private:
82 bool __is_neg;
83 chrono::hours __h;
84 chrono::minutes __m;
85 chrono::seconds __s;
86 precision __f;
87};
88
89_LIBCPP_HIDE_FROM_ABI constexpr bool is_am(const hours& __h) noexcept { return __h >= hours( 0) && __h < hours(12); }
90_LIBCPP_HIDE_FROM_ABI constexpr bool is_pm(const hours& __h) noexcept { return __h >= hours(12) && __h < hours(24); }
91
92_LIBCPP_HIDE_FROM_ABI constexpr hours make12(const hours& __h) noexcept
93{
94 if (__h == hours( 0)) return hours(12);
95 else if (__h <= hours(12)) return __h;
96 else return __h - hours(12);
97}
98
99_LIBCPP_HIDE_FROM_ABI constexpr hours make24(const hours& __h, bool __is_pm) noexcept
100{
101 if (__is_pm)
102 return __h == hours(12) ? __h : __h + hours(12);
103 else
104 return __h == hours(12) ? hours(0) : __h;
105}
106} // namespace chrono
107
108_LIBCPP_END_NAMESPACE_STD
109
110#endif // _LIBCPP_STD_VER > 17
111
112#endif // _LIBCPP___CHRONO_HH_MM_SS_H
lib/libcxx/include/__chrono/high_resolution_clock.h+1-1
...@@ -15,7 +15,7 @@...@@ -15,7 +15,7 @@
15#include <__config>15#include <__config>
1616
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header18# pragma GCC system_header
19#endif19#endif
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__chrono/literals.h created+49
...@@ -0,0 +1,49 @@
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_LITERALS_H
11#define _LIBCPP___CHRONO_LITERALS_H
12
13#include <__chrono/day.h>
14#include <__chrono/year.h>
15#include <__config>
16
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header
19#endif
20
21#if _LIBCPP_STD_VER > 17
22
23_LIBCPP_BEGIN_NAMESPACE_STD
24
25inline namespace literals
26{
27 inline namespace chrono_literals
28 {
29 _LIBCPP_HIDE_FROM_ABI constexpr chrono::day operator ""d(unsigned long long __d) noexcept
30 {
31 return chrono::day(static_cast<unsigned>(__d));
32 }
33
34 _LIBCPP_HIDE_FROM_ABI constexpr chrono::year operator ""y(unsigned long long __y) noexcept
35 {
36 return chrono::year(static_cast<int>(__y));
37 }
38} // namespace chrono_literals
39} // namespace literals
40
41namespace chrono { // hoist the literals into namespace std::chrono
42 using namespace literals::chrono_literals;
43} // namespace chrono
44
45_LIBCPP_END_NAMESPACE_STD
46
47#endif // _LIBCPP_STD_VER > 17
48
49#endif // _LIBCPP___CHRONO_LITERALS_H
lib/libcxx/include/__chrono/month.h created+118
...@@ -0,0 +1,118 @@
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_MONTH_H
11#define _LIBCPP___CHRONO_MONTH_H
12
13#include <__chrono/duration.h>
14#include <__config>
15
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header
18#endif
19
20#if _LIBCPP_STD_VER > 17
21
22_LIBCPP_BEGIN_NAMESPACE_STD
23
24namespace chrono
25{
26
27class month {
28private:
29 unsigned char __m;
30public:
31 _LIBCPP_HIDE_FROM_ABI month() = default;
32 _LIBCPP_HIDE_FROM_ABI explicit inline constexpr month(unsigned __val) noexcept : __m(static_cast<unsigned char>(__val)) {}
33 _LIBCPP_HIDE_FROM_ABI inline constexpr month& operator++() noexcept { ++__m; return *this; }
34 _LIBCPP_HIDE_FROM_ABI inline constexpr month operator++(int) noexcept { month __tmp = *this; ++(*this); return __tmp; }
35 _LIBCPP_HIDE_FROM_ABI inline constexpr month& operator--() noexcept { --__m; return *this; }
36 _LIBCPP_HIDE_FROM_ABI inline constexpr month operator--(int) noexcept { month __tmp = *this; --(*this); return __tmp; }
37 _LIBCPP_HIDE_FROM_ABI constexpr month& operator+=(const months& __m1) noexcept;
38 _LIBCPP_HIDE_FROM_ABI constexpr month& operator-=(const months& __m1) noexcept;
39 _LIBCPP_HIDE_FROM_ABI explicit inline constexpr operator unsigned() const noexcept { return __m; }
40 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __m >= 1 && __m <= 12; }
41};
42
43
44_LIBCPP_HIDE_FROM_ABI inline constexpr
45bool operator==(const month& __lhs, const month& __rhs) noexcept
46{ return static_cast<unsigned>(__lhs) == static_cast<unsigned>(__rhs); }
47
48_LIBCPP_HIDE_FROM_ABI inline constexpr
49bool operator!=(const month& __lhs, const month& __rhs) noexcept
50{ return !(__lhs == __rhs); }
51
52_LIBCPP_HIDE_FROM_ABI inline constexpr
53bool operator< (const month& __lhs, const month& __rhs) noexcept
54{ return static_cast<unsigned>(__lhs) < static_cast<unsigned>(__rhs); }
55
56_LIBCPP_HIDE_FROM_ABI inline constexpr
57bool operator> (const month& __lhs, const month& __rhs) noexcept
58{ return __rhs < __lhs; }
59
60_LIBCPP_HIDE_FROM_ABI inline constexpr
61bool operator<=(const month& __lhs, const month& __rhs) noexcept
62{ return !(__rhs < __lhs); }
63
64_LIBCPP_HIDE_FROM_ABI inline constexpr
65bool operator>=(const month& __lhs, const month& __rhs) noexcept
66{ return !(__lhs < __rhs); }
67
68_LIBCPP_HIDE_FROM_ABI inline constexpr
69month operator+ (const month& __lhs, const months& __rhs) noexcept
70{
71 auto const __mu = static_cast<long long>(static_cast<unsigned>(__lhs)) + (__rhs.count() - 1);
72 auto const __yr = (__mu >= 0 ? __mu : __mu - 11) / 12;
73 return month{static_cast<unsigned>(__mu - __yr * 12 + 1)};
74}
75
76_LIBCPP_HIDE_FROM_ABI inline constexpr
77month operator+ (const months& __lhs, const month& __rhs) noexcept
78{ return __rhs + __lhs; }
79
80_LIBCPP_HIDE_FROM_ABI inline constexpr
81month operator- (const month& __lhs, const months& __rhs) noexcept
82{ return __lhs + -__rhs; }
83
84_LIBCPP_HIDE_FROM_ABI inline constexpr
85months operator-(const month& __lhs, const month& __rhs) noexcept
86{
87 auto const __dm = static_cast<unsigned>(__lhs) - static_cast<unsigned>(__rhs);
88 return months(__dm <= 11 ? __dm : __dm + 12);
89}
90
91_LIBCPP_HIDE_FROM_ABI inline constexpr
92month& month::operator+=(const months& __dm) noexcept
93{ *this = *this + __dm; return *this; }
94
95_LIBCPP_HIDE_FROM_ABI inline constexpr
96month& month::operator-=(const months& __dm) noexcept
97{ *this = *this - __dm; return *this; }
98
99inline constexpr month January{1};
100inline constexpr month February{2};
101inline constexpr month March{3};
102inline constexpr month April{4};
103inline constexpr month May{5};
104inline constexpr month June{6};
105inline constexpr month July{7};
106inline constexpr month August{8};
107inline constexpr month September{9};
108inline constexpr month October{10};
109inline constexpr month November{11};
110inline constexpr month December{12};
111
112} // namespace chrono
113
114_LIBCPP_END_NAMESPACE_STD
115
116#endif // _LIBCPP_STD_VER > 17
117
118#endif // _LIBCPP___CHRONO_MONTH_H
lib/libcxx/include/__chrono/month_weekday.h created+106
...@@ -0,0 +1,106 @@
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_MONTH_WEEKDAY_H
11#define _LIBCPP___CHRONO_MONTH_WEEKDAY_H
12
13#include <__chrono/month.h>
14#include <__chrono/weekday.h>
15#include <__config>
16
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header
19#endif
20
21#if _LIBCPP_STD_VER > 17
22
23_LIBCPP_BEGIN_NAMESPACE_STD
24
25namespace chrono
26{
27
28class month_weekday {
29private:
30 chrono::month __m;
31 chrono::weekday_indexed __wdi;
32public:
33 _LIBCPP_HIDE_FROM_ABI constexpr month_weekday(const chrono::month& __mval, const chrono::weekday_indexed& __wdival) noexcept
34 : __m{__mval}, __wdi{__wdival} {}
35 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m; }
36 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday_indexed weekday_indexed() const noexcept { return __wdi; }
37 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __m.ok() && __wdi.ok(); }
38};
39
40_LIBCPP_HIDE_FROM_ABI inline constexpr
41bool operator==(const month_weekday& __lhs, const month_weekday& __rhs) noexcept
42{ return __lhs.month() == __rhs.month() && __lhs.weekday_indexed() == __rhs.weekday_indexed(); }
43
44_LIBCPP_HIDE_FROM_ABI inline constexpr
45bool operator!=(const month_weekday& __lhs, const month_weekday& __rhs) noexcept
46{ return !(__lhs == __rhs); }
47
48_LIBCPP_HIDE_FROM_ABI inline constexpr
49month_weekday operator/(const month& __lhs, const weekday_indexed& __rhs) noexcept
50{ return month_weekday{__lhs, __rhs}; }
51
52_LIBCPP_HIDE_FROM_ABI inline constexpr
53month_weekday operator/(int __lhs, const weekday_indexed& __rhs) noexcept
54{ return month_weekday{month(__lhs), __rhs}; }
55
56_LIBCPP_HIDE_FROM_ABI inline constexpr
57month_weekday operator/(const weekday_indexed& __lhs, const month& __rhs) noexcept
58{ return month_weekday{__rhs, __lhs}; }
59
60_LIBCPP_HIDE_FROM_ABI inline constexpr
61month_weekday operator/(const weekday_indexed& __lhs, int __rhs) noexcept
62{ return month_weekday{month(__rhs), __lhs}; }
63
64
65class month_weekday_last {
66 chrono::month __m;
67 chrono::weekday_last __wdl;
68 public:
69 _LIBCPP_HIDE_FROM_ABI constexpr month_weekday_last(const chrono::month& __mval, const chrono::weekday_last& __wdlval) noexcept
70 : __m{__mval}, __wdl{__wdlval} {}
71 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m; }
72 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday_last weekday_last() const noexcept { return __wdl; }
73 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __m.ok() && __wdl.ok(); }
74};
75
76_LIBCPP_HIDE_FROM_ABI inline constexpr
77bool operator==(const month_weekday_last& __lhs, const month_weekday_last& __rhs) noexcept
78{ return __lhs.month() == __rhs.month() && __lhs.weekday_last() == __rhs.weekday_last(); }
79
80_LIBCPP_HIDE_FROM_ABI inline constexpr
81bool operator!=(const month_weekday_last& __lhs, const month_weekday_last& __rhs) noexcept
82{ return !(__lhs == __rhs); }
83
84
85_LIBCPP_HIDE_FROM_ABI inline constexpr
86month_weekday_last operator/(const month& __lhs, const weekday_last& __rhs) noexcept
87{ return month_weekday_last{__lhs, __rhs}; }
88
89_LIBCPP_HIDE_FROM_ABI inline constexpr
90month_weekday_last operator/(int __lhs, const weekday_last& __rhs) noexcept
91{ return month_weekday_last{month(__lhs), __rhs}; }
92
93_LIBCPP_HIDE_FROM_ABI inline constexpr
94month_weekday_last operator/(const weekday_last& __lhs, const month& __rhs) noexcept
95{ return month_weekday_last{__rhs, __lhs}; }
96
97_LIBCPP_HIDE_FROM_ABI inline constexpr
98month_weekday_last operator/(const weekday_last& __lhs, int __rhs) noexcept
99{ return month_weekday_last{month(__rhs), __lhs}; }
100} // namespace chrono
101
102_LIBCPP_END_NAMESPACE_STD
103
104#endif // _LIBCPP_STD_VER > 17
105
106#endif // _LIBCPP___CHRONO_MONTH_WEEKDAY_H
lib/libcxx/include/__chrono/monthday.h created+160
...@@ -0,0 +1,160 @@
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_MONTHDAY_H
11#define _LIBCPP___CHRONO_MONTHDAY_H
12
13#include <__chrono/calendar.h>
14#include <__chrono/day.h>
15#include <__chrono/month.h>
16#include <__config>
17
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header
20#endif
21
22#if _LIBCPP_STD_VER > 17
23
24_LIBCPP_BEGIN_NAMESPACE_STD
25
26namespace chrono
27{
28
29class month_day {
30private:
31 chrono::month __m;
32 chrono::day __d;
33public:
34 _LIBCPP_HIDE_FROM_ABI month_day() = default;
35 _LIBCPP_HIDE_FROM_ABI constexpr month_day(const chrono::month& __mval, const chrono::day& __dval) noexcept
36 : __m{__mval}, __d{__dval} {}
37 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m; }
38 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::day day() const noexcept { return __d; }
39 _LIBCPP_HIDE_FROM_ABI constexpr bool ok() const noexcept;
40};
41
42_LIBCPP_HIDE_FROM_ABI inline constexpr
43bool month_day::ok() const noexcept
44{
45 if (!__m.ok()) return false;
46 const unsigned __dval = static_cast<unsigned>(__d);
47 if (__dval < 1 || __dval > 31) return false;
48 if (__dval <= 29) return true;
49// Now we've got either 30 or 31
50 const unsigned __mval = static_cast<unsigned>(__m);
51 if (__mval == 2) return false;
52 if (__mval == 4 || __mval == 6 || __mval == 9 || __mval == 11)
53 return __dval == 30;
54 return true;
55}
56
57_LIBCPP_HIDE_FROM_ABI inline constexpr
58bool operator==(const month_day& __lhs, const month_day& __rhs) noexcept
59{ return __lhs.month() == __rhs.month() && __lhs.day() == __rhs.day(); }
60
61_LIBCPP_HIDE_FROM_ABI inline constexpr
62bool operator!=(const month_day& __lhs, const month_day& __rhs) noexcept
63{ return !(__lhs == __rhs); }
64
65_LIBCPP_HIDE_FROM_ABI inline constexpr
66month_day operator/(const month& __lhs, const day& __rhs) noexcept
67{ return month_day{__lhs, __rhs}; }
68
69_LIBCPP_HIDE_FROM_ABI constexpr
70month_day operator/(const day& __lhs, const month& __rhs) noexcept
71{ return __rhs / __lhs; }
72
73_LIBCPP_HIDE_FROM_ABI inline constexpr
74month_day operator/(const month& __lhs, int __rhs) noexcept
75{ return __lhs / day(__rhs); }
76
77_LIBCPP_HIDE_FROM_ABI constexpr
78month_day operator/(int __lhs, const day& __rhs) noexcept
79{ return month(__lhs) / __rhs; }
80
81_LIBCPP_HIDE_FROM_ABI constexpr
82month_day operator/(const day& __lhs, int __rhs) noexcept
83{ return month(__rhs) / __lhs; }
84
85
86_LIBCPP_HIDE_FROM_ABI inline constexpr
87bool operator< (const month_day& __lhs, const month_day& __rhs) noexcept
88{ return __lhs.month() != __rhs.month() ? __lhs.month() < __rhs.month() : __lhs.day() < __rhs.day(); }
89
90_LIBCPP_HIDE_FROM_ABI inline constexpr
91bool operator> (const month_day& __lhs, const month_day& __rhs) noexcept
92{ return __rhs < __lhs; }
93
94_LIBCPP_HIDE_FROM_ABI inline constexpr
95bool operator<=(const month_day& __lhs, const month_day& __rhs) noexcept
96{ return !(__rhs < __lhs);}
97
98_LIBCPP_HIDE_FROM_ABI inline constexpr
99bool operator>=(const month_day& __lhs, const month_day& __rhs) noexcept
100{ return !(__lhs < __rhs); }
101
102
103
104class month_day_last {
105private:
106 chrono::month __m;
107public:
108 _LIBCPP_HIDE_FROM_ABI explicit constexpr month_day_last(const chrono::month& __val) noexcept
109 : __m{__val} {}
110 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m; }
111 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __m.ok(); }
112};
113
114_LIBCPP_HIDE_FROM_ABI inline constexpr
115bool operator==(const month_day_last& __lhs, const month_day_last& __rhs) noexcept
116{ return __lhs.month() == __rhs.month(); }
117
118_LIBCPP_HIDE_FROM_ABI inline constexpr
119bool operator!=(const month_day_last& __lhs, const month_day_last& __rhs) noexcept
120{ return !(__lhs == __rhs); }
121
122_LIBCPP_HIDE_FROM_ABI inline constexpr
123bool operator< (const month_day_last& __lhs, const month_day_last& __rhs) noexcept
124{ return __lhs.month() < __rhs.month(); }
125
126_LIBCPP_HIDE_FROM_ABI inline constexpr
127bool operator> (const month_day_last& __lhs, const month_day_last& __rhs) noexcept
128{ return __rhs < __lhs; }
129
130_LIBCPP_HIDE_FROM_ABI inline constexpr
131bool operator<=(const month_day_last& __lhs, const month_day_last& __rhs) noexcept
132{ return !(__rhs < __lhs);}
133
134_LIBCPP_HIDE_FROM_ABI inline constexpr
135bool operator>=(const month_day_last& __lhs, const month_day_last& __rhs) noexcept
136{ return !(__lhs < __rhs); }
137
138_LIBCPP_HIDE_FROM_ABI inline constexpr
139month_day_last operator/(const month& __lhs, last_spec) noexcept
140{ return month_day_last{__lhs}; }
141
142_LIBCPP_HIDE_FROM_ABI inline constexpr
143month_day_last operator/(last_spec, const month& __rhs) noexcept
144{ return month_day_last{__rhs}; }
145
146_LIBCPP_HIDE_FROM_ABI inline constexpr
147month_day_last operator/(int __lhs, last_spec) noexcept
148{ return month_day_last{month(__lhs)}; }
149
150_LIBCPP_HIDE_FROM_ABI inline constexpr
151month_day_last operator/(last_spec, int __rhs) noexcept
152{ return month_day_last{month(__rhs)}; }
153
154} // namespace chrono
155
156_LIBCPP_END_NAMESPACE_STD
157
158#endif // _LIBCPP_STD_VER > 17
159
160#endif // _LIBCPP___CHRONO_MONTHDAY_H
lib/libcxx/include/__chrono/steady_clock.h+1-1
...@@ -15,7 +15,7 @@...@@ -15,7 +15,7 @@
15#include <__config>15#include <__config>
1616
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header18# pragma GCC system_header
19#endif19#endif
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__chrono/system_clock.h+1-1
...@@ -16,7 +16,7 @@...@@ -16,7 +16,7 @@
16#include <ctime>16#include <ctime>
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_LIBCPP_BEGIN_NAMESPACE_STD22_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__chrono/time_point.h+3-3
...@@ -16,7 +16,7 @@...@@ -16,7 +16,7 @@
16#include <type_traits>16#include <type_traits>
1717
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19#pragma GCC system_header19# pragma GCC system_header
20#endif20#endif
2121
22_LIBCPP_PUSH_MACROS22_LIBCPP_PUSH_MACROS
...@@ -47,12 +47,12 @@ public:...@@ -47,12 +47,12 @@ public:
47 // conversions47 // conversions
48 template <class _Duration2>48 template <class _Duration2>
49 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1149 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
50 time_point(const time_point<clock, _Duration2>& t,50 time_point(const time_point<clock, _Duration2>& __t,
51 typename enable_if51 typename enable_if
52 <52 <
53 is_convertible<_Duration2, duration>::value53 is_convertible<_Duration2, duration>::value
54 >::type* = nullptr)54 >::type* = nullptr)
55 : __d_(t.time_since_epoch()) {}55 : __d_(__t.time_since_epoch()) {}
5656
57 // observer57 // observer
5858
lib/libcxx/include/__chrono/weekday.h created+185
...@@ -0,0 +1,185 @@
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_WEEKDAY_H
11#define _LIBCPP___CHRONO_WEEKDAY_H
12
13#include <__chrono/calendar.h>
14#include <__chrono/duration.h>
15#include <__chrono/system_clock.h>
16#include <__chrono/time_point.h>
17#include <__config>
18
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20# pragma GCC system_header
21#endif
22
23#if _LIBCPP_STD_VER > 17
24
25_LIBCPP_BEGIN_NAMESPACE_STD
26
27namespace chrono
28{
29
30class weekday_indexed;
31class weekday_last;
32
33class weekday {
34private:
35 unsigned char __wd;
36 _LIBCPP_HIDE_FROM_ABI static constexpr unsigned char __weekday_from_days(int __days) noexcept;
37public:
38 _LIBCPP_HIDE_FROM_ABI weekday() = default;
39 _LIBCPP_HIDE_FROM_ABI inline explicit constexpr weekday(unsigned __val) noexcept : __wd(static_cast<unsigned char>(__val == 7 ? 0 : __val)) {}
40 _LIBCPP_HIDE_FROM_ABI inline constexpr weekday(const sys_days& __sysd) noexcept
41 : __wd(__weekday_from_days(__sysd.time_since_epoch().count())) {}
42 _LIBCPP_HIDE_FROM_ABI inline explicit constexpr weekday(const local_days& __locd) noexcept
43 : __wd(__weekday_from_days(__locd.time_since_epoch().count())) {}
44
45 _LIBCPP_HIDE_FROM_ABI inline constexpr weekday& operator++() noexcept { __wd = (__wd == 6 ? 0 : __wd + 1); return *this; }
46 _LIBCPP_HIDE_FROM_ABI inline constexpr weekday operator++(int) noexcept { weekday __tmp = *this; ++(*this); return __tmp; }
47 _LIBCPP_HIDE_FROM_ABI inline constexpr weekday& operator--() noexcept { __wd = (__wd == 0 ? 6 : __wd - 1); return *this; }
48 _LIBCPP_HIDE_FROM_ABI inline constexpr weekday operator--(int) noexcept { weekday __tmp = *this; --(*this); return __tmp; }
49 _LIBCPP_HIDE_FROM_ABI constexpr weekday& operator+=(const days& __dd) noexcept;
50 _LIBCPP_HIDE_FROM_ABI constexpr weekday& operator-=(const days& __dd) noexcept;
51 _LIBCPP_HIDE_FROM_ABI inline constexpr unsigned c_encoding() const noexcept { return __wd; }
52 _LIBCPP_HIDE_FROM_ABI inline constexpr unsigned iso_encoding() const noexcept { return __wd == 0u ? 7 : __wd; }
53 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __wd <= 6; }
54 _LIBCPP_HIDE_FROM_ABI constexpr weekday_indexed operator[](unsigned __index) const noexcept;
55 _LIBCPP_HIDE_FROM_ABI constexpr weekday_last operator[](last_spec) const noexcept;
56};
57
58
59// https://howardhinnant.github.io/date_algorithms.html#weekday_from_days
60_LIBCPP_HIDE_FROM_ABI inline constexpr
61unsigned char weekday::__weekday_from_days(int __days) noexcept
62{
63 return static_cast<unsigned char>(
64 static_cast<unsigned>(__days >= -4 ? (__days+4) % 7 : (__days+5) % 7 + 6)
65 );
66}
67
68_LIBCPP_HIDE_FROM_ABI inline constexpr
69bool operator==(const weekday& __lhs, const weekday& __rhs) noexcept
70{ return __lhs.c_encoding() == __rhs.c_encoding(); }
71
72_LIBCPP_HIDE_FROM_ABI inline constexpr
73bool operator!=(const weekday& __lhs, const weekday& __rhs) noexcept
74{ return !(__lhs == __rhs); }
75
76_LIBCPP_HIDE_FROM_ABI inline constexpr
77bool operator< (const weekday& __lhs, const weekday& __rhs) noexcept
78{ return __lhs.c_encoding() < __rhs.c_encoding(); }
79
80_LIBCPP_HIDE_FROM_ABI inline constexpr
81bool operator> (const weekday& __lhs, const weekday& __rhs) noexcept
82{ return __rhs < __lhs; }
83
84_LIBCPP_HIDE_FROM_ABI inline constexpr
85bool operator<=(const weekday& __lhs, const weekday& __rhs) noexcept
86{ return !(__rhs < __lhs);}
87
88_LIBCPP_HIDE_FROM_ABI inline constexpr
89bool operator>=(const weekday& __lhs, const weekday& __rhs) noexcept
90{ return !(__lhs < __rhs); }
91
92_LIBCPP_HIDE_FROM_ABI constexpr
93weekday operator+(const weekday& __lhs, const days& __rhs) noexcept
94{
95 auto const __mu = static_cast<long long>(__lhs.c_encoding()) + __rhs.count();
96 auto const __yr = (__mu >= 0 ? __mu : __mu - 6) / 7;
97 return weekday{static_cast<unsigned>(__mu - __yr * 7)};
98}
99
100_LIBCPP_HIDE_FROM_ABI constexpr
101weekday operator+(const days& __lhs, const weekday& __rhs) noexcept
102{ return __rhs + __lhs; }
103
104_LIBCPP_HIDE_FROM_ABI constexpr
105weekday operator-(const weekday& __lhs, const days& __rhs) noexcept
106{ return __lhs + -__rhs; }
107
108_LIBCPP_HIDE_FROM_ABI constexpr
109days operator-(const weekday& __lhs, const weekday& __rhs) noexcept
110{
111 const int __wdu = __lhs.c_encoding() - __rhs.c_encoding();
112 const int __wk = (__wdu >= 0 ? __wdu : __wdu-6) / 7;
113 return days{__wdu - __wk * 7};
114}
115
116_LIBCPP_HIDE_FROM_ABI inline constexpr
117weekday& weekday::operator+=(const days& __dd) noexcept
118{ *this = *this + __dd; return *this; }
119
120_LIBCPP_HIDE_FROM_ABI inline constexpr
121weekday& weekday::operator-=(const days& __dd) noexcept
122{ *this = *this - __dd; return *this; }
123
124class weekday_indexed {
125private:
126 chrono::weekday __wd;
127 unsigned char __idx;
128public:
129 _LIBCPP_HIDE_FROM_ABI weekday_indexed() = default;
130 _LIBCPP_HIDE_FROM_ABI inline constexpr weekday_indexed(const chrono::weekday& __wdval, unsigned __idxval) noexcept
131 : __wd{__wdval}, __idx(__idxval) {}
132 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday weekday() const noexcept { return __wd; }
133 _LIBCPP_HIDE_FROM_ABI inline constexpr unsigned index() const noexcept { return __idx; }
134 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __wd.ok() && __idx >= 1 && __idx <= 5; }
135};
136
137_LIBCPP_HIDE_FROM_ABI inline constexpr
138bool operator==(const weekday_indexed& __lhs, const weekday_indexed& __rhs) noexcept
139{ return __lhs.weekday() == __rhs.weekday() && __lhs.index() == __rhs.index(); }
140
141_LIBCPP_HIDE_FROM_ABI inline constexpr
142bool operator!=(const weekday_indexed& __lhs, const weekday_indexed& __rhs) noexcept
143{ return !(__lhs == __rhs); }
144
145
146class weekday_last {
147private:
148 chrono::weekday __wd;
149public:
150 _LIBCPP_HIDE_FROM_ABI explicit constexpr weekday_last(const chrono::weekday& __val) noexcept
151 : __wd{__val} {}
152 _LIBCPP_HIDE_FROM_ABI constexpr chrono::weekday weekday() const noexcept { return __wd; }
153 _LIBCPP_HIDE_FROM_ABI constexpr bool ok() const noexcept { return __wd.ok(); }
154};
155
156_LIBCPP_HIDE_FROM_ABI inline constexpr
157bool operator==(const weekday_last& __lhs, const weekday_last& __rhs) noexcept
158{ return __lhs.weekday() == __rhs.weekday(); }
159
160_LIBCPP_HIDE_FROM_ABI inline constexpr
161bool operator!=(const weekday_last& __lhs, const weekday_last& __rhs) noexcept
162{ return !(__lhs == __rhs); }
163
164_LIBCPP_HIDE_FROM_ABI inline constexpr
165weekday_indexed weekday::operator[](unsigned __index) const noexcept { return weekday_indexed{*this, __index}; }
166
167_LIBCPP_HIDE_FROM_ABI inline constexpr
168weekday_last weekday::operator[](last_spec) const noexcept { return weekday_last{*this}; }
169
170
171inline constexpr weekday Sunday{0};
172inline constexpr weekday Monday{1};
173inline constexpr weekday Tuesday{2};
174inline constexpr weekday Wednesday{3};
175inline constexpr weekday Thursday{4};
176inline constexpr weekday Friday{5};
177inline constexpr weekday Saturday{6};
178
179} // namespace chrono
180
181_LIBCPP_END_NAMESPACE_STD
182
183#endif // _LIBCPP_STD_VER > 17
184
185#endif // _LIBCPP___CHRONO_WEEKDAY_H
lib/libcxx/include/__chrono/year.h created+117
...@@ -0,0 +1,117 @@
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_YEAR_H
11#define _LIBCPP___CHRONO_YEAR_H
12
13#include <__chrono/duration.h>
14#include <__config>
15#include <limits>
16
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header
19#endif
20
21_LIBCPP_PUSH_MACROS
22#include <__undef_macros>
23
24#if _LIBCPP_STD_VER > 17
25
26_LIBCPP_BEGIN_NAMESPACE_STD
27
28namespace chrono
29{
30
31class year {
32private:
33 short __y;
34public:
35 _LIBCPP_HIDE_FROM_ABI year() = default;
36 _LIBCPP_HIDE_FROM_ABI explicit inline constexpr year(int __val) noexcept : __y(static_cast<short>(__val)) {}
37
38 _LIBCPP_HIDE_FROM_ABI inline constexpr year& operator++() noexcept { ++__y; return *this; }
39 _LIBCPP_HIDE_FROM_ABI inline constexpr year operator++(int) noexcept { year __tmp = *this; ++(*this); return __tmp; }
40 _LIBCPP_HIDE_FROM_ABI inline constexpr year& operator--() noexcept { --__y; return *this; }
41 _LIBCPP_HIDE_FROM_ABI inline constexpr year operator--(int) noexcept { year __tmp = *this; --(*this); return __tmp; }
42 _LIBCPP_HIDE_FROM_ABI constexpr year& operator+=(const years& __dy) noexcept;
43 _LIBCPP_HIDE_FROM_ABI constexpr year& operator-=(const years& __dy) noexcept;
44 _LIBCPP_HIDE_FROM_ABI inline constexpr year operator+() const noexcept { return *this; }
45 _LIBCPP_HIDE_FROM_ABI inline constexpr year operator-() const noexcept { return year{-__y}; }
46
47 _LIBCPP_HIDE_FROM_ABI inline constexpr bool is_leap() const noexcept { return __y % 4 == 0 && (__y % 100 != 0 || __y % 400 == 0); }
48 _LIBCPP_HIDE_FROM_ABI explicit inline constexpr operator int() const noexcept { return __y; }
49 _LIBCPP_HIDE_FROM_ABI constexpr bool ok() const noexcept;
50 _LIBCPP_HIDE_FROM_ABI static inline constexpr year min() noexcept { return year{-32767}; }
51 _LIBCPP_HIDE_FROM_ABI static inline constexpr year max() noexcept { return year{ 32767}; }
52};
53
54
55_LIBCPP_HIDE_FROM_ABI inline constexpr
56bool operator==(const year& __lhs, const year& __rhs) noexcept
57{ return static_cast<int>(__lhs) == static_cast<int>(__rhs); }
58
59_LIBCPP_HIDE_FROM_ABI inline constexpr
60bool operator!=(const year& __lhs, const year& __rhs) noexcept
61{ return !(__lhs == __rhs); }
62
63_LIBCPP_HIDE_FROM_ABI inline constexpr
64bool operator< (const year& __lhs, const year& __rhs) noexcept
65{ return static_cast<int>(__lhs) < static_cast<int>(__rhs); }
66
67_LIBCPP_HIDE_FROM_ABI inline constexpr
68bool operator> (const year& __lhs, const year& __rhs) noexcept
69{ return __rhs < __lhs; }
70
71_LIBCPP_HIDE_FROM_ABI inline constexpr
72bool operator<=(const year& __lhs, const year& __rhs) noexcept
73{ return !(__rhs < __lhs); }
74
75_LIBCPP_HIDE_FROM_ABI inline constexpr
76bool operator>=(const year& __lhs, const year& __rhs) noexcept
77{ return !(__lhs < __rhs); }
78
79_LIBCPP_HIDE_FROM_ABI inline constexpr
80year operator+ (const year& __lhs, const years& __rhs) noexcept
81{ return year(static_cast<int>(__lhs) + __rhs.count()); }
82
83_LIBCPP_HIDE_FROM_ABI inline constexpr
84year operator+ (const years& __lhs, const year& __rhs) noexcept
85{ return __rhs + __lhs; }
86
87_LIBCPP_HIDE_FROM_ABI inline constexpr
88year operator- (const year& __lhs, const years& __rhs) noexcept
89{ return __lhs + -__rhs; }
90
91_LIBCPP_HIDE_FROM_ABI inline constexpr
92years operator-(const year& __lhs, const year& __rhs) noexcept
93{ return years{static_cast<int>(__lhs) - static_cast<int>(__rhs)}; }
94
95
96_LIBCPP_HIDE_FROM_ABI inline constexpr
97year& year::operator+=(const years& __dy) noexcept
98{ *this = *this + __dy; return *this; }
99
100_LIBCPP_HIDE_FROM_ABI inline constexpr
101year& year::operator-=(const years& __dy) noexcept
102{ *this = *this - __dy; return *this; }
103
104_LIBCPP_HIDE_FROM_ABI constexpr bool year::ok() const noexcept {
105 static_assert(static_cast<int>(std::numeric_limits<decltype(__y)>::max()) == static_cast<int>(max()));
106 return static_cast<int>(min()) <= __y;
107}
108
109} // namespace chrono
110
111_LIBCPP_END_NAMESPACE_STD
112
113#endif // _LIBCPP_STD_VER > 17
114
115_LIBCPP_POP_MACROS
116
117#endif // _LIBCPP___CHRONO_YEAR_H
lib/libcxx/include/__chrono/year_month.h created+114
...@@ -0,0 +1,114 @@
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_YEAR_MONTH_H
11#define _LIBCPP___CHRONO_YEAR_MONTH_H
12
13#include <__chrono/duration.h>
14#include <__chrono/month.h>
15#include <__chrono/year.h>
16#include <__config>
17
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header
20#endif
21
22#if _LIBCPP_STD_VER > 17
23
24_LIBCPP_BEGIN_NAMESPACE_STD
25
26namespace chrono
27{
28
29class year_month {
30 chrono::year __y;
31 chrono::month __m;
32public:
33 _LIBCPP_HIDE_FROM_ABI year_month() = default;
34 _LIBCPP_HIDE_FROM_ABI constexpr year_month(const chrono::year& __yval, const chrono::month& __mval) noexcept
35 : __y{__yval}, __m{__mval} {}
36 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::year year() const noexcept { return __y; }
37 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m; }
38 _LIBCPP_HIDE_FROM_ABI inline constexpr year_month& operator+=(const months& __dm) noexcept { this->__m += __dm; return *this; }
39 _LIBCPP_HIDE_FROM_ABI inline constexpr year_month& operator-=(const months& __dm) noexcept { this->__m -= __dm; return *this; }
40 _LIBCPP_HIDE_FROM_ABI inline constexpr year_month& operator+=(const years& __dy) noexcept { this->__y += __dy; return *this; }
41 _LIBCPP_HIDE_FROM_ABI inline constexpr year_month& operator-=(const years& __dy) noexcept { this->__y -= __dy; return *this; }
42 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __y.ok() && __m.ok(); }
43};
44
45_LIBCPP_HIDE_FROM_ABI inline constexpr
46year_month operator/(const year& __y, const month& __m) noexcept { return year_month{__y, __m}; }
47
48_LIBCPP_HIDE_FROM_ABI inline constexpr
49year_month operator/(const year& __y, int __m) noexcept { return year_month{__y, month(__m)}; }
50
51_LIBCPP_HIDE_FROM_ABI inline constexpr
52bool operator==(const year_month& __lhs, const year_month& __rhs) noexcept
53{ return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month(); }
54
55_LIBCPP_HIDE_FROM_ABI inline constexpr
56bool operator!=(const year_month& __lhs, const year_month& __rhs) noexcept
57{ return !(__lhs == __rhs); }
58
59_LIBCPP_HIDE_FROM_ABI inline constexpr
60bool operator< (const year_month& __lhs, const year_month& __rhs) noexcept
61{ return __lhs.year() != __rhs.year() ? __lhs.year() < __rhs.year() : __lhs.month() < __rhs.month(); }
62
63_LIBCPP_HIDE_FROM_ABI inline constexpr
64bool operator> (const year_month& __lhs, const year_month& __rhs) noexcept
65{ return __rhs < __lhs; }
66
67_LIBCPP_HIDE_FROM_ABI inline constexpr
68bool operator<=(const year_month& __lhs, const year_month& __rhs) noexcept
69{ return !(__rhs < __lhs);}
70
71_LIBCPP_HIDE_FROM_ABI inline constexpr
72bool operator>=(const year_month& __lhs, const year_month& __rhs) noexcept
73{ return !(__lhs < __rhs); }
74
75_LIBCPP_HIDE_FROM_ABI constexpr
76year_month operator+(const year_month& __lhs, const months& __rhs) noexcept
77{
78 int __dmi = static_cast<int>(static_cast<unsigned>(__lhs.month())) - 1 + __rhs.count();
79 const int __dy = (__dmi >= 0 ? __dmi : __dmi-11) / 12;
80 __dmi = __dmi - __dy * 12 + 1;
81 return (__lhs.year() + years(__dy)) / month(static_cast<unsigned>(__dmi));
82}
83
84_LIBCPP_HIDE_FROM_ABI constexpr
85year_month operator+(const months& __lhs, const year_month& __rhs) noexcept
86{ return __rhs + __lhs; }
87
88_LIBCPP_HIDE_FROM_ABI constexpr
89year_month operator+(const year_month& __lhs, const years& __rhs) noexcept
90{ return (__lhs.year() + __rhs) / __lhs.month(); }
91
92_LIBCPP_HIDE_FROM_ABI constexpr
93year_month operator+(const years& __lhs, const year_month& __rhs) noexcept
94{ return __rhs + __lhs; }
95
96_LIBCPP_HIDE_FROM_ABI constexpr
97months operator-(const year_month& __lhs, const year_month& __rhs) noexcept
98{ return (__lhs.year() - __rhs.year()) + months(static_cast<unsigned>(__lhs.month()) - static_cast<unsigned>(__rhs.month())); }
99
100_LIBCPP_HIDE_FROM_ABI constexpr
101year_month operator-(const year_month& __lhs, const months& __rhs) noexcept
102{ return __lhs + -__rhs; }
103
104_LIBCPP_HIDE_FROM_ABI constexpr
105year_month operator-(const year_month& __lhs, const years& __rhs) noexcept
106{ return __lhs + -__rhs; }
107
108} // namespace chrono
109
110_LIBCPP_END_NAMESPACE_STD
111
112#endif // _LIBCPP_STD_VER > 17
113
114#endif // _LIBCPP___CHRONO_YEAR_MONTH_H
lib/libcxx/include/__chrono/year_month_day.h created+323
...@@ -0,0 +1,323 @@
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_YEAR_MONTH_DAY_H
11#define _LIBCPP___CHRONO_YEAR_MONTH_DAY_H
12
13#include <__chrono/calendar.h>
14#include <__chrono/day.h>
15#include <__chrono/duration.h>
16#include <__chrono/month.h>
17#include <__chrono/monthday.h>
18#include <__chrono/system_clock.h>
19#include <__chrono/time_point.h>
20#include <__chrono/year.h>
21#include <__chrono/year_month.h>
22#include <__config>
23#include <limits>
24
25#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
26# pragma GCC system_header
27#endif
28
29#if _LIBCPP_STD_VER > 17
30
31_LIBCPP_BEGIN_NAMESPACE_STD
32
33namespace chrono
34{
35
36class year_month_day_last;
37
38class year_month_day {
39private:
40 chrono::year __y;
41 chrono::month __m;
42 chrono::day __d;
43public:
44 _LIBCPP_HIDE_FROM_ABI year_month_day() = default;
45 _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day(
46 const chrono::year& __yval, const chrono::month& __mval, const chrono::day& __dval) noexcept
47 : __y{__yval}, __m{__mval}, __d{__dval} {}
48 _LIBCPP_HIDE_FROM_ABI constexpr year_month_day(const year_month_day_last& __ymdl) noexcept;
49 _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day(const sys_days& __sysd) noexcept
50 : year_month_day(__from_days(__sysd.time_since_epoch())) {}
51 _LIBCPP_HIDE_FROM_ABI inline explicit constexpr year_month_day(const local_days& __locd) noexcept
52 : year_month_day(__from_days(__locd.time_since_epoch())) {}
53
54 _LIBCPP_HIDE_FROM_ABI constexpr year_month_day& operator+=(const months& __dm) noexcept;
55 _LIBCPP_HIDE_FROM_ABI constexpr year_month_day& operator-=(const months& __dm) noexcept;
56 _LIBCPP_HIDE_FROM_ABI constexpr year_month_day& operator+=(const years& __dy) noexcept;
57 _LIBCPP_HIDE_FROM_ABI constexpr year_month_day& operator-=(const years& __dy) noexcept;
58
59 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::year year() const noexcept { return __y; }
60 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m; }
61 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::day day() const noexcept { return __d; }
62 _LIBCPP_HIDE_FROM_ABI inline constexpr operator sys_days() const noexcept { return sys_days{__to_days()}; }
63 _LIBCPP_HIDE_FROM_ABI inline explicit constexpr operator local_days() const noexcept { return local_days{__to_days()}; }
64
65 _LIBCPP_HIDE_FROM_ABI constexpr bool ok() const noexcept;
66
67 _LIBCPP_HIDE_FROM_ABI static constexpr year_month_day __from_days(days __d) noexcept;
68 _LIBCPP_HIDE_FROM_ABI constexpr days __to_days() const noexcept;
69};
70
71
72// https://howardhinnant.github.io/date_algorithms.html#civil_from_days
73_LIBCPP_HIDE_FROM_ABI inline constexpr
74year_month_day year_month_day::__from_days(days __d) noexcept
75{
76 static_assert(numeric_limits<unsigned>::digits >= 18, "");
77 static_assert(numeric_limits<int>::digits >= 20 , "");
78 const int __z = __d.count() + 719468;
79 const int __era = (__z >= 0 ? __z : __z - 146096) / 146097;
80 const unsigned __doe = static_cast<unsigned>(__z - __era * 146097); // [0, 146096]
81 const unsigned __yoe = (__doe - __doe/1460 + __doe/36524 - __doe/146096) / 365; // [0, 399]
82 const int __yr = static_cast<int>(__yoe) + __era * 400;
83 const unsigned __doy = __doe - (365 * __yoe + __yoe/4 - __yoe/100); // [0, 365]
84 const unsigned __mp = (5 * __doy + 2)/153; // [0, 11]
85 const unsigned __dy = __doy - (153 * __mp + 2)/5 + 1; // [1, 31]
86 const unsigned __mth = __mp + (__mp < 10 ? 3 : -9); // [1, 12]
87 return year_month_day{chrono::year{__yr + (__mth <= 2)}, chrono::month{__mth}, chrono::day{__dy}};
88}
89
90// https://howardhinnant.github.io/date_algorithms.html#days_from_civil
91_LIBCPP_HIDE_FROM_ABI inline constexpr
92days year_month_day::__to_days() const noexcept
93{
94 static_assert(numeric_limits<unsigned>::digits >= 18, "");
95 static_assert(numeric_limits<int>::digits >= 20 , "");
96
97 const int __yr = static_cast<int>(__y) - (__m <= February);
98 const unsigned __mth = static_cast<unsigned>(__m);
99 const unsigned __dy = static_cast<unsigned>(__d);
100
101 const int __era = (__yr >= 0 ? __yr : __yr - 399) / 400;
102 const unsigned __yoe = static_cast<unsigned>(__yr - __era * 400); // [0, 399]
103 const unsigned __doy = (153 * (__mth + (__mth > 2 ? -3 : 9)) + 2) / 5 + __dy-1; // [0, 365]
104 const unsigned __doe = __yoe * 365 + __yoe/4 - __yoe/100 + __doy; // [0, 146096]
105 return days{__era * 146097 + static_cast<int>(__doe) - 719468};
106}
107
108_LIBCPP_HIDE_FROM_ABI inline constexpr
109bool operator==(const year_month_day& __lhs, const year_month_day& __rhs) noexcept
110{ return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month() && __lhs.day() == __rhs.day(); }
111
112_LIBCPP_HIDE_FROM_ABI inline constexpr
113bool operator!=(const year_month_day& __lhs, const year_month_day& __rhs) noexcept
114{ return !(__lhs == __rhs); }
115
116_LIBCPP_HIDE_FROM_ABI inline constexpr
117bool operator< (const year_month_day& __lhs, const year_month_day& __rhs) noexcept
118{
119 if (__lhs.year() < __rhs.year()) return true;
120 if (__lhs.year() > __rhs.year()) return false;
121 if (__lhs.month() < __rhs.month()) return true;
122 if (__lhs.month() > __rhs.month()) return false;
123 return __lhs.day() < __rhs.day();
124}
125
126_LIBCPP_HIDE_FROM_ABI inline constexpr
127bool operator> (const year_month_day& __lhs, const year_month_day& __rhs) noexcept
128{ return __rhs < __lhs; }
129
130_LIBCPP_HIDE_FROM_ABI inline constexpr
131bool operator<=(const year_month_day& __lhs, const year_month_day& __rhs) noexcept
132{ return !(__rhs < __lhs);}
133
134_LIBCPP_HIDE_FROM_ABI inline constexpr
135bool operator>=(const year_month_day& __lhs, const year_month_day& __rhs) noexcept
136{ return !(__lhs < __rhs); }
137
138_LIBCPP_HIDE_FROM_ABI inline constexpr
139year_month_day operator/(const year_month& __lhs, const day& __rhs) noexcept
140{ return year_month_day{__lhs.year(), __lhs.month(), __rhs}; }
141
142_LIBCPP_HIDE_FROM_ABI inline constexpr
143year_month_day operator/(const year_month& __lhs, int __rhs) noexcept
144{ return __lhs / day(__rhs); }
145
146_LIBCPP_HIDE_FROM_ABI inline constexpr
147year_month_day operator/(const year& __lhs, const month_day& __rhs) noexcept
148{ return __lhs / __rhs.month() / __rhs.day(); }
149
150_LIBCPP_HIDE_FROM_ABI inline constexpr
151year_month_day operator/(int __lhs, const month_day& __rhs) noexcept
152{ return year(__lhs) / __rhs; }
153
154_LIBCPP_HIDE_FROM_ABI inline constexpr
155year_month_day operator/(const month_day& __lhs, const year& __rhs) noexcept
156{ return __rhs / __lhs; }
157
158_LIBCPP_HIDE_FROM_ABI inline constexpr
159year_month_day operator/(const month_day& __lhs, int __rhs) noexcept
160{ return year(__rhs) / __lhs; }
161
162
163_LIBCPP_HIDE_FROM_ABI inline constexpr
164year_month_day operator+(const year_month_day& __lhs, const months& __rhs) noexcept
165{ return (__lhs.year()/__lhs.month() + __rhs)/__lhs.day(); }
166
167_LIBCPP_HIDE_FROM_ABI inline constexpr
168year_month_day operator+(const months& __lhs, const year_month_day& __rhs) noexcept
169{ return __rhs + __lhs; }
170
171_LIBCPP_HIDE_FROM_ABI inline constexpr
172year_month_day operator-(const year_month_day& __lhs, const months& __rhs) noexcept
173{ return __lhs + -__rhs; }
174
175_LIBCPP_HIDE_FROM_ABI inline constexpr
176year_month_day operator+(const year_month_day& __lhs, const years& __rhs) noexcept
177{ return (__lhs.year() + __rhs) / __lhs.month() / __lhs.day(); }
178
179_LIBCPP_HIDE_FROM_ABI inline constexpr
180year_month_day operator+(const years& __lhs, const year_month_day& __rhs) noexcept
181{ return __rhs + __lhs; }
182
183_LIBCPP_HIDE_FROM_ABI inline constexpr
184year_month_day operator-(const year_month_day& __lhs, const years& __rhs) noexcept
185{ return __lhs + -__rhs; }
186
187_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day& year_month_day::operator+=(const months& __dm) noexcept { *this = *this + __dm; return *this; }
188_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day& year_month_day::operator-=(const months& __dm) noexcept { *this = *this - __dm; return *this; }
189_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day& year_month_day::operator+=(const years& __dy) noexcept { *this = *this + __dy; return *this; }
190_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day& year_month_day::operator-=(const years& __dy) noexcept { *this = *this - __dy; return *this; }
191
192class year_month_day_last {
193private:
194 chrono::year __y;
195 chrono::month_day_last __mdl;
196public:
197 _LIBCPP_HIDE_FROM_ABI constexpr year_month_day_last(const year& __yval, const month_day_last& __mdlval) noexcept
198 : __y{__yval}, __mdl{__mdlval} {}
199
200 _LIBCPP_HIDE_FROM_ABI constexpr year_month_day_last& operator+=(const months& __m) noexcept;
201 _LIBCPP_HIDE_FROM_ABI constexpr year_month_day_last& operator-=(const months& __m) noexcept;
202 _LIBCPP_HIDE_FROM_ABI constexpr year_month_day_last& operator+=(const years& __y) noexcept;
203 _LIBCPP_HIDE_FROM_ABI constexpr year_month_day_last& operator-=(const years& __y) noexcept;
204
205 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::year year() const noexcept { return __y; }
206 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __mdl.month(); }
207 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month_day_last month_day_last() const noexcept { return __mdl; }
208 _LIBCPP_HIDE_FROM_ABI constexpr chrono::day day() const noexcept;
209 _LIBCPP_HIDE_FROM_ABI inline constexpr operator sys_days() const noexcept { return sys_days{year()/month()/day()}; }
210 _LIBCPP_HIDE_FROM_ABI inline explicit constexpr operator local_days() const noexcept { return local_days{year()/month()/day()}; }
211 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __y.ok() && __mdl.ok(); }
212};
213
214_LIBCPP_HIDE_FROM_ABI inline constexpr
215chrono::day year_month_day_last::day() const noexcept
216{
217 constexpr chrono::day __d[] =
218 {
219 chrono::day(31), chrono::day(28), chrono::day(31),
220 chrono::day(30), chrono::day(31), chrono::day(30),
221 chrono::day(31), chrono::day(31), chrono::day(30),
222 chrono::day(31), chrono::day(30), chrono::day(31)
223 };
224 return (month() != February || !__y.is_leap()) && month().ok() ?
225 __d[static_cast<unsigned>(month()) - 1] : chrono::day{29};
226}
227
228_LIBCPP_HIDE_FROM_ABI inline constexpr
229bool operator==(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept
230{ return __lhs.year() == __rhs.year() && __lhs.month_day_last() == __rhs.month_day_last(); }
231
232_LIBCPP_HIDE_FROM_ABI inline constexpr
233bool operator!=(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept
234{ return !(__lhs == __rhs); }
235
236_LIBCPP_HIDE_FROM_ABI inline constexpr
237bool operator< (const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept
238{
239 if (__lhs.year() < __rhs.year()) return true;
240 if (__lhs.year() > __rhs.year()) return false;
241 return __lhs.month_day_last() < __rhs.month_day_last();
242}
243
244_LIBCPP_HIDE_FROM_ABI inline constexpr
245bool operator> (const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept
246{ return __rhs < __lhs; }
247
248_LIBCPP_HIDE_FROM_ABI inline constexpr
249bool operator<=(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept
250{ return !(__rhs < __lhs);}
251
252_LIBCPP_HIDE_FROM_ABI inline constexpr
253bool operator>=(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept
254{ return !(__lhs < __rhs); }
255
256_LIBCPP_HIDE_FROM_ABI inline constexpr
257year_month_day_last operator/(const year_month& __lhs, last_spec) noexcept
258{ return year_month_day_last{__lhs.year(), month_day_last{__lhs.month()}}; }
259
260_LIBCPP_HIDE_FROM_ABI inline constexpr
261year_month_day_last operator/(const year& __lhs, const month_day_last& __rhs) noexcept
262{ return year_month_day_last{__lhs, __rhs}; }
263
264_LIBCPP_HIDE_FROM_ABI inline constexpr
265year_month_day_last operator/(int __lhs, const month_day_last& __rhs) noexcept
266{ return year_month_day_last{year{__lhs}, __rhs}; }
267
268_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day_last
269operator/(const month_day_last& __lhs, const year& __rhs) noexcept
270{ return __rhs / __lhs; }
271
272_LIBCPP_HIDE_FROM_ABI inline constexpr
273year_month_day_last operator/(const month_day_last& __lhs, int __rhs) noexcept
274{ return year{__rhs} / __lhs; }
275
276
277_LIBCPP_HIDE_FROM_ABI inline constexpr
278year_month_day_last operator+(const year_month_day_last& __lhs, const months& __rhs) noexcept
279{ return (__lhs.year() / __lhs.month() + __rhs) / last; }
280
281_LIBCPP_HIDE_FROM_ABI inline constexpr
282year_month_day_last operator+(const months& __lhs, const year_month_day_last& __rhs) noexcept
283{ return __rhs + __lhs; }
284
285_LIBCPP_HIDE_FROM_ABI inline constexpr
286year_month_day_last operator-(const year_month_day_last& __lhs, const months& __rhs) noexcept
287{ return __lhs + (-__rhs); }
288
289_LIBCPP_HIDE_FROM_ABI inline constexpr
290year_month_day_last operator+(const year_month_day_last& __lhs, const years& __rhs) noexcept
291{ return year_month_day_last{__lhs.year() + __rhs, __lhs.month_day_last()}; }
292
293_LIBCPP_HIDE_FROM_ABI inline constexpr
294year_month_day_last operator+(const years& __lhs, const year_month_day_last& __rhs) noexcept
295{ return __rhs + __lhs; }
296
297_LIBCPP_HIDE_FROM_ABI inline constexpr
298year_month_day_last operator-(const year_month_day_last& __lhs, const years& __rhs) noexcept
299{ return __lhs + (-__rhs); }
300
301_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day_last& year_month_day_last::operator+=(const months& __dm) noexcept { *this = *this + __dm; return *this; }
302_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day_last& year_month_day_last::operator-=(const months& __dm) noexcept { *this = *this - __dm; return *this; }
303_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day_last& year_month_day_last::operator+=(const years& __dy) noexcept { *this = *this + __dy; return *this; }
304_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day_last& year_month_day_last::operator-=(const years& __dy) noexcept { *this = *this - __dy; return *this; }
305
306_LIBCPP_HIDE_FROM_ABI inline constexpr
307year_month_day::year_month_day(const year_month_day_last& __ymdl) noexcept
308 : __y{__ymdl.year()}, __m{__ymdl.month()}, __d{__ymdl.day()} {}
309
310_LIBCPP_HIDE_FROM_ABI inline constexpr
311bool year_month_day::ok() const noexcept
312{
313 if (!__y.ok() || !__m.ok()) return false;
314 return chrono::day{1} <= __d && __d <= (__y / __m / last).day();
315}
316
317} // namespace chrono
318
319_LIBCPP_END_NAMESPACE_STD
320
321#endif // _LIBCPP_STD_VER > 17
322
323#endif // _LIBCPP___CHRONO_YEAR_MONTH_DAY_H
lib/libcxx/include/__chrono/year_month_weekday.h created+255
...@@ -0,0 +1,255 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___CHRONO_YEAR_MONTH_WEEKDAY_H
11#define _LIBCPP___CHRONO_YEAR_MONTH_WEEKDAY_H
12
13#include <__chrono/calendar.h>
14#include <__chrono/day.h>
15#include <__chrono/duration.h>
16#include <__chrono/month.h>
17#include <__chrono/month_weekday.h>
18#include <__chrono/system_clock.h>
19#include <__chrono/time_point.h>
20#include <__chrono/weekday.h>
21#include <__chrono/year.h>
22#include <__chrono/year_month.h>
23#include <__chrono/year_month_day.h>
24#include <__config>
25
26#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
27# pragma GCC system_header
28#endif
29
30#if _LIBCPP_STD_VER > 17
31
32_LIBCPP_BEGIN_NAMESPACE_STD
33
34namespace chrono
35{
36
37class year_month_weekday {
38 chrono::year __y;
39 chrono::month __m;
40 chrono::weekday_indexed __wdi;
41public:
42 _LIBCPP_HIDE_FROM_ABI year_month_weekday() = default;
43 _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday(const chrono::year& __yval, const chrono::month& __mval,
44 const chrono::weekday_indexed& __wdival) noexcept
45 : __y{__yval}, __m{__mval}, __wdi{__wdival} {}
46 _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday(const sys_days& __sysd) noexcept
47 : year_month_weekday(__from_days(__sysd.time_since_epoch())) {}
48 _LIBCPP_HIDE_FROM_ABI inline explicit constexpr year_month_weekday(const local_days& __locd) noexcept
49 : year_month_weekday(__from_days(__locd.time_since_epoch())) {}
50 _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday& operator+=(const months&) noexcept;
51 _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday& operator-=(const months&) noexcept;
52 _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday& operator+=(const years&) noexcept;
53 _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday& operator-=(const years&) noexcept;
54
55 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::year year() const noexcept { return __y; }
56 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m; }
57 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday weekday() const noexcept { return __wdi.weekday(); }
58 _LIBCPP_HIDE_FROM_ABI inline constexpr unsigned index() const noexcept { return __wdi.index(); }
59 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday_indexed weekday_indexed() const noexcept { return __wdi; }
60
61 _LIBCPP_HIDE_FROM_ABI inline constexpr operator sys_days() const noexcept { return sys_days{__to_days()}; }
62 _LIBCPP_HIDE_FROM_ABI inline explicit constexpr operator local_days() const noexcept { return local_days{__to_days()}; }
63 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept
64 {
65 if (!__y.ok() || !__m.ok() || !__wdi.ok()) return false;
66 if (__wdi.index() <= 4) return true;
67 auto __nth_weekday_day =
68 __wdi.weekday() -
69 chrono::weekday{static_cast<sys_days>(__y / __m / 1)} +
70 days{(__wdi.index() - 1) * 7 + 1};
71 return static_cast<unsigned>(__nth_weekday_day.count()) <=
72 static_cast<unsigned>((__y / __m / last).day());
73 }
74
75 _LIBCPP_HIDE_FROM_ABI static constexpr year_month_weekday __from_days(days __d) noexcept;
76 _LIBCPP_HIDE_FROM_ABI constexpr days __to_days() const noexcept;
77};
78
79_LIBCPP_HIDE_FROM_ABI inline constexpr
80year_month_weekday year_month_weekday::__from_days(days __d) noexcept
81{
82 const sys_days __sysd{__d};
83 const chrono::weekday __wd = chrono::weekday(__sysd);
84 const year_month_day __ymd = year_month_day(__sysd);
85 return year_month_weekday{__ymd.year(), __ymd.month(),
86 __wd[(static_cast<unsigned>(__ymd.day())-1)/7+1]};
87}
88
89_LIBCPP_HIDE_FROM_ABI inline constexpr
90days year_month_weekday::__to_days() const noexcept
91{
92 const sys_days __sysd = sys_days(__y/__m/1);
93 return (__sysd + (__wdi.weekday() - chrono::weekday(__sysd) + days{(__wdi.index()-1)*7}))
94 .time_since_epoch();
95}
96
97_LIBCPP_HIDE_FROM_ABI inline constexpr
98bool operator==(const year_month_weekday& __lhs, const year_month_weekday& __rhs) noexcept
99{ return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month() && __lhs.weekday_indexed() == __rhs.weekday_indexed(); }
100
101_LIBCPP_HIDE_FROM_ABI inline constexpr
102bool operator!=(const year_month_weekday& __lhs, const year_month_weekday& __rhs) noexcept
103{ return !(__lhs == __rhs); }
104
105_LIBCPP_HIDE_FROM_ABI inline constexpr
106year_month_weekday operator/(const year_month& __lhs, const weekday_indexed& __rhs) noexcept
107{ return year_month_weekday{__lhs.year(), __lhs.month(), __rhs}; }
108
109_LIBCPP_HIDE_FROM_ABI inline constexpr
110year_month_weekday operator/(const year& __lhs, const month_weekday& __rhs) noexcept
111{ return year_month_weekday{__lhs, __rhs.month(), __rhs.weekday_indexed()}; }
112
113_LIBCPP_HIDE_FROM_ABI inline constexpr
114year_month_weekday operator/(int __lhs, const month_weekday& __rhs) noexcept
115{ return year(__lhs) / __rhs; }
116
117_LIBCPP_HIDE_FROM_ABI inline constexpr
118year_month_weekday operator/(const month_weekday& __lhs, const year& __rhs) noexcept
119{ return __rhs / __lhs; }
120
121_LIBCPP_HIDE_FROM_ABI inline constexpr
122year_month_weekday operator/(const month_weekday& __lhs, int __rhs) noexcept
123{ return year(__rhs) / __lhs; }
124
125
126_LIBCPP_HIDE_FROM_ABI inline constexpr
127year_month_weekday operator+(const year_month_weekday& __lhs, const months& __rhs) noexcept
128{ return (__lhs.year() / __lhs.month() + __rhs) / __lhs.weekday_indexed(); }
129
130_LIBCPP_HIDE_FROM_ABI inline constexpr
131year_month_weekday operator+(const months& __lhs, const year_month_weekday& __rhs) noexcept
132{ return __rhs + __lhs; }
133
134_LIBCPP_HIDE_FROM_ABI inline constexpr
135year_month_weekday operator-(const year_month_weekday& __lhs, const months& __rhs) noexcept
136{ return __lhs + (-__rhs); }
137
138_LIBCPP_HIDE_FROM_ABI inline constexpr
139year_month_weekday operator+(const year_month_weekday& __lhs, const years& __rhs) noexcept
140{ return year_month_weekday{__lhs.year() + __rhs, __lhs.month(), __lhs.weekday_indexed()}; }
141
142_LIBCPP_HIDE_FROM_ABI inline constexpr
143year_month_weekday operator+(const years& __lhs, const year_month_weekday& __rhs) noexcept
144{ return __rhs + __lhs; }
145
146_LIBCPP_HIDE_FROM_ABI inline constexpr
147year_month_weekday operator-(const year_month_weekday& __lhs, const years& __rhs) noexcept
148{ return __lhs + (-__rhs); }
149
150
151_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday& year_month_weekday::operator+=(const months& __dm) noexcept { *this = *this + __dm; return *this; }
152_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday& year_month_weekday::operator-=(const months& __dm) noexcept { *this = *this - __dm; return *this; }
153_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday& year_month_weekday::operator+=(const years& __dy) noexcept { *this = *this + __dy; return *this; }
154_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday& year_month_weekday::operator-=(const years& __dy) noexcept { *this = *this - __dy; return *this; }
155
156class year_month_weekday_last {
157private:
158 chrono::year __y;
159 chrono::month __m;
160 chrono::weekday_last __wdl;
161public:
162 _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday_last(const chrono::year& __yval, const chrono::month& __mval,
163 const chrono::weekday_last& __wdlval) noexcept
164 : __y{__yval}, __m{__mval}, __wdl{__wdlval} {}
165 _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday_last& operator+=(const months& __dm) noexcept;
166 _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday_last& operator-=(const months& __dm) noexcept;
167 _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday_last& operator+=(const years& __dy) noexcept;
168 _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday_last& operator-=(const years& __dy) noexcept;
169
170 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::year year() const noexcept { return __y; }
171 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m; }
172 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday weekday() const noexcept { return __wdl.weekday(); }
173 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday_last weekday_last() const noexcept { return __wdl; }
174 _LIBCPP_HIDE_FROM_ABI inline constexpr operator sys_days() const noexcept { return sys_days{__to_days()}; }
175 _LIBCPP_HIDE_FROM_ABI inline explicit constexpr operator local_days() const noexcept { return local_days{__to_days()}; }
176 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __y.ok() && __m.ok() && __wdl.ok(); }
177
178 _LIBCPP_HIDE_FROM_ABI constexpr days __to_days() const noexcept;
179
180};
181
182_LIBCPP_HIDE_FROM_ABI inline constexpr
183days year_month_weekday_last::__to_days() const noexcept
184{
185 const sys_days __last = sys_days{__y/__m/last};
186 return (__last - (chrono::weekday{__last} - __wdl.weekday())).time_since_epoch();
187
188}
189
190_LIBCPP_HIDE_FROM_ABI inline constexpr
191bool operator==(const year_month_weekday_last& __lhs, const year_month_weekday_last& __rhs) noexcept
192{ return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month() && __lhs.weekday_last() == __rhs.weekday_last(); }
193
194_LIBCPP_HIDE_FROM_ABI inline constexpr
195bool operator!=(const year_month_weekday_last& __lhs, const year_month_weekday_last& __rhs) noexcept
196{ return !(__lhs == __rhs); }
197
198
199_LIBCPP_HIDE_FROM_ABI inline constexpr
200year_month_weekday_last operator/(const year_month& __lhs, const weekday_last& __rhs) noexcept
201{ return year_month_weekday_last{__lhs.year(), __lhs.month(), __rhs}; }
202
203_LIBCPP_HIDE_FROM_ABI inline constexpr
204year_month_weekday_last operator/(const year& __lhs, const month_weekday_last& __rhs) noexcept
205{ return year_month_weekday_last{__lhs, __rhs.month(), __rhs.weekday_last()}; }
206
207_LIBCPP_HIDE_FROM_ABI inline constexpr
208year_month_weekday_last operator/(int __lhs, const month_weekday_last& __rhs) noexcept
209{ return year(__lhs) / __rhs; }
210
211_LIBCPP_HIDE_FROM_ABI inline constexpr
212year_month_weekday_last operator/(const month_weekday_last& __lhs, const year& __rhs) noexcept
213{ return __rhs / __lhs; }
214
215_LIBCPP_HIDE_FROM_ABI inline constexpr
216year_month_weekday_last operator/(const month_weekday_last& __lhs, int __rhs) noexcept
217{ return year(__rhs) / __lhs; }
218
219
220_LIBCPP_HIDE_FROM_ABI inline constexpr
221year_month_weekday_last operator+(const year_month_weekday_last& __lhs, const months& __rhs) noexcept
222{ return (__lhs.year() / __lhs.month() + __rhs) / __lhs.weekday_last(); }
223
224_LIBCPP_HIDE_FROM_ABI inline constexpr
225year_month_weekday_last operator+(const months& __lhs, const year_month_weekday_last& __rhs) noexcept
226{ return __rhs + __lhs; }
227
228_LIBCPP_HIDE_FROM_ABI inline constexpr
229year_month_weekday_last operator-(const year_month_weekday_last& __lhs, const months& __rhs) noexcept
230{ return __lhs + (-__rhs); }
231
232_LIBCPP_HIDE_FROM_ABI inline constexpr
233year_month_weekday_last operator+(const year_month_weekday_last& __lhs, const years& __rhs) noexcept
234{ return year_month_weekday_last{__lhs.year() + __rhs, __lhs.month(), __lhs.weekday_last()}; }
235
236_LIBCPP_HIDE_FROM_ABI inline constexpr
237year_month_weekday_last operator+(const years& __lhs, const year_month_weekday_last& __rhs) noexcept
238{ return __rhs + __lhs; }
239
240_LIBCPP_HIDE_FROM_ABI inline constexpr
241year_month_weekday_last operator-(const year_month_weekday_last& __lhs, const years& __rhs) noexcept
242{ return __lhs + (-__rhs); }
243
244_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday_last& year_month_weekday_last::operator+=(const months& __dm) noexcept { *this = *this + __dm; return *this; }
245_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday_last& year_month_weekday_last::operator-=(const months& __dm) noexcept { *this = *this - __dm; return *this; }
246_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday_last& year_month_weekday_last::operator+=(const years& __dy) noexcept { *this = *this + __dy; return *this; }
247_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday_last& year_month_weekday_last::operator-=(const years& __dy) noexcept { *this = *this - __dy; return *this; }
248
249} // namespace chrono
250
251_LIBCPP_END_NAMESPACE_STD
252
253#endif // _LIBCPP_STD_VER > 17
254
255#endif // _LIBCPP___CHRONO_YEAR_MONTH_WEEKDAY_H
lib/libcxx/include/__compare/common_comparison_category.h+1-1
...@@ -14,7 +14,7 @@...@@ -14,7 +14,7 @@
14#include <type_traits>14#include <type_traits>
1515
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17#pragma GCC system_header17# pragma GCC system_header
18#endif18#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__compare/compare_partial_order_fallback.h+3-3
...@@ -17,12 +17,12 @@...@@ -17,12 +17,12 @@
17#include <type_traits>17#include <type_traits>
1818
19#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER19#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
20#pragma GCC system_header20# pragma GCC system_header
21#endif21#endif
2222
23_LIBCPP_BEGIN_NAMESPACE_STD23_LIBCPP_BEGIN_NAMESPACE_STD
2424
25#if !defined(_LIBCPP_HAS_NO_CONCEPTS)25#if _LIBCPP_STD_VER > 17
2626
27// [cmp.alg]27// [cmp.alg]
28namespace __compare_partial_order_fallback {28namespace __compare_partial_order_fallback {
...@@ -66,7 +66,7 @@ inline namespace __cpo {...@@ -66,7 +66,7 @@ inline namespace __cpo {
66 inline constexpr auto compare_partial_order_fallback = __compare_partial_order_fallback::__fn{};66 inline constexpr auto compare_partial_order_fallback = __compare_partial_order_fallback::__fn{};
67} // namespace __cpo67} // namespace __cpo
6868
69#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)69#endif // _LIBCPP_STD_VER > 17
7070
71_LIBCPP_END_NAMESPACE_STD71_LIBCPP_END_NAMESPACE_STD
7272
lib/libcxx/include/__compare/compare_strong_order_fallback.h+3-3
...@@ -17,12 +17,12 @@...@@ -17,12 +17,12 @@
17#include <type_traits>17#include <type_traits>
1818
19#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER19#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
20#pragma GCC system_header20# pragma GCC system_header
21#endif21#endif
2222
23_LIBCPP_BEGIN_NAMESPACE_STD23_LIBCPP_BEGIN_NAMESPACE_STD
2424
25#if !defined(_LIBCPP_HAS_NO_CONCEPTS)25#if _LIBCPP_STD_VER > 17
2626
27// [cmp.alg]27// [cmp.alg]
28namespace __compare_strong_order_fallback {28namespace __compare_strong_order_fallback {
...@@ -63,7 +63,7 @@ inline namespace __cpo {...@@ -63,7 +63,7 @@ inline namespace __cpo {
63 inline constexpr auto compare_strong_order_fallback = __compare_strong_order_fallback::__fn{};63 inline constexpr auto compare_strong_order_fallback = __compare_strong_order_fallback::__fn{};
64} // namespace __cpo64} // namespace __cpo
6565
66#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)66#endif // _LIBCPP_STD_VER > 17
6767
68_LIBCPP_END_NAMESPACE_STD68_LIBCPP_END_NAMESPACE_STD
6969
lib/libcxx/include/__compare/compare_three_way.h+3-3
...@@ -15,12 +15,12 @@...@@ -15,12 +15,12 @@
15#include <__utility/forward.h>15#include <__utility/forward.h>
1616
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header18# pragma GCC system_header
19#endif19#endif
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
23#if !defined(_LIBCPP_HAS_NO_CONCEPTS)23#if _LIBCPP_STD_VER > 17
2424
25struct _LIBCPP_TEMPLATE_VIS compare_three_way25struct _LIBCPP_TEMPLATE_VIS compare_three_way
26{26{
...@@ -34,7 +34,7 @@ struct _LIBCPP_TEMPLATE_VIS compare_three_way...@@ -34,7 +34,7 @@ struct _LIBCPP_TEMPLATE_VIS compare_three_way
34 using is_transparent = void;34 using is_transparent = void;
35};35};
3636
37#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)37#endif // _LIBCPP_STD_VER > 17
3838
39_LIBCPP_END_NAMESPACE_STD39_LIBCPP_END_NAMESPACE_STD
4040
lib/libcxx/include/__compare/compare_three_way_result.h+1-1
...@@ -13,7 +13,7 @@...@@ -13,7 +13,7 @@
13#include <type_traits>13#include <type_traits>
1414
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16#pragma GCC system_header16# pragma GCC system_header
17#endif17#endif
1818
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__compare/compare_weak_order_fallback.h+3-3
...@@ -17,12 +17,12 @@...@@ -17,12 +17,12 @@
17#include <type_traits>17#include <type_traits>
1818
19#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER19#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
20#pragma GCC system_header20# pragma GCC system_header
21#endif21#endif
2222
23_LIBCPP_BEGIN_NAMESPACE_STD23_LIBCPP_BEGIN_NAMESPACE_STD
2424
25#if !defined(_LIBCPP_HAS_NO_CONCEPTS)25#if _LIBCPP_STD_VER > 17
2626
27// [cmp.alg]27// [cmp.alg]
28namespace __compare_weak_order_fallback {28namespace __compare_weak_order_fallback {
...@@ -63,7 +63,7 @@ inline namespace __cpo {...@@ -63,7 +63,7 @@ inline namespace __cpo {
63 inline constexpr auto compare_weak_order_fallback = __compare_weak_order_fallback::__fn{};63 inline constexpr auto compare_weak_order_fallback = __compare_weak_order_fallback::__fn{};
64} // namespace __cpo64} // namespace __cpo
6565
66#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)66#endif // _LIBCPP_STD_VER > 17
6767
68_LIBCPP_END_NAMESPACE_STD68_LIBCPP_END_NAMESPACE_STD
6969
lib/libcxx/include/__compare/is_eq.h+1-1
...@@ -13,7 +13,7 @@...@@ -13,7 +13,7 @@
13#include <__config>13#include <__config>
1414
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16#pragma GCC system_header16# pragma GCC system_header
17#endif17#endif
1818
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__compare/ordering.h+1-1
...@@ -13,7 +13,7 @@...@@ -13,7 +13,7 @@
13#include <type_traits>13#include <type_traits>
1414
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16#pragma GCC system_header16# pragma GCC system_header
17#endif17#endif
1818
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__compare/partial_order.h+3-3
...@@ -18,12 +18,12 @@...@@ -18,12 +18,12 @@
18#include <type_traits>18#include <type_traits>
1919
20#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER20#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
21#pragma GCC system_header21# pragma GCC system_header
22#endif22#endif
2323
24_LIBCPP_BEGIN_NAMESPACE_STD24_LIBCPP_BEGIN_NAMESPACE_STD
2525
26#if !defined(_LIBCPP_HAS_NO_CONCEPTS)26#if _LIBCPP_STD_VER > 17
2727
28// [cmp.alg]28// [cmp.alg]
29namespace __partial_order {29namespace __partial_order {
...@@ -64,7 +64,7 @@ inline namespace __cpo {...@@ -64,7 +64,7 @@ inline namespace __cpo {
64 inline constexpr auto partial_order = __partial_order::__fn{};64 inline constexpr auto partial_order = __partial_order::__fn{};
65} // namespace __cpo65} // namespace __cpo
6666
67#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)67#endif // _LIBCPP_STD_VER > 17
6868
69_LIBCPP_END_NAMESPACE_STD69_LIBCPP_END_NAMESPACE_STD
7070
lib/libcxx/include/__compare/strong_order.h+3-3
...@@ -21,7 +21,7 @@...@@ -21,7 +21,7 @@
21#include <type_traits>21#include <type_traits>
2222
23#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER23#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
24#pragma GCC system_header24# pragma GCC system_header
25#endif25#endif
2626
27_LIBCPP_PUSH_MACROS27_LIBCPP_PUSH_MACROS
...@@ -29,7 +29,7 @@ _LIBCPP_PUSH_MACROS...@@ -29,7 +29,7 @@ _LIBCPP_PUSH_MACROS
2929
30_LIBCPP_BEGIN_NAMESPACE_STD30_LIBCPP_BEGIN_NAMESPACE_STD
3131
32#if !defined(_LIBCPP_HAS_NO_CONCEPTS)32#if _LIBCPP_STD_VER > 17
3333
34// [cmp.alg]34// [cmp.alg]
35namespace __strong_order {35namespace __strong_order {
...@@ -127,7 +127,7 @@ inline namespace __cpo {...@@ -127,7 +127,7 @@ inline namespace __cpo {
127 inline constexpr auto strong_order = __strong_order::__fn{};127 inline constexpr auto strong_order = __strong_order::__fn{};
128} // namespace __cpo128} // namespace __cpo
129129
130#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)130#endif // _LIBCPP_STD_VER > 17
131131
132_LIBCPP_END_NAMESPACE_STD132_LIBCPP_END_NAMESPACE_STD
133133
lib/libcxx/include/__compare/synth_three_way.h+4-4
...@@ -16,12 +16,12 @@...@@ -16,12 +16,12 @@
16#include <__utility/declval.h>16#include <__utility/declval.h>
1717
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19#pragma GCC system_header19# pragma GCC system_header
20#endif20#endif
2121
22_LIBCPP_BEGIN_NAMESPACE_STD22_LIBCPP_BEGIN_NAMESPACE_STD
2323
24#if !defined(_LIBCPP_HAS_NO_CONCEPTS)24#if _LIBCPP_STD_VER > 17
2525
26// [expos.only.func]26// [expos.only.func]
2727
...@@ -42,9 +42,9 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr auto __synth_three_way =...@@ -42,9 +42,9 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr auto __synth_three_way =
42 };42 };
4343
44template <class _Tp, class _Up = _Tp>44template <class _Tp, class _Up = _Tp>
45using __synth_three_way_result = decltype(__synth_three_way(declval<_Tp&>(), declval<_Up&>()));45using __synth_three_way_result = decltype(std::__synth_three_way(declval<_Tp&>(), declval<_Up&>()));
4646
47#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)47#endif // _LIBCPP_STD_VER > 17
4848
49_LIBCPP_END_NAMESPACE_STD49_LIBCPP_END_NAMESPACE_STD
5050
lib/libcxx/include/__compare/three_way_comparable.h+3-3
...@@ -19,12 +19,12 @@...@@ -19,12 +19,12 @@
19#include <type_traits>19#include <type_traits>
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
23#endif23#endif
2424
25_LIBCPP_BEGIN_NAMESPACE_STD25_LIBCPP_BEGIN_NAMESPACE_STD
2626
27#if !defined(_LIBCPP_HAS_NO_CONCEPTS)27#if _LIBCPP_STD_VER > 17
2828
29template<class _Tp, class _Cat>29template<class _Tp, class _Cat>
30concept __compares_as =30concept __compares_as =
...@@ -51,7 +51,7 @@ concept three_way_comparable_with =...@@ -51,7 +51,7 @@ concept three_way_comparable_with =
51 { __u <=> __t } -> __compares_as<_Cat>;51 { __u <=> __t } -> __compares_as<_Cat>;
52 };52 };
5353
54#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)54#endif // _LIBCPP_STD_VER > 17
5555
56_LIBCPP_END_NAMESPACE_STD56_LIBCPP_END_NAMESPACE_STD
5757
lib/libcxx/include/__compare/weak_order.h+3-3
...@@ -19,12 +19,12 @@...@@ -19,12 +19,12 @@
19#include <type_traits>19#include <type_traits>
2020
21#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER21#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
22#pragma GCC system_header22# pragma GCC system_header
23#endif23#endif
2424
25_LIBCPP_BEGIN_NAMESPACE_STD25_LIBCPP_BEGIN_NAMESPACE_STD
2626
27#if !defined(_LIBCPP_HAS_NO_CONCEPTS)27#if _LIBCPP_STD_VER > 17
2828
29// [cmp.alg]29// [cmp.alg]
30namespace __weak_order {30namespace __weak_order {
...@@ -93,7 +93,7 @@ inline namespace __cpo {...@@ -93,7 +93,7 @@ inline namespace __cpo {
93 inline constexpr auto weak_order = __weak_order::__fn{};93 inline constexpr auto weak_order = __weak_order::__fn{};
94} // namespace __cpo94} // namespace __cpo
9595
96#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)96#endif // _LIBCPP_STD_VER > 17
9797
98_LIBCPP_END_NAMESPACE_STD98_LIBCPP_END_NAMESPACE_STD
9999
lib/libcxx/include/__concepts/arithmetic.h+5-3
...@@ -10,15 +10,17 @@...@@ -10,15 +10,17 @@
10#define _LIBCPP___CONCEPTS_ARITHMETIC_H10#define _LIBCPP___CONCEPTS_ARITHMETIC_H
1111
12#include <__config>12#include <__config>
13#include <__type_traits/is_signed_integer.h>
14#include <__type_traits/is_unsigned_integer.h>
13#include <type_traits>15#include <type_traits>
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
17#endif19#endif
1820
19_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2022
21#if !defined(_LIBCPP_HAS_NO_CONCEPTS)23#if _LIBCPP_STD_VER > 17
2224
23// [concepts.arithmetic], arithmetic concepts25// [concepts.arithmetic], arithmetic concepts
2426
...@@ -41,7 +43,7 @@ concept __libcpp_unsigned_integer = __libcpp_is_unsigned_integer<_Tp>::value;...@@ -41,7 +43,7 @@ concept __libcpp_unsigned_integer = __libcpp_is_unsigned_integer<_Tp>::value;
41template <class _Tp>43template <class _Tp>
42concept __libcpp_signed_integer = __libcpp_is_signed_integer<_Tp>::value;44concept __libcpp_signed_integer = __libcpp_is_signed_integer<_Tp>::value;
4345
44#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)46#endif // _LIBCPP_STD_VER > 17
4547
46_LIBCPP_END_NAMESPACE_STD48_LIBCPP_END_NAMESPACE_STD
4749
lib/libcxx/include/__concepts/assignable.h+3-3
...@@ -16,12 +16,12 @@...@@ -16,12 +16,12 @@
16#include <type_traits>16#include <type_traits>
1717
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19#pragma GCC system_header19# pragma GCC system_header
20#endif20#endif
2121
22_LIBCPP_BEGIN_NAMESPACE_STD22_LIBCPP_BEGIN_NAMESPACE_STD
2323
24#if !defined(_LIBCPP_HAS_NO_CONCEPTS)24#if _LIBCPP_STD_VER > 17
2525
26// [concept.assignable]26// [concept.assignable]
2727
...@@ -33,7 +33,7 @@ concept assignable_from =...@@ -33,7 +33,7 @@ concept assignable_from =
33 { __lhs = _VSTD::forward<_Rhs>(__rhs) } -> same_as<_Lhs>;33 { __lhs = _VSTD::forward<_Rhs>(__rhs) } -> same_as<_Lhs>;
34 };34 };
3535
36#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)36#endif // _LIBCPP_STD_VER > 17
3737
38_LIBCPP_END_NAMESPACE_STD38_LIBCPP_END_NAMESPACE_STD
3939
lib/libcxx/include/__concepts/boolean_testable.h+3-3
...@@ -14,12 +14,12 @@...@@ -14,12 +14,12 @@
14#include <__utility/forward.h>14#include <__utility/forward.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
18#endif18#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
2121
22#if !defined(_LIBCPP_HAS_NO_CONCEPTS)22#if _LIBCPP_STD_VER > 17
2323
24// [concepts.booleantestable]24// [concepts.booleantestable]
2525
...@@ -31,7 +31,7 @@ concept __boolean_testable = __boolean_testable_impl<_Tp> && requires(_Tp&& __t)...@@ -31,7 +31,7 @@ concept __boolean_testable = __boolean_testable_impl<_Tp> && requires(_Tp&& __t)
31 { !_VSTD::forward<_Tp>(__t) } -> __boolean_testable_impl;31 { !_VSTD::forward<_Tp>(__t) } -> __boolean_testable_impl;
32};32};
3333
34#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)34#endif // _LIBCPP_STD_VER > 17
3535
36_LIBCPP_END_NAMESPACE_STD36_LIBCPP_END_NAMESPACE_STD
3737
lib/libcxx/include/__concepts/class_or_enum.h+4-3
...@@ -13,12 +13,12 @@...@@ -13,12 +13,12 @@
13#include <type_traits>13#include <type_traits>
1414
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16#pragma GCC system_header16# pragma GCC system_header
17#endif17#endif
1818
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21#if !defined(_LIBCPP_HAS_NO_CONCEPTS)21#if _LIBCPP_STD_VER > 17
2222
23// Whether a type is a class type or enumeration type according to the Core wording.23// Whether a type is a class type or enumeration type according to the Core wording.
2424
...@@ -26,10 +26,11 @@ template<class _Tp>...@@ -26,10 +26,11 @@ template<class _Tp>
26concept __class_or_enum = is_class_v<_Tp> || is_union_v<_Tp> || is_enum_v<_Tp>;26concept __class_or_enum = is_class_v<_Tp> || is_union_v<_Tp> || is_enum_v<_Tp>;
2727
28// Work around Clang bug https://llvm.org/PR5297028// Work around Clang bug https://llvm.org/PR52970
29// TODO: remove this workaround once libc++ no longer has to support Clang 13 (it was fixed in Clang 14).
29template<class _Tp>30template<class _Tp>
30concept __workaround_52970 = is_class_v<__uncvref_t<_Tp>> || is_union_v<__uncvref_t<_Tp>>;31concept __workaround_52970 = is_class_v<__uncvref_t<_Tp>> || is_union_v<__uncvref_t<_Tp>>;
3132
32#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)33#endif // _LIBCPP_STD_VER > 17
3334
34_LIBCPP_END_NAMESPACE_STD35_LIBCPP_END_NAMESPACE_STD
3536
lib/libcxx/include/__concepts/common_reference_with.h+3-3
...@@ -15,12 +15,12 @@...@@ -15,12 +15,12 @@
15#include <type_traits>15#include <type_traits>
1616
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header18# pragma GCC system_header
19#endif19#endif
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
23#if !defined(_LIBCPP_HAS_NO_CONCEPTS)23#if _LIBCPP_STD_VER > 17
2424
25// [concept.commonref]25// [concept.commonref]
2626
...@@ -30,7 +30,7 @@ concept common_reference_with =...@@ -30,7 +30,7 @@ concept common_reference_with =
30 convertible_to<_Tp, common_reference_t<_Tp, _Up>> &&30 convertible_to<_Tp, common_reference_t<_Tp, _Up>> &&
31 convertible_to<_Up, common_reference_t<_Tp, _Up>>;31 convertible_to<_Up, common_reference_t<_Tp, _Up>>;
3232
33#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)33#endif // _LIBCPP_STD_VER > 17
3434
35_LIBCPP_END_NAMESPACE_STD35_LIBCPP_END_NAMESPACE_STD
3636
lib/libcxx/include/__concepts/common_with.h+3-3
...@@ -15,12 +15,12 @@...@@ -15,12 +15,12 @@
15#include <type_traits>15#include <type_traits>
1616
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header18# pragma GCC system_header
19#endif19#endif
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
23#if !defined(_LIBCPP_HAS_NO_CONCEPTS)23#if _LIBCPP_STD_VER > 17
2424
25// [concept.common]25// [concept.common]
2626
...@@ -40,7 +40,7 @@ concept common_with =...@@ -40,7 +40,7 @@ concept common_with =
40 add_lvalue_reference_t<const _Tp>,40 add_lvalue_reference_t<const _Tp>,
41 add_lvalue_reference_t<const _Up>>>;41 add_lvalue_reference_t<const _Up>>>;
4242
43#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)43#endif // _LIBCPP_STD_VER > 17
4444
45_LIBCPP_END_NAMESPACE_STD45_LIBCPP_END_NAMESPACE_STD
4646
lib/libcxx/include/__concepts/constructible.h+3-3
...@@ -15,12 +15,12 @@...@@ -15,12 +15,12 @@
15#include <type_traits>15#include <type_traits>
1616
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header18# pragma GCC system_header
19#endif19#endif
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
23#if !defined(_LIBCPP_HAS_NO_CONCEPTS)23#if _LIBCPP_STD_VER > 17
2424
25// [concept.constructible]25// [concept.constructible]
26template<class _Tp, class... _Args>26template<class _Tp, class... _Args>
...@@ -49,7 +49,7 @@ concept copy_constructible =...@@ -49,7 +49,7 @@ concept copy_constructible =
49 constructible_from<_Tp, const _Tp&> && convertible_to<const _Tp&, _Tp> &&49 constructible_from<_Tp, const _Tp&> && convertible_to<const _Tp&, _Tp> &&
50 constructible_from<_Tp, const _Tp> && convertible_to<const _Tp, _Tp>;50 constructible_from<_Tp, const _Tp> && convertible_to<const _Tp, _Tp>;
5151
52#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)52#endif // _LIBCPP_STD_VER > 17
5353
54_LIBCPP_END_NAMESPACE_STD54_LIBCPP_END_NAMESPACE_STD
5555
lib/libcxx/include/__concepts/convertible_to.h+3-3
...@@ -14,12 +14,12 @@...@@ -14,12 +14,12 @@
14#include <type_traits>14#include <type_traits>
1515
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17#pragma GCC system_header17# pragma GCC system_header
18#endif18#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
2121
22#if !defined(_LIBCPP_HAS_NO_CONCEPTS)22#if _LIBCPP_STD_VER > 17
2323
24// [concept.convertible]24// [concept.convertible]
2525
...@@ -30,7 +30,7 @@ concept convertible_to =...@@ -30,7 +30,7 @@ concept convertible_to =
30 static_cast<_To>(declval<_From>());30 static_cast<_To>(declval<_From>());
31 };31 };
3232
33#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)33#endif // _LIBCPP_STD_VER > 17
3434
35_LIBCPP_END_NAMESPACE_STD35_LIBCPP_END_NAMESPACE_STD
3636
lib/libcxx/include/__concepts/copyable.h+3-3
...@@ -15,12 +15,12 @@...@@ -15,12 +15,12 @@
15#include <__config>15#include <__config>
1616
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header18# pragma GCC system_header
19#endif19#endif
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
23#if !defined(_LIBCPP_HAS_NO_CONCEPTS)23#if _LIBCPP_STD_VER > 17
2424
25// [concepts.object]25// [concepts.object]
2626
...@@ -32,7 +32,7 @@ concept copyable =...@@ -32,7 +32,7 @@ concept copyable =
32 assignable_from<_Tp&, const _Tp&> &&32 assignable_from<_Tp&, const _Tp&> &&
33 assignable_from<_Tp&, const _Tp>;33 assignable_from<_Tp&, const _Tp>;
3434
35#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)35#endif // _LIBCPP_STD_VER > 17
3636
37_LIBCPP_END_NAMESPACE_STD37_LIBCPP_END_NAMESPACE_STD
3838
lib/libcxx/include/__concepts/derived_from.h+3-3
...@@ -13,12 +13,12 @@...@@ -13,12 +13,12 @@
13#include <type_traits>13#include <type_traits>
1414
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16#pragma GCC system_header16# pragma GCC system_header
17#endif17#endif
1818
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21#if !defined(_LIBCPP_HAS_NO_CONCEPTS)21#if _LIBCPP_STD_VER > 17
2222
23// [concept.derived]23// [concept.derived]
2424
...@@ -27,7 +27,7 @@ concept derived_from =...@@ -27,7 +27,7 @@ concept derived_from =
27 is_base_of_v<_Bp, _Dp> &&27 is_base_of_v<_Bp, _Dp> &&
28 is_convertible_v<const volatile _Dp*, const volatile _Bp*>;28 is_convertible_v<const volatile _Dp*, const volatile _Bp*>;
2929
30#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)30#endif // _LIBCPP_STD_VER > 17
3131
32_LIBCPP_END_NAMESPACE_STD32_LIBCPP_END_NAMESPACE_STD
3333
lib/libcxx/include/__concepts/destructible.h+3-3
...@@ -13,19 +13,19 @@...@@ -13,19 +13,19 @@
13#include <type_traits>13#include <type_traits>
1414
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16#pragma GCC system_header16# pragma GCC system_header
17#endif17#endif
1818
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21#if !defined(_LIBCPP_HAS_NO_CONCEPTS)21#if _LIBCPP_STD_VER > 17
2222
23// [concept.destructible]23// [concept.destructible]
2424
25template<class _Tp>25template<class _Tp>
26concept destructible = is_nothrow_destructible_v<_Tp>;26concept destructible = is_nothrow_destructible_v<_Tp>;
2727
28#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)28#endif // _LIBCPP_STD_VER > 17
2929
30_LIBCPP_END_NAMESPACE_STD30_LIBCPP_END_NAMESPACE_STD
3131
lib/libcxx/include/__concepts/different_from.h+3-3
...@@ -14,17 +14,17 @@...@@ -14,17 +14,17 @@
14#include <type_traits>14#include <type_traits>
1515
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17#pragma GCC system_header17# pragma GCC system_header
18#endif18#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
2121
22#if !defined(_LIBCPP_HAS_NO_CONCEPTS)22#if _LIBCPP_STD_VER > 17
2323
24template<class _Tp, class _Up>24template<class _Tp, class _Up>
25concept __different_from = !same_as<remove_cvref_t<_Tp>, remove_cvref_t<_Up>>;25concept __different_from = !same_as<remove_cvref_t<_Tp>, remove_cvref_t<_Up>>;
2626
27#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)27#endif // _LIBCPP_STD_VER > 17
2828
29_LIBCPP_END_NAMESPACE_STD29_LIBCPP_END_NAMESPACE_STD
3030
lib/libcxx/include/__concepts/equality_comparable.h+3-3
...@@ -15,12 +15,12 @@...@@ -15,12 +15,12 @@
15#include <type_traits>15#include <type_traits>
1616
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header18# pragma GCC system_header
19#endif19#endif
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
23#if !defined(_LIBCPP_HAS_NO_CONCEPTS)23#if _LIBCPP_STD_VER > 17
2424
25// [concept.equalitycomparable]25// [concept.equalitycomparable]
2626
...@@ -46,7 +46,7 @@ concept equality_comparable_with =...@@ -46,7 +46,7 @@ concept equality_comparable_with =
46 __make_const_lvalue_ref<_Up>>> &&46 __make_const_lvalue_ref<_Up>>> &&
47 __weakly_equality_comparable_with<_Tp, _Up>;47 __weakly_equality_comparable_with<_Tp, _Up>;
4848
49#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)49#endif // _LIBCPP_STD_VER > 17
5050
51_LIBCPP_END_NAMESPACE_STD51_LIBCPP_END_NAMESPACE_STD
5252
lib/libcxx/include/__concepts/invocable.h+3-3
...@@ -15,12 +15,12 @@...@@ -15,12 +15,12 @@
15#include <type_traits>15#include <type_traits>
1616
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header18# pragma GCC system_header
19#endif19#endif
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
23#if !defined(_LIBCPP_HAS_NO_CONCEPTS)23#if _LIBCPP_STD_VER > 17
2424
25// [concept.invocable]25// [concept.invocable]
2626
...@@ -34,7 +34,7 @@ concept invocable = requires(_Fn&& __fn, _Args&&... __args) {...@@ -34,7 +34,7 @@ concept invocable = requires(_Fn&& __fn, _Args&&... __args) {
34template<class _Fn, class... _Args>34template<class _Fn, class... _Args>
35concept regular_invocable = invocable<_Fn, _Args...>;35concept regular_invocable = invocable<_Fn, _Args...>;
3636
37#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)37#endif // _LIBCPP_STD_VER > 17
3838
39_LIBCPP_END_NAMESPACE_STD39_LIBCPP_END_NAMESPACE_STD
4040
lib/libcxx/include/__concepts/movable.h+3-3
...@@ -16,12 +16,12 @@...@@ -16,12 +16,12 @@
16#include <type_traits>16#include <type_traits>
1717
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19#pragma GCC system_header19# pragma GCC system_header
20#endif20#endif
2121
22_LIBCPP_BEGIN_NAMESPACE_STD22_LIBCPP_BEGIN_NAMESPACE_STD
2323
24#if !defined(_LIBCPP_HAS_NO_CONCEPTS)24#if _LIBCPP_STD_VER > 17
2525
26// [concepts.object]26// [concepts.object]
2727
...@@ -32,7 +32,7 @@ concept movable =...@@ -32,7 +32,7 @@ concept movable =
32 assignable_from<_Tp&, _Tp> &&32 assignable_from<_Tp&, _Tp> &&
33 swappable<_Tp>;33 swappable<_Tp>;
3434
35#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)35#endif // _LIBCPP_STD_VER > 17
3636
37_LIBCPP_END_NAMESPACE_STD37_LIBCPP_END_NAMESPACE_STD
3838
lib/libcxx/include/__concepts/predicate.h+3-3
...@@ -15,12 +15,12 @@...@@ -15,12 +15,12 @@
15#include <type_traits>15#include <type_traits>
1616
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header18# pragma GCC system_header
19#endif19#endif
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
23#if !defined(_LIBCPP_HAS_NO_CONCEPTS)23#if _LIBCPP_STD_VER > 17
2424
25// [concept.predicate]25// [concept.predicate]
2626
...@@ -28,7 +28,7 @@ template<class _Fn, class... _Args>...@@ -28,7 +28,7 @@ template<class _Fn, class... _Args>
28concept predicate =28concept predicate =
29 regular_invocable<_Fn, _Args...> && __boolean_testable<invoke_result_t<_Fn, _Args...>>;29 regular_invocable<_Fn, _Args...> && __boolean_testable<invoke_result_t<_Fn, _Args...>>;
3030
31#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)31#endif // _LIBCPP_STD_VER > 17
3232
33_LIBCPP_END_NAMESPACE_STD33_LIBCPP_END_NAMESPACE_STD
3434
lib/libcxx/include/__concepts/regular.h+3-3
...@@ -14,19 +14,19 @@...@@ -14,19 +14,19 @@
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)
17#pragma GCC system_header17# pragma GCC system_header
18#endif18#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
2121
22#if !defined(_LIBCPP_HAS_NO_CONCEPTS)22#if _LIBCPP_STD_VER > 17
2323
24// [concept.object]24// [concept.object]
2525
26template<class _Tp>26template<class _Tp>
27concept regular = semiregular<_Tp> && equality_comparable<_Tp>;27concept regular = semiregular<_Tp> && equality_comparable<_Tp>;
2828
29#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)29#endif // _LIBCPP_STD_VER > 17
3030
31_LIBCPP_END_NAMESPACE_STD31_LIBCPP_END_NAMESPACE_STD
3232
lib/libcxx/include/__concepts/relation.h+3-3
...@@ -13,12 +13,12 @@...@@ -13,12 +13,12 @@
13#include <__config>13#include <__config>
1414
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16#pragma GCC system_header16# pragma GCC system_header
17#endif17#endif
1818
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21#if !defined(_LIBCPP_HAS_NO_CONCEPTS)21#if _LIBCPP_STD_VER > 17
2222
23// [concept.relation]23// [concept.relation]
2424
...@@ -37,7 +37,7 @@ concept equivalence_relation = relation<_Rp, _Tp, _Up>;...@@ -37,7 +37,7 @@ concept equivalence_relation = relation<_Rp, _Tp, _Up>;
37template<class _Rp, class _Tp, class _Up>37template<class _Rp, class _Tp, class _Up>
38concept strict_weak_order = relation<_Rp, _Tp, _Up>;38concept strict_weak_order = relation<_Rp, _Tp, _Up>;
3939
40#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)40#endif // _LIBCPP_STD_VER > 17
4141
42_LIBCPP_END_NAMESPACE_STD42_LIBCPP_END_NAMESPACE_STD
4343
lib/libcxx/include/__concepts/same_as.h+3-3
...@@ -13,12 +13,12 @@...@@ -13,12 +13,12 @@
13#include <type_traits>13#include <type_traits>
1414
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16#pragma GCC system_header16# pragma GCC system_header
17#endif17#endif
1818
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21#if !defined(_LIBCPP_HAS_NO_CONCEPTS)21#if _LIBCPP_STD_VER > 17
2222
23// [concept.same]23// [concept.same]
2424
...@@ -28,7 +28,7 @@ concept __same_as_impl = _IsSame<_Tp, _Up>::value;...@@ -28,7 +28,7 @@ concept __same_as_impl = _IsSame<_Tp, _Up>::value;
28template<class _Tp, class _Up>28template<class _Tp, class _Up>
29concept same_as = __same_as_impl<_Tp, _Up> && __same_as_impl<_Up, _Tp>;29concept same_as = __same_as_impl<_Tp, _Up> && __same_as_impl<_Up, _Tp>;
3030
31#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)31#endif // _LIBCPP_STD_VER > 17
3232
33_LIBCPP_END_NAMESPACE_STD33_LIBCPP_END_NAMESPACE_STD
3434
lib/libcxx/include/__concepts/semiregular.h+3-3
...@@ -14,19 +14,19 @@...@@ -14,19 +14,19 @@
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)
17#pragma GCC system_header17# pragma GCC system_header
18#endif18#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
2121
22#if !defined(_LIBCPP_HAS_NO_CONCEPTS)22#if _LIBCPP_STD_VER > 17
2323
24// [concept.object]24// [concept.object]
2525
26template<class _Tp>26template<class _Tp>
27concept semiregular = copyable<_Tp> && default_initializable<_Tp>;27concept semiregular = copyable<_Tp> && default_initializable<_Tp>;
2828
29#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)29#endif // _LIBCPP_STD_VER > 17
3030
31_LIBCPP_END_NAMESPACE_STD31_LIBCPP_END_NAMESPACE_STD
3232
lib/libcxx/include/__concepts/swappable.h+3-3
...@@ -20,12 +20,12 @@...@@ -20,12 +20,12 @@
20#include <type_traits>20#include <type_traits>
2121
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23#pragma GCC system_header23# pragma GCC system_header
24#endif24#endif
2525
26_LIBCPP_BEGIN_NAMESPACE_STD26_LIBCPP_BEGIN_NAMESPACE_STD
2727
28#if !defined(_LIBCPP_HAS_NO_CONCEPTS)28#if _LIBCPP_STD_VER > 17
2929
30// [concept.swappable]30// [concept.swappable]
3131
...@@ -109,7 +109,7 @@ concept swappable_with =...@@ -109,7 +109,7 @@ concept swappable_with =
109 ranges::swap(_VSTD::forward<_Up>(__u), _VSTD::forward<_Tp>(__t));109 ranges::swap(_VSTD::forward<_Up>(__u), _VSTD::forward<_Tp>(__t));
110 };110 };
111111
112#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)112#endif // _LIBCPP_STD_VER > 17
113113
114_LIBCPP_END_NAMESPACE_STD114_LIBCPP_END_NAMESPACE_STD
115115
lib/libcxx/include/__concepts/totally_ordered.h+3-3
...@@ -15,12 +15,12 @@...@@ -15,12 +15,12 @@
15#include <type_traits>15#include <type_traits>
1616
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header18# pragma GCC system_header
19#endif19#endif
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
23#if !defined(_LIBCPP_HAS_NO_CONCEPTS)23#if _LIBCPP_STD_VER > 17
2424
25// [concept.totallyordered]25// [concept.totallyordered]
2626
...@@ -50,7 +50,7 @@ concept totally_ordered_with =...@@ -50,7 +50,7 @@ concept totally_ordered_with =
50 __make_const_lvalue_ref<_Up>>> &&50 __make_const_lvalue_ref<_Up>>> &&
51 __partially_ordered_with<_Tp, _Up>;51 __partially_ordered_with<_Tp, _Up>;
5252
53#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)53#endif // _LIBCPP_STD_VER > 17
5454
55_LIBCPP_END_NAMESPACE_STD55_LIBCPP_END_NAMESPACE_STD
5656
lib/libcxx/include/__config+872-1083
...@@ -7,8 +7,8 @@...@@ -7,8 +7,8 @@
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
99
10#ifndef _LIBCPP_CONFIG10#ifndef _LIBCPP___CONFIG
11#define _LIBCPP_CONFIG11#define _LIBCPP___CONFIG
1212
13#if defined(_MSC_VER) && !defined(__clang__)13#if defined(_MSC_VER) && !defined(__clang__)
14# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)14# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -17,334 +17,326 @@...@@ -17,334 +17,326 @@
17#endif17#endif
1818
19#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER19#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
20#pragma GCC system_header20# pragma GCC system_header
21#endif21#endif
2222
23#ifdef __cplusplus23#ifdef __cplusplus
2424
25#define _LIBCPP_VERSION 1400025# define _LIBCPP_VERSION 15000
2626
27#ifndef _LIBCPP_ABI_VERSION27# define _LIBCPP_CONCAT_IMPL(_X, _Y) _X##_Y
28# define _LIBCPP_ABI_VERSION 128# define _LIBCPP_CONCAT(_X, _Y) _LIBCPP_CONCAT_IMPL(_X, _Y)
29#endif
3029
31#if __STDC_HOSTED__ == 030// Valid C++ identifier that revs with every libc++ version. This can be used to
32# define _LIBCPP_FREESTANDING31// generate identifiers that must be unique for every released libc++ version.
33#endif32# define _LIBCPP_VERSIONED_IDENTIFIER _LIBCPP_CONCAT(v, _LIBCPP_VERSION)
33
34# if __STDC_HOSTED__ == 0
35# define _LIBCPP_FREESTANDING
36# endif
3437
35#ifndef _LIBCPP_STD_VER38# ifndef _LIBCPP_STD_VER
36# if __cplusplus <= 201103L39# if __cplusplus <= 201103L
37# define _LIBCPP_STD_VER 1140# define _LIBCPP_STD_VER 11
38# elif __cplusplus <= 201402L41# elif __cplusplus <= 201402L
39# define _LIBCPP_STD_VER 1442# define _LIBCPP_STD_VER 14
40# elif __cplusplus <= 201703L43# elif __cplusplus <= 201703L
41# define _LIBCPP_STD_VER 1744# define _LIBCPP_STD_VER 17
42# elif __cplusplus <= 202002L45# elif __cplusplus <= 202002L
43# define _LIBCPP_STD_VER 2046# define _LIBCPP_STD_VER 20
47# else
48# define _LIBCPP_STD_VER 22 // current year, or date of c++2b ratification
49# endif
50# endif // _LIBCPP_STD_VER
51
52# if defined(__ELF__)
53# define _LIBCPP_OBJECT_FORMAT_ELF 1
54# elif defined(__MACH__)
55# define _LIBCPP_OBJECT_FORMAT_MACHO 1
56# elif defined(_WIN32)
57# define _LIBCPP_OBJECT_FORMAT_COFF 1
58# elif defined(__wasm__)
59# define _LIBCPP_OBJECT_FORMAT_WASM 1
60# elif defined(_AIX)
61# define _LIBCPP_OBJECT_FORMAT_XCOFF 1
44# else62# else
45# define _LIBCPP_STD_VER 21 // current year, or date of c++2b ratification63// ... add new file formats here ...
46# endif64# endif
47#endif // _LIBCPP_STD_VER
48
49#if defined(__ELF__)
50# define _LIBCPP_OBJECT_FORMAT_ELF 1
51#elif defined(__MACH__)
52# define _LIBCPP_OBJECT_FORMAT_MACHO 1
53#elif defined(_WIN32)
54# define _LIBCPP_OBJECT_FORMAT_COFF 1
55#elif defined(__wasm__)
56# define _LIBCPP_OBJECT_FORMAT_WASM 1
57#else
58 // ... add new file formats here ...
59#endif
6065
61#if defined(_LIBCPP_ABI_UNSTABLE) || _LIBCPP_ABI_VERSION >= 266# if _LIBCPP_ABI_VERSION >= 2
62// Change short string representation so that string data starts at offset 0,67// Change short string representation so that string data starts at offset 0,
63// improving its alignment in some cases.68// improving its alignment in some cases.
64# define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT69# define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
65// Fix deque iterator type in order to support incomplete types.70// Fix deque iterator type in order to support incomplete types.
66# define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE71# define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE
67// Fix undefined behavior in how std::list stores its linked nodes.72// Fix undefined behavior in how std::list stores its linked nodes.
68# define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB73# define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB
69// Fix undefined behavior in how __tree stores its end and parent nodes.74// Fix undefined behavior in how __tree stores its end and parent nodes.
70# define _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB75# define _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB
71// Fix undefined behavior in how __hash_table stores its pointer types.76// Fix undefined behavior in how __hash_table stores its pointer types.
72# define _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB77# define _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB
73# define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB78# define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB
74# define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE79# define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE
75// Define a key function for `bad_function_call` in the library, to centralize80// Define a key function for `bad_function_call` in the library, to centralize
76// its vtable and typeinfo to libc++ rather than having all other libraries81// its vtable and typeinfo to libc++ rather than having all other libraries
77// using that class define their own copies.82// using that class define their own copies.
78# define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION83# define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
79// Override the default return value of exception::what() for84// Override the default return value of exception::what() for
80// bad_function_call::what() with a string that is specific to85// bad_function_call::what() with a string that is specific to
81// bad_function_call (see http://wg21.link/LWG2233). This is an ABI break86// bad_function_call (see http://wg21.link/LWG2233). This is an ABI break
82// because it changes the vtable layout of bad_function_call.87// because it changes the vtable layout of bad_function_call.
83# define _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE88# define _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE
84// Enable optimized version of __do_get_(un)signed which avoids redundant copies.89// Enable optimized version of __do_get_(un)signed which avoids redundant copies.
85# define _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET90# define _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
86// In C++20 and later, don't derive std::plus from std::binary_function,
87// nor std::negate from std::unary_function.
88# define _LIBCPP_ABI_NO_BINDER_BASES
89// Give reverse_iterator<T> one data member of type T, not two.91// Give reverse_iterator<T> one data member of type T, not two.
90// Also, in C++17 and later, don't derive iterator types from std::iterator.92// Also, in C++17 and later, don't derive iterator types from std::iterator.
91# define _LIBCPP_ABI_NO_ITERATOR_BASES93# define _LIBCPP_ABI_NO_ITERATOR_BASES
92// Use the smallest possible integer type to represent the index of the variant.94// Use the smallest possible integer type to represent the index of the variant.
93// Previously libc++ used "unsigned int" exclusively.95// Previously libc++ used "unsigned int" exclusively.
94# define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION96# define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION
95// Unstable attempt to provide a more optimized std::function97// Unstable attempt to provide a more optimized std::function
96# define _LIBCPP_ABI_OPTIMIZED_FUNCTION98# define _LIBCPP_ABI_OPTIMIZED_FUNCTION
97// All the regex constants must be distinct and nonzero.99// All the regex constants must be distinct and nonzero.
98# define _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO100# define _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO
99// Use raw pointers, not wrapped ones, for std::span's iterator type.
100# define _LIBCPP_ABI_SPAN_POINTER_ITERATORS
101// Re-worked external template instantiations for std::string with a focus on101// Re-worked external template instantiations for std::string with a focus on
102// performance and fast-path inlining.102// performance and fast-path inlining.
103# define _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION103# define _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION
104// Enable clang::trivial_abi on std::unique_ptr.104// Enable clang::trivial_abi on std::unique_ptr.
105# define _LIBCPP_ABI_ENABLE_UNIQUE_PTR_TRIVIAL_ABI105# define _LIBCPP_ABI_ENABLE_UNIQUE_PTR_TRIVIAL_ABI
106// Enable clang::trivial_abi on std::shared_ptr and std::weak_ptr106// Enable clang::trivial_abi on std::shared_ptr and std::weak_ptr
107# define _LIBCPP_ABI_ENABLE_SHARED_PTR_TRIVIAL_ABI107# define _LIBCPP_ABI_ENABLE_SHARED_PTR_TRIVIAL_ABI
108// std::random_device holds some state when it uses an implementation that gets108// std::random_device holds some state when it uses an implementation that gets
109// entropy from a file (see _LIBCPP_USING_DEV_RANDOM). When switching from this109// entropy from a file (see _LIBCPP_USING_DEV_RANDOM). When switching from this
110// implementation to another one on a platform that has already shipped110// implementation to another one on a platform that has already shipped
111// std::random_device, one needs to retain the same object layout to remain ABI111// std::random_device, one needs to retain the same object layout to remain ABI
112// compatible. This switch removes these workarounds for platforms that don't care112// compatible. This switch removes these workarounds for platforms that don't care
113// about ABI compatibility.113// about ABI compatibility.
114# define _LIBCPP_ABI_NO_RANDOM_DEVICE_COMPATIBILITY_LAYOUT114# define _LIBCPP_ABI_NO_RANDOM_DEVICE_COMPATIBILITY_LAYOUT
115// Remove basic_string common base115// Don't export the legacy __basic_string_common class and its methods from the built library.
116# define _LIBCPP_ABI_DO_NOT_EXPORT_BASIC_STRING_COMMON116# define _LIBCPP_ABI_DO_NOT_EXPORT_BASIC_STRING_COMMON
117// Remove vector base class117// Don't export the legacy __vector_base_common class and its methods from the built library.
118# define _LIBCPP_ABI_DO_NOT_EXPORT_VECTOR_BASE_COMMON118# define _LIBCPP_ABI_DO_NOT_EXPORT_VECTOR_BASE_COMMON
119#elif _LIBCPP_ABI_VERSION == 1119// According to the Standard, `bitset::operator[] const` returns bool
120# if !defined(_LIBCPP_OBJECT_FORMAT_COFF)120# define _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL
121// Remove the base 10 implementation of std::to_chars from the dylib.
122// The implementation moved to the header, but we still export the symbols from
123// the dylib for backwards compatibility.
124# define _LIBCPP_ABI_DO_NOT_EXPORT_TO_CHARS_BASE_10
125# elif _LIBCPP_ABI_VERSION == 1
126# if !(defined(_LIBCPP_OBJECT_FORMAT_COFF) || defined(_LIBCPP_OBJECT_FORMAT_XCOFF))
121// Enable compiling copies of now inline methods into the dylib to support127// Enable compiling copies of now inline methods into the dylib to support
122// applications compiled against older libraries. This is unnecessary with128// applications compiled against older libraries. This is unnecessary with
123// COFF dllexport semantics, since dllexport forces a non-inline definition129// COFF dllexport semantics, since dllexport forces a non-inline definition
124// of inline functions to be emitted anyway. Our own non-inline copy would130// of inline functions to be emitted anyway. Our own non-inline copy would
125// conflict with the dllexport-emitted copy, so we disable it.131// conflict with the dllexport-emitted copy, so we disable it. For XCOFF,
126# define _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS132// the linker will take issue with the symbols in the shared object if the
127# endif133// weak inline methods get visibility (such as from -fvisibility-inlines-hidden),
134// so disable it.
135# define _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS
136# endif
128// Feature macros for disabling pre ABI v1 features. All of these options137// Feature macros for disabling pre ABI v1 features. All of these options
129// are deprecated.138// are deprecated.
130# if defined(__FreeBSD__)139# if defined(__FreeBSD__)
131# define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR140# define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR
141# endif
132# endif142# endif
133#endif
134
135// By default, don't use a nullptr_t emulation type in C++03.
136//
137// This is technically an ABI break from previous releases, however it is
138// very unlikely to impact anyone. If a user is impacted by this break,
139// they can return to using the C++03 nullptr emulation by defining
140// _LIBCPP_ABI_USE_CXX03_NULLPTR_EMULATION.
141//
142// This switch will be removed entirely in favour of never providing a
143// C++03 emulation after one release.
144//
145// IMPORTANT: IF YOU ARE READING THIS AND YOU TURN THIS MACRO ON, PLEASE LEAVE
146// A COMMENT ON https://reviews.llvm.org/D109459 OR YOU WILL BE BROKEN
147// IN THE FUTURE WHEN WE REMOVE THE ABILITY TO USE THE C++03 EMULATION.
148#ifndef _LIBCPP_ABI_USE_CXX03_NULLPTR_EMULATION
149# define _LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR
150#endif
151143
152#if defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCPP_ABI_UNSTABLE) || _LIBCPP_ABI_VERSION >= 2144# if defined(_LIBCPP_BUILDING_LIBRARY) || _LIBCPP_ABI_VERSION >= 2
153// Enable additional explicit instantiations of iostreams components. This145// Enable additional explicit instantiations of iostreams components. This
154// reduces the number of weak definitions generated in programs that use146// reduces the number of weak definitions generated in programs that use
155// iostreams by providing a single strong definition in the shared library.147// iostreams by providing a single strong definition in the shared library.
156# define _LIBCPP_ABI_ENABLE_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1148# define _LIBCPP_ABI_ENABLE_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1
157149
158// Define a key function for `bad_function_call` in the library, to centralize150// Define a key function for `bad_function_call` in the library, to centralize
159// its vtable and typeinfo to libc++ rather than having all other libraries151// its vtable and typeinfo to libc++ rather than having all other libraries
160// using that class define their own copies.152// using that class define their own copies.
161# define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION153# define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
162#endif154# endif
163155
164#define _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_X##_LIBCPP_Y156# define _LIBCPP_TOSTRING2(x) # x
165#define _LIBCPP_CONCAT(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y)157# define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x)
166158
167#ifndef _LIBCPP_ABI_NAMESPACE159# if __cplusplus < 201103L
168# define _LIBCPP_ABI_NAMESPACE _LIBCPP_CONCAT(__,_LIBCPP_ABI_VERSION)160# define _LIBCPP_CXX03_LANG
169#endif161# endif
170
171#if __cplusplus < 201103L
172#define _LIBCPP_CXX03_LANG
173#endif
174162
175#ifndef __has_attribute163# ifndef __has_attribute
176#define __has_attribute(__x) 0164# define __has_attribute(__x) 0
177#endif165# endif
178166
179#ifndef __has_builtin167# ifndef __has_builtin
180#define __has_builtin(__x) 0168# define __has_builtin(__x) 0
181#endif169# endif
182170
183#ifndef __has_extension171# ifndef __has_extension
184#define __has_extension(__x) 0172# define __has_extension(__x) 0
185#endif173# endif
186174
187#ifndef __has_feature175# ifndef __has_feature
188#define __has_feature(__x) 0176# define __has_feature(__x) 0
189#endif177# endif
190178
191#ifndef __has_cpp_attribute179# ifndef __has_cpp_attribute
192#define __has_cpp_attribute(__x) 0180# define __has_cpp_attribute(__x) 0
193#endif181# endif
194182
195// '__is_identifier' returns '0' if '__x' is a reserved identifier provided by183// '__is_identifier' returns '0' if '__x' is a reserved identifier provided by
196// the compiler and '1' otherwise.184// the compiler and '1' otherwise.
197#ifndef __is_identifier185# ifndef __is_identifier
198#define __is_identifier(__x) 1186# define __is_identifier(__x) 1
199#endif187# endif
200188
201#ifndef __has_declspec_attribute189# ifndef __has_declspec_attribute
202#define __has_declspec_attribute(__x) 0190# define __has_declspec_attribute(__x) 0
203#endif191# endif
204192
205#define __has_keyword(__x) !(__is_identifier(__x))193# define __has_keyword(__x) !(__is_identifier(__x))
206194
207#ifndef __has_include195# ifndef __has_include
208#define __has_include(...) 0196# define __has_include(...) 0
209#endif197# endif
210198
211#if defined(__apple_build_version__)199# if defined(__apple_build_version__)
212# define _LIBCPP_COMPILER_CLANG_BASED200# define _LIBCPP_COMPILER_CLANG_BASED
213# define _LIBCPP_APPLE_CLANG_VER (__apple_build_version__ / 10000)201# define _LIBCPP_APPLE_CLANG_VER (__apple_build_version__ / 10000)
214#elif defined(__clang__)202# elif defined(__clang__)
215# define _LIBCPP_COMPILER_CLANG_BASED203# define _LIBCPP_COMPILER_CLANG_BASED
216# define _LIBCPP_CLANG_VER (__clang_major__ * 100 + __clang_minor__)204# define _LIBCPP_CLANG_VER (__clang_major__ * 100 + __clang_minor__)
217#elif defined(__GNUC__)205# elif defined(__GNUC__)
218# define _LIBCPP_COMPILER_GCC206# define _LIBCPP_COMPILER_GCC
219#elif defined(_MSC_VER)207# elif defined(_MSC_VER)
220# define _LIBCPP_COMPILER_MSVC208# define _LIBCPP_COMPILER_MSVC
221#elif defined(__IBMCPP__)209# endif
222# define _LIBCPP_COMPILER_IBM
223#endif
224210
225#if defined(_LIBCPP_COMPILER_GCC) && __cplusplus < 201103L211# if !defined(_LIBCPP_COMPILER_CLANG_BASED) && __cplusplus < 201103L
226#error "libc++ does not support using GCC with C++03. Please enable C++11"212# error "libc++ only supports C++03 with Clang-based compilers. Please enable C++11"
227#endif213# endif
214
215# ifdef _LIBCPP_COMPILER_MSVC
216# error If you successfully use libc++ with MSVC please tell the libc++ developers and consider upstreaming your \
217changes. We are not aware of anybody using this configuration and know that at least some code is currently broken. \
218If there are users of this configuration we are happy to provide support.
219# endif
228220
229// FIXME: ABI detection should be done via compiler builtin macros. This221// FIXME: ABI detection should be done via compiler builtin macros. This
230// is just a placeholder until Clang implements such macros. For now assume222// is just a placeholder until Clang implements such macros. For now assume
231// that Windows compilers pretending to be MSVC++ target the Microsoft ABI,223// that Windows compilers pretending to be MSVC++ target the Microsoft ABI,
232// and allow the user to explicitly specify the ABI to handle cases where this224// and allow the user to explicitly specify the ABI to handle cases where this
233// heuristic falls short.225// heuristic falls short.
234#if defined(_LIBCPP_ABI_FORCE_ITANIUM) && defined(_LIBCPP_ABI_FORCE_MICROSOFT)226# if defined(_LIBCPP_ABI_FORCE_ITANIUM) && defined(_LIBCPP_ABI_FORCE_MICROSOFT)
235# error "Only one of _LIBCPP_ABI_FORCE_ITANIUM and _LIBCPP_ABI_FORCE_MICROSOFT can be defined"227# error "Only one of _LIBCPP_ABI_FORCE_ITANIUM and _LIBCPP_ABI_FORCE_MICROSOFT can be defined"
236#elif defined(_LIBCPP_ABI_FORCE_ITANIUM)228# elif defined(_LIBCPP_ABI_FORCE_ITANIUM)
237# define _LIBCPP_ABI_ITANIUM229# define _LIBCPP_ABI_ITANIUM
238#elif defined(_LIBCPP_ABI_FORCE_MICROSOFT)230# elif defined(_LIBCPP_ABI_FORCE_MICROSOFT)
239# define _LIBCPP_ABI_MICROSOFT
240#else
241# if defined(_WIN32) && defined(_MSC_VER)
242# define _LIBCPP_ABI_MICROSOFT231# define _LIBCPP_ABI_MICROSOFT
243# else232# else
244# define _LIBCPP_ABI_ITANIUM233# if defined(_WIN32) && defined(_MSC_VER)
234# define _LIBCPP_ABI_MICROSOFT
235# else
236# define _LIBCPP_ABI_ITANIUM
237# endif
245# endif238# endif
246#endif
247239
248#if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME)240# if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME)
249# define _LIBCPP_ABI_VCRUNTIME241# define _LIBCPP_ABI_VCRUNTIME
250#endif242# endif
251243
252// Need to detect which libc we're using if we're on Linux.244# if __has_feature(experimental_library)
253#if defined(__linux__)245# ifndef _LIBCPP_ENABLE_EXPERIMENTAL
254# include <features.h>246# define _LIBCPP_ENABLE_EXPERIMENTAL
255# if defined(__GLIBC_PREREQ)247# endif
256# define _LIBCPP_GLIBC_PREREQ(a, b) __GLIBC_PREREQ(a, b)248# endif
257# else
258# define _LIBCPP_GLIBC_PREREQ(a, b) 0
259# endif // defined(__GLIBC_PREREQ)
260#endif // defined(__linux__)
261249
262#if defined(__MVS__)250// Incomplete features get their own specific disabling flags. This makes it
263# include <features.h> // for __NATIVE_ASCII_F251// easier to grep for target specific flags once the feature is complete.
264#endif252# if !defined(_LIBCPP_ENABLE_EXPERIMENTAL) && !defined(_LIBCPP_BUILDING_LIBRARY)
253# define _LIBCPP_HAS_NO_INCOMPLETE_FORMAT
254# define _LIBCPP_HAS_NO_INCOMPLETE_RANGES
255# endif
265256
266#ifdef __LITTLE_ENDIAN__257// Need to detect which libc we're using if we're on Linux.
267# if __LITTLE_ENDIAN__258# if defined(__linux__)
268# define _LIBCPP_LITTLE_ENDIAN259# include <features.h>
269# endif // __LITTLE_ENDIAN__260# if defined(__GLIBC_PREREQ)
270#endif // __LITTLE_ENDIAN__261# define _LIBCPP_GLIBC_PREREQ(a, b) __GLIBC_PREREQ(a, b)
262# else
263# define _LIBCPP_GLIBC_PREREQ(a, b) 0
264# endif // defined(__GLIBC_PREREQ)
265# endif // defined(__linux__)
271266
272#ifdef __BIG_ENDIAN__267# if defined(__MVS__)
273# if __BIG_ENDIAN__268# include <features.h> // for __NATIVE_ASCII_F
274# define _LIBCPP_BIG_ENDIAN269# endif
275# endif // __BIG_ENDIAN__
276#endif // __BIG_ENDIAN__
277270
278#ifdef __BYTE_ORDER__271# ifdef __LITTLE_ENDIAN__
279# if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__272# if __LITTLE_ENDIAN__
273# define _LIBCPP_LITTLE_ENDIAN
274# endif // __LITTLE_ENDIAN__
275# endif // __LITTLE_ENDIAN__
276
277# ifdef __BIG_ENDIAN__
278# if __BIG_ENDIAN__
279# define _LIBCPP_BIG_ENDIAN
280# endif // __BIG_ENDIAN__
281# endif // __BIG_ENDIAN__
282
283# ifdef __BYTE_ORDER__
284# if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
285# define _LIBCPP_LITTLE_ENDIAN
286# elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
287# define _LIBCPP_BIG_ENDIAN
288# endif // __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
289# endif // __BYTE_ORDER__
290
291# ifdef __FreeBSD__
292# include <sys/endian.h>
293# include <osreldate.h>
294# if _BYTE_ORDER == _LITTLE_ENDIAN
295# define _LIBCPP_LITTLE_ENDIAN
296# else // _BYTE_ORDER == _LITTLE_ENDIAN
297# define _LIBCPP_BIG_ENDIAN
298# endif // _BYTE_ORDER == _LITTLE_ENDIAN
299# endif // __FreeBSD__
300
301# if defined(__NetBSD__) || defined(__OpenBSD__)
302# include <sys/endian.h>
303# if _BYTE_ORDER == _LITTLE_ENDIAN
304# define _LIBCPP_LITTLE_ENDIAN
305# else // _BYTE_ORDER == _LITTLE_ENDIAN
306# define _LIBCPP_BIG_ENDIAN
307# endif // _BYTE_ORDER == _LITTLE_ENDIAN
308# endif // defined(__NetBSD__) || defined(__OpenBSD__)
309
310# if defined(_WIN32)
311# define _LIBCPP_WIN32API
280# define _LIBCPP_LITTLE_ENDIAN312# define _LIBCPP_LITTLE_ENDIAN
281# elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__313# define _LIBCPP_SHORT_WCHAR 1
282# define _LIBCPP_BIG_ENDIAN
283# endif // __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
284#endif // __BYTE_ORDER__
285
286#ifdef __FreeBSD__
287# include <sys/endian.h>
288# include <osreldate.h>
289# if _BYTE_ORDER == _LITTLE_ENDIAN
290# define _LIBCPP_LITTLE_ENDIAN
291# else // _BYTE_ORDER == _LITTLE_ENDIAN
292# define _LIBCPP_BIG_ENDIAN
293# endif // _BYTE_ORDER == _LITTLE_ENDIAN
294#endif // __FreeBSD__
295
296#if defined(__NetBSD__) || defined(__OpenBSD__)
297# include <sys/endian.h>
298# if _BYTE_ORDER == _LITTLE_ENDIAN
299# define _LIBCPP_LITTLE_ENDIAN
300# else // _BYTE_ORDER == _LITTLE_ENDIAN
301# define _LIBCPP_BIG_ENDIAN
302# endif // _BYTE_ORDER == _LITTLE_ENDIAN
303#endif // defined(__NetBSD__) || defined(__OpenBSD__)
304
305#if defined(_WIN32)
306# define _LIBCPP_WIN32API
307# define _LIBCPP_LITTLE_ENDIAN
308# define _LIBCPP_SHORT_WCHAR 1
309// Both MinGW and native MSVC provide a "MSVC"-like environment314// Both MinGW and native MSVC provide a "MSVC"-like environment
310# define _LIBCPP_MSVCRT_LIKE315# define _LIBCPP_MSVCRT_LIKE
311// If mingw not explicitly detected, assume using MS C runtime only if316// If mingw not explicitly detected, assume using MS C runtime only if
312// a MS compatibility version is specified.317// a MS compatibility version is specified.
313# if defined(_MSC_VER) && !defined(__MINGW32__)318# if defined(_MSC_VER) && !defined(__MINGW32__)
314# define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library319# define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library
315# endif320# endif
316# if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || defined(__arm__))321# if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || defined(__arm__))
317# define _LIBCPP_HAS_BITSCAN64322# define _LIBCPP_HAS_BITSCAN64
318# endif323# endif
319# define _LIBCPP_HAS_OPEN_WITH_WCHAR324# define _LIBCPP_HAS_OPEN_WITH_WCHAR
320# if defined(_LIBCPP_MSVCRT)325# endif // defined(_WIN32)
321# define _LIBCPP_HAS_QUICK_EXIT
322# endif
323326
324// Some CRT APIs are unavailable to store apps327# ifdef __sun__
325# if defined(WINAPI_FAMILY)328# include <sys/isa_defs.h>
326# include <winapifamily.h>329# ifdef _LITTLE_ENDIAN
327# if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && \330# define _LIBCPP_LITTLE_ENDIAN
328 (!defined(WINAPI_PARTITION_SYSTEM) || \331# else
329 !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_SYSTEM))332# define _LIBCPP_BIG_ENDIAN
330# define _LIBCPP_WINDOWS_STORE_APP
331# endif333# endif
332# endif334# endif // __sun__
333#endif // defined(_WIN32)
334335
335#ifdef __sun__336# if defined(_AIX) && !defined(__64BIT__)
336# include <sys/isa_defs.h>337// The size of wchar is 2 byte on 32-bit mode on AIX.
337# ifdef _LITTLE_ENDIAN338# define _LIBCPP_SHORT_WCHAR 1
338# define _LIBCPP_LITTLE_ENDIAN
339# else
340# define _LIBCPP_BIG_ENDIAN
341# endif339# endif
342#endif // __sun__
343
344#if defined(_AIX) && !defined(__64BIT__)
345 // The size of wchar is 2 byte on 32-bit mode on AIX.
346# define _LIBCPP_SHORT_WCHAR 1
347#endif
348340
349// Libc++ supports various implementations of std::random_device.341// Libc++ supports various implementations of std::random_device.
350//342//
...@@ -384,806 +376,581 @@...@@ -384,806 +376,581 @@
384// Use rand_s(), for use on Windows.376// Use rand_s(), for use on Windows.
385// When this option is used, the token passed to `std::random_device`'s377// When this option is used, the token passed to `std::random_device`'s
386// constructor *must* be "/dev/urandom" -- anything else is an error.378// constructor *must* be "/dev/urandom" -- anything else is an error.
387#if defined(__OpenBSD__) || defined(__APPLE__)379# if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \
388# define _LIBCPP_USING_ARC4_RANDOM380 defined(__DragonFly__) || defined(__sun__)
389#elif defined(__wasi__)381# define _LIBCPP_USING_ARC4_RANDOM
390# define _LIBCPP_USING_GETENTROPY382# elif defined(__wasi__) || defined(__EMSCRIPTEN__)
391#elif defined(__Fuchsia__)383# define _LIBCPP_USING_GETENTROPY
392# define _LIBCPP_USING_FUCHSIA_CPRNG384# elif defined(__Fuchsia__)
393#elif defined(__native_client__)385# define _LIBCPP_USING_FUCHSIA_CPRNG
394# define _LIBCPP_USING_NACL_RANDOM386# elif defined(__native_client__)
395#elif defined(_LIBCPP_WIN32API)387# define _LIBCPP_USING_NACL_RANDOM
396# define _LIBCPP_USING_WIN32_RANDOM388# elif defined(_LIBCPP_WIN32API)
397#else389# define _LIBCPP_USING_WIN32_RANDOM
398# define _LIBCPP_USING_DEV_RANDOM390# else
399#endif391# define _LIBCPP_USING_DEV_RANDOM
400
401#if !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN)
402# include <endian.h>
403# if __BYTE_ORDER == __LITTLE_ENDIAN
404# define _LIBCPP_LITTLE_ENDIAN
405# elif __BYTE_ORDER == __BIG_ENDIAN
406# define _LIBCPP_BIG_ENDIAN
407# else // __BYTE_ORDER == __BIG_ENDIAN
408# error unable to determine endian
409# endif392# endif
410#endif // !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN)
411393
412#if __has_attribute(__no_sanitize__) && !defined(_LIBCPP_COMPILER_GCC)394# if !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN)
413# define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi")))395# include <endian.h>
414#else396# if __BYTE_ORDER == __LITTLE_ENDIAN
415# define _LIBCPP_NO_CFI397# define _LIBCPP_LITTLE_ENDIAN
416#endif398# elif __BYTE_ORDER == __BIG_ENDIAN
417399# define _LIBCPP_BIG_ENDIAN
418// If the compiler supports using_if_exists, pretend we have those functions and they'll400# else // __BYTE_ORDER == __BIG_ENDIAN
419// be picked up if the C library provides them.401# error unable to determine endian
420//
421// TODO: Once we drop support for Clang 12, we can assume the compiler supports using_if_exists
422// for platforms that don't have a conforming C11 library, so we can drop this whole thing.
423#if __has_attribute(using_if_exists)
424# define _LIBCPP_HAS_TIMESPEC_GET
425# define _LIBCPP_HAS_QUICK_EXIT
426# define _LIBCPP_HAS_ALIGNED_ALLOC
427#else
428#if (defined(__ISO_C_VISIBLE) && (__ISO_C_VISIBLE >= 2011)) || __cplusplus >= 201103L
429# if defined(__FreeBSD__)
430# define _LIBCPP_HAS_ALIGNED_ALLOC
431# define _LIBCPP_HAS_QUICK_EXIT
432# if __FreeBSD_version >= 1300064 || \
433 (__FreeBSD_version >= 1201504 && __FreeBSD_version < 1300000)
434# define _LIBCPP_HAS_TIMESPEC_GET
435# endif
436# elif defined(__BIONIC__)
437# if __ANDROID_API__ >= 21
438# define _LIBCPP_HAS_QUICK_EXIT
439# endif
440# if __ANDROID_API__ >= 28
441# define _LIBCPP_HAS_ALIGNED_ALLOC
442# endif
443# if __ANDROID_API__ >= 29
444# define _LIBCPP_HAS_TIMESPEC_GET
445# endif
446# elif defined(__Fuchsia__) || defined(__wasi__) || defined(__NetBSD__)
447# define _LIBCPP_HAS_ALIGNED_ALLOC
448# define _LIBCPP_HAS_QUICK_EXIT
449# define _LIBCPP_HAS_TIMESPEC_GET
450# elif defined(__OpenBSD__)
451# define _LIBCPP_HAS_ALIGNED_ALLOC
452# define _LIBCPP_HAS_TIMESPEC_GET
453# elif defined(__linux__)
454# if !defined(_LIBCPP_HAS_MUSL_LIBC)
455# if _LIBCPP_GLIBC_PREREQ(2, 15) || defined(__BIONIC__)
456# define _LIBCPP_HAS_QUICK_EXIT
457# endif
458# if _LIBCPP_GLIBC_PREREQ(2, 17)
459# define _LIBCPP_HAS_ALIGNED_ALLOC
460# define _LIBCPP_HAS_TIMESPEC_GET
461# endif
462# else // defined(_LIBCPP_HAS_MUSL_LIBC)
463# define _LIBCPP_HAS_ALIGNED_ALLOC
464# define _LIBCPP_HAS_QUICK_EXIT
465# define _LIBCPP_HAS_TIMESPEC_GET
466# endif
467# elif defined(_LIBCPP_MSVCRT)
468 // Using Microsoft's C Runtime library, not MinGW
469# define _LIBCPP_HAS_TIMESPEC_GET
470# elif defined(__APPLE__)
471 // timespec_get and aligned_alloc were introduced in macOS 10.15 and
472 // aligned releases
473# if ((defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101500) || \
474 (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 130000) || \
475 (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ >= 130000) || \
476 (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ >= 60000))
477# define _LIBCPP_HAS_ALIGNED_ALLOC
478# define _LIBCPP_HAS_TIMESPEC_GET
479# endif402# endif
480# endif // __APPLE__403# endif // !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN)
481#endif
482#endif // __has_attribute(using_if_exists)
483
484#ifndef _LIBCPP_CXX03_LANG
485# define _LIBCPP_ALIGNOF(_Tp) alignof(_Tp)
486#elif defined(_LIBCPP_COMPILER_CLANG_BASED)
487# define _LIBCPP_ALIGNOF(_Tp) _Alignof(_Tp)
488#else
489# error "We don't know a correct way to implement alignof(T) in C++03 outside of Clang"
490#endif
491404
492#define _LIBCPP_PREFERRED_ALIGNOF(_Tp) __alignof(_Tp)405# if __has_attribute(__no_sanitize__) && !defined(_LIBCPP_COMPILER_GCC)
406# define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi")))
407# else
408# define _LIBCPP_NO_CFI
409# endif
493410
494#if defined(_LIBCPP_COMPILER_CLANG_BASED)411# ifndef _LIBCPP_CXX03_LANG
495412
496#if defined(_LIBCPP_ALTERNATE_STRING_LAYOUT)413# define _LIBCPP_ALIGNOF(_Tp) alignof(_Tp)
497# error _LIBCPP_ALTERNATE_STRING_LAYOUT is deprecated, please use _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT instead414# define _ALIGNAS_TYPE(x) alignas(x)
498#endif415# define _ALIGNAS(x) alignas(x)
499#if defined(__APPLE__) && !defined(__i386__) && !defined(__x86_64__) && \416# define _LIBCPP_NORETURN [[noreturn]]
500 (!defined(__arm__) || __ARM_ARCH_7K__ >= 2)417# define _NOEXCEPT noexcept
501# define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT418# define _NOEXCEPT_(x) noexcept(x)
502#endif
503419
504#if __has_feature(cxx_alignas)420# else
505# define _ALIGNAS_TYPE(x) alignas(x)421
506# define _ALIGNAS(x) alignas(x)422# define _LIBCPP_ALIGNOF(_Tp) _Alignof(_Tp)
507#else423# define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x))))
508# define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x))))424# define _ALIGNAS(x) __attribute__((__aligned__(x)))
509# define _ALIGNAS(x) __attribute__((__aligned__(x)))425# define _LIBCPP_NORETURN __attribute__((noreturn))
510#endif426# define _LIBCPP_HAS_NO_NOEXCEPT
427# define nullptr __nullptr
428# define _NOEXCEPT throw()
429# define _NOEXCEPT_(x)
511430
512#if __cplusplus < 201103L
513typedef __char16_t char16_t;431typedef __char16_t char16_t;
514typedef __char32_t char32_t;432typedef __char32_t char32_t;
515#endif
516
517#if !__has_feature(cxx_exceptions)
518# define _LIBCPP_NO_EXCEPTIONS
519#endif
520433
521#if !(__has_feature(cxx_strong_enums))
522#define _LIBCPP_HAS_NO_STRONG_ENUMS
523#endif
524
525#if __has_feature(cxx_attributes)
526# define _LIBCPP_NORETURN [[noreturn]]
527#else
528# define _LIBCPP_NORETURN __attribute__ ((noreturn))
529#endif
530
531#if !(__has_feature(cxx_nullptr))
532# if (__has_extension(cxx_nullptr) || __has_keyword(__nullptr)) && defined(_LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR)
533# define nullptr __nullptr
534# else
535# define _LIBCPP_HAS_NO_NULLPTR
536# endif434# endif
537#endif
538
539// Objective-C++ features (opt-in)
540#if __has_feature(objc_arc)
541#define _LIBCPP_HAS_OBJC_ARC
542#endif
543
544#if __has_feature(objc_arc_weak)
545#define _LIBCPP_HAS_OBJC_ARC_WEAK
546#endif
547
548#if __has_extension(blocks)
549# define _LIBCPP_HAS_EXTENSION_BLOCKS
550#endif
551435
552#if defined(_LIBCPP_HAS_EXTENSION_BLOCKS) && defined(__APPLE__)436# if !defined(__cpp_exceptions) || __cpp_exceptions < 199711L
553# define _LIBCPP_HAS_BLOCKS_RUNTIME437# define _LIBCPP_NO_EXCEPTIONS
554#endif438# endif
555439
556#if !(__has_feature(cxx_noexcept))440# define _LIBCPP_PREFERRED_ALIGNOF(_Tp) __alignof(_Tp)
557#define _LIBCPP_HAS_NO_NOEXCEPT
558#endif
559441
560#if !__has_feature(address_sanitizer)442# if defined(_LIBCPP_COMPILER_CLANG_BASED)
561#define _LIBCPP_HAS_NO_ASAN
562#endif
563443
564// Allow for build-time disabling of unsigned integer sanitization444# if defined(__APPLE__) && !defined(__i386__) && !defined(__x86_64__) && (!defined(__arm__) || __ARM_ARCH_7K__ >= 2)
565#if __has_attribute(no_sanitize)445# define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
566#define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow")))446# endif
567#endif
568
569#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
570447
571#define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__448// Objective-C++ features (opt-in)
449# if __has_feature(objc_arc)
450# define _LIBCPP_HAS_OBJC_ARC
451# endif
572452
573#elif defined(_LIBCPP_COMPILER_GCC)453# if __has_feature(objc_arc_weak)
454# define _LIBCPP_HAS_OBJC_ARC_WEAK
455# endif
574456
575#define _ALIGNAS(x) __attribute__((__aligned__(x)))457# if __has_extension(blocks)
576#define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x))))458# define _LIBCPP_HAS_EXTENSION_BLOCKS
459# endif
577460
578#define _LIBCPP_NORETURN __attribute__((noreturn))461# if defined(_LIBCPP_HAS_EXTENSION_BLOCKS) && defined(__APPLE__)
462# define _LIBCPP_HAS_BLOCKS_RUNTIME
463# endif
579464
580#if !defined(__EXCEPTIONS)465# if !__has_feature(address_sanitizer)
581# define _LIBCPP_NO_EXCEPTIONS466# define _LIBCPP_HAS_NO_ASAN
582#endif467# endif
583468
584#if !defined(__SANITIZE_ADDRESS__)469// Allow for build-time disabling of unsigned integer sanitization
585#define _LIBCPP_HAS_NO_ASAN470# if __has_attribute(no_sanitize)
586#endif471# define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow")))
472# endif
587473
588#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))474# define _LIBCPP_ALWAYS_INLINE __attribute__((__always_inline__))
589475
590#define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__476# define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__
591477
592#elif defined(_LIBCPP_COMPILER_MSVC)478# elif defined(_LIBCPP_COMPILER_GCC)
593479
594#define _LIBCPP_TOSTRING2(x) #x480# if !defined(__SANITIZE_ADDRESS__)
595#define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x)481# define _LIBCPP_HAS_NO_ASAN
596#define _LIBCPP_WARNING(x) __pragma(message(__FILE__ "(" _LIBCPP_TOSTRING(__LINE__) ") : warning note: " x))482# endif
597483
598#if _MSC_VER < 1900484# define _LIBCPP_ALWAYS_INLINE __attribute__((__always_inline__))
599#error "MSVC versions prior to Visual Studio 2015 are not supported"
600#endif
601485
602#define __alignof__ __alignof486# define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__
603#define _LIBCPP_NORETURN __declspec(noreturn)
604#define _ALIGNAS(x) __declspec(align(x))
605#define _ALIGNAS_TYPE(x) alignas(x)
606487
607#define _LIBCPP_WEAK488# elif defined(_LIBCPP_COMPILER_MSVC)
608489
609#define _LIBCPP_HAS_NO_ASAN490# define _LIBCPP_WARNING(x) __pragma(message(__FILE__ "(" _LIBCPP_TOSTRING(__LINE__) ") : warning note: " x))
610491
611#define _LIBCPP_ALWAYS_INLINE __forceinline492# if _MSC_VER < 1900
493# error "MSVC versions prior to Visual Studio 2015 are not supported"
494# endif
612495
613#define _LIBCPP_HAS_NO_VECTOR_EXTENSION496# define _LIBCPP_NORETURN __declspec(noreturn)
614497
615#define _LIBCPP_DISABLE_EXTENSION_WARNING498# define _LIBCPP_WEAK
616499
617#elif defined(_LIBCPP_COMPILER_IBM)500# define _LIBCPP_HAS_NO_ASAN
618501
619#define _ALIGNAS(x) __attribute__((__aligned__(x)))502# define _LIBCPP_ALWAYS_INLINE __forceinline
620#define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x))))
621#define _ATTRIBUTE(x) __attribute__((x))
622#define _LIBCPP_NORETURN __attribute__((noreturn))
623503
624#define _LIBCPP_HAS_NO_UNICODE_CHARS504# define _LIBCPP_HAS_NO_VECTOR_EXTENSION
625505
626#if defined(_AIX)506# define _LIBCPP_DISABLE_EXTENSION_WARNING
627#define __MULTILOCALE_API
628#endif
629507
630#define _LIBCPP_HAS_NO_ASAN508# endif // _LIBCPP_COMPILER_[CLANG|GCC|MSVC]
631509
632#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))510# if defined(_LIBCPP_OBJECT_FORMAT_COFF)
633511
634#define _LIBCPP_HAS_NO_VECTOR_EXTENSION512# ifdef _DLL
513# define _LIBCPP_CRT_FUNC __declspec(dllimport)
514# else
515# define _LIBCPP_CRT_FUNC
516# endif
635517
636#define _LIBCPP_DISABLE_EXTENSION_WARNING518# if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) || (defined(__MINGW32__) && !defined(_LIBCPP_BUILDING_LIBRARY))
519# define _LIBCPP_DLL_VIS
520# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
521# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
522# define _LIBCPP_OVERRIDABLE_FUNC_VIS
523# define _LIBCPP_EXPORTED_FROM_ABI
524# elif defined(_LIBCPP_BUILDING_LIBRARY)
525# define _LIBCPP_DLL_VIS __declspec(dllexport)
526# if defined(__MINGW32__)
527# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS
528# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
529# else
530# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
531# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS _LIBCPP_DLL_VIS
532# endif
533# define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_DLL_VIS
534# define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllexport)
535# else
536# define _LIBCPP_DLL_VIS __declspec(dllimport)
537# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS
538# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
539# define _LIBCPP_OVERRIDABLE_FUNC_VIS
540# define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllimport)
541# endif
637542
638#endif // _LIBCPP_COMPILER_[CLANG|GCC|MSVC|IBM]543# define _LIBCPP_TYPE_VIS _LIBCPP_DLL_VIS
544# define _LIBCPP_FUNC_VIS _LIBCPP_DLL_VIS
545# define _LIBCPP_EXCEPTION_ABI _LIBCPP_DLL_VIS
546# define _LIBCPP_HIDDEN
547# define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
548# define _LIBCPP_TEMPLATE_VIS
549# define _LIBCPP_TEMPLATE_DATA_VIS
550# define _LIBCPP_ENUM_VIS
639551
640#if defined(_LIBCPP_OBJECT_FORMAT_COFF)552# else
641553
642#ifdef _DLL554# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
643# define _LIBCPP_CRT_FUNC __declspec(dllimport)555# define _LIBCPP_VISIBILITY(vis) __attribute__((__visibility__(vis)))
644#else556# else
645# define _LIBCPP_CRT_FUNC557# define _LIBCPP_VISIBILITY(vis)
646#endif558# endif
647559
648#if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)560# define _LIBCPP_HIDDEN _LIBCPP_VISIBILITY("hidden")
649# define _LIBCPP_DLL_VIS561# define _LIBCPP_FUNC_VIS _LIBCPP_VISIBILITY("default")
650# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS562# define _LIBCPP_TYPE_VIS _LIBCPP_VISIBILITY("default")
651# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS563# define _LIBCPP_TEMPLATE_DATA_VIS _LIBCPP_VISIBILITY("default")
652# define _LIBCPP_OVERRIDABLE_FUNC_VIS564# define _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_VISIBILITY("default")
653# define _LIBCPP_EXPORTED_FROM_ABI565# define _LIBCPP_EXCEPTION_ABI _LIBCPP_VISIBILITY("default")
654#elif defined(_LIBCPP_BUILDING_LIBRARY)566# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_VISIBILITY("default")
655# define _LIBCPP_DLL_VIS __declspec(dllexport)
656# if defined(__MINGW32__)
657# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS
658# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS567# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
659# else
660# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
661# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS _LIBCPP_DLL_VIS
662# endif
663# define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_DLL_VIS
664# define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllexport)
665#else
666# define _LIBCPP_DLL_VIS __declspec(dllimport)
667# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS
668# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
669# define _LIBCPP_OVERRIDABLE_FUNC_VIS
670# define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllimport)
671#endif
672568
673#define _LIBCPP_TYPE_VIS _LIBCPP_DLL_VIS569// TODO: Make this a proper customization point or remove the option to override it.
674#define _LIBCPP_FUNC_VIS _LIBCPP_DLL_VIS570# ifndef _LIBCPP_OVERRIDABLE_FUNC_VIS
675#define _LIBCPP_EXCEPTION_ABI _LIBCPP_DLL_VIS571# define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_VISIBILITY("default")
676#define _LIBCPP_HIDDEN572# endif
677#define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
678#define _LIBCPP_TEMPLATE_VIS
679#define _LIBCPP_TEMPLATE_DATA_VIS
680#define _LIBCPP_ENUM_VIS
681573
682#endif // defined(_LIBCPP_OBJECT_FORMAT_COFF)574# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
575// The inline should be removed once PR32114 is resolved
576# define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS inline _LIBCPP_HIDDEN
577# else
578# define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
579# endif
683580
684#ifndef _LIBCPP_HIDDEN581# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
685# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)582# if __has_attribute(__type_visibility__)
686# define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden")))583# define _LIBCPP_TEMPLATE_VIS __attribute__((__type_visibility__("default")))
687# else584# else
688# define _LIBCPP_HIDDEN585# define _LIBCPP_TEMPLATE_VIS __attribute__((__visibility__("default")))
689# endif586# endif
690#endif587# else
588# define _LIBCPP_TEMPLATE_VIS
589# endif
691590
692#ifndef _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS591# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__)
693# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)592# define _LIBCPP_ENUM_VIS __attribute__((__type_visibility__("default")))
694// The inline should be removed once PR32114 is resolved593# else
695# define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS inline _LIBCPP_HIDDEN594# define _LIBCPP_ENUM_VIS
696# else595# endif
697# define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS596
698# endif597# endif // defined(_LIBCPP_OBJECT_FORMAT_COFF)
699#endif
700598
701#ifndef _LIBCPP_FUNC_VIS599# if __has_attribute(exclude_from_explicit_instantiation)
702# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)600# define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__((__exclude_from_explicit_instantiation__))
703# define _LIBCPP_FUNC_VIS __attribute__ ((__visibility__("default")))
704# else601# else
705# define _LIBCPP_FUNC_VIS602// Try to approximate the effect of exclude_from_explicit_instantiation
603// (which is that entities are not assumed to be provided by explicit
604// template instantiations in the dylib) by always inlining those entities.
605# define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION _LIBCPP_ALWAYS_INLINE
706# endif606# endif
707#endif
708607
709#ifndef _LIBCPP_TYPE_VIS608// This macro marks a symbol as being hidden from libc++'s ABI. This is achieved
710# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)609// on two levels:
711# define _LIBCPP_TYPE_VIS __attribute__ ((__visibility__("default")))610// 1. The symbol is given hidden visibility, which ensures that users won't start exporting
611// symbols from their dynamic library by means of using the libc++ headers. This ensures
612// that those symbols stay private to the dynamic library in which it is defined.
613//
614// 2. The symbol is given an ABI tag that changes with each version of libc++. This ensures
615// that no ODR violation can arise from mixing two TUs compiled with different versions
616// of libc++ where we would have changed the definition of a symbol. If the symbols shared
617// the same name, the ODR would require that their definitions be token-by-token equivalent,
618// which basically prevents us from being able to make any change to any function in our
619// headers. Using this ABI tag ensures that the symbol name is "bumped" artificially at
620// each release, which lets us change the definition of these symbols at our leisure.
621// Note that historically, this has been achieved in various ways, including force-inlining
622// all functions or giving internal linkage to all functions. Both these (previous) solutions
623// suffer from drawbacks that lead notably to code bloat.
624//
625// Note that we use _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION to ensure that we don't depend
626// on _LIBCPP_HIDE_FROM_ABI methods of classes explicitly instantiated in the dynamic library.
627//
628// TODO: We provide a escape hatch with _LIBCPP_NO_ABI_TAG for folks who want to avoid increasing
629// the length of symbols with an ABI tag. In practice, we should remove the escape hatch and
630// use compression mangling instead, see https://github.com/itanium-cxx-abi/cxx-abi/issues/70.
631# ifndef _LIBCPP_NO_ABI_TAG
632# define _LIBCPP_HIDE_FROM_ABI \
633 _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION \
634 __attribute__((__abi_tag__(_LIBCPP_TOSTRING(_LIBCPP_VERSIONED_IDENTIFIER))))
712# else635# else
713# define _LIBCPP_TYPE_VIS636# define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
714# endif637# endif
715#endif
716638
717#ifndef _LIBCPP_TEMPLATE_VIS639# ifdef _LIBCPP_BUILDING_LIBRARY
718# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)640# if _LIBCPP_ABI_VERSION > 1
719# if __has_attribute(__type_visibility__)641# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI
720# define _LIBCPP_TEMPLATE_VIS __attribute__ ((__type_visibility__("default")))
721# else642# else
722# define _LIBCPP_TEMPLATE_VIS __attribute__ ((__visibility__("default")))643# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1
723# endif644# endif
724# else645# else
725# define _LIBCPP_TEMPLATE_VIS646# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI
726# endif647# endif
727#endif
728648
729#ifndef _LIBCPP_TEMPLATE_DATA_VIS649// Just so we can migrate to the new macros gradually.
730# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)650# define _LIBCPP_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI
731# define _LIBCPP_TEMPLATE_DATA_VIS __attribute__ ((__visibility__("default")))
732# else
733# define _LIBCPP_TEMPLATE_DATA_VIS
734# endif
735#endif
736651
737#ifndef _LIBCPP_EXPORTED_FROM_ABI652// Inline namespaces are available in Clang/GCC/MSVC regardless of C++ dialect.
738# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)653// clang-format off
739# define _LIBCPP_EXPORTED_FROM_ABI __attribute__((__visibility__("default")))654# define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { inline namespace _LIBCPP_ABI_NAMESPACE {
740# else655# define _LIBCPP_END_NAMESPACE_STD }}
741# define _LIBCPP_EXPORTED_FROM_ABI656# define _VSTD std
742# endif
743#endif
744657
745#ifndef _LIBCPP_OVERRIDABLE_FUNC_VIS658_LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
746#define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_FUNC_VIS
747#endif
748659
749#ifndef _LIBCPP_EXCEPTION_ABI660# if _LIBCPP_STD_VER > 14
750# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)661# define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \
751# define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default")))662 _LIBCPP_BEGIN_NAMESPACE_STD inline namespace __fs { namespace filesystem {
752# else663# else
753# define _LIBCPP_EXCEPTION_ABI664# define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \
665 _LIBCPP_BEGIN_NAMESPACE_STD namespace __fs { namespace filesystem {
754# endif666# endif
755#endif
756667
757#ifndef _LIBCPP_ENUM_VIS668# define _LIBCPP_END_NAMESPACE_FILESYSTEM _LIBCPP_END_NAMESPACE_STD }}
758# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__)669// clang-format on
759# define _LIBCPP_ENUM_VIS __attribute__ ((__type_visibility__("default")))
760# else
761# define _LIBCPP_ENUM_VIS
762# endif
763#endif
764670
765#ifndef _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS671# define _VSTD_FS std::__fs::filesystem
766# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
767# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __attribute__ ((__visibility__("default")))
768# else
769# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
770# endif
771#endif
772672
773#ifndef _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS673# if __has_attribute(__enable_if__)
774#define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS674# define _LIBCPP_PREFERRED_OVERLOAD __attribute__((__enable_if__(true, "")))
775#endif675# endif
776676
777#if __has_attribute(internal_linkage)677# ifndef __SIZEOF_INT128__
778# define _LIBCPP_INTERNAL_LINKAGE __attribute__ ((internal_linkage))678# define _LIBCPP_HAS_NO_INT128
779#else679# endif
780# define _LIBCPP_INTERNAL_LINKAGE _LIBCPP_ALWAYS_INLINE
781#endif
782680
783#if __has_attribute(exclude_from_explicit_instantiation)681# ifdef _LIBCPP_CXX03_LANG
784# define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__ ((__exclude_from_explicit_instantiation__))682# define static_assert(...) _Static_assert(__VA_ARGS__)
785#else683# define decltype(...) __decltype(__VA_ARGS__)
786 // Try to approximate the effect of exclude_from_explicit_instantiation684# endif // _LIBCPP_CXX03_LANG
787 // (which is that entities are not assumed to be provided by explicit
788 // template instantiations in the dylib) by always inlining those entities.
789# define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION _LIBCPP_ALWAYS_INLINE
790#endif
791685
792#ifndef _LIBCPP_HIDE_FROM_ABI_PER_TU686# ifdef _LIBCPP_CXX03_LANG
793# ifndef _LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT687# define _LIBCPP_CONSTEXPR
794# define _LIBCPP_HIDE_FROM_ABI_PER_TU 0
795# else688# else
796# define _LIBCPP_HIDE_FROM_ABI_PER_TU 1689# define _LIBCPP_CONSTEXPR constexpr
797# endif690# endif
798#endif
799691
800#ifndef _LIBCPP_HIDE_FROM_ABI692# ifndef __cpp_consteval
801# if _LIBCPP_HIDE_FROM_ABI_PER_TU693# define _LIBCPP_CONSTEVAL _LIBCPP_CONSTEXPR
802# define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_INTERNAL_LINKAGE
803# else694# else
804# define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION695# define _LIBCPP_CONSTEVAL consteval
805# endif696# endif
806#endif
807697
808#ifdef _LIBCPP_BUILDING_LIBRARY698# ifdef __GNUC__
809# if _LIBCPP_ABI_VERSION > 1699# define _LIBCPP_NOALIAS __attribute__((__malloc__))
810# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI
811# else700# else
812# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1701# define _LIBCPP_NOALIAS
813# endif702# endif
814#else
815# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI
816#endif
817
818// Just so we can migrate to the new macros gradually.
819#define _LIBCPP_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI
820
821// Inline namespaces are available in Clang/GCC/MSVC regardless of C++ dialect.
822#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { inline namespace _LIBCPP_ABI_NAMESPACE {
823#define _LIBCPP_END_NAMESPACE_STD } }
824#define _VSTD std
825_LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
826
827#if _LIBCPP_STD_VER > 14
828#define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \
829 _LIBCPP_BEGIN_NAMESPACE_STD inline namespace __fs { namespace filesystem {
830#else
831#define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \
832 _LIBCPP_BEGIN_NAMESPACE_STD namespace __fs { namespace filesystem {
833#endif
834
835#define _LIBCPP_END_NAMESPACE_FILESYSTEM \
836 _LIBCPP_END_NAMESPACE_STD } }
837
838#define _VSTD_FS _VSTD::__fs::filesystem
839
840#if __has_attribute(__enable_if__)
841# define _LIBCPP_PREFERRED_OVERLOAD __attribute__ ((__enable_if__(true, "")))
842#endif
843
844#ifndef _LIBCPP_HAS_NO_NOEXCEPT
845# define _NOEXCEPT noexcept
846# define _NOEXCEPT_(x) noexcept(x)
847#else
848# define _NOEXCEPT throw()
849# define _NOEXCEPT_(x)
850#endif
851
852#ifdef _LIBCPP_HAS_NO_UNICODE_CHARS
853typedef unsigned short char16_t;
854typedef unsigned int char32_t;
855#endif
856
857#ifndef __SIZEOF_INT128__
858#define _LIBCPP_HAS_NO_INT128
859#endif
860703
861#ifdef _LIBCPP_CXX03_LANG704# if __has_attribute(using_if_exists)
862# define static_assert(...) _Static_assert(__VA_ARGS__)705# define _LIBCPP_USING_IF_EXISTS __attribute__((using_if_exists))
863# define decltype(...) __decltype(__VA_ARGS__)
864#endif // _LIBCPP_CXX03_LANG
865
866#ifdef _LIBCPP_CXX03_LANG
867# define _LIBCPP_CONSTEXPR
868#else
869# define _LIBCPP_CONSTEXPR constexpr
870#endif
871
872#ifndef __cpp_consteval
873# define _LIBCPP_CONSTEVAL _LIBCPP_CONSTEXPR
874#else
875# define _LIBCPP_CONSTEVAL consteval
876#endif
877
878#if _LIBCPP_STD_VER <= 17 || !defined(__cpp_concepts) || __cpp_concepts < 201907L
879#define _LIBCPP_HAS_NO_CONCEPTS
880#endif
881
882#ifdef __GNUC__
883# define _LIBCPP_NOALIAS __attribute__((__malloc__))
884#else
885# define _LIBCPP_NOALIAS
886#endif
887
888#if __has_attribute(using_if_exists)
889# define _LIBCPP_USING_IF_EXISTS __attribute__((using_if_exists))
890#else
891# define _LIBCPP_USING_IF_EXISTS
892#endif
893
894#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS
895# define _LIBCPP_DECLARE_STRONG_ENUM(x) struct _LIBCPP_TYPE_VIS x { enum __lx
896# define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \
897 __lx __v_; \
898 _LIBCPP_INLINE_VISIBILITY x(__lx __v) : __v_(__v) {} \
899 _LIBCPP_INLINE_VISIBILITY explicit x(int __v) : __v_(static_cast<__lx>(__v)) {} \
900 _LIBCPP_INLINE_VISIBILITY operator int() const {return __v_;} \
901 };
902#else // _LIBCPP_HAS_NO_STRONG_ENUMS
903# define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_ENUM_VIS x
904# define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)
905#endif // _LIBCPP_HAS_NO_STRONG_ENUMS
906
907// _LIBCPP_DEBUG potential values:
908// - undefined: No assertions. This is the default.
909// - 0: Basic assertions
910// - 1: Basic assertions + iterator validity checks + unspecified behavior randomization.
911# if !defined(_LIBCPP_DEBUG)
912# define _LIBCPP_DEBUG_LEVEL 0
913# elif _LIBCPP_DEBUG == 0
914# define _LIBCPP_DEBUG_LEVEL 1
915# elif _LIBCPP_DEBUG == 1
916# define _LIBCPP_DEBUG_LEVEL 2
917# else706# else
918# error Supported values for _LIBCPP_DEBUG are 0 and 1707# define _LIBCPP_USING_IF_EXISTS
919# endif708# endif
920709
921# if _LIBCPP_DEBUG_LEVEL >= 2 && !defined(_LIBCPP_CXX03_LANG)710# ifdef _LIBCPP_CXX03_LANG
922# define _LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY711# define _LIBCPP_DECLARE_STRONG_ENUM(x) \
712 struct _LIBCPP_TYPE_VIS x { \
713 enum __lx
714// clang-format off
715# define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \
716 __lx __v_; \
717 _LIBCPP_INLINE_VISIBILITY x(__lx __v) : __v_(__v) {} \
718 _LIBCPP_INLINE_VISIBILITY explicit x(int __v) : __v_(static_cast<__lx>(__v)) {} \
719 _LIBCPP_INLINE_VISIBILITY operator int() const { return __v_; } \
720 };
721// clang-format on
722
723# else // _LIBCPP_CXX03_LANG
724# define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_ENUM_VIS x
725# define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)
726# endif // _LIBCPP_CXX03_LANG
727
728# if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || defined(__sun__) || \
729 defined(__NetBSD__)
730# define _LIBCPP_LOCALE__L_EXTENSIONS 1
923# endif731# endif
924732
925# if defined(_LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY)733# ifdef __FreeBSD__
926# if defined(_LIBCPP_CXX03_LANG)734# define _DECLARE_C99_LDBL_MATH 1
927# error Support for unspecified stability is only for C++11 and higher
928# endif
929# define _LIBCPP_DEBUG_RANDOMIZE_RANGE(__first, __last) \
930 do { \
931 if (!__builtin_is_constant_evaluated()) \
932 _VSTD::shuffle(__first, __last, __libcpp_debug_randomizer()); \
933 } while (false)
934# else
935# define _LIBCPP_DEBUG_RANDOMIZE_RANGE(__first, __last) \
936 do { \
937 } while (false)
938# endif735# endif
939736
940// Libc++ allows disabling extern template instantiation declarations by
941// means of users defining _LIBCPP_DISABLE_EXTERN_TEMPLATE.
942//
943// Furthermore, when the Debug mode is enabled, we disable extern declarations
944// when building user code because we don't want to use the functions compiled
945// in the library, which might not have had the debug mode enabled when built.
946// However, some extern declarations need to be used, because code correctness
947// depends on it (several instances in <locale>). Those special declarations
948// are declared with _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE, which is enabled
949// even when the debug mode is enabled.
950#if defined(_LIBCPP_DISABLE_EXTERN_TEMPLATE)
951# define _LIBCPP_EXTERN_TEMPLATE(...) /* nothing */
952# define _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(...) /* nothing */
953#elif _LIBCPP_DEBUG_LEVEL >= 1 && !defined(_LIBCPP_BUILDING_LIBRARY)
954# define _LIBCPP_EXTERN_TEMPLATE(...) /* nothing */
955# define _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(...) extern template __VA_ARGS__;
956#else
957# define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
958# define _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(...) extern template __VA_ARGS__;
959#endif
960
961#if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || \
962 defined(__sun__) || defined(__NetBSD__)
963#define _LIBCPP_LOCALE__L_EXTENSIONS 1
964#endif
965
966#ifdef __FreeBSD__
967#define _DECLARE_C99_LDBL_MATH 1
968#endif
969
970// If we are getting operator new from the MSVC CRT, then allocation overloads737// If we are getting operator new from the MSVC CRT, then allocation overloads
971// for align_val_t were added in 19.12, aka VS 2017 version 15.3.738// for align_val_t were added in 19.12, aka VS 2017 version 15.3.
972#if defined(_LIBCPP_MSVCRT) && defined(_MSC_VER) && _MSC_VER < 1912739# if defined(_LIBCPP_MSVCRT) && defined(_MSC_VER) && _MSC_VER < 1912
973# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION740# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
974#elif defined(_LIBCPP_ABI_VCRUNTIME) && !defined(__cpp_aligned_new)741# elif defined(_LIBCPP_ABI_VCRUNTIME) && !defined(__cpp_aligned_new)
975 // We're deferring to Microsoft's STL to provide aligned new et al. We don't742// We're deferring to Microsoft's STL to provide aligned new et al. We don't
976 // have it unless the language feature test macro is defined.743// have it unless the language feature test macro is defined.
977# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION744# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
978#elif defined(__MVS__)745# elif defined(__MVS__)
979# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION746# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
980#endif747# endif
981748
982#if defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) || \749# if defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) || (!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606)
983 (!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606)750# define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
984# define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION751# endif
985#endif
986752
987#if defined(__APPLE__) || defined(__FreeBSD__)753# if defined(__APPLE__) || defined(__FreeBSD__)
988#define _LIBCPP_HAS_DEFAULTRUNELOCALE754# define _LIBCPP_HAS_DEFAULTRUNELOCALE
989#endif755# endif
990756
991#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__)757# if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__)
992#define _LIBCPP_WCTYPE_IS_MASK758# define _LIBCPP_WCTYPE_IS_MASK
993#endif759# endif
994760
995#if _LIBCPP_STD_VER <= 17 || !defined(__cpp_char8_t)761# if _LIBCPP_STD_VER <= 17 || !defined(__cpp_char8_t)
996#define _LIBCPP_HAS_NO_CHAR8_T762# define _LIBCPP_HAS_NO_CHAR8_T
997#endif763# endif
998764
999// Deprecation macros.765// Deprecation macros.
1000//766//
1001// Deprecations warnings are always enabled, except when users explicitly opt-out767// Deprecations warnings are always enabled, except when users explicitly opt-out
1002// by defining _LIBCPP_DISABLE_DEPRECATION_WARNINGS.768// by defining _LIBCPP_DISABLE_DEPRECATION_WARNINGS.
1003#if !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)769# if !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
1004# if __has_attribute(deprecated)770# if __has_attribute(deprecated)
1005# define _LIBCPP_DEPRECATED __attribute__ ((deprecated))771# define _LIBCPP_DEPRECATED __attribute__((deprecated))
1006# elif _LIBCPP_STD_VER > 11772# define _LIBCPP_DEPRECATED_(m) __attribute__((deprected(m)))
1007# define _LIBCPP_DEPRECATED [[deprecated]]773# elif _LIBCPP_STD_VER > 11
774# define _LIBCPP_DEPRECATED [[deprecated]]
775# define _LIBCPP_DEPRECATED_(m) [[deprecated(m)]]
776# else
777# define _LIBCPP_DEPRECATED
778# define _LIBCPP_DEPRECATED_(m)
779# endif
1008# else780# else
1009# define _LIBCPP_DEPRECATED781# define _LIBCPP_DEPRECATED
782# define _LIBCPP_DEPRECATED_(m)
1010# endif783# endif
1011#else
1012# define _LIBCPP_DEPRECATED
1013#endif
1014784
1015#if !defined(_LIBCPP_CXX03_LANG)785# if !defined(_LIBCPP_CXX03_LANG)
1016# define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED786# define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED
1017#else787# else
1018# define _LIBCPP_DEPRECATED_IN_CXX11788# define _LIBCPP_DEPRECATED_IN_CXX11
1019#endif789# endif
1020790
1021#if _LIBCPP_STD_VER >= 14791# if _LIBCPP_STD_VER > 11
1022# define _LIBCPP_DEPRECATED_IN_CXX14 _LIBCPP_DEPRECATED792# define _LIBCPP_DEPRECATED_IN_CXX14 _LIBCPP_DEPRECATED
1023#else793# else
1024# define _LIBCPP_DEPRECATED_IN_CXX14794# define _LIBCPP_DEPRECATED_IN_CXX14
1025#endif795# endif
1026796
1027#if _LIBCPP_STD_VER >= 17797# if _LIBCPP_STD_VER > 14
1028# define _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_DEPRECATED798# define _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_DEPRECATED
1029#else799# else
1030# define _LIBCPP_DEPRECATED_IN_CXX17800# define _LIBCPP_DEPRECATED_IN_CXX17
1031#endif801# endif
1032802
1033#if _LIBCPP_STD_VER > 17803# if _LIBCPP_STD_VER > 17
1034# define _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_DEPRECATED804# define _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_DEPRECATED
1035#else805# else
1036# define _LIBCPP_DEPRECATED_IN_CXX20806# define _LIBCPP_DEPRECATED_IN_CXX20
1037#endif807# endif
1038808
1039#if !defined(_LIBCPP_HAS_NO_CHAR8_T)809# if !defined(_LIBCPP_HAS_NO_CHAR8_T)
1040# define _LIBCPP_DEPRECATED_WITH_CHAR8_T _LIBCPP_DEPRECATED810# define _LIBCPP_DEPRECATED_WITH_CHAR8_T _LIBCPP_DEPRECATED
1041#else811# else
1042# define _LIBCPP_DEPRECATED_WITH_CHAR8_T812# define _LIBCPP_DEPRECATED_WITH_CHAR8_T
1043#endif813# endif
1044814
1045// Macros to enter and leave a state where deprecation warnings are suppressed.815// Macros to enter and leave a state where deprecation warnings are suppressed.
1046#if defined(_LIBCPP_COMPILER_CLANG_BASED) || defined(_LIBCPP_COMPILER_GCC)816# if defined(_LIBCPP_COMPILER_CLANG_BASED) || defined(_LIBCPP_COMPILER_GCC)
1047# define _LIBCPP_SUPPRESS_DEPRECATED_PUSH \817# define _LIBCPP_SUPPRESS_DEPRECATED_PUSH \
1048 _Pragma("GCC diagnostic push") \818 _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wdeprecated\"") \
1049 _Pragma("GCC diagnostic ignored \"-Wdeprecated\"") \819 _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1050 _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")820# define _LIBCPP_SUPPRESS_DEPRECATED_POP _Pragma("GCC diagnostic pop")
1051# define _LIBCPP_SUPPRESS_DEPRECATED_POP \821# else
1052 _Pragma("GCC diagnostic pop")822# define _LIBCPP_SUPPRESS_DEPRECATED_PUSH
1053#else823# define _LIBCPP_SUPPRESS_DEPRECATED_POP
1054# define _LIBCPP_SUPPRESS_DEPRECATED_PUSH824# endif
1055# define _LIBCPP_SUPPRESS_DEPRECATED_POP
1056#endif
1057825
1058#if _LIBCPP_STD_VER <= 11826# if _LIBCPP_STD_VER <= 11
1059# define _LIBCPP_EXPLICIT_AFTER_CXX11827# define _LIBCPP_EXPLICIT_AFTER_CXX11
1060#else828# else
1061# define _LIBCPP_EXPLICIT_AFTER_CXX11 explicit829# define _LIBCPP_EXPLICIT_AFTER_CXX11 explicit
1062#endif830# endif
1063831
1064#if _LIBCPP_STD_VER > 11832# if _LIBCPP_STD_VER > 11
1065# define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr833# define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr
1066#else834# else
1067# define _LIBCPP_CONSTEXPR_AFTER_CXX11835# define _LIBCPP_CONSTEXPR_AFTER_CXX11
1068#endif836# endif
1069837
1070#if _LIBCPP_STD_VER > 14838# if _LIBCPP_STD_VER > 14
1071# define _LIBCPP_CONSTEXPR_AFTER_CXX14 constexpr839# define _LIBCPP_CONSTEXPR_AFTER_CXX14 constexpr
1072#else840# else
1073# define _LIBCPP_CONSTEXPR_AFTER_CXX14841# define _LIBCPP_CONSTEXPR_AFTER_CXX14
1074#endif842# endif
1075843
1076#if _LIBCPP_STD_VER > 17844# if _LIBCPP_STD_VER > 17
1077# define _LIBCPP_CONSTEXPR_AFTER_CXX17 constexpr845# define _LIBCPP_CONSTEXPR_AFTER_CXX17 constexpr
1078#else846# else
1079# define _LIBCPP_CONSTEXPR_AFTER_CXX17847# define _LIBCPP_CONSTEXPR_AFTER_CXX17
1080#endif848# endif
1081849
1082#if __has_cpp_attribute(nodiscard) || defined(_LIBCPP_COMPILER_MSVC)850# if __has_cpp_attribute(nodiscard) || defined(_LIBCPP_COMPILER_MSVC)
1083# define _LIBCPP_NODISCARD [[nodiscard]]851# define _LIBCPP_NODISCARD [[nodiscard]]
1084#elif defined(_LIBCPP_COMPILER_CLANG_BASED) && !defined(_LIBCPP_CXX03_LANG)852# elif defined(_LIBCPP_COMPILER_CLANG_BASED) && !defined(_LIBCPP_CXX03_LANG)
1085# define _LIBCPP_NODISCARD [[clang::warn_unused_result]]853# define _LIBCPP_NODISCARD [[clang::warn_unused_result]]
1086#else854# else
1087// We can't use GCC's [[gnu::warn_unused_result]] and855// We can't use GCC's [[gnu::warn_unused_result]] and
1088// __attribute__((warn_unused_result)), because GCC does not silence them via856// __attribute__((warn_unused_result)), because GCC does not silence them via
1089// (void) cast.857// (void) cast.
1090# define _LIBCPP_NODISCARD858# define _LIBCPP_NODISCARD
1091#endif859# endif
1092860
1093// _LIBCPP_NODISCARD_EXT may be used to apply [[nodiscard]] to entities not861// _LIBCPP_NODISCARD_EXT may be used to apply [[nodiscard]] to entities not
1094// specified as such as an extension.862// specified as such as an extension.
1095#if defined(_LIBCPP_ENABLE_NODISCARD) && !defined(_LIBCPP_DISABLE_NODISCARD_EXT)863# if defined(_LIBCPP_ENABLE_NODISCARD) && !defined(_LIBCPP_DISABLE_NODISCARD_EXT)
1096# define _LIBCPP_NODISCARD_EXT _LIBCPP_NODISCARD864# define _LIBCPP_NODISCARD_EXT _LIBCPP_NODISCARD
1097#else865# else
1098# define _LIBCPP_NODISCARD_EXT866# define _LIBCPP_NODISCARD_EXT
1099#endif867# endif
1100868
1101#if !defined(_LIBCPP_DISABLE_NODISCARD_AFTER_CXX17) && \869# if !defined(_LIBCPP_DISABLE_NODISCARD_AFTER_CXX17) && (_LIBCPP_STD_VER > 17 || defined(_LIBCPP_ENABLE_NODISCARD))
1102 (_LIBCPP_STD_VER > 17 || defined(_LIBCPP_ENABLE_NODISCARD))870# define _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_NODISCARD
1103# define _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_NODISCARD871# else
1104#else872# define _LIBCPP_NODISCARD_AFTER_CXX17
1105# define _LIBCPP_NODISCARD_AFTER_CXX17873# endif
1106#endif
1107874
1108#if __has_attribute(no_destroy)875# if __has_attribute(no_destroy)
1109# define _LIBCPP_NO_DESTROY __attribute__((__no_destroy__))876# define _LIBCPP_NO_DESTROY __attribute__((__no_destroy__))
1110#else877# else
1111# define _LIBCPP_NO_DESTROY878# define _LIBCPP_NO_DESTROY
1112#endif879# endif
1113880
1114#ifndef _LIBCPP_HAS_NO_ASAN881# ifndef _LIBCPP_HAS_NO_ASAN
1115extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container(882 extern "C" _LIBCPP_FUNC_VIS void
1116 const void *, const void *, const void *, const void *);883 __sanitizer_annotate_contiguous_container(const void*, const void*, const void*, const void*);
1117#endif884# endif
1118885
1119// Try to find out if RTTI is disabled.886// Try to find out if RTTI is disabled.
1120#if defined(_LIBCPP_COMPILER_CLANG_BASED) && !__has_feature(cxx_rtti)887# if !defined(__cpp_rtti) || __cpp_rtti < 199711L
1121# define _LIBCPP_NO_RTTI888# define _LIBCPP_NO_RTTI
1122#elif defined(__GNUC__) && !defined(__GXX_RTTI)889# endif
1123# define _LIBCPP_NO_RTTI
1124#elif defined(_LIBCPP_COMPILER_MSVC) && !defined(_CPPRTTI)
1125# define _LIBCPP_NO_RTTI
1126#endif
1127890
1128#ifndef _LIBCPP_WEAK891# ifndef _LIBCPP_WEAK
1129#define _LIBCPP_WEAK __attribute__((__weak__))892# define _LIBCPP_WEAK __attribute__((__weak__))
1130#endif893# endif
1131894
1132// Thread API895// Thread API
1133#if !defined(_LIBCPP_HAS_NO_THREADS) && \896// clang-format off
1134 !defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && \897# if !defined(_LIBCPP_HAS_NO_THREADS) && \
1135 !defined(_LIBCPP_HAS_THREAD_API_WIN32) && \898 !defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && \
1136 !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)899 !defined(_LIBCPP_HAS_THREAD_API_WIN32) && \
1137# if defined(__FreeBSD__) || \900 !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
1138 defined(__wasi__) || \901
1139 defined(__NetBSD__) || \902# if defined(__FreeBSD__) || \
1140 defined(__OpenBSD__) || \903 defined(__wasi__) || \
1141 defined(__NuttX__) || \904 defined(__NetBSD__) || \
1142 defined(__linux__) || \905 defined(__OpenBSD__) || \
1143 defined(__GNU__) || \906 defined(__NuttX__) || \
1144 defined(__APPLE__) || \907 defined(__linux__) || \
1145 defined(__sun__) || \908 defined(__GNU__) || \
1146 defined(__MVS__) || \909 defined(__APPLE__) || \
1147 defined(_AIX)910 defined(__sun__) || \
1148# define _LIBCPP_HAS_THREAD_API_PTHREAD911 defined(__MVS__) || \
1149# elif defined(__Fuchsia__)912 defined(_AIX) || \
1150 // TODO(44575): Switch to C11 thread API when possible.913 defined(__EMSCRIPTEN__)
1151# define _LIBCPP_HAS_THREAD_API_PTHREAD914// clang-format on
1152# elif defined(_LIBCPP_WIN32API)915# define _LIBCPP_HAS_THREAD_API_PTHREAD
1153# define _LIBCPP_HAS_THREAD_API_WIN32916# elif defined(__Fuchsia__)
1154# else917// TODO(44575): Switch to C11 thread API when possible.
1155# error "No thread API"918# define _LIBCPP_HAS_THREAD_API_PTHREAD
1156# endif // _LIBCPP_HAS_THREAD_API919# elif defined(_LIBCPP_WIN32API)
1157#endif // _LIBCPP_HAS_NO_THREADS920# define _LIBCPP_HAS_THREAD_API_WIN32
1158921# else
1159#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)922# error "No thread API"
1160#if defined(__ANDROID__) && __ANDROID_API__ >= 30923# endif // _LIBCPP_HAS_THREAD_API
1161#define _LIBCPP_HAS_COND_CLOCKWAIT924# endif // _LIBCPP_HAS_NO_THREADS
1162#elif defined(_LIBCPP_GLIBC_PREREQ)925
1163#if _LIBCPP_GLIBC_PREREQ(2, 30)926# if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
1164#define _LIBCPP_HAS_COND_CLOCKWAIT927# if defined(__ANDROID__) && __ANDROID_API__ >= 30
1165#endif928# define _LIBCPP_HAS_COND_CLOCKWAIT
1166#endif929# elif defined(_LIBCPP_GLIBC_PREREQ)
1167#endif930# if _LIBCPP_GLIBC_PREREQ(2, 30)
931# define _LIBCPP_HAS_COND_CLOCKWAIT
932# endif
933# endif
934# endif
1168935
1169#if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_PTHREAD)936# if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
1170#error _LIBCPP_HAS_THREAD_API_PTHREAD may only be defined when \937# error _LIBCPP_HAS_THREAD_API_PTHREAD may only be defined when \
1171 _LIBCPP_HAS_NO_THREADS is not defined.938 _LIBCPP_HAS_NO_THREADS is not defined.
1172#endif939# endif
1173940
1174#if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)941# if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
1175#error _LIBCPP_HAS_THREAD_API_EXTERNAL may not be defined when \942# error _LIBCPP_HAS_THREAD_API_EXTERNAL may not be defined when \
1176 _LIBCPP_HAS_NO_THREADS is defined.943 _LIBCPP_HAS_NO_THREADS is defined.
1177#endif944# endif
1178945
1179#if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(_LIBCPP_HAS_NO_THREADS)946# if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(_LIBCPP_HAS_NO_THREADS)
1180#error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \947# error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \
1181 _LIBCPP_HAS_NO_THREADS is defined.948 _LIBCPP_HAS_NO_THREADS is defined.
1182#endif949# endif
1183950
1184#if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(__STDCPP_THREADS__)951# if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(__STDCPP_THREADS__)
1185#define __STDCPP_THREADS__ 1952# define __STDCPP_THREADS__ 1
1186#endif953# endif
1187954
1188// The glibc and Bionic implementation of pthreads implements955// The glibc and Bionic implementation of pthreads implements
1189// pthread_mutex_destroy as nop for regular mutexes. Additionally, Win32956// pthread_mutex_destroy as nop for regular mutexes. Additionally, Win32
...@@ -1195,11 +962,13 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container(...@@ -1195,11 +962,13 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container(
1195//962//
1196// TODO(EricWF): Enable this optimization on Bionic after speaking to their963// TODO(EricWF): Enable this optimization on Bionic after speaking to their
1197// respective stakeholders.964// respective stakeholders.
1198#if (defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && defined(__GLIBC__)) \965// clang-format off
1199 || (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) \966# if (defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && defined(__GLIBC__)) || \
1200 || defined(_LIBCPP_HAS_THREAD_API_WIN32)967 (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) || \
1201# define _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION968 defined(_LIBCPP_HAS_THREAD_API_WIN32)
1202#endif969// clang-format on
970# define _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION
971# endif
1203972
1204// Destroying a condvar is a nop on Windows.973// Destroying a condvar is a nop on Windows.
1205//974//
...@@ -1209,225 +978,245 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container(...@@ -1209,225 +978,245 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container(
1209//978//
1210// TODO(EricWF): This is potentially true for some pthread implementations979// TODO(EricWF): This is potentially true for some pthread implementations
1211// as well.980// as well.
1212#if (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) || \981# if (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) || defined(_LIBCPP_HAS_THREAD_API_WIN32)
1213 defined(_LIBCPP_HAS_THREAD_API_WIN32)982# define _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION
1214# define _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION983# endif
1215#endif
1216984
1217// Some systems do not provide gets() in their C library, for security reasons.985// Some systems do not provide gets() in their C library, for security reasons.
1218#if defined(_LIBCPP_MSVCRT) || \986# if defined(_LIBCPP_MSVCRT) || (defined(__FreeBSD_version) && __FreeBSD_version >= 1300043) || defined(__OpenBSD__)
1219 (defined(__FreeBSD_version) && __FreeBSD_version >= 1300043) || \987# define _LIBCPP_C_HAS_NO_GETS
1220 defined(__OpenBSD__)988# endif
1221# define _LIBCPP_C_HAS_NO_GETS
1222#endif
1223
1224#if defined(__BIONIC__) || defined(__NuttX__) || \
1225 defined(__Fuchsia__) || defined(__wasi__) || \
1226 defined(_LIBCPP_HAS_MUSL_LIBC) || defined(__OpenBSD__)
1227#define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
1228#endif
1229989
1230#if __has_feature(cxx_atomic) || __has_extension(c_atomic) || __has_keyword(_Atomic)990# if defined(__BIONIC__) || defined(__NuttX__) || defined(__Fuchsia__) || defined(__wasi__) || \
1231# define _LIBCPP_HAS_C_ATOMIC_IMP991 defined(_LIBCPP_HAS_MUSL_LIBC) || defined(__OpenBSD__)
1232#elif defined(_LIBCPP_COMPILER_GCC)992# define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
1233# define _LIBCPP_HAS_GCC_ATOMIC_IMP993# endif
1234#endif
1235994
1236#if !defined(_LIBCPP_HAS_C_ATOMIC_IMP) && \995# if __has_feature(cxx_atomic) || __has_extension(c_atomic) || __has_keyword(_Atomic)
1237 !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) && \996# define _LIBCPP_HAS_C_ATOMIC_IMP
1238 !defined(_LIBCPP_HAS_EXTERNAL_ATOMIC_IMP)997# elif defined(_LIBCPP_COMPILER_GCC)
1239# define _LIBCPP_HAS_NO_ATOMIC_HEADER998# define _LIBCPP_HAS_GCC_ATOMIC_IMP
1240#else
1241# ifndef _LIBCPP_ATOMIC_FLAG_TYPE
1242# define _LIBCPP_ATOMIC_FLAG_TYPE bool
1243# endif999# endif
1244# ifdef _LIBCPP_FREESTANDING1000
1245# define _LIBCPP_ATOMIC_ONLY_USE_BUILTINS1001# if !defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) && \
1002 !defined(_LIBCPP_HAS_EXTERNAL_ATOMIC_IMP)
1003# define _LIBCPP_HAS_NO_ATOMIC_HEADER
1004# else
1005# ifndef _LIBCPP_ATOMIC_FLAG_TYPE
1006# define _LIBCPP_ATOMIC_FLAG_TYPE bool
1007# endif
1008# ifdef _LIBCPP_FREESTANDING
1009# define _LIBCPP_ATOMIC_ONLY_USE_BUILTINS
1010# endif
1246# endif1011# endif
1247#endif
12481012
1249#ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK1013# ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
1250#define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK1014# define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
1251#endif1015# endif
12521016
1253#if defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS)1017# if defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS)
1254# if defined(__clang__) && __has_attribute(acquire_capability)1018# if defined(__clang__) && __has_attribute(acquire_capability)
1255// Work around the attribute handling in clang. When both __declspec and1019// Work around the attribute handling in clang. When both __declspec and
1256// __attribute__ are present, the processing goes awry preventing the definition1020// __attribute__ are present, the processing goes awry preventing the definition
1257// of the types. In MinGW mode, __declspec evaluates to __attribute__, and thus1021// of the types. In MinGW mode, __declspec evaluates to __attribute__, and thus
1258// combining the two does work.1022// combining the two does work.
1259# if !defined(_MSC_VER)1023# if !defined(_MSC_VER)
1260# define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS1024# define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
1025# endif
1261# endif1026# endif
1262# endif1027# endif
1263#endif
12641028
1265#ifdef _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS1029# ifdef _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
1266# define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) __attribute__((x))1030# define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) __attribute__((x))
1267#else1031# else
1268# define _LIBCPP_THREAD_SAFETY_ANNOTATION(x)1032# define _LIBCPP_THREAD_SAFETY_ANNOTATION(x)
1269#endif1033# endif
12701034
1271#if __has_attribute(require_constant_initialization)1035# if _LIBCPP_STD_VER > 17
1272# define _LIBCPP_SAFE_STATIC __attribute__((__require_constant_initialization__))1036# define _LIBCPP_CONSTINIT constinit
1273#else1037# elif __has_attribute(require_constant_initialization)
1274# define _LIBCPP_SAFE_STATIC1038# define _LIBCPP_CONSTINIT __attribute__((__require_constant_initialization__))
1275#endif1039# else
1040# define _LIBCPP_CONSTINIT
1041# endif
12761042
1277#if __has_attribute(diagnose_if) && !defined(_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS)1043# if __has_attribute(diagnose_if) && !defined(_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS)
1278# define _LIBCPP_DIAGNOSE_WARNING(...) \1044# define _LIBCPP_DIAGNOSE_WARNING(...) __attribute__((diagnose_if(__VA_ARGS__, "warning")))
1279 __attribute__((diagnose_if(__VA_ARGS__, "warning")))1045# define _LIBCPP_DIAGNOSE_ERROR(...) __attribute__((diagnose_if(__VA_ARGS__, "error")))
1280# define _LIBCPP_DIAGNOSE_ERROR(...) \1046# else
1281 __attribute__((diagnose_if(__VA_ARGS__, "error")))1047# define _LIBCPP_DIAGNOSE_WARNING(...)
1282#else1048# define _LIBCPP_DIAGNOSE_ERROR(...)
1283# define _LIBCPP_DIAGNOSE_WARNING(...)1049# endif
1284# define _LIBCPP_DIAGNOSE_ERROR(...)
1285#endif
12861050
1287// Use a function like macro to imply that it must be followed by a semicolon1051// Use a function like macro to imply that it must be followed by a semicolon
1288#if __cplusplus > 201402L && __has_cpp_attribute(fallthrough)1052# if __has_cpp_attribute(fallthrough)
1289# define _LIBCPP_FALLTHROUGH() [[fallthrough]]1053# define _LIBCPP_FALLTHROUGH() [[fallthrough]]
1290#elif __has_cpp_attribute(clang::fallthrough)1054# elif __has_attribute(__fallthrough__)
1291# define _LIBCPP_FALLTHROUGH() [[clang::fallthrough]]1055# define _LIBCPP_FALLTHROUGH() __attribute__((__fallthrough__))
1292#elif __has_attribute(__fallthrough__)1056# else
1293# define _LIBCPP_FALLTHROUGH() __attribute__((__fallthrough__))1057# define _LIBCPP_FALLTHROUGH() ((void)0)
1294#else1058# endif
1295# define _LIBCPP_FALLTHROUGH() ((void)0)
1296#endif
12971059
1298#if __has_attribute(__nodebug__)1060# if __has_attribute(__nodebug__)
1299#define _LIBCPP_NODEBUG __attribute__((__nodebug__))1061# define _LIBCPP_NODEBUG __attribute__((__nodebug__))
1300#else1062# else
1301#define _LIBCPP_NODEBUG1063# define _LIBCPP_NODEBUG
1302#endif1064# endif
13031065
1304#if __has_attribute(__standalone_debug__)1066# if __has_attribute(__standalone_debug__)
1305#define _LIBCPP_STANDALONE_DEBUG __attribute__((__standalone_debug__))1067# define _LIBCPP_STANDALONE_DEBUG __attribute__((__standalone_debug__))
1306#else1068# else
1307#define _LIBCPP_STANDALONE_DEBUG1069# define _LIBCPP_STANDALONE_DEBUG
1308#endif1070# endif
13091071
1310#if __has_attribute(__preferred_name__)1072# if __has_attribute(__preferred_name__)
1311#define _LIBCPP_PREFERRED_NAME(x) __attribute__((__preferred_name__(x)))1073# define _LIBCPP_PREFERRED_NAME(x) __attribute__((__preferred_name__(x)))
1312#else1074# else
1313#define _LIBCPP_PREFERRED_NAME(x)1075# define _LIBCPP_PREFERRED_NAME(x)
1314#endif1076# endif
13151077
1316// We often repeat things just for handling wide characters in the library.1078// We often repeat things just for handling wide characters in the library.
1317// When wide characters are disabled, it can be useful to have a quick way of1079// When wide characters are disabled, it can be useful to have a quick way of
1318// disabling it without having to resort to #if-#endif, which has a larger1080// disabling it without having to resort to #if-#endif, which has a larger
1319// impact on readability.1081// impact on readability.
1320#if defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)1082# if defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
1321# define _LIBCPP_IF_WIDE_CHARACTERS(...)1083# define _LIBCPP_IF_WIDE_CHARACTERS(...)
1322#else1084# else
1323# define _LIBCPP_IF_WIDE_CHARACTERS(...) __VA_ARGS__1085# define _LIBCPP_IF_WIDE_CHARACTERS(...) __VA_ARGS__
1324#endif1086# endif
1325
1326#if defined(_LIBCPP_ABI_MICROSOFT) && \
1327 (defined(_LIBCPP_COMPILER_MSVC) || __has_declspec_attribute(empty_bases))
1328# define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases)
1329#else
1330# define _LIBCPP_DECLSPEC_EMPTY_BASES
1331#endif
1332
1333#if defined(_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES)
1334#define _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR
1335#define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS
1336#define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE
1337#define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS
1338#endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES
1339
1340#if defined(_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES)
1341#define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS
1342#define _LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS
1343#define _LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS
1344#define _LIBCPP_ENABLE_CXX20_REMOVED_RAW_STORAGE_ITERATOR
1345#define _LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS
1346#endif // _LIBCPP_ENABLE_CXX20_REMOVED_FEATURES
1347
1348#if !defined(__cpp_impl_coroutine) || __cpp_impl_coroutine < 201902L
1349#define _LIBCPP_HAS_NO_CXX20_COROUTINES
1350#endif
1351
1352#if defined(_LIBCPP_COMPILER_IBM)
1353#define _LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO
1354#endif
13551087
1356#if defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO)1088# if defined(_LIBCPP_ABI_MICROSOFT) && (defined(_LIBCPP_COMPILER_MSVC) || __has_declspec_attribute(empty_bases))
1357# define _LIBCPP_PUSH_MACROS1089# define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases)
1358# define _LIBCPP_POP_MACROS
1359#else
1360 // Don't warn about macro conflicts when we can restore them at the
1361 // end of the header.
1362# ifndef _LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS
1363# define _LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS
1364# endif
1365# if defined(_LIBCPP_COMPILER_MSVC)
1366# define _LIBCPP_PUSH_MACROS \
1367 __pragma(push_macro("min")) \
1368 __pragma(push_macro("max"))
1369# define _LIBCPP_POP_MACROS \
1370 __pragma(pop_macro("min")) \
1371 __pragma(pop_macro("max"))
1372# else1090# else
1373# define _LIBCPP_PUSH_MACROS \1091# define _LIBCPP_DECLSPEC_EMPTY_BASES
1374 _Pragma("push_macro(\"min\")") \
1375 _Pragma("push_macro(\"max\")")
1376# define _LIBCPP_POP_MACROS \
1377 _Pragma("pop_macro(\"min\")") \
1378 _Pragma("pop_macro(\"max\")")
1379# endif1092# endif
1380#endif // defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO)
13811093
1382#ifndef _LIBCPP_NO_AUTO_LINK1094# if defined(_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES)
1383# if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)1095# define _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR
1384# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)1096# define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS
1385# pragma comment(lib, "c++.lib")1097# define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE
1386# else1098# define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS
1387# pragma comment(lib, "libc++.lib")1099# define _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION
1388# endif1100# endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES
1389# endif // defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)1101
1390#endif // _LIBCPP_NO_AUTO_LINK1102# if defined(_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES)
1103# define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS
1104# define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_VOID_SPECIALIZATION
1105# define _LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS
1106# define _LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS
1107# define _LIBCPP_ENABLE_CXX20_REMOVED_RAW_STORAGE_ITERATOR
1108# define _LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS
1109# endif // _LIBCPP_ENABLE_CXX20_REMOVED_FEATURES
1110
1111# if !defined(__cpp_impl_coroutine) || __cpp_impl_coroutine < 201902L
1112# define _LIBCPP_HAS_NO_CXX20_COROUTINES
1113# endif
1114
1115# define _LIBCPP_PUSH_MACROS _Pragma("push_macro(\"min\")") _Pragma("push_macro(\"max\")")
1116# define _LIBCPP_POP_MACROS _Pragma("pop_macro(\"min\")") _Pragma("pop_macro(\"max\")")
1117
1118# ifndef _LIBCPP_NO_AUTO_LINK
1119# if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
1120# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
1121# pragma comment(lib, "c++.lib")
1122# else
1123# pragma comment(lib, "libc++.lib")
1124# endif
1125# endif // defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
1126# endif // _LIBCPP_NO_AUTO_LINK
13911127
1392// Configures the fopen close-on-exec mode character, if any. This string will1128// Configures the fopen close-on-exec mode character, if any. This string will
1393// be appended to any mode string used by fstream for fopen/fdopen.1129// be appended to any mode string used by fstream for fopen/fdopen.
1394//1130//
1395// Not all platforms support this, but it helps avoid fd-leaks on platforms that1131// Not all platforms support this, but it helps avoid fd-leaks on platforms that
1396// do.1132// do.
1397#if defined(__BIONIC__)1133# if defined(__BIONIC__)
1398# define _LIBCPP_FOPEN_CLOEXEC_MODE "e"1134# define _LIBCPP_FOPEN_CLOEXEC_MODE "e"
1399#else1135# else
1400# define _LIBCPP_FOPEN_CLOEXEC_MODE1136# define _LIBCPP_FOPEN_CLOEXEC_MODE
1401#endif1137# endif
14021138
1403// Support for _FILE_OFFSET_BITS=64 landed gradually in Android, so the full set1139// Support for _FILE_OFFSET_BITS=64 landed gradually in Android, so the full set
1404// of functions used in cstdio may not be available for low API levels when1140// of functions used in cstdio may not be available for low API levels when
1405// using 64-bit file offsets on LP32.1141// using 64-bit file offsets on LP32.
1406#if defined(__BIONIC__) && defined(__USE_FILE_OFFSET64) && __ANDROID_API__ < 241142# if defined(__BIONIC__) && defined(__USE_FILE_OFFSET64) && __ANDROID_API__ < 24
1407#define _LIBCPP_HAS_NO_FGETPOS_FSETPOS1143# define _LIBCPP_HAS_NO_FGETPOS_FSETPOS
1408#endif1144# endif
14091145
1410#if __has_attribute(init_priority)1146# if __has_attribute(init_priority)
1411 // TODO: Remove this once we drop support for building libc++ with old Clangs1147// TODO: Remove this once we drop support for building libc++ with old Clangs
1412# if (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 1200) || \1148# if (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 1200) || \
1413 (defined(__apple_build_version__) && __apple_build_version__ < 13000000)1149 (defined(__apple_build_version__) && __apple_build_version__ < 13000000)
1414# define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(101)))1150# define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(101)))
1415# else1151# else
1416# define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(100)))1152# define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(100)))
1417# endif1153# endif
1418#else1154# else
1419# define _LIBCPP_INIT_PRIORITY_MAX1155# define _LIBCPP_INIT_PRIORITY_MAX
1420#endif1156# endif
14211157
1422#if defined(__GNUC__) || defined(__clang__)1158# if defined(__GNUC__) || defined(__clang__)
1423 // The attribute uses 1-based indices for ordinary and static member functions.1159// The attribute uses 1-based indices for ordinary and static member functions.
1424 // The attribute uses 2-based indices for non-static member functions.1160// The attribute uses 2-based indices for non-static member functions.
1425# define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) \1161# define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) \
1426 __attribute__((__format__(archetype, format_string_index, first_format_arg_index)))1162 __attribute__((__format__(archetype, format_string_index, first_format_arg_index)))
1427#else1163# else
1428# define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) /* nothing */1164# define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) /* nothing */
1429#endif1165# endif
1166
1167# if __has_cpp_attribute(msvc::no_unique_address)
1168// MSVC implements [[no_unique_address]] as a silent no-op currently.
1169// (If/when MSVC breaks its C++ ABI, it will be changed to work as intended.)
1170// However, MSVC implements [[msvc::no_unique_address]] which does what
1171// [[no_unique_address]] is supposed to do, in general.
1172
1173// Clang-cl does not yet (14.0) implement either [[no_unique_address]] or
1174// [[msvc::no_unique_address]] though. If/when it does implement
1175// [[msvc::no_unique_address]], this should be preferred though.
1176# define _LIBCPP_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]
1177# elif __has_cpp_attribute(no_unique_address)
1178# define _LIBCPP_NO_UNIQUE_ADDRESS [[no_unique_address]]
1179# else
1180# define _LIBCPP_NO_UNIQUE_ADDRESS /* nothing */
1181// Note that this can be replaced by #error as soon as clang-cl
1182// implements msvc::no_unique_address, since there should be no C++20
1183// compiler that doesn't support one of the two attributes at that point.
1184// We generally don't want to use this macro outside of C++20-only code,
1185// because using it conditionally in one language version only would make
1186// the ABI inconsistent.
1187# endif
1188
1189# ifdef _LIBCPP_COMPILER_CLANG_BASED
1190# define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
1191# define _LIBCPP_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
1192# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(clang diagnostic ignored str))
1193# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str)
1194# elif defined(_LIBCPP_COMPILER_GCC)
1195# define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
1196# define _LIBCPP_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
1197# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str)
1198# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(GCC diagnostic ignored str))
1199# else
1200# define _LIBCPP_DIAGNOSTIC_PUSH
1201# define _LIBCPP_DIAGNOSTIC_POP
1202# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str)
1203# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str)
1204# endif
1205
1206# if defined(_AIX) && !defined(_LIBCPP_COMPILER_GCC)
1207# define _LIBCPP_PACKED_BYTE_FOR_AIX _Pragma("pack(1)")
1208# define _LIBCPP_PACKED_BYTE_FOR_AIX_END _Pragma("pack(pop)")
1209# else
1210# define _LIBCPP_PACKED_BYTE_FOR_AIX /* empty */
1211# define _LIBCPP_PACKED_BYTE_FOR_AIX_END /* empty */
1212# endif
1213
1214# if __has_attribute(__packed__)
1215# define _LIBCPP_PACKED __attribute__((__packed__))
1216# else
1217# define _LIBCPP_PACKED
1218# endif
14301219
1431#endif // __cplusplus1220#endif // __cplusplus
14321221
1433#endif // _LIBCPP_CONFIG1222#endif // _LIBCPP___CONFIG
lib/libcxx/include/__coroutine/coroutine_handle.h+2-2
...@@ -9,15 +9,15 @@...@@ -9,15 +9,15 @@
9#ifndef _LIBCPP___COROUTINE_COROUTINE_HANDLE_H9#ifndef _LIBCPP___COROUTINE_COROUTINE_HANDLE_H
10#define _LIBCPP___COROUTINE_COROUTINE_HANDLE_H10#define _LIBCPP___COROUTINE_COROUTINE_HANDLE_H
1111
12#include <__assert>
12#include <__config>13#include <__config>
13#include <__debug>
14#include <__functional/hash.h>14#include <__functional/hash.h>
15#include <__memory/addressof.h>15#include <__memory/addressof.h>
16#include <compare>16#include <compare>
17#include <type_traits>17#include <type_traits>
1818
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20#pragma GCC system_header20# pragma GCC system_header
21#endif21#endif
2222
23#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES)23#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES)
lib/libcxx/include/__coroutine/coroutine_traits.h+1-1
...@@ -13,7 +13,7 @@...@@ -13,7 +13,7 @@
13#include <type_traits>13#include <type_traits>
1414
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16#pragma GCC system_header16# pragma GCC system_header
17#endif17#endif
1818
19#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES)19#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES)
lib/libcxx/include/__coroutine/noop_coroutine_handle.h+2-2
...@@ -13,7 +13,7 @@...@@ -13,7 +13,7 @@
13#include <__coroutine/coroutine_handle.h>13#include <__coroutine/coroutine_handle.h>
1414
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16#pragma GCC system_header16# pragma GCC system_header
17#endif17#endif
1818
19#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES)19#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES)
...@@ -66,7 +66,7 @@ private:...@@ -66,7 +66,7 @@ private:
66 friend coroutine_handle<noop_coroutine_promise> noop_coroutine() noexcept;66 friend coroutine_handle<noop_coroutine_promise> noop_coroutine() noexcept;
6767
68#if __has_builtin(__builtin_coro_noop)68#if __has_builtin(__builtin_coro_noop)
69 _LIBCPP_HIDE_FROM_ABI coroutine_handle() noexcept { 69 _LIBCPP_HIDE_FROM_ABI coroutine_handle() noexcept {
70 this->__handle_ = __builtin_coro_noop();70 this->__handle_ = __builtin_coro_noop();
71 }71 }
7272
lib/libcxx/include/__coroutine/trivial_awaitables.h+1-1
...@@ -13,7 +13,7 @@...@@ -13,7 +13,7 @@
13#include <__coroutine/coroutine_handle.h>13#include <__coroutine/coroutine_handle.h>
1414
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16#pragma GCC system_header16# pragma GCC system_header
17#endif17#endif
1818
19#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES)19#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES)
lib/libcxx/include/__debug+58-85
...@@ -7,80 +7,37 @@...@@ -7,80 +7,37 @@
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
99
10#ifndef _LIBCPP_DEBUG_H10#ifndef _LIBCPP___DEBUG
11#define _LIBCPP_DEBUG_H11#define _LIBCPP___DEBUG
1212
13#include <__assert>
13#include <__config>14#include <__config>
14#include <iosfwd>15#include <cstddef>
15#include <type_traits>16#include <type_traits>
1617
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header19# pragma GCC system_header
19#endif20#endif
2021
21#if defined(_LIBCPP_HAS_NO_NULLPTR)22// Catch invalid uses of the legacy _LIBCPP_DEBUG toggle.
22# include <cstddef>23#if defined(_LIBCPP_DEBUG) && _LIBCPP_DEBUG != 0 && !defined(_LIBCPP_ENABLE_DEBUG_MODE)
24# error "Enabling the debug mode now requires having configured the library with support for the debug mode"
23#endif25#endif
2426
25#if _LIBCPP_DEBUG_LEVEL >= 1 || defined(_LIBCPP_BUILDING_LIBRARY)27#if defined(_LIBCPP_ENABLE_DEBUG_MODE) && !defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY)
26# include <cstddef>28# define _LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY
27# include <cstdio>
28# include <cstdlib>
29#endif29#endif
3030
31#if _LIBCPP_DEBUG_LEVEL == 031#ifdef _LIBCPP_ENABLE_DEBUG_MODE
32# define _LIBCPP_DEBUG_ASSERT(x, m) ((void)0)32# define _LIBCPP_DEBUG_ASSERT(x, m) _LIBCPP_ASSERT(::std::__libcpp_is_constant_evaluated() || (x), m)
33# define _LIBCPP_ASSERT_IMPL(x, m) ((void)0)
34#elif _LIBCPP_DEBUG_LEVEL == 1
35# define _LIBCPP_DEBUG_ASSERT(x, m) ((void)0)
36# define _LIBCPP_ASSERT_IMPL(x, m) ((x) ? (void)0 : _VSTD::__libcpp_debug_function(_VSTD::__libcpp_debug_info(__FILE__, __LINE__, #x, m)))
37#elif _LIBCPP_DEBUG_LEVEL == 2
38# define _LIBCPP_DEBUG_ASSERT(x, m) _LIBCPP_ASSERT(__libcpp_is_constant_evaluated() || (x), m)
39# define _LIBCPP_ASSERT_IMPL(x, m) ((x) ? (void)0 : _VSTD::__libcpp_debug_function(_VSTD::__libcpp_debug_info(__FILE__, __LINE__, #x, m)))
40#else33#else
41# error _LIBCPP_DEBUG_LEVEL must be one of 0, 1, 234# define _LIBCPP_DEBUG_ASSERT(x, m) ((void)0)
42#endif35#endif
4336
44#if !defined(_LIBCPP_ASSERT)37#if defined(_LIBCPP_ENABLE_DEBUG_MODE) || defined(_LIBCPP_BUILDING_LIBRARY)
45# define _LIBCPP_ASSERT(x, m) _LIBCPP_ASSERT_IMPL(x, m)
46#endif
4738
48_LIBCPP_BEGIN_NAMESPACE_STD39_LIBCPP_BEGIN_NAMESPACE_STD
4940
50struct _LIBCPP_TEMPLATE_VIS __libcpp_debug_info {
51 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
52 __libcpp_debug_info()
53 : __file_(nullptr), __line_(-1), __pred_(nullptr), __msg_(nullptr) {}
54 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
55 __libcpp_debug_info(const char* __f, int __l, const char* __p, const char* __m)
56 : __file_(__f), __line_(__l), __pred_(__p), __msg_(__m) {}
57
58 _LIBCPP_FUNC_VIS string what() const;
59
60 const char* __file_;
61 int __line_;
62 const char* __pred_;
63 const char* __msg_;
64};
65
66/// __libcpp_debug_function_type - The type of the assertion failure handler.
67typedef void(*__libcpp_debug_function_type)(__libcpp_debug_info const&);
68
69/// __libcpp_debug_function - The handler function called when a _LIBCPP_ASSERT
70/// fails.
71extern _LIBCPP_EXPORTED_FROM_ABI __libcpp_debug_function_type __libcpp_debug_function;
72
73/// __libcpp_abort_debug_function - A debug handler that aborts when called.
74_LIBCPP_NORETURN _LIBCPP_FUNC_VIS
75void __libcpp_abort_debug_function(__libcpp_debug_info const&);
76
77/// __libcpp_set_debug_function - Set the debug handler to the specified
78/// function.
79_LIBCPP_FUNC_VIS
80bool __libcpp_set_debug_function(__libcpp_debug_function_type __func);
81
82#if _LIBCPP_DEBUG_LEVEL == 2 || defined(_LIBCPP_BUILDING_LIBRARY)
83
84struct _LIBCPP_TYPE_VIS __c_node;41struct _LIBCPP_TYPE_VIS __c_node;
8542
86struct _LIBCPP_TYPE_VIS __i_node43struct _LIBCPP_TYPE_VIS __i_node
...@@ -89,15 +46,9 @@ struct _LIBCPP_TYPE_VIS __i_node...@@ -89,15 +46,9 @@ struct _LIBCPP_TYPE_VIS __i_node
89 __i_node* __next_;46 __i_node* __next_;
90 __c_node* __c_;47 __c_node* __c_;
9148
92#ifndef _LIBCPP_CXX03_LANG
93 __i_node(const __i_node&) = delete;49 __i_node(const __i_node&) = delete;
94 __i_node& operator=(const __i_node&) = delete;50 __i_node& operator=(const __i_node&) = delete;
95#else51
96private:
97 __i_node(const __i_node&);
98 __i_node& operator=(const __i_node&);
99public:
100#endif
101 _LIBCPP_INLINE_VISIBILITY52 _LIBCPP_INLINE_VISIBILITY
102 __i_node(void* __i, __i_node* __next, __c_node* __c)53 __i_node(void* __i, __i_node* __next, __c_node* __c)
103 : __i_(__i), __next_(__next), __c_(__c) {}54 : __i_(__i), __next_(__next), __c_(__c) {}
...@@ -112,17 +63,11 @@ struct _LIBCPP_TYPE_VIS __c_node...@@ -112,17 +63,11 @@ struct _LIBCPP_TYPE_VIS __c_node
112 __i_node** end_;63 __i_node** end_;
113 __i_node** cap_;64 __i_node** cap_;
11465
115#ifndef _LIBCPP_CXX03_LANG
116 __c_node(const __c_node&) = delete;66 __c_node(const __c_node&) = delete;
117 __c_node& operator=(const __c_node&) = delete;67 __c_node& operator=(const __c_node&) = delete;
118#else68
119private:
120 __c_node(const __c_node&);
121 __c_node& operator=(const __c_node&);
122public:
123#endif
124 _LIBCPP_INLINE_VISIBILITY69 _LIBCPP_INLINE_VISIBILITY
125 __c_node(void* __c, __c_node* __next)70 explicit __c_node(void* __c, __c_node* __next)
126 : __c_(__c), __next_(__next), beg_(nullptr), end_(nullptr), cap_(nullptr) {}71 : __c_(__c), __next_(__next), beg_(nullptr), end_(nullptr), cap_(nullptr) {}
127 virtual ~__c_node();72 virtual ~__c_node();
12873
...@@ -139,7 +84,7 @@ template <class _Cont>...@@ -139,7 +84,7 @@ template <class _Cont>
139struct _C_node84struct _C_node
140 : public __c_node85 : public __c_node
141{86{
142 _C_node(void* __c, __c_node* __n)87 explicit _C_node(void* __c, __c_node* __n)
143 : __c_node(__c, __n) {}88 : __c_node(__c, __n) {}
14489
145 virtual bool __dereferenceable(const void*) const;90 virtual bool __dereferenceable(const void*) const;
...@@ -197,17 +142,11 @@ class _LIBCPP_TYPE_VIS __libcpp_db...@@ -197,17 +142,11 @@ class _LIBCPP_TYPE_VIS __libcpp_db
197 __i_node** __iend_;142 __i_node** __iend_;
198 size_t __isz_;143 size_t __isz_;
199144
200 __libcpp_db();145 explicit __libcpp_db();
201public:146public:
202#ifndef _LIBCPP_CXX03_LANG
203 __libcpp_db(const __libcpp_db&) = delete;147 __libcpp_db(const __libcpp_db&) = delete;
204 __libcpp_db& operator=(const __libcpp_db&) = delete;148 __libcpp_db& operator=(const __libcpp_db&) = delete;
205#else149
206private:
207 __libcpp_db(const __libcpp_db&);
208 __libcpp_db& operator=(const __libcpp_db&);
209public:
210#endif
211 ~__libcpp_db();150 ~__libcpp_db();
212151
213 class __db_c_iterator;152 class __db_c_iterator;
...@@ -266,12 +205,15 @@ private:...@@ -266,12 +205,15 @@ private:
266_LIBCPP_FUNC_VIS __libcpp_db* __get_db();205_LIBCPP_FUNC_VIS __libcpp_db* __get_db();
267_LIBCPP_FUNC_VIS const __libcpp_db* __get_const_db();206_LIBCPP_FUNC_VIS const __libcpp_db* __get_const_db();
268207
208_LIBCPP_END_NAMESPACE_STD
269209
270#endif // _LIBCPP_DEBUG_LEVEL == 2 || defined(_LIBCPP_BUILDING_LIBRARY)210#endif // defined(_LIBCPP_ENABLE_DEBUG_MODE) || defined(_LIBCPP_BUILDING_LIBRARY)
211
212_LIBCPP_BEGIN_NAMESPACE_STD
271213
272template <class _Tp>214template <class _Tp>
273_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_insert_c(_Tp* __c) {215_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_insert_c(_Tp* __c) {
274#if _LIBCPP_DEBUG_LEVEL == 2216#ifdef _LIBCPP_ENABLE_DEBUG_MODE
275 if (!__libcpp_is_constant_evaluated())217 if (!__libcpp_is_constant_evaluated())
276 __get_db()->__insert_c(__c);218 __get_db()->__insert_c(__c);
277#else219#else
...@@ -281,7 +223,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_inser...@@ -281,7 +223,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_inser
281223
282template <class _Tp>224template <class _Tp>
283_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_insert_i(_Tp* __i) {225_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_insert_i(_Tp* __i) {
284#if _LIBCPP_DEBUG_LEVEL == 2226#ifdef _LIBCPP_ENABLE_DEBUG_MODE
285 if (!__libcpp_is_constant_evaluated())227 if (!__libcpp_is_constant_evaluated())
286 __get_db()->__insert_i(__i);228 __get_db()->__insert_i(__i);
287#else229#else
...@@ -289,6 +231,37 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_inser...@@ -289,6 +231,37 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_inser
289#endif231#endif
290}232}
291233
234template <class _Tp>
235_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_erase_c(_Tp* __c) {
236#ifdef _LIBCPP_ENABLE_DEBUG_MODE
237 if (!__libcpp_is_constant_evaluated())
238 __get_db()->__erase_c(__c);
239#else
240 (void)(__c);
241#endif
242}
243
244template <class _Tp>
245_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_swap(_Tp* __lhs, _Tp* __rhs) {
246#ifdef _LIBCPP_ENABLE_DEBUG_MODE
247 if (!__libcpp_is_constant_evaluated())
248 __get_db()->swap(__lhs, __rhs);
249#else
250 (void)(__lhs);
251 (void)(__rhs);
252#endif
253}
254
255template <class _Tp>
256_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_invalidate_all(_Tp* __c) {
257#ifdef _LIBCPP_ENABLE_DEBUG_MODE
258 if (!__libcpp_is_constant_evaluated())
259 __get_db()->__invalidate_all(__c);
260#else
261 (void)(__c);
262#endif
263}
264
292_LIBCPP_END_NAMESPACE_STD265_LIBCPP_END_NAMESPACE_STD
293266
294#endif // _LIBCPP_DEBUG_H267#endif // _LIBCPP___DEBUG
lib/libcxx/include/__debug_utils/randomize_range.h created+43
...@@ -0,0 +1,43 @@
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___LIBCXX_DEBUG_RANDOMIZE_RANGE_H
10#define _LIBCPP___LIBCXX_DEBUG_RANDOMIZE_RANGE_H
11
12#include <__config>
13
14#ifdef _LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY
15# include <__algorithm/shuffle.h>
16# include <__type_traits/is_constant_evaluated.h>
17#endif
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 _AlgPolicy, class _Iterator, class _Sentinel>
26_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
27void __debug_randomize_range(_Iterator __first, _Sentinel __last) {
28#ifdef _LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY
29# ifdef _LIBCPP_CXX03_LANG
30# error Support for unspecified stability is only for C++11 and higher
31# endif
32
33 if (!__libcpp_is_constant_evaluated())
34 std::__shuffle<_AlgPolicy>(__first, __last, __libcpp_debug_randomizer());
35#else
36 (void)__first;
37 (void)__last;
38#endif
39}
40
41_LIBCPP_END_NAMESPACE_STD
42
43#endif // _LIBCPP___LIBCXX_DEBUG_RANDOMIZE_RANGE_H
lib/libcxx/include/__errc+1-1
...@@ -104,7 +104,7 @@ enum class errc...@@ -104,7 +104,7 @@ enum class errc
104#include <cerrno>104#include <cerrno>
105105
106#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)106#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
107#pragma GCC system_header107# pragma GCC system_header
108#endif108#endif
109109
110_LIBCPP_BEGIN_NAMESPACE_STD110_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__filesystem/copy_options.h+21-17
...@@ -13,6 +13,10 @@...@@ -13,6 +13,10 @@
13#include <__availability>13#include <__availability>
14#include <__config>14#include <__config>
1515
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header
18#endif
19
16#ifndef _LIBCPP_CXX03_LANG20#ifndef _LIBCPP_CXX03_LANG
1721
18_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM22_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
...@@ -34,41 +38,41 @@ enum class _LIBCPP_ENUM_VIS copy_options : unsigned short {...@@ -34,41 +38,41 @@ enum class _LIBCPP_ENUM_VIS copy_options : unsigned short {
34};38};
3539
36_LIBCPP_INLINE_VISIBILITY40_LIBCPP_INLINE_VISIBILITY
37inline constexpr copy_options operator&(copy_options _LHS, copy_options _RHS) {41inline constexpr copy_options operator&(copy_options __lhs, copy_options __rhs) {
38 return static_cast<copy_options>(static_cast<unsigned short>(_LHS) &42 return static_cast<copy_options>(static_cast<unsigned short>(__lhs) &
39 static_cast<unsigned short>(_RHS));43 static_cast<unsigned short>(__rhs));
40}44}
4145
42_LIBCPP_INLINE_VISIBILITY46_LIBCPP_INLINE_VISIBILITY
43inline constexpr copy_options operator|(copy_options _LHS, copy_options _RHS) {47inline constexpr copy_options operator|(copy_options __lhs, copy_options __rhs) {
44 return static_cast<copy_options>(static_cast<unsigned short>(_LHS) |48 return static_cast<copy_options>(static_cast<unsigned short>(__lhs) |
45 static_cast<unsigned short>(_RHS));49 static_cast<unsigned short>(__rhs));
46}50}
4751
48_LIBCPP_INLINE_VISIBILITY52_LIBCPP_INLINE_VISIBILITY
49inline constexpr copy_options operator^(copy_options _LHS, copy_options _RHS) {53inline constexpr copy_options operator^(copy_options __lhs, copy_options __rhs) {
50 return static_cast<copy_options>(static_cast<unsigned short>(_LHS) ^54 return static_cast<copy_options>(static_cast<unsigned short>(__lhs) ^
51 static_cast<unsigned short>(_RHS));55 static_cast<unsigned short>(__rhs));
52}56}
5357
54_LIBCPP_INLINE_VISIBILITY58_LIBCPP_INLINE_VISIBILITY
55inline constexpr copy_options operator~(copy_options _LHS) {59inline constexpr copy_options operator~(copy_options __lhs) {
56 return static_cast<copy_options>(~static_cast<unsigned short>(_LHS));60 return static_cast<copy_options>(~static_cast<unsigned short>(__lhs));
57}61}
5862
59_LIBCPP_INLINE_VISIBILITY63_LIBCPP_INLINE_VISIBILITY
60inline copy_options& operator&=(copy_options& _LHS, copy_options _RHS) {64inline copy_options& operator&=(copy_options& __lhs, copy_options __rhs) {
61 return _LHS = _LHS & _RHS;65 return __lhs = __lhs & __rhs;
62}66}
6367
64_LIBCPP_INLINE_VISIBILITY68_LIBCPP_INLINE_VISIBILITY
65inline copy_options& operator|=(copy_options& _LHS, copy_options _RHS) {69inline copy_options& operator|=(copy_options& __lhs, copy_options __rhs) {
66 return _LHS = _LHS | _RHS;70 return __lhs = __lhs | __rhs;
67}71}
6872
69_LIBCPP_INLINE_VISIBILITY73_LIBCPP_INLINE_VISIBILITY
70inline copy_options& operator^=(copy_options& _LHS, copy_options _RHS) {74inline copy_options& operator^=(copy_options& __lhs, copy_options __rhs) {
71 return _LHS = _LHS ^ _RHS;75 return __lhs = __lhs ^ __rhs;
72}76}
7377
74_LIBCPP_AVAILABILITY_FILESYSTEM_POP78_LIBCPP_AVAILABILITY_FILESYSTEM_POP
lib/libcxx/include/__filesystem/directory_entry.h+13-8
...@@ -11,6 +11,7 @@...@@ -11,6 +11,7 @@
11#define _LIBCPP___FILESYSTEM_DIRECTORY_ENTRY_H11#define _LIBCPP___FILESYSTEM_DIRECTORY_ENTRY_H
1212
13#include <__availability>13#include <__availability>
14#include <__chrono/time_point.h>
14#include <__config>15#include <__config>
15#include <__errc>16#include <__errc>
16#include <__filesystem/file_status.h>17#include <__filesystem/file_status.h>
...@@ -20,12 +21,16 @@...@@ -20,12 +21,16 @@
20#include <__filesystem/operations.h>21#include <__filesystem/operations.h>
21#include <__filesystem/path.h>22#include <__filesystem/path.h>
22#include <__filesystem/perms.h>23#include <__filesystem/perms.h>
23#include <chrono>24#include <__utility/unreachable.h>
24#include <cstdint>25#include <cstdint>
25#include <cstdlib>26#include <cstdlib>
26#include <iosfwd>27#include <iosfwd>
27#include <system_error>28#include <system_error>
2829
30#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
31# pragma GCC system_header
32#endif
33
29_LIBCPP_PUSH_MACROS34_LIBCPP_PUSH_MACROS
30#include <__undef_macros>35#include <__undef_macros>
3136
...@@ -358,7 +363,7 @@ private:...@@ -358,7 +363,7 @@ private:
358 __ec->clear();363 __ec->clear();
359 return __data_.__type_;364 return __data_.__type_;
360 }365 }
361 _LIBCPP_UNREACHABLE();366 __libcpp_unreachable();
362 }367 }
363368
364 _LIBCPP_INLINE_VISIBILITY369 _LIBCPP_INLINE_VISIBILITY
...@@ -379,7 +384,7 @@ private:...@@ -379,7 +384,7 @@ private:
379 return __data_.__type_;384 return __data_.__type_;
380 }385 }
381 }386 }
382 _LIBCPP_UNREACHABLE();387 __libcpp_unreachable();
383 }388 }
384389
385 _LIBCPP_INLINE_VISIBILITY390 _LIBCPP_INLINE_VISIBILITY
...@@ -394,7 +399,7 @@ private:...@@ -394,7 +399,7 @@ private:
394 case _RefreshSymlink:399 case _RefreshSymlink:
395 return file_status(__get_ft(__ec), __data_.__non_sym_perms_);400 return file_status(__get_ft(__ec), __data_.__non_sym_perms_);
396 }401 }
397 _LIBCPP_UNREACHABLE();402 __libcpp_unreachable();
398 }403 }
399404
400 _LIBCPP_INLINE_VISIBILITY405 _LIBCPP_INLINE_VISIBILITY
...@@ -410,7 +415,7 @@ private:...@@ -410,7 +415,7 @@ private:
410 case _RefreshSymlinkUnresolved:415 case _RefreshSymlinkUnresolved:
411 return file_status(__get_sym_ft(__ec), __data_.__sym_perms_);416 return file_status(__get_sym_ft(__ec), __data_.__sym_perms_);
412 }417 }
413 _LIBCPP_UNREACHABLE();418 __libcpp_unreachable();
414 }419 }
415420
416 _LIBCPP_INLINE_VISIBILITY421 _LIBCPP_INLINE_VISIBILITY
...@@ -435,7 +440,7 @@ private:...@@ -435,7 +440,7 @@ private:
435 return __data_.__size_;440 return __data_.__size_;
436 }441 }
437 }442 }
438 _LIBCPP_UNREACHABLE();443 __libcpp_unreachable();
439 }444 }
440445
441 _LIBCPP_INLINE_VISIBILITY446 _LIBCPP_INLINE_VISIBILITY
...@@ -454,7 +459,7 @@ private:...@@ -454,7 +459,7 @@ private:
454 return __data_.__nlink_;459 return __data_.__nlink_;
455 }460 }
456 }461 }
457 _LIBCPP_UNREACHABLE();462 __libcpp_unreachable();
458 }463 }
459464
460 _LIBCPP_INLINE_VISIBILITY465 _LIBCPP_INLINE_VISIBILITY
...@@ -477,7 +482,7 @@ private:...@@ -477,7 +482,7 @@ private:
477 return __data_.__write_time_;482 return __data_.__write_time_;
478 }483 }
479 }484 }
480 _LIBCPP_UNREACHABLE();485 __libcpp_unreachable();
481 }486 }
482487
483private:488private:
lib/libcxx/include/__filesystem/directory_iterator.h+27-12
...@@ -10,9 +10,9 @@...@@ -10,9 +10,9 @@
10#ifndef _LIBCPP___FILESYSTEM_DIRECTORY_ITERATOR_H10#ifndef _LIBCPP___FILESYSTEM_DIRECTORY_ITERATOR_H
11#define _LIBCPP___FILESYSTEM_DIRECTORY_ITERATOR_H11#define _LIBCPP___FILESYSTEM_DIRECTORY_ITERATOR_H
1212
13#include <__assert>
13#include <__availability>14#include <__availability>
14#include <__config>15#include <__config>
15#include <__debug>
16#include <__filesystem/directory_entry.h>16#include <__filesystem/directory_entry.h>
17#include <__filesystem/directory_options.h>17#include <__filesystem/directory_options.h>
18#include <__filesystem/path.h>18#include <__filesystem/path.h>
...@@ -23,6 +23,10 @@...@@ -23,6 +23,10 @@
23#include <cstddef>23#include <cstddef>
24#include <system_error>24#include <system_error>
2525
26#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
27# pragma GCC system_header
28#endif
29
26#ifndef _LIBCPP_CXX03_LANG30#ifndef _LIBCPP_CXX03_LANG
2731
28_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM32_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
...@@ -40,25 +44,31 @@ public:...@@ -40,25 +44,31 @@ public:
4044
41public:45public:
42 //ctor & dtor46 //ctor & dtor
47 _LIBCPP_HIDE_FROM_ABI
43 directory_iterator() noexcept {}48 directory_iterator() noexcept {}
4449
50 _LIBCPP_HIDE_FROM_ABI
45 explicit directory_iterator(const path& __p)51 explicit directory_iterator(const path& __p)
46 : directory_iterator(__p, nullptr) {}52 : directory_iterator(__p, nullptr) {}
4753
54 _LIBCPP_HIDE_FROM_ABI
48 directory_iterator(const path& __p, directory_options __opts)55 directory_iterator(const path& __p, directory_options __opts)
49 : directory_iterator(__p, nullptr, __opts) {}56 : directory_iterator(__p, nullptr, __opts) {}
5057
58 _LIBCPP_HIDE_FROM_ABI
51 directory_iterator(const path& __p, error_code& __ec)59 directory_iterator(const path& __p, error_code& __ec)
52 : directory_iterator(__p, &__ec) {}60 : directory_iterator(__p, &__ec) {}
5361
62 _LIBCPP_HIDE_FROM_ABI
54 directory_iterator(const path& __p, directory_options __opts,63 directory_iterator(const path& __p, directory_options __opts,
55 error_code& __ec)64 error_code& __ec)
56 : directory_iterator(__p, &__ec, __opts) {}65 : directory_iterator(__p, &__ec, __opts) {}
5766
58 directory_iterator(const directory_iterator&) = default;67 _LIBCPP_HIDE_FROM_ABI directory_iterator(const directory_iterator&) = default;
59 directory_iterator(directory_iterator&&) = default;68 _LIBCPP_HIDE_FROM_ABI directory_iterator(directory_iterator&&) = default;
60 directory_iterator& operator=(const directory_iterator&) = default;69 _LIBCPP_HIDE_FROM_ABI directory_iterator& operator=(const directory_iterator&) = default;
6170
71 _LIBCPP_HIDE_FROM_ABI
62 directory_iterator& operator=(directory_iterator&& __o) noexcept {72 directory_iterator& operator=(directory_iterator&& __o) noexcept {
63 // non-default implementation provided to support self-move assign.73 // non-default implementation provided to support self-move assign.
64 if (this != &__o) {74 if (this != &__o) {
...@@ -67,27 +77,32 @@ public:...@@ -67,27 +77,32 @@ public:
67 return *this;77 return *this;
68 }78 }
6979
70 ~directory_iterator() = default;80 _LIBCPP_HIDE_FROM_ABI ~directory_iterator() = default;
7181
82 _LIBCPP_HIDE_FROM_ABI
72 const directory_entry& operator*() const {83 const directory_entry& operator*() const {
73 _LIBCPP_ASSERT(__imp_, "The end iterator cannot be dereferenced");84 _LIBCPP_ASSERT(__imp_, "The end iterator cannot be dereferenced");
74 return __dereference();85 return __dereference();
75 }86 }
7687
88 _LIBCPP_HIDE_FROM_ABI
77 const directory_entry* operator->() const { return &**this; }89 const directory_entry* operator->() const { return &**this; }
7890
91 _LIBCPP_HIDE_FROM_ABI
79 directory_iterator& operator++() { return __increment(); }92 directory_iterator& operator++() { return __increment(); }
8093
94 _LIBCPP_HIDE_FROM_ABI
81 __dir_element_proxy operator++(int) {95 __dir_element_proxy operator++(int) {
82 __dir_element_proxy __p(**this);96 __dir_element_proxy __p(**this);
83 __increment();97 __increment();
84 return __p;98 return __p;
85 }99 }
86100
101 _LIBCPP_HIDE_FROM_ABI
87 directory_iterator& increment(error_code& __ec) { return __increment(&__ec); }102 directory_iterator& increment(error_code& __ec) { return __increment(&__ec); }
88103
89private:104private:
90 inline _LIBCPP_INLINE_VISIBILITY friend bool105 inline _LIBCPP_HIDE_FROM_ABI friend bool
91 operator==(const directory_iterator& __lhs,106 operator==(const directory_iterator& __lhs,
92 const directory_iterator& __rhs) noexcept;107 const directory_iterator& __rhs) noexcept;
93108
...@@ -106,25 +121,25 @@ private:...@@ -106,25 +121,25 @@ private:
106 shared_ptr<__dir_stream> __imp_;121 shared_ptr<__dir_stream> __imp_;
107};122};
108123
109inline _LIBCPP_INLINE_VISIBILITY bool124inline _LIBCPP_HIDE_FROM_ABI bool
110operator==(const directory_iterator& __lhs,125operator==(const directory_iterator& __lhs,
111 const directory_iterator& __rhs) noexcept {126 const directory_iterator& __rhs) noexcept {
112 return __lhs.__imp_ == __rhs.__imp_;127 return __lhs.__imp_ == __rhs.__imp_;
113}128}
114129
115inline _LIBCPP_INLINE_VISIBILITY bool130inline _LIBCPP_HIDE_FROM_ABI bool
116operator!=(const directory_iterator& __lhs,131operator!=(const directory_iterator& __lhs,
117 const directory_iterator& __rhs) noexcept {132 const directory_iterator& __rhs) noexcept {
118 return !(__lhs == __rhs);133 return !(__lhs == __rhs);
119}134}
120135
121// enable directory_iterator range-based for statements136// enable directory_iterator range-based for statements
122inline _LIBCPP_INLINE_VISIBILITY directory_iterator137inline _LIBCPP_HIDE_FROM_ABI directory_iterator
123begin(directory_iterator __iter) noexcept {138begin(directory_iterator __iter) noexcept {
124 return __iter;139 return __iter;
125}140}
126141
127inline _LIBCPP_INLINE_VISIBILITY directory_iterator142inline _LIBCPP_HIDE_FROM_ABI directory_iterator
128end(directory_iterator) noexcept {143end(directory_iterator) noexcept {
129 return directory_iterator();144 return directory_iterator();
130}145}
...@@ -133,7 +148,7 @@ _LIBCPP_AVAILABILITY_FILESYSTEM_POP...@@ -133,7 +148,7 @@ _LIBCPP_AVAILABILITY_FILESYSTEM_POP
133148
134_LIBCPP_END_NAMESPACE_FILESYSTEM149_LIBCPP_END_NAMESPACE_FILESYSTEM
135150
136#if !defined(_LIBCPP_HAS_NO_CONCEPTS)151#if _LIBCPP_STD_VER > 17
137152
138template <>153template <>
139_LIBCPP_AVAILABILITY_FILESYSTEM154_LIBCPP_AVAILABILITY_FILESYSTEM
...@@ -143,7 +158,7 @@ template <>...@@ -143,7 +158,7 @@ template <>
143_LIBCPP_AVAILABILITY_FILESYSTEM158_LIBCPP_AVAILABILITY_FILESYSTEM
144inline constexpr bool _VSTD::ranges::enable_view<_VSTD_FS::directory_iterator> = true;159inline constexpr bool _VSTD::ranges::enable_view<_VSTD_FS::directory_iterator> = true;
145160
146#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)161#endif // _LIBCPP_STD_VER > 17
147162
148#endif // _LIBCPP_CXX03_LANG163#endif // _LIBCPP_CXX03_LANG
149164
lib/libcxx/include/__filesystem/directory_options.h+27-23
...@@ -13,6 +13,10 @@...@@ -13,6 +13,10 @@
13#include <__availability>13#include <__availability>
14#include <__config>14#include <__config>
1515
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header
18#endif
19
16#ifndef _LIBCPP_CXX03_LANG20#ifndef _LIBCPP_CXX03_LANG
1721
18_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM22_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
...@@ -26,47 +30,47 @@ enum class _LIBCPP_ENUM_VIS directory_options : unsigned char {...@@ -26,47 +30,47 @@ enum class _LIBCPP_ENUM_VIS directory_options : unsigned char {
26};30};
2731
28_LIBCPP_INLINE_VISIBILITY32_LIBCPP_INLINE_VISIBILITY
29inline constexpr directory_options operator&(directory_options _LHS,33inline constexpr directory_options operator&(directory_options __lhs,
30 directory_options _RHS) {34 directory_options __rhs) {
31 return static_cast<directory_options>(static_cast<unsigned char>(_LHS) &35 return static_cast<directory_options>(static_cast<unsigned char>(__lhs) &
32 static_cast<unsigned char>(_RHS));36 static_cast<unsigned char>(__rhs));
33}37}
3438
35_LIBCPP_INLINE_VISIBILITY39_LIBCPP_INLINE_VISIBILITY
36inline constexpr directory_options operator|(directory_options _LHS,40inline constexpr directory_options operator|(directory_options __lhs,
37 directory_options _RHS) {41 directory_options __rhs) {
38 return static_cast<directory_options>(static_cast<unsigned char>(_LHS) |42 return static_cast<directory_options>(static_cast<unsigned char>(__lhs) |
39 static_cast<unsigned char>(_RHS));43 static_cast<unsigned char>(__rhs));
40}44}
4145
42_LIBCPP_INLINE_VISIBILITY46_LIBCPP_INLINE_VISIBILITY
43inline constexpr directory_options operator^(directory_options _LHS,47inline constexpr directory_options operator^(directory_options __lhs,
44 directory_options _RHS) {48 directory_options __rhs) {
45 return static_cast<directory_options>(static_cast<unsigned char>(_LHS) ^49 return static_cast<directory_options>(static_cast<unsigned char>(__lhs) ^
46 static_cast<unsigned char>(_RHS));50 static_cast<unsigned char>(__rhs));
47}51}
4852
49_LIBCPP_INLINE_VISIBILITY53_LIBCPP_INLINE_VISIBILITY
50inline constexpr directory_options operator~(directory_options _LHS) {54inline constexpr directory_options operator~(directory_options __lhs) {
51 return static_cast<directory_options>(~static_cast<unsigned char>(_LHS));55 return static_cast<directory_options>(~static_cast<unsigned char>(__lhs));
52}56}
5357
54_LIBCPP_INLINE_VISIBILITY58_LIBCPP_INLINE_VISIBILITY
55inline directory_options& operator&=(directory_options& _LHS,59inline directory_options& operator&=(directory_options& __lhs,
56 directory_options _RHS) {60 directory_options __rhs) {
57 return _LHS = _LHS & _RHS;61 return __lhs = __lhs & __rhs;
58}62}
5963
60_LIBCPP_INLINE_VISIBILITY64_LIBCPP_INLINE_VISIBILITY
61inline directory_options& operator|=(directory_options& _LHS,65inline directory_options& operator|=(directory_options& __lhs,
62 directory_options _RHS) {66 directory_options __rhs) {
63 return _LHS = _LHS | _RHS;67 return __lhs = __lhs | __rhs;
64}68}
6569
66_LIBCPP_INLINE_VISIBILITY70_LIBCPP_INLINE_VISIBILITY
67inline directory_options& operator^=(directory_options& _LHS,71inline directory_options& operator^=(directory_options& __lhs,
68 directory_options _RHS) {72 directory_options __rhs) {
69 return _LHS = _LHS ^ _RHS;73 return __lhs = __lhs ^ __rhs;
70}74}
7175
72_LIBCPP_AVAILABILITY_FILESYSTEM_POP76_LIBCPP_AVAILABILITY_FILESYSTEM_POP
lib/libcxx/include/__filesystem/file_status.h+4
...@@ -15,6 +15,10 @@...@@ -15,6 +15,10 @@
15#include <__filesystem/file_type.h>15#include <__filesystem/file_type.h>
16#include <__filesystem/perms.h>16#include <__filesystem/perms.h>
1717
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header
20#endif
21
18#ifndef _LIBCPP_CXX03_LANG22#ifndef _LIBCPP_CXX03_LANG
1923
20_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM24_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
lib/libcxx/include/__filesystem/file_time_type.h+6-1
...@@ -11,8 +11,13 @@...@@ -11,8 +11,13 @@
11#define _LIBCPP___FILESYSTEM_FILE_TIME_TYPE_H11#define _LIBCPP___FILESYSTEM_FILE_TIME_TYPE_H
1212
13#include <__availability>13#include <__availability>
14#include <__chrono/file_clock.h>
15#include <__chrono/time_point.h>
14#include <__config>16#include <__config>
15#include <chrono>17
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header
20#endif
1621
17#ifndef _LIBCPP_CXX03_LANG22#ifndef _LIBCPP_CXX03_LANG
1823
lib/libcxx/include/__filesystem/file_type.h+4
...@@ -13,6 +13,10 @@...@@ -13,6 +13,10 @@
13#include <__availability>13#include <__availability>
14#include <__config>14#include <__config>
1515
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header
18#endif
19
16#ifndef _LIBCPP_CXX03_LANG20#ifndef _LIBCPP_CXX03_LANG
1721
18_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM22_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
lib/libcxx/include/__filesystem/filesystem_error.h+4
...@@ -19,6 +19,10 @@...@@ -19,6 +19,10 @@
19#include <system_error>19#include <system_error>
20#include <type_traits>20#include <type_traits>
2121
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23# pragma GCC system_header
24#endif
25
22#ifndef _LIBCPP_CXX03_LANG26#ifndef _LIBCPP_CXX03_LANG
2327
24_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM28_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
lib/libcxx/include/__filesystem/operations.h+112-108
...@@ -11,6 +11,7 @@...@@ -11,6 +11,7 @@
11#define _LIBCPP___FILESYSTEM_OPERATIONS_H11#define _LIBCPP___FILESYSTEM_OPERATIONS_H
1212
13#include <__availability>13#include <__availability>
14#include <__chrono/time_point.h>
14#include <__config>15#include <__config>
15#include <__filesystem/copy_options.h>16#include <__filesystem/copy_options.h>
16#include <__filesystem/file_status.h>17#include <__filesystem/file_status.h>
...@@ -20,10 +21,13 @@...@@ -20,10 +21,13 @@
20#include <__filesystem/perm_options.h>21#include <__filesystem/perm_options.h>
21#include <__filesystem/perms.h>22#include <__filesystem/perms.h>
22#include <__filesystem/space_info.h>23#include <__filesystem/space_info.h>
23#include <chrono>
24#include <cstdint>24#include <cstdint>
25#include <system_error>25#include <system_error>
2626
27#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
28# pragma GCC system_header
29#endif
30
27#ifndef _LIBCPP_CXX03_LANG31#ifndef _LIBCPP_CXX03_LANG
2832
29_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM33_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
...@@ -35,10 +39,10 @@ _LIBCPP_FUNC_VIS path __canonical(const path&, error_code* __ec = nullptr);...@@ -35,10 +39,10 @@ _LIBCPP_FUNC_VIS path __canonical(const path&, error_code* __ec = nullptr);
35_LIBCPP_FUNC_VIS bool __copy_file(const path& __from, const path& __to, copy_options __opt, error_code* __ec = nullptr);39_LIBCPP_FUNC_VIS bool __copy_file(const path& __from, const path& __to, copy_options __opt, error_code* __ec = nullptr);
36_LIBCPP_FUNC_VIS void __copy_symlink(const path& __existing_symlink, const path& __new_symlink, error_code* __ec = nullptr);40_LIBCPP_FUNC_VIS void __copy_symlink(const path& __existing_symlink, const path& __new_symlink, error_code* __ec = nullptr);
37_LIBCPP_FUNC_VIS void __copy(const path& __from, const path& __to, copy_options __opt, error_code* __ec = nullptr);41_LIBCPP_FUNC_VIS void __copy(const path& __from, const path& __to, copy_options __opt, error_code* __ec = nullptr);
38_LIBCPP_FUNC_VIS bool __create_directories(const path& p, error_code* ec = nullptr);42_LIBCPP_FUNC_VIS bool __create_directories(const path&, error_code* = nullptr);
39_LIBCPP_FUNC_VIS void __create_directory_symlink(const path& __to, const path& __new_symlink, error_code* __ec = nullptr);43_LIBCPP_FUNC_VIS void __create_directory_symlink(const path& __to, const path& __new_symlink, error_code* __ec = nullptr);
40_LIBCPP_FUNC_VIS bool __create_directory(const path& p, error_code* ec = nullptr);44_LIBCPP_FUNC_VIS bool __create_directory(const path&, error_code* = nullptr);
41_LIBCPP_FUNC_VIS bool __create_directory(const path& p, const path& attributes, error_code* ec = nullptr);45_LIBCPP_FUNC_VIS bool __create_directory(const path&, const path& __attributes, error_code* = nullptr);
42_LIBCPP_FUNC_VIS void __create_hard_link(const path& __to, const path& __new_hard_link, error_code* __ec = nullptr);46_LIBCPP_FUNC_VIS void __create_hard_link(const path& __to, const path& __new_hard_link, error_code* __ec = nullptr);
43_LIBCPP_FUNC_VIS void __create_symlink(const path& __to, const path& __new_symlink, error_code* __ec = nullptr);47_LIBCPP_FUNC_VIS void __create_symlink(const path& __to, const path& __new_symlink, error_code* __ec = nullptr);
44_LIBCPP_FUNC_VIS path __current_path(error_code* __ec = nullptr);48_LIBCPP_FUNC_VIS path __current_path(error_code* __ec = nullptr);
...@@ -48,51 +52,51 @@ _LIBCPP_FUNC_VIS file_status __status(const path&, error_code* __ec = nullptr);...@@ -48,51 +52,51 @@ _LIBCPP_FUNC_VIS file_status __status(const path&, error_code* __ec = nullptr);
48_LIBCPP_FUNC_VIS uintmax_t __file_size(const path&, error_code* __ec = nullptr);52_LIBCPP_FUNC_VIS uintmax_t __file_size(const path&, error_code* __ec = nullptr);
49_LIBCPP_FUNC_VIS uintmax_t __hard_link_count(const path&, error_code* __ec = nullptr);53_LIBCPP_FUNC_VIS uintmax_t __hard_link_count(const path&, error_code* __ec = nullptr);
50_LIBCPP_FUNC_VIS file_status __symlink_status(const path&, error_code* __ec = nullptr);54_LIBCPP_FUNC_VIS file_status __symlink_status(const path&, error_code* __ec = nullptr);
51_LIBCPP_FUNC_VIS file_time_type __last_write_time(const path& p, error_code* ec = nullptr);55_LIBCPP_FUNC_VIS file_time_type __last_write_time(const path&, error_code* __ec = nullptr);
52_LIBCPP_FUNC_VIS void __last_write_time(const path& p, file_time_type new_time, error_code* ec = nullptr);56_LIBCPP_FUNC_VIS void __last_write_time(const path&, file_time_type __new_time, error_code* __ec = nullptr);
53_LIBCPP_FUNC_VIS path __weakly_canonical(path const& __p, error_code* __ec = nullptr);57_LIBCPP_FUNC_VIS path __weakly_canonical(path const& __p, error_code* __ec = nullptr);
54_LIBCPP_FUNC_VIS path __read_symlink(const path& p, error_code* ec = nullptr);58_LIBCPP_FUNC_VIS path __read_symlink(const path&, error_code* __ec = nullptr);
55_LIBCPP_FUNC_VIS uintmax_t __remove_all(const path& p, error_code* ec = nullptr);59_LIBCPP_FUNC_VIS uintmax_t __remove_all(const path&, error_code* __ec = nullptr);
56_LIBCPP_FUNC_VIS bool __remove(const path& p, error_code* ec = nullptr);60_LIBCPP_FUNC_VIS bool __remove(const path&, error_code* __ec = nullptr);
57_LIBCPP_FUNC_VIS void __rename(const path& from, const path& to, error_code* ec = nullptr);61_LIBCPP_FUNC_VIS void __rename(const path& __from, const path& __to, error_code* __ec = nullptr);
58_LIBCPP_FUNC_VIS void __resize_file(const path& p, uintmax_t size, error_code* ec = nullptr);62_LIBCPP_FUNC_VIS void __resize_file(const path&, uintmax_t __size, error_code* = nullptr);
59_LIBCPP_FUNC_VIS path __temp_directory_path(error_code* __ec = nullptr);63_LIBCPP_FUNC_VIS path __temp_directory_path(error_code* __ec = nullptr);
6064
61inline _LIBCPP_INLINE_VISIBILITY path absolute(const path& __p) { return __absolute(__p); }65inline _LIBCPP_HIDE_FROM_ABI path absolute(const path& __p) { return __absolute(__p); }
62inline _LIBCPP_INLINE_VISIBILITY path absolute(const path& __p, error_code& __ec) { return __absolute(__p, &__ec); }66inline _LIBCPP_HIDE_FROM_ABI path absolute(const path& __p, error_code& __ec) { return __absolute(__p, &__ec); }
63inline _LIBCPP_INLINE_VISIBILITY path canonical(const path& __p) { return __canonical(__p); }67inline _LIBCPP_HIDE_FROM_ABI path canonical(const path& __p) { return __canonical(__p); }
64inline _LIBCPP_INLINE_VISIBILITY path canonical(const path& __p, error_code& __ec) { return __canonical(__p, &__ec); }68inline _LIBCPP_HIDE_FROM_ABI path canonical(const path& __p, error_code& __ec) { return __canonical(__p, &__ec); }
65inline _LIBCPP_INLINE_VISIBILITY bool copy_file(const path& __from, const path& __to) { return __copy_file(__from, __to, copy_options::none); }69inline _LIBCPP_HIDE_FROM_ABI bool copy_file(const path& __from, const path& __to) { return __copy_file(__from, __to, copy_options::none); }
66inline _LIBCPP_INLINE_VISIBILITY bool copy_file(const path& __from, const path& __to, error_code& __ec) { return __copy_file(__from, __to, copy_options::none, &__ec); }70inline _LIBCPP_HIDE_FROM_ABI bool copy_file(const path& __from, const path& __to, error_code& __ec) { return __copy_file(__from, __to, copy_options::none, &__ec); }
67inline _LIBCPP_INLINE_VISIBILITY bool copy_file(const path& __from, const path& __to, copy_options __opt) { return __copy_file(__from, __to, __opt); }71inline _LIBCPP_HIDE_FROM_ABI bool copy_file(const path& __from, const path& __to, copy_options __opt) { return __copy_file(__from, __to, __opt); }
68inline _LIBCPP_INLINE_VISIBILITY bool copy_file(const path& __from, const path& __to, copy_options __opt, error_code& __ec) { return __copy_file(__from, __to, __opt, &__ec); }72inline _LIBCPP_HIDE_FROM_ABI bool copy_file(const path& __from, const path& __to, copy_options __opt, error_code& __ec) { return __copy_file(__from, __to, __opt, &__ec); }
69inline _LIBCPP_INLINE_VISIBILITY void copy_symlink(const path& __from, const path& __to) { __copy_symlink(__from, __to); }73inline _LIBCPP_HIDE_FROM_ABI void copy_symlink(const path& __from, const path& __to) { __copy_symlink(__from, __to); }
70inline _LIBCPP_INLINE_VISIBILITY void copy_symlink(const path& __from, const path& __to, error_code& __ec) noexcept { __copy_symlink(__from, __to, &__ec); }74inline _LIBCPP_HIDE_FROM_ABI void copy_symlink(const path& __from, const path& __to, error_code& __ec) noexcept { __copy_symlink(__from, __to, &__ec); }
71inline _LIBCPP_INLINE_VISIBILITY void copy(const path& __from, const path& __to) { __copy(__from, __to, copy_options::none); }75inline _LIBCPP_HIDE_FROM_ABI void copy(const path& __from, const path& __to) { __copy(__from, __to, copy_options::none); }
72inline _LIBCPP_INLINE_VISIBILITY void copy(const path& __from, const path& __to, error_code& __ec) { __copy(__from, __to, copy_options::none, &__ec); }76inline _LIBCPP_HIDE_FROM_ABI void copy(const path& __from, const path& __to, error_code& __ec) { __copy(__from, __to, copy_options::none, &__ec); }
73inline _LIBCPP_INLINE_VISIBILITY void copy(const path& __from, const path& __to, copy_options __opt) { __copy(__from, __to, __opt); }77inline _LIBCPP_HIDE_FROM_ABI void copy(const path& __from, const path& __to, copy_options __opt) { __copy(__from, __to, __opt); }
74inline _LIBCPP_INLINE_VISIBILITY void copy(const path& __from, const path& __to, copy_options __opt, error_code& __ec) { __copy(__from, __to, __opt, &__ec); }78inline _LIBCPP_HIDE_FROM_ABI void copy(const path& __from, const path& __to, copy_options __opt, error_code& __ec) { __copy(__from, __to, __opt, &__ec); }
75inline _LIBCPP_INLINE_VISIBILITY bool create_directories(const path& __p) { return __create_directories(__p); }79inline _LIBCPP_HIDE_FROM_ABI bool create_directories(const path& __p) { return __create_directories(__p); }
76inline _LIBCPP_INLINE_VISIBILITY bool create_directories(const path& __p, error_code& __ec) { return __create_directories(__p, &__ec); }80inline _LIBCPP_HIDE_FROM_ABI bool create_directories(const path& __p, error_code& __ec) { return __create_directories(__p, &__ec); }
77inline _LIBCPP_INLINE_VISIBILITY void create_directory_symlink(const path& __target, const path& __link) { __create_directory_symlink(__target, __link); }81inline _LIBCPP_HIDE_FROM_ABI void create_directory_symlink(const path& __target, const path& __link) { __create_directory_symlink(__target, __link); }
78inline _LIBCPP_INLINE_VISIBILITY void create_directory_symlink(const path& __target, const path& __link, error_code& __ec) noexcept { __create_directory_symlink(__target, __link, &__ec); }82inline _LIBCPP_HIDE_FROM_ABI void create_directory_symlink(const path& __target, const path& __link, error_code& __ec) noexcept { __create_directory_symlink(__target, __link, &__ec); }
79inline _LIBCPP_INLINE_VISIBILITY bool create_directory(const path& __p) { return __create_directory(__p); }83inline _LIBCPP_HIDE_FROM_ABI bool create_directory(const path& __p) { return __create_directory(__p); }
80inline _LIBCPP_INLINE_VISIBILITY bool create_directory(const path& __p, error_code& __ec) noexcept { return __create_directory(__p, &__ec); }84inline _LIBCPP_HIDE_FROM_ABI bool create_directory(const path& __p, error_code& __ec) noexcept { return __create_directory(__p, &__ec); }
81inline _LIBCPP_INLINE_VISIBILITY bool create_directory(const path& __p, const path& __attrs) { return __create_directory(__p, __attrs); }85inline _LIBCPP_HIDE_FROM_ABI bool create_directory(const path& __p, const path& __attrs) { return __create_directory(__p, __attrs); }
82inline _LIBCPP_INLINE_VISIBILITY bool create_directory(const path& __p, const path& __attrs, error_code& __ec) noexcept { return __create_directory(__p, __attrs, &__ec); }86inline _LIBCPP_HIDE_FROM_ABI bool create_directory(const path& __p, const path& __attrs, error_code& __ec) noexcept { return __create_directory(__p, __attrs, &__ec); }
83inline _LIBCPP_INLINE_VISIBILITY void create_hard_link(const path& __target, const path& __link) { __create_hard_link(__target, __link); }87inline _LIBCPP_HIDE_FROM_ABI void create_hard_link(const path& __target, const path& __link) { __create_hard_link(__target, __link); }
84inline _LIBCPP_INLINE_VISIBILITY void create_hard_link(const path& __target, const path& __link, error_code& __ec) noexcept { __create_hard_link(__target, __link, &__ec); }88inline _LIBCPP_HIDE_FROM_ABI void create_hard_link(const path& __target, const path& __link, error_code& __ec) noexcept { __create_hard_link(__target, __link, &__ec); }
85inline _LIBCPP_INLINE_VISIBILITY void create_symlink(const path& __target, const path& __link) { __create_symlink(__target, __link); }89inline _LIBCPP_HIDE_FROM_ABI void create_symlink(const path& __target, const path& __link) { __create_symlink(__target, __link); }
86inline _LIBCPP_INLINE_VISIBILITY void create_symlink(const path& __target, const path& __link, error_code& __ec) noexcept { return __create_symlink(__target, __link, &__ec); }90inline _LIBCPP_HIDE_FROM_ABI void create_symlink(const path& __target, const path& __link, error_code& __ec) noexcept { return __create_symlink(__target, __link, &__ec); }
87inline _LIBCPP_INLINE_VISIBILITY path current_path() { return __current_path(); }91inline _LIBCPP_HIDE_FROM_ABI path current_path() { return __current_path(); }
88inline _LIBCPP_INLINE_VISIBILITY path current_path(error_code& __ec) { return __current_path(&__ec); }92inline _LIBCPP_HIDE_FROM_ABI path current_path(error_code& __ec) { return __current_path(&__ec); }
89inline _LIBCPP_INLINE_VISIBILITY void current_path(const path& __p) { __current_path(__p); }93inline _LIBCPP_HIDE_FROM_ABI void current_path(const path& __p) { __current_path(__p); }
90inline _LIBCPP_INLINE_VISIBILITY void current_path(const path& __p, error_code& __ec) noexcept { __current_path(__p, &__ec); }94inline _LIBCPP_HIDE_FROM_ABI void current_path(const path& __p, error_code& __ec) noexcept { __current_path(__p, &__ec); }
91inline _LIBCPP_INLINE_VISIBILITY bool equivalent(const path& __p1, const path& __p2) { return __equivalent(__p1, __p2); }95inline _LIBCPP_HIDE_FROM_ABI bool equivalent(const path& __p1, const path& __p2) { return __equivalent(__p1, __p2); }
92inline _LIBCPP_INLINE_VISIBILITY bool equivalent(const path& __p1, const path& __p2, error_code& __ec) noexcept { return __equivalent(__p1, __p2, &__ec); }96inline _LIBCPP_HIDE_FROM_ABI bool equivalent(const path& __p1, const path& __p2, error_code& __ec) noexcept { return __equivalent(__p1, __p2, &__ec); }
93inline _LIBCPP_INLINE_VISIBILITY bool status_known(file_status __s) noexcept { return __s.type() != file_type::none; }97inline _LIBCPP_HIDE_FROM_ABI bool status_known(file_status __s) noexcept { return __s.type() != file_type::none; }
94inline _LIBCPP_INLINE_VISIBILITY bool exists(file_status __s) noexcept { return status_known(__s) && __s.type() != file_type::not_found; }98inline _LIBCPP_HIDE_FROM_ABI bool exists(file_status __s) noexcept { return status_known(__s) && __s.type() != file_type::not_found; }
95inline _LIBCPP_INLINE_VISIBILITY bool exists(const path& __p) { return exists(__status(__p)); }99inline _LIBCPP_HIDE_FROM_ABI bool exists(const path& __p) { return exists(__status(__p)); }
96100
97inline _LIBCPP_INLINE_VISIBILITY bool exists(const path& __p, error_code& __ec) noexcept {101inline _LIBCPP_INLINE_VISIBILITY bool exists(const path& __p, error_code& __ec) noexcept {
98 auto __s = __status(__p, &__ec);102 auto __s = __status(__p, &__ec);
...@@ -101,45 +105,45 @@ inline _LIBCPP_INLINE_VISIBILITY bool exists(const path& __p, error_code& __ec)...@@ -101,45 +105,45 @@ inline _LIBCPP_INLINE_VISIBILITY bool exists(const path& __p, error_code& __ec)
101 return exists(__s);105 return exists(__s);
102}106}
103107
104inline _LIBCPP_INLINE_VISIBILITY uintmax_t file_size(const path& __p) { return __file_size(__p); }108inline _LIBCPP_HIDE_FROM_ABI uintmax_t file_size(const path& __p) { return __file_size(__p); }
105inline _LIBCPP_INLINE_VISIBILITY uintmax_t file_size(const path& __p, error_code& __ec) noexcept { return __file_size(__p, &__ec); }109inline _LIBCPP_HIDE_FROM_ABI uintmax_t file_size(const path& __p, error_code& __ec) noexcept { return __file_size(__p, &__ec); }
106inline _LIBCPP_INLINE_VISIBILITY uintmax_t hard_link_count(const path& __p) { return __hard_link_count(__p); }110inline _LIBCPP_HIDE_FROM_ABI uintmax_t hard_link_count(const path& __p) { return __hard_link_count(__p); }
107inline _LIBCPP_INLINE_VISIBILITY uintmax_t hard_link_count(const path& __p, error_code& __ec) noexcept { return __hard_link_count(__p, &__ec); }111inline _LIBCPP_HIDE_FROM_ABI uintmax_t hard_link_count(const path& __p, error_code& __ec) noexcept { return __hard_link_count(__p, &__ec); }
108inline _LIBCPP_INLINE_VISIBILITY bool is_block_file(file_status __s) noexcept { return __s.type() == file_type::block; }112inline _LIBCPP_HIDE_FROM_ABI bool is_block_file(file_status __s) noexcept { return __s.type() == file_type::block; }
109inline _LIBCPP_INLINE_VISIBILITY bool is_block_file(const path& __p) { return is_block_file(__status(__p)); }113inline _LIBCPP_HIDE_FROM_ABI bool is_block_file(const path& __p) { return is_block_file(__status(__p)); }
110inline _LIBCPP_INLINE_VISIBILITY bool is_block_file(const path& __p, error_code& __ec) noexcept { return is_block_file(__status(__p, &__ec)); }114inline _LIBCPP_HIDE_FROM_ABI bool is_block_file(const path& __p, error_code& __ec) noexcept { return is_block_file(__status(__p, &__ec)); }
111inline _LIBCPP_INLINE_VISIBILITY bool is_character_file(file_status __s) noexcept { return __s.type() == file_type::character; }115inline _LIBCPP_HIDE_FROM_ABI bool is_character_file(file_status __s) noexcept { return __s.type() == file_type::character; }
112inline _LIBCPP_INLINE_VISIBILITY bool is_character_file(const path& __p) { return is_character_file(__status(__p)); }116inline _LIBCPP_HIDE_FROM_ABI bool is_character_file(const path& __p) { return is_character_file(__status(__p)); }
113inline _LIBCPP_INLINE_VISIBILITY bool is_character_file(const path& __p, error_code& __ec) noexcept { return is_character_file(__status(__p, &__ec)); }117inline _LIBCPP_HIDE_FROM_ABI bool is_character_file(const path& __p, error_code& __ec) noexcept { return is_character_file(__status(__p, &__ec)); }
114inline _LIBCPP_INLINE_VISIBILITY bool is_directory(file_status __s) noexcept { return __s.type() == file_type::directory; }118inline _LIBCPP_HIDE_FROM_ABI bool is_directory(file_status __s) noexcept { return __s.type() == file_type::directory; }
115inline _LIBCPP_INLINE_VISIBILITY bool is_directory(const path& __p) { return is_directory(__status(__p)); }119inline _LIBCPP_HIDE_FROM_ABI bool is_directory(const path& __p) { return is_directory(__status(__p)); }
116inline _LIBCPP_INLINE_VISIBILITY bool is_directory(const path& __p, error_code& __ec) noexcept { return is_directory(__status(__p, &__ec)); }120inline _LIBCPP_HIDE_FROM_ABI bool is_directory(const path& __p, error_code& __ec) noexcept { return is_directory(__status(__p, &__ec)); }
117_LIBCPP_FUNC_VIS bool __fs_is_empty(const path& p, error_code* ec = nullptr);121_LIBCPP_FUNC_VIS bool __fs_is_empty(const path& __p, error_code* __ec = nullptr);
118inline _LIBCPP_INLINE_VISIBILITY bool is_empty(const path& __p) { return __fs_is_empty(__p); }122inline _LIBCPP_HIDE_FROM_ABI bool is_empty(const path& __p) { return __fs_is_empty(__p); }
119inline _LIBCPP_INLINE_VISIBILITY bool is_empty(const path& __p, error_code& __ec) { return __fs_is_empty(__p, &__ec); }123inline _LIBCPP_HIDE_FROM_ABI bool is_empty(const path& __p, error_code& __ec) { return __fs_is_empty(__p, &__ec); }
120inline _LIBCPP_INLINE_VISIBILITY bool is_fifo(file_status __s) noexcept { return __s.type() == file_type::fifo; }124inline _LIBCPP_HIDE_FROM_ABI bool is_fifo(file_status __s) noexcept { return __s.type() == file_type::fifo; }
121inline _LIBCPP_INLINE_VISIBILITY bool is_fifo(const path& __p) { return is_fifo(__status(__p)); }125inline _LIBCPP_HIDE_FROM_ABI bool is_fifo(const path& __p) { return is_fifo(__status(__p)); }
122inline _LIBCPP_INLINE_VISIBILITY bool is_fifo(const path& __p, error_code& __ec) noexcept { return is_fifo(__status(__p, &__ec)); } 126inline _LIBCPP_HIDE_FROM_ABI bool is_fifo(const path& __p, error_code& __ec) noexcept { return is_fifo(__status(__p, &__ec)); }
123inline _LIBCPP_INLINE_VISIBILITY bool is_regular_file(file_status __s) noexcept { return __s.type() == file_type::regular; }127inline _LIBCPP_HIDE_FROM_ABI bool is_regular_file(file_status __s) noexcept { return __s.type() == file_type::regular; }
124inline _LIBCPP_INLINE_VISIBILITY bool is_regular_file(const path& __p) { return is_regular_file(__status(__p)); }128inline _LIBCPP_HIDE_FROM_ABI bool is_regular_file(const path& __p) { return is_regular_file(__status(__p)); }
125inline _LIBCPP_INLINE_VISIBILITY bool is_regular_file(const path& __p, error_code& __ec) noexcept { return is_regular_file(__status(__p, &__ec)); }129inline _LIBCPP_HIDE_FROM_ABI bool is_regular_file(const path& __p, error_code& __ec) noexcept { return is_regular_file(__status(__p, &__ec)); }
126inline _LIBCPP_INLINE_VISIBILITY bool is_symlink(file_status __s) noexcept { return __s.type() == file_type::symlink; }130inline _LIBCPP_HIDE_FROM_ABI bool is_symlink(file_status __s) noexcept { return __s.type() == file_type::symlink; }
127inline _LIBCPP_INLINE_VISIBILITY bool is_symlink(const path& __p) { return is_symlink(__symlink_status(__p)); }131inline _LIBCPP_HIDE_FROM_ABI bool is_symlink(const path& __p) { return is_symlink(__symlink_status(__p)); }
128inline _LIBCPP_INLINE_VISIBILITY bool is_symlink(const path& __p, error_code& __ec) noexcept { return is_symlink(__symlink_status(__p, &__ec)); }132inline _LIBCPP_HIDE_FROM_ABI bool is_symlink(const path& __p, error_code& __ec) noexcept { return is_symlink(__symlink_status(__p, &__ec)); }
129inline _LIBCPP_INLINE_VISIBILITY bool is_other(file_status __s) noexcept { return exists(__s) && !is_regular_file(__s) && !is_directory(__s) && !is_symlink(__s); }133inline _LIBCPP_HIDE_FROM_ABI bool is_other(file_status __s) noexcept { return exists(__s) && !is_regular_file(__s) && !is_directory(__s) && !is_symlink(__s); }
130inline _LIBCPP_INLINE_VISIBILITY bool is_other(const path& __p) { return is_other(__status(__p)); }134inline _LIBCPP_HIDE_FROM_ABI bool is_other(const path& __p) { return is_other(__status(__p)); }
131inline _LIBCPP_INLINE_VISIBILITY bool is_other(const path& __p, error_code& __ec) noexcept { return is_other(__status(__p, &__ec)); }135inline _LIBCPP_HIDE_FROM_ABI bool is_other(const path& __p, error_code& __ec) noexcept { return is_other(__status(__p, &__ec)); }
132inline _LIBCPP_INLINE_VISIBILITY bool is_socket(file_status __s) noexcept { return __s.type() == file_type::socket; }136inline _LIBCPP_HIDE_FROM_ABI bool is_socket(file_status __s) noexcept { return __s.type() == file_type::socket; }
133inline _LIBCPP_INLINE_VISIBILITY bool is_socket(const path& __p) { return is_socket(__status(__p)); }137inline _LIBCPP_HIDE_FROM_ABI bool is_socket(const path& __p) { return is_socket(__status(__p)); }
134inline _LIBCPP_INLINE_VISIBILITY bool is_socket(const path& __p, error_code& __ec) noexcept { return is_socket(__status(__p, &__ec)); }138inline _LIBCPP_HIDE_FROM_ABI bool is_socket(const path& __p, error_code& __ec) noexcept { return is_socket(__status(__p, &__ec)); }
135inline _LIBCPP_INLINE_VISIBILITY file_time_type last_write_time(const path& __p) { return __last_write_time(__p); }139inline _LIBCPP_HIDE_FROM_ABI file_time_type last_write_time(const path& __p) { return __last_write_time(__p); }
136inline _LIBCPP_INLINE_VISIBILITY file_time_type last_write_time(const path& __p, error_code& __ec) noexcept { return __last_write_time(__p, &__ec); }140inline _LIBCPP_HIDE_FROM_ABI file_time_type last_write_time(const path& __p, error_code& __ec) noexcept { return __last_write_time(__p, &__ec); }
137inline _LIBCPP_INLINE_VISIBILITY void last_write_time(const path& __p, file_time_type __t) { __last_write_time(__p, __t); }141inline _LIBCPP_HIDE_FROM_ABI void last_write_time(const path& __p, file_time_type __t) { __last_write_time(__p, __t); }
138inline _LIBCPP_INLINE_VISIBILITY void last_write_time(const path& __p, file_time_type __t, error_code& __ec) noexcept { __last_write_time(__p, __t, &__ec); }142inline _LIBCPP_HIDE_FROM_ABI void last_write_time(const path& __p, file_time_type __t, error_code& __ec) noexcept { __last_write_time(__p, __t, &__ec); }
139_LIBCPP_FUNC_VIS void __permissions(const path&, perms, perm_options, error_code* = nullptr);143_LIBCPP_FUNC_VIS void __permissions(const path&, perms, perm_options, error_code* = nullptr);
140inline _LIBCPP_INLINE_VISIBILITY void permissions(const path& __p, perms __prms, perm_options __opts = perm_options::replace) { __permissions(__p, __prms, __opts); }144inline _LIBCPP_HIDE_FROM_ABI void permissions(const path& __p, perms __prms, perm_options __opts = perm_options::replace) { __permissions(__p, __prms, __opts); }
141inline _LIBCPP_INLINE_VISIBILITY void permissions(const path& __p, perms __prms, error_code& __ec) noexcept { __permissions(__p, __prms, perm_options::replace, &__ec); }145inline _LIBCPP_HIDE_FROM_ABI void permissions(const path& __p, perms __prms, error_code& __ec) noexcept { __permissions(__p, __prms, perm_options::replace, &__ec); }
142inline _LIBCPP_INLINE_VISIBILITY void permissions(const path& __p, perms __prms, perm_options __opts, error_code& __ec) { __permissions(__p, __prms, __opts, &__ec); }146inline _LIBCPP_HIDE_FROM_ABI void permissions(const path& __p, perms __prms, perm_options __opts, error_code& __ec) { __permissions(__p, __prms, __opts, &__ec); }
143147
144inline _LIBCPP_INLINE_VISIBILITY path proximate(const path& __p, const path& __base, error_code& __ec) {148inline _LIBCPP_INLINE_VISIBILITY path proximate(const path& __p, const path& __base, error_code& __ec) {
145 path __tmp = __weakly_canonical(__p, &__ec);149 path __tmp = __weakly_canonical(__p, &__ec);
...@@ -151,10 +155,10 @@ inline _LIBCPP_INLINE_VISIBILITY path proximate(const path& __p, const path& __b...@@ -151,10 +155,10 @@ inline _LIBCPP_INLINE_VISIBILITY path proximate(const path& __p, const path& __b
151 return __tmp.lexically_proximate(__tmp_base);155 return __tmp.lexically_proximate(__tmp_base);
152}156}
153157
154inline _LIBCPP_INLINE_VISIBILITY path proximate(const path& __p, error_code& __ec) { return proximate(__p, current_path(), __ec); }158inline _LIBCPP_HIDE_FROM_ABI path proximate(const path& __p, error_code& __ec) { return proximate(__p, current_path(), __ec); }
155inline _LIBCPP_INLINE_VISIBILITY path proximate(const path& __p, const path& __base = current_path()) { return __weakly_canonical(__p).lexically_proximate(__weakly_canonical(__base)); }159inline _LIBCPP_HIDE_FROM_ABI path proximate(const path& __p, const path& __base = current_path()) { return __weakly_canonical(__p).lexically_proximate(__weakly_canonical(__base)); }
156inline _LIBCPP_INLINE_VISIBILITY path read_symlink(const path& __p) { return __read_symlink(__p); }160inline _LIBCPP_HIDE_FROM_ABI path read_symlink(const path& __p) { return __read_symlink(__p); }
157inline _LIBCPP_INLINE_VISIBILITY path read_symlink(const path& __p, error_code& __ec) { return __read_symlink(__p, &__ec); }161inline _LIBCPP_HIDE_FROM_ABI path read_symlink(const path& __p, error_code& __ec) { return __read_symlink(__p, &__ec); }
158162
159inline _LIBCPP_INLINE_VISIBILITY path relative(const path& __p, const path& __base, error_code& __ec) {163inline _LIBCPP_INLINE_VISIBILITY path relative(const path& __p, const path& __base, error_code& __ec) {
160 path __tmp = __weakly_canonical(__p, &__ec);164 path __tmp = __weakly_canonical(__p, &__ec);
...@@ -166,27 +170,27 @@ inline _LIBCPP_INLINE_VISIBILITY path relative(const path& __p, const path& __ba...@@ -166,27 +170,27 @@ inline _LIBCPP_INLINE_VISIBILITY path relative(const path& __p, const path& __ba
166 return __tmp.lexically_relative(__tmpbase);170 return __tmp.lexically_relative(__tmpbase);
167}171}
168172
169inline _LIBCPP_INLINE_VISIBILITY path relative(const path& __p, error_code& __ec) { return relative(__p, current_path(), __ec); }173inline _LIBCPP_HIDE_FROM_ABI path relative(const path& __p, error_code& __ec) { return relative(__p, current_path(), __ec); }
170inline _LIBCPP_INLINE_VISIBILITY path relative(const path& __p, const path& __base = current_path()) { return __weakly_canonical(__p).lexically_relative(__weakly_canonical(__base)); }174inline _LIBCPP_HIDE_FROM_ABI path relative(const path& __p, const path& __base = current_path()) { return __weakly_canonical(__p).lexically_relative(__weakly_canonical(__base)); }
171inline _LIBCPP_INLINE_VISIBILITY uintmax_t remove_all(const path& __p) { return __remove_all(__p); }175inline _LIBCPP_HIDE_FROM_ABI uintmax_t remove_all(const path& __p) { return __remove_all(__p); }
172inline _LIBCPP_INLINE_VISIBILITY uintmax_t remove_all(const path& __p, error_code& __ec) { return __remove_all(__p, &__ec); }176inline _LIBCPP_HIDE_FROM_ABI uintmax_t remove_all(const path& __p, error_code& __ec) { return __remove_all(__p, &__ec); }
173inline _LIBCPP_INLINE_VISIBILITY bool remove(const path& __p) { return __remove(__p); }177inline _LIBCPP_HIDE_FROM_ABI bool remove(const path& __p) { return __remove(__p); }
174inline _LIBCPP_INLINE_VISIBILITY bool remove(const path& __p, error_code& __ec) noexcept { return __remove(__p, &__ec); }178inline _LIBCPP_HIDE_FROM_ABI bool remove(const path& __p, error_code& __ec) noexcept { return __remove(__p, &__ec); }
175inline _LIBCPP_INLINE_VISIBILITY void rename(const path& __from, const path& __to) { return __rename(__from, __to); }179inline _LIBCPP_HIDE_FROM_ABI void rename(const path& __from, const path& __to) { return __rename(__from, __to); }
176inline _LIBCPP_INLINE_VISIBILITY void rename(const path& __from, const path& __to, error_code& __ec) noexcept { return __rename(__from, __to, &__ec); }180inline _LIBCPP_HIDE_FROM_ABI void rename(const path& __from, const path& __to, error_code& __ec) noexcept { return __rename(__from, __to, &__ec); }
177inline _LIBCPP_INLINE_VISIBILITY void resize_file(const path& __p, uintmax_t __ns) { return __resize_file(__p, __ns); }181inline _LIBCPP_HIDE_FROM_ABI void resize_file(const path& __p, uintmax_t __ns) { return __resize_file(__p, __ns); }
178inline _LIBCPP_INLINE_VISIBILITY void resize_file(const path& __p, uintmax_t __ns, error_code& __ec) noexcept { return __resize_file(__p, __ns, &__ec); }182inline _LIBCPP_HIDE_FROM_ABI void resize_file(const path& __p, uintmax_t __ns, error_code& __ec) noexcept { return __resize_file(__p, __ns, &__ec); }
179_LIBCPP_FUNC_VIS space_info __space(const path&, error_code* __ec = nullptr);183_LIBCPP_FUNC_VIS space_info __space(const path&, error_code* __ec = nullptr);
180inline _LIBCPP_INLINE_VISIBILITY space_info space(const path& __p) { return __space(__p); }184inline _LIBCPP_HIDE_FROM_ABI space_info space(const path& __p) { return __space(__p); }
181inline _LIBCPP_INLINE_VISIBILITY space_info space(const path& __p, error_code& __ec) noexcept { return __space(__p, &__ec); }185inline _LIBCPP_HIDE_FROM_ABI space_info space(const path& __p, error_code& __ec) noexcept { return __space(__p, &__ec); }
182inline _LIBCPP_INLINE_VISIBILITY file_status status(const path& __p) { return __status(__p); }186inline _LIBCPP_HIDE_FROM_ABI file_status status(const path& __p) { return __status(__p); }
183inline _LIBCPP_INLINE_VISIBILITY file_status status(const path& __p, error_code& __ec) noexcept { return __status(__p, &__ec); }187inline _LIBCPP_HIDE_FROM_ABI file_status status(const path& __p, error_code& __ec) noexcept { return __status(__p, &__ec); }
184inline _LIBCPP_INLINE_VISIBILITY file_status symlink_status(const path& __p) { return __symlink_status(__p); }188inline _LIBCPP_HIDE_FROM_ABI file_status symlink_status(const path& __p) { return __symlink_status(__p); }
185inline _LIBCPP_INLINE_VISIBILITY file_status symlink_status(const path& __p, error_code& __ec) noexcept { return __symlink_status(__p, &__ec); }189inline _LIBCPP_HIDE_FROM_ABI file_status symlink_status(const path& __p, error_code& __ec) noexcept { return __symlink_status(__p, &__ec); }
186inline _LIBCPP_INLINE_VISIBILITY path temp_directory_path() { return __temp_directory_path(); }190inline _LIBCPP_HIDE_FROM_ABI path temp_directory_path() { return __temp_directory_path(); }
187inline _LIBCPP_INLINE_VISIBILITY path temp_directory_path(error_code& __ec) { return __temp_directory_path(&__ec); }191inline _LIBCPP_HIDE_FROM_ABI path temp_directory_path(error_code& __ec) { return __temp_directory_path(&__ec); }
188inline _LIBCPP_INLINE_VISIBILITY path weakly_canonical(path const& __p) { return __weakly_canonical(__p); }192inline _LIBCPP_HIDE_FROM_ABI path weakly_canonical(path const& __p) { return __weakly_canonical(__p); }
189inline _LIBCPP_INLINE_VISIBILITY path weakly_canonical(path const& __p, error_code& __ec) { return __weakly_canonical(__p, &__ec); }193inline _LIBCPP_HIDE_FROM_ABI path weakly_canonical(path const& __p, error_code& __ec) { return __weakly_canonical(__p, &__ec); }
190194
191_LIBCPP_AVAILABILITY_FILESYSTEM_POP195_LIBCPP_AVAILABILITY_FILESYSTEM_POP
192196
lib/libcxx/include/__filesystem/path.h+147-81
...@@ -10,6 +10,8 @@...@@ -10,6 +10,8 @@
10#ifndef _LIBCPP___FILESYSTEM_PATH_H10#ifndef _LIBCPP___FILESYSTEM_PATH_H
11#define _LIBCPP___FILESYSTEM_PATH_H11#define _LIBCPP___FILESYSTEM_PATH_H
1212
13#include <__algorithm/replace.h>
14#include <__algorithm/replace_copy.h>
13#include <__availability>15#include <__availability>
14#include <__config>16#include <__config>
15#include <__iterator/back_insert_iterator.h>17#include <__iterator/back_insert_iterator.h>
...@@ -24,6 +26,10 @@...@@ -24,6 +26,10 @@
24# include <locale>26# include <locale>
25#endif27#endif
2628
29#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
30# pragma GCC system_header
31#endif
32
27#ifndef _LIBCPP_CXX03_LANG33#ifndef _LIBCPP_CXX03_LANG
2834
29_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM35_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
...@@ -65,6 +71,7 @@ struct __can_convert_char<char32_t> {...@@ -65,6 +71,7 @@ struct __can_convert_char<char32_t> {
65};71};
6672
67template <class _ECharT>73template <class _ECharT>
74_LIBCPP_HIDE_FROM_ABI
68typename enable_if<__can_convert_char<_ECharT>::value, bool>::type75typename enable_if<__can_convert_char<_ECharT>::value, bool>::type
69__is_separator(_ECharT __e) {76__is_separator(_ECharT __e) {
70#if defined(_LIBCPP_WIN32API)77#if defined(_LIBCPP_WIN32API)
...@@ -95,10 +102,16 @@ struct __is_pathable_string<...@@ -95,10 +102,16 @@ struct __is_pathable_string<
95 : public __can_convert_char<_ECharT> {102 : public __can_convert_char<_ECharT> {
96 using _Str = basic_string<_ECharT, _Traits, _Alloc>;103 using _Str = basic_string<_ECharT, _Traits, _Alloc>;
97 using _Base = __can_convert_char<_ECharT>;104 using _Base = __can_convert_char<_ECharT>;
105
106 _LIBCPP_HIDE_FROM_ABI
98 static _ECharT const* __range_begin(_Str const& __s) { return __s.data(); }107 static _ECharT const* __range_begin(_Str const& __s) { return __s.data(); }
108
109 _LIBCPP_HIDE_FROM_ABI
99 static _ECharT const* __range_end(_Str const& __s) {110 static _ECharT const* __range_end(_Str const& __s) {
100 return __s.data() + __s.length();111 return __s.data() + __s.length();
101 }112 }
113
114 _LIBCPP_HIDE_FROM_ABI
102 static _ECharT __first_or_null(_Str const& __s) {115 static _ECharT __first_or_null(_Str const& __s) {
103 return __s.empty() ? _ECharT{} : __s[0];116 return __s.empty() ? _ECharT{} : __s[0];
104 }117 }
...@@ -111,10 +124,16 @@ struct __is_pathable_string<...@@ -111,10 +124,16 @@ struct __is_pathable_string<
111 : public __can_convert_char<_ECharT> {124 : public __can_convert_char<_ECharT> {
112 using _Str = basic_string_view<_ECharT, _Traits>;125 using _Str = basic_string_view<_ECharT, _Traits>;
113 using _Base = __can_convert_char<_ECharT>;126 using _Base = __can_convert_char<_ECharT>;
127
128 _LIBCPP_HIDE_FROM_ABI
114 static _ECharT const* __range_begin(_Str const& __s) { return __s.data(); }129 static _ECharT const* __range_begin(_Str const& __s) { return __s.data(); }
130
131 _LIBCPP_HIDE_FROM_ABI
115 static _ECharT const* __range_end(_Str const& __s) {132 static _ECharT const* __range_end(_Str const& __s) {
116 return __s.data() + __s.length();133 return __s.data() + __s.length();
117 }134 }
135
136 _LIBCPP_HIDE_FROM_ABI
118 static _ECharT __first_or_null(_Str const& __s) {137 static _ECharT __first_or_null(_Str const& __s) {
119 return __s.empty() ? _ECharT{} : __s[0];138 return __s.empty() ? _ECharT{} : __s[0];
120 }139 }
...@@ -132,7 +151,10 @@ struct __is_pathable_char_array<_Source, _ECharT*, _UPtr, true>...@@ -132,7 +151,10 @@ struct __is_pathable_char_array<_Source, _ECharT*, _UPtr, true>
132 : __can_convert_char<typename remove_const<_ECharT>::type> {151 : __can_convert_char<typename remove_const<_ECharT>::type> {
133 using _Base = __can_convert_char<typename remove_const<_ECharT>::type>;152 using _Base = __can_convert_char<typename remove_const<_ECharT>::type>;
134153
154 _LIBCPP_HIDE_FROM_ABI
135 static _ECharT const* __range_begin(const _ECharT* __b) { return __b; }155 static _ECharT const* __range_begin(const _ECharT* __b) { return __b; }
156
157 _LIBCPP_HIDE_FROM_ABI
136 static _ECharT const* __range_end(const _ECharT* __b) {158 static _ECharT const* __range_end(const _ECharT* __b) {
137 using _Iter = const _ECharT*;159 using _Iter = const _ECharT*;
138 const _ECharT __sentinel = _ECharT{};160 const _ECharT __sentinel = _ECharT{};
...@@ -142,6 +164,7 @@ struct __is_pathable_char_array<_Source, _ECharT*, _UPtr, true>...@@ -142,6 +164,7 @@ struct __is_pathable_char_array<_Source, _ECharT*, _UPtr, true>
142 return __e;164 return __e;
143 }165 }
144166
167 _LIBCPP_HIDE_FROM_ABI
145 static _ECharT __first_or_null(const _ECharT* __b) { return *__b; }168 static _ECharT __first_or_null(const _ECharT* __b) { return *__b; }
146};169};
147170
...@@ -158,9 +181,13 @@ struct __is_pathable_iter<...@@ -158,9 +181,13 @@ struct __is_pathable_iter<
158 using _ECharT = typename iterator_traits<_Iter>::value_type;181 using _ECharT = typename iterator_traits<_Iter>::value_type;
159 using _Base = __can_convert_char<_ECharT>;182 using _Base = __can_convert_char<_ECharT>;
160183
184 _LIBCPP_HIDE_FROM_ABI
161 static _Iter __range_begin(_Iter __b) { return __b; }185 static _Iter __range_begin(_Iter __b) { return __b; }
186
187 _LIBCPP_HIDE_FROM_ABI
162 static _NullSentinel __range_end(_Iter) { return _NullSentinel{}; }188 static _NullSentinel __range_end(_Iter) { return _NullSentinel{}; }
163189
190 _LIBCPP_HIDE_FROM_ABI
164 static _ECharT __first_or_null(_Iter __b) { return *__b; }191 static _ECharT __first_or_null(_Iter __b) { return *__b; }
165};192};
166193
...@@ -210,6 +237,7 @@ struct _PathCVT {...@@ -210,6 +237,7 @@ struct _PathCVT {
210 typedef __widen_from_utf8<sizeof(wchar_t) * __CHAR_BIT__> _Widener;237 typedef __widen_from_utf8<sizeof(wchar_t) * __CHAR_BIT__> _Widener;
211#endif238#endif
212239
240 _LIBCPP_HIDE_FROM_ABI
213 static void __append_range(__path_string& __dest, _ECharT const* __b,241 static void __append_range(__path_string& __dest, _ECharT const* __b,
214 _ECharT const* __e) {242 _ECharT const* __e) {
215#if defined(_LIBCPP_WIN32API)243#if defined(_LIBCPP_WIN32API)
...@@ -222,6 +250,7 @@ struct _PathCVT {...@@ -222,6 +250,7 @@ struct _PathCVT {
222 }250 }
223251
224 template <class _Iter>252 template <class _Iter>
253 _LIBCPP_HIDE_FROM_ABI
225 static void __append_range(__path_string& __dest, _Iter __b, _Iter __e) {254 static void __append_range(__path_string& __dest, _Iter __b, _Iter __e) {
226 static_assert(!is_same<_Iter, _ECharT*>::value, "Call const overload");255 static_assert(!is_same<_Iter, _ECharT*>::value, "Call const overload");
227 if (__b == __e)256 if (__b == __e)
...@@ -239,6 +268,7 @@ struct _PathCVT {...@@ -239,6 +268,7 @@ struct _PathCVT {
239 }268 }
240269
241 template <class _Iter>270 template <class _Iter>
271 _LIBCPP_HIDE_FROM_ABI
242 static void __append_range(__path_string& __dest, _Iter __b, _NullSentinel) {272 static void __append_range(__path_string& __dest, _Iter __b, _NullSentinel) {
243 static_assert(!is_same<_Iter, _ECharT*>::value, "Call const overload");273 static_assert(!is_same<_Iter, _ECharT*>::value, "Call const overload");
244 const _ECharT __sentinel = _ECharT{};274 const _ECharT __sentinel = _ECharT{};
...@@ -259,6 +289,7 @@ struct _PathCVT {...@@ -259,6 +289,7 @@ struct _PathCVT {
259 }289 }
260290
261 template <class _Source>291 template <class _Source>
292 _LIBCPP_HIDE_FROM_ABI
262 static void __append_source(__path_string& __dest, _Source const& __s) {293 static void __append_source(__path_string& __dest, _Source const& __s) {
263 using _Traits = __is_pathable<_Source>;294 using _Traits = __is_pathable<_Source>;
264 __append_range(__dest, _Traits::__range_begin(__s),295 __append_range(__dest, _Traits::__range_begin(__s),
...@@ -271,6 +302,7 @@ template <>...@@ -271,6 +302,7 @@ template <>
271struct _PathCVT<__path_value> {302struct _PathCVT<__path_value> {
272303
273 template <class _Iter>304 template <class _Iter>
305 _LIBCPP_HIDE_FROM_ABI
274 static typename enable_if<__is_exactly_cpp17_input_iterator<_Iter>::value>::type306 static typename enable_if<__is_exactly_cpp17_input_iterator<_Iter>::value>::type
275 __append_range(__path_string& __dest, _Iter __b, _Iter __e) {307 __append_range(__path_string& __dest, _Iter __b, _Iter __e) {
276 for (; __b != __e; ++__b)308 for (; __b != __e; ++__b)
...@@ -278,12 +310,14 @@ struct _PathCVT<__path_value> {...@@ -278,12 +310,14 @@ struct _PathCVT<__path_value> {
278 }310 }
279311
280 template <class _Iter>312 template <class _Iter>
313 _LIBCPP_HIDE_FROM_ABI
281 static typename enable_if<__is_cpp17_forward_iterator<_Iter>::value>::type314 static typename enable_if<__is_cpp17_forward_iterator<_Iter>::value>::type
282 __append_range(__path_string& __dest, _Iter __b, _Iter __e) {315 __append_range(__path_string& __dest, _Iter __b, _Iter __e) {
283 __dest.append(__b, __e);316 __dest.append(__b, __e);
284 }317 }
285318
286 template <class _Iter>319 template <class _Iter>
320 _LIBCPP_HIDE_FROM_ABI
287 static void __append_range(__path_string& __dest, _Iter __b, _NullSentinel) {321 static void __append_range(__path_string& __dest, _Iter __b, _NullSentinel) {
288 const char __sentinel = char{};322 const char __sentinel = char{};
289 for (; *__b != __sentinel; ++__b)323 for (; *__b != __sentinel; ++__b)
...@@ -291,6 +325,7 @@ struct _PathCVT<__path_value> {...@@ -291,6 +325,7 @@ struct _PathCVT<__path_value> {
291 }325 }
292326
293 template <class _Source>327 template <class _Source>
328 _LIBCPP_HIDE_FROM_ABI
294 static void __append_source(__path_string& __dest, _Source const& __s) {329 static void __append_source(__path_string& __dest, _Source const& __s) {
295 using _Traits = __is_pathable<_Source>;330 using _Traits = __is_pathable<_Source>;
296 __append_range(__dest, _Traits::__range_begin(__s),331 __append_range(__dest, _Traits::__range_begin(__s),
...@@ -302,6 +337,7 @@ struct _PathCVT<__path_value> {...@@ -302,6 +337,7 @@ struct _PathCVT<__path_value> {
302template <>337template <>
303struct _PathCVT<char> {338struct _PathCVT<char> {
304339
340 _LIBCPP_HIDE_FROM_ABI
305 static void341 static void
306 __append_string(__path_string& __dest, const basic_string<char> &__str) {342 __append_string(__path_string& __dest, const basic_string<char> &__str) {
307 size_t __size = __char_to_wide(__str, nullptr, 0);343 size_t __size = __char_to_wide(__str, nullptr, 0);
...@@ -311,6 +347,7 @@ struct _PathCVT<char> {...@@ -311,6 +347,7 @@ struct _PathCVT<char> {
311 }347 }
312348
313 template <class _Iter>349 template <class _Iter>
350 _LIBCPP_HIDE_FROM_ABI
314 static typename enable_if<__is_exactly_cpp17_input_iterator<_Iter>::value>::type351 static typename enable_if<__is_exactly_cpp17_input_iterator<_Iter>::value>::type
315 __append_range(__path_string& __dest, _Iter __b, _Iter __e) {352 __append_range(__path_string& __dest, _Iter __b, _Iter __e) {
316 basic_string<char> __tmp(__b, __e);353 basic_string<char> __tmp(__b, __e);
...@@ -318,6 +355,7 @@ struct _PathCVT<char> {...@@ -318,6 +355,7 @@ struct _PathCVT<char> {
318 }355 }
319356
320 template <class _Iter>357 template <class _Iter>
358 _LIBCPP_HIDE_FROM_ABI
321 static typename enable_if<__is_cpp17_forward_iterator<_Iter>::value>::type359 static typename enable_if<__is_cpp17_forward_iterator<_Iter>::value>::type
322 __append_range(__path_string& __dest, _Iter __b, _Iter __e) {360 __append_range(__path_string& __dest, _Iter __b, _Iter __e) {
323 basic_string<char> __tmp(__b, __e);361 basic_string<char> __tmp(__b, __e);
...@@ -325,6 +363,7 @@ struct _PathCVT<char> {...@@ -325,6 +363,7 @@ struct _PathCVT<char> {
325 }363 }
326364
327 template <class _Iter>365 template <class _Iter>
366 _LIBCPP_HIDE_FROM_ABI
328 static void __append_range(__path_string& __dest, _Iter __b, _NullSentinel) {367 static void __append_range(__path_string& __dest, _Iter __b, _NullSentinel) {
329 const char __sentinel = char{};368 const char __sentinel = char{};
330 basic_string<char> __tmp;369 basic_string<char> __tmp;
...@@ -334,6 +373,7 @@ struct _PathCVT<char> {...@@ -334,6 +373,7 @@ struct _PathCVT<char> {
334 }373 }
335374
336 template <class _Source>375 template <class _Source>
376 _LIBCPP_HIDE_FROM_ABI
337 static void __append_source(__path_string& __dest, _Source const& __s) {377 static void __append_source(__path_string& __dest, _Source const& __s) {
338 using _Traits = __is_pathable<_Source>;378 using _Traits = __is_pathable<_Source>;
339 __append_range(__dest, _Traits::__range_begin(__s),379 __append_range(__dest, _Traits::__range_begin(__s),
...@@ -347,6 +387,7 @@ struct _PathExport {...@@ -347,6 +387,7 @@ struct _PathExport {
347 typedef __widen_from_utf8<sizeof(_ECharT) * __CHAR_BIT__> _Widener;387 typedef __widen_from_utf8<sizeof(_ECharT) * __CHAR_BIT__> _Widener;
348388
349 template <class _Str>389 template <class _Str>
390 _LIBCPP_HIDE_FROM_ABI
350 static void __append(_Str& __dest, const __path_string& __src) {391 static void __append(_Str& __dest, const __path_string& __src) {
351 string __utf8;392 string __utf8;
352 _Narrower()(back_inserter(__utf8), __src.data(), __src.data() + __src.size());393 _Narrower()(back_inserter(__utf8), __src.data(), __src.data() + __src.size());
...@@ -357,6 +398,7 @@ struct _PathExport {...@@ -357,6 +398,7 @@ struct _PathExport {
357template <>398template <>
358struct _PathExport<char> {399struct _PathExport<char> {
359 template <class _Str>400 template <class _Str>
401 _LIBCPP_HIDE_FROM_ABI
360 static void __append(_Str& __dest, const __path_string& __src) {402 static void __append(_Str& __dest, const __path_string& __src) {
361 size_t __size = __wide_to_char(__src, nullptr, 0);403 size_t __size = __wide_to_char(__src, nullptr, 0);
362 size_t __pos = __dest.size();404 size_t __pos = __dest.size();
...@@ -368,6 +410,7 @@ struct _PathExport<char> {...@@ -368,6 +410,7 @@ struct _PathExport<char> {
368template <>410template <>
369struct _PathExport<wchar_t> {411struct _PathExport<wchar_t> {
370 template <class _Str>412 template <class _Str>
413 _LIBCPP_HIDE_FROM_ABI
371 static void __append(_Str& __dest, const __path_string& __src) {414 static void __append(_Str& __dest, const __path_string& __src) {
372 __dest.append(__src.begin(), __src.end());415 __dest.append(__src.begin(), __src.end());
373 }416 }
...@@ -376,6 +419,7 @@ struct _PathExport<wchar_t> {...@@ -376,6 +419,7 @@ struct _PathExport<wchar_t> {
376template <>419template <>
377struct _PathExport<char16_t> {420struct _PathExport<char16_t> {
378 template <class _Str>421 template <class _Str>
422 _LIBCPP_HIDE_FROM_ABI
379 static void __append(_Str& __dest, const __path_string& __src) {423 static void __append(_Str& __dest, const __path_string& __src) {
380 __dest.append(__src.begin(), __src.end());424 __dest.append(__src.begin(), __src.end());
381 }425 }
...@@ -387,6 +431,7 @@ struct _PathExport<char8_t> {...@@ -387,6 +431,7 @@ struct _PathExport<char8_t> {
387 typedef __narrow_to_utf8<sizeof(wchar_t) * __CHAR_BIT__> _Narrower;431 typedef __narrow_to_utf8<sizeof(wchar_t) * __CHAR_BIT__> _Narrower;
388432
389 template <class _Str>433 template <class _Str>
434 _LIBCPP_HIDE_FROM_ABI
390 static void __append(_Str& __dest, const __path_string& __src) {435 static void __append(_Str& __dest, const __path_string& __src) {
391 _Narrower()(back_inserter(__dest), __src.data(), __src.data() + __src.size());436 _Narrower()(back_inserter(__dest), __src.data(), __src.data() + __src.size());
392 }437 }
...@@ -423,21 +468,23 @@ public:...@@ -423,21 +468,23 @@ public:
423 };468 };
424469
425 // constructors and destructor470 // constructors and destructor
426 _LIBCPP_INLINE_VISIBILITY path() noexcept {}471 _LIBCPP_HIDE_FROM_ABI path() noexcept {}
427 _LIBCPP_INLINE_VISIBILITY path(const path& __p) : __pn_(__p.__pn_) {}472 _LIBCPP_HIDE_FROM_ABI path(const path& __p) : __pn_(__p.__pn_) {}
428 _LIBCPP_INLINE_VISIBILITY path(path&& __p) noexcept473 _LIBCPP_HIDE_FROM_ABI path(path&& __p) noexcept
429 : __pn_(_VSTD::move(__p.__pn_)) {}474 : __pn_(_VSTD::move(__p.__pn_)) {}
430475
431 _LIBCPP_INLINE_VISIBILITY476 _LIBCPP_HIDE_FROM_ABI
432 path(string_type&& __s, format = format::auto_format) noexcept477 path(string_type&& __s, format = format::auto_format) noexcept
433 : __pn_(_VSTD::move(__s)) {}478 : __pn_(_VSTD::move(__s)) {}
434479
435 template <class _Source, class = _EnableIfPathable<_Source, void> >480 template <class _Source, class = _EnableIfPathable<_Source, void> >
481 _LIBCPP_HIDE_FROM_ABI
436 path(const _Source& __src, format = format::auto_format) {482 path(const _Source& __src, format = format::auto_format) {
437 _SourceCVT<_Source>::__append_source(__pn_, __src);483 _SourceCVT<_Source>::__append_source(__pn_, __src);
438 }484 }
439485
440 template <class _InputIt>486 template <class _InputIt>
487 _LIBCPP_HIDE_FROM_ABI
441 path(_InputIt __first, _InputIt __last, format = format::auto_format) {488 path(_InputIt __first, _InputIt __last, format = format::auto_format) {
442 typedef typename iterator_traits<_InputIt>::value_type _ItVal;489 typedef typename iterator_traits<_InputIt>::value_type _ItVal;
443 _PathCVT<_ItVal>::__append_range(__pn_, __first, __last);490 _PathCVT<_ItVal>::__append_range(__pn_, __first, __last);
...@@ -454,41 +501,42 @@ public:...@@ -454,41 +501,42 @@ public:
454#endif501#endif
455*/502*/
456503
457 _LIBCPP_INLINE_VISIBILITY504 _LIBCPP_HIDE_FROM_ABI
458 ~path() = default;505 ~path() = default;
459506
460 // assignments507 // assignments
461 _LIBCPP_INLINE_VISIBILITY508 _LIBCPP_HIDE_FROM_ABI
462 path& operator=(const path& __p) {509 path& operator=(const path& __p) {
463 __pn_ = __p.__pn_;510 __pn_ = __p.__pn_;
464 return *this;511 return *this;
465 }512 }
466513
467 _LIBCPP_INLINE_VISIBILITY514 _LIBCPP_HIDE_FROM_ABI
468 path& operator=(path&& __p) noexcept {515 path& operator=(path&& __p) noexcept {
469 __pn_ = _VSTD::move(__p.__pn_);516 __pn_ = _VSTD::move(__p.__pn_);
470 return *this;517 return *this;
471 }518 }
472519
473 _LIBCPP_INLINE_VISIBILITY520 _LIBCPP_HIDE_FROM_ABI
474 path& operator=(string_type&& __s) noexcept {521 path& operator=(string_type&& __s) noexcept {
475 __pn_ = _VSTD::move(__s);522 __pn_ = _VSTD::move(__s);
476 return *this;523 return *this;
477 }524 }
478525
479 _LIBCPP_INLINE_VISIBILITY526 _LIBCPP_HIDE_FROM_ABI
480 path& assign(string_type&& __s) noexcept {527 path& assign(string_type&& __s) noexcept {
481 __pn_ = _VSTD::move(__s);528 __pn_ = _VSTD::move(__s);
482 return *this;529 return *this;
483 }530 }
484531
485 template <class _Source>532 template <class _Source>
486 _LIBCPP_INLINE_VISIBILITY _EnableIfPathable<_Source>533 _LIBCPP_HIDE_FROM_ABI _EnableIfPathable<_Source>
487 operator=(const _Source& __src) {534 operator=(const _Source& __src) {
488 return this->assign(__src);535 return this->assign(__src);
489 }536 }
490537
491 template <class _Source>538 template <class _Source>
539 _LIBCPP_HIDE_FROM_ABI
492 _EnableIfPathable<_Source> assign(const _Source& __src) {540 _EnableIfPathable<_Source> assign(const _Source& __src) {
493 __pn_.clear();541 __pn_.clear();
494 _SourceCVT<_Source>::__append_source(__pn_, __src);542 _SourceCVT<_Source>::__append_source(__pn_, __src);
...@@ -496,6 +544,7 @@ public:...@@ -496,6 +544,7 @@ public:
496 }544 }
497545
498 template <class _InputIt>546 template <class _InputIt>
547 _LIBCPP_HIDE_FROM_ABI
499 path& assign(_InputIt __first, _InputIt __last) {548 path& assign(_InputIt __first, _InputIt __last) {
500 typedef typename iterator_traits<_InputIt>::value_type _ItVal;549 typedef typename iterator_traits<_InputIt>::value_type _ItVal;
501 __pn_.clear();550 __pn_.clear();
...@@ -506,6 +555,7 @@ public:...@@ -506,6 +555,7 @@ public:
506public:555public:
507 // appends556 // appends
508#if defined(_LIBCPP_WIN32API)557#if defined(_LIBCPP_WIN32API)
558 _LIBCPP_HIDE_FROM_ABI
509 path& operator/=(const path& __p) {559 path& operator/=(const path& __p) {
510 auto __p_root_name = __p.__root_name();560 auto __p_root_name = __p.__root_name();
511 auto __p_root_name_size = __p_root_name.size();561 auto __p_root_name_size = __p_root_name.size();
...@@ -532,15 +582,18 @@ public:...@@ -532,15 +582,18 @@ public:
532 }582 }
533583
534 template <class _Source>584 template <class _Source>
585 _LIBCPP_HIDE_FROM_ABI
535 _EnableIfPathable<_Source> append(const _Source& __src) {586 _EnableIfPathable<_Source> append(const _Source& __src) {
536 return operator/=(path(__src));587 return operator/=(path(__src));
537 }588 }
538589
539 template <class _InputIt>590 template <class _InputIt>
591 _LIBCPP_HIDE_FROM_ABI
540 path& append(_InputIt __first, _InputIt __last) {592 path& append(_InputIt __first, _InputIt __last) {
541 return operator/=(path(__first, __last));593 return operator/=(path(__first, __last));
542 }594 }
543#else595#else
596 _LIBCPP_HIDE_FROM_ABI
544 path& operator/=(const path& __p) {597 path& operator/=(const path& __p) {
545 if (__p.is_absolute()) {598 if (__p.is_absolute()) {
546 __pn_ = __p.__pn_;599 __pn_ = __p.__pn_;
...@@ -556,12 +609,13 @@ public:...@@ -556,12 +609,13 @@ public:
556 // is known at compile time to be "/' since the user almost certainly intended609 // is known at compile time to be "/' since the user almost certainly intended
557 // to append a separator instead of overwriting the path with "/"610 // to append a separator instead of overwriting the path with "/"
558 template <class _Source>611 template <class _Source>
559 _LIBCPP_INLINE_VISIBILITY _EnableIfPathable<_Source>612 _LIBCPP_HIDE_FROM_ABI _EnableIfPathable<_Source>
560 operator/=(const _Source& __src) {613 operator/=(const _Source& __src) {
561 return this->append(__src);614 return this->append(__src);
562 }615 }
563616
564 template <class _Source>617 template <class _Source>
618 _LIBCPP_HIDE_FROM_ABI
565 _EnableIfPathable<_Source> append(const _Source& __src) {619 _EnableIfPathable<_Source> append(const _Source& __src) {
566 using _Traits = __is_pathable<_Source>;620 using _Traits = __is_pathable<_Source>;
567 using _CVT = _PathCVT<_SourceChar<_Source> >;621 using _CVT = _PathCVT<_SourceChar<_Source> >;
...@@ -575,6 +629,7 @@ public:...@@ -575,6 +629,7 @@ public:
575 }629 }
576630
577 template <class _InputIt>631 template <class _InputIt>
632 _LIBCPP_HIDE_FROM_ABI
578 path& append(_InputIt __first, _InputIt __last) {633 path& append(_InputIt __first, _InputIt __last) {
579 typedef typename iterator_traits<_InputIt>::value_type _ItVal;634 typedef typename iterator_traits<_InputIt>::value_type _ItVal;
580 static_assert(__can_convert_char<_ItVal>::value, "Must convertible");635 static_assert(__can_convert_char<_ItVal>::value, "Must convertible");
...@@ -589,37 +644,38 @@ public:...@@ -589,37 +644,38 @@ public:
589#endif644#endif
590645
591 // concatenation646 // concatenation
592 _LIBCPP_INLINE_VISIBILITY647 _LIBCPP_HIDE_FROM_ABI
593 path& operator+=(const path& __x) {648 path& operator+=(const path& __x) {
594 __pn_ += __x.__pn_;649 __pn_ += __x.__pn_;
595 return *this;650 return *this;
596 }651 }
597652
598 _LIBCPP_INLINE_VISIBILITY653 _LIBCPP_HIDE_FROM_ABI
599 path& operator+=(const string_type& __x) {654 path& operator+=(const string_type& __x) {
600 __pn_ += __x;655 __pn_ += __x;
601 return *this;656 return *this;
602 }657 }
603658
604 _LIBCPP_INLINE_VISIBILITY659 _LIBCPP_HIDE_FROM_ABI
605 path& operator+=(__string_view __x) {660 path& operator+=(__string_view __x) {
606 __pn_ += __x;661 __pn_ += __x;
607 return *this;662 return *this;
608 }663 }
609664
610 _LIBCPP_INLINE_VISIBILITY665 _LIBCPP_HIDE_FROM_ABI
611 path& operator+=(const value_type* __x) {666 path& operator+=(const value_type* __x) {
612 __pn_ += __x;667 __pn_ += __x;
613 return *this;668 return *this;
614 }669 }
615670
616 _LIBCPP_INLINE_VISIBILITY671 _LIBCPP_HIDE_FROM_ABI
617 path& operator+=(value_type __x) {672 path& operator+=(value_type __x) {
618 __pn_ += __x;673 __pn_ += __x;
619 return *this;674 return *this;
620 }675 }
621676
622 template <class _ECharT>677 template <class _ECharT>
678 _LIBCPP_HIDE_FROM_ABI
623 typename enable_if<__can_convert_char<_ECharT>::value, path&>::type679 typename enable_if<__can_convert_char<_ECharT>::value, path&>::type
624 operator+=(_ECharT __x) {680 operator+=(_ECharT __x) {
625 _PathCVT<_ECharT>::__append_source(__pn_,681 _PathCVT<_ECharT>::__append_source(__pn_,
...@@ -628,17 +684,20 @@ public:...@@ -628,17 +684,20 @@ public:
628 }684 }
629685
630 template <class _Source>686 template <class _Source>
687 _LIBCPP_HIDE_FROM_ABI
631 _EnableIfPathable<_Source> operator+=(const _Source& __x) {688 _EnableIfPathable<_Source> operator+=(const _Source& __x) {
632 return this->concat(__x);689 return this->concat(__x);
633 }690 }
634691
635 template <class _Source>692 template <class _Source>
693 _LIBCPP_HIDE_FROM_ABI
636 _EnableIfPathable<_Source> concat(const _Source& __x) {694 _EnableIfPathable<_Source> concat(const _Source& __x) {
637 _SourceCVT<_Source>::__append_source(__pn_, __x);695 _SourceCVT<_Source>::__append_source(__pn_, __x);
638 return *this;696 return *this;
639 }697 }
640698
641 template <class _InputIt>699 template <class _InputIt>
700 _LIBCPP_HIDE_FROM_ABI
642 path& concat(_InputIt __first, _InputIt __last) {701 path& concat(_InputIt __first, _InputIt __last) {
643 typedef typename iterator_traits<_InputIt>::value_type _ItVal;702 typedef typename iterator_traits<_InputIt>::value_type _ItVal;
644 _PathCVT<_ItVal>::__append_range(__pn_, __first, __last);703 _PathCVT<_ItVal>::__append_range(__pn_, __first, __last);
...@@ -646,9 +705,10 @@ public:...@@ -646,9 +705,10 @@ public:
646 }705 }
647706
648 // modifiers707 // modifiers
649 _LIBCPP_INLINE_VISIBILITY708 _LIBCPP_HIDE_FROM_ABI
650 void clear() noexcept { __pn_.clear(); }709 void clear() noexcept { __pn_.clear(); }
651710
711 _LIBCPP_HIDE_FROM_ABI
652 path& make_preferred() {712 path& make_preferred() {
653#if defined(_LIBCPP_WIN32API)713#if defined(_LIBCPP_WIN32API)
654 _VSTD::replace(__pn_.begin(), __pn_.end(), L'/', L'\\');714 _VSTD::replace(__pn_.begin(), __pn_.end(), L'/', L'\\');
...@@ -656,7 +716,7 @@ public:...@@ -656,7 +716,7 @@ public:
656 return *this;716 return *this;
657 }717 }
658718
659 _LIBCPP_INLINE_VISIBILITY719 _LIBCPP_HIDE_FROM_ABI
660 path& remove_filename() {720 path& remove_filename() {
661 auto __fname = __filename();721 auto __fname = __filename();
662 if (!__fname.empty())722 if (!__fname.empty())
...@@ -664,6 +724,7 @@ public:...@@ -664,6 +724,7 @@ public:
664 return *this;724 return *this;
665 }725 }
666726
727 _LIBCPP_HIDE_FROM_ABI
667 path& replace_filename(const path& __replacement) {728 path& replace_filename(const path& __replacement) {
668 remove_filename();729 remove_filename();
669 return (*this /= __replacement);730 return (*this /= __replacement);
...@@ -671,25 +732,26 @@ public:...@@ -671,25 +732,26 @@ public:
671732
672 path& replace_extension(const path& __replacement = path());733 path& replace_extension(const path& __replacement = path());
673734
674 _LIBCPP_INLINE_VISIBILITY735 _LIBCPP_HIDE_FROM_ABI
675 void swap(path& __rhs) noexcept { __pn_.swap(__rhs.__pn_); }736 void swap(path& __rhs) noexcept { __pn_.swap(__rhs.__pn_); }
676737
677 // private helper to allow reserving memory in the path738 // private helper to allow reserving memory in the path
678 _LIBCPP_INLINE_VISIBILITY739 _LIBCPP_HIDE_FROM_ABI
679 void __reserve(size_t __s) { __pn_.reserve(__s); }740 void __reserve(size_t __s) { __pn_.reserve(__s); }
680741
681 // native format observers742 // native format observers
682 _LIBCPP_INLINE_VISIBILITY743 _LIBCPP_HIDE_FROM_ABI
683 const string_type& native() const noexcept { return __pn_; }744 const string_type& native() const noexcept { return __pn_; }
684745
685 _LIBCPP_INLINE_VISIBILITY746 _LIBCPP_HIDE_FROM_ABI
686 const value_type* c_str() const noexcept { return __pn_.c_str(); }747 const value_type* c_str() const noexcept { return __pn_.c_str(); }
687748
688 _LIBCPP_INLINE_VISIBILITY operator string_type() const { return __pn_; }749 _LIBCPP_HIDE_FROM_ABI operator string_type() const { return __pn_; }
689750
690#if defined(_LIBCPP_WIN32API)751#if defined(_LIBCPP_WIN32API)
691 _LIBCPP_INLINE_VISIBILITY _VSTD::wstring wstring() const { return __pn_; }752 _LIBCPP_HIDE_FROM_ABI _VSTD::wstring wstring() const { return __pn_; }
692753
754 _LIBCPP_HIDE_FROM_ABI
693 _VSTD::wstring generic_wstring() const {755 _VSTD::wstring generic_wstring() const {
694 _VSTD::wstring __s;756 _VSTD::wstring __s;
695 __s.resize(__pn_.size());757 __s.resize(__pn_.size());
...@@ -700,6 +762,7 @@ public:...@@ -700,6 +762,7 @@ public:
700#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)762#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
701 template <class _ECharT, class _Traits = char_traits<_ECharT>,763 template <class _ECharT, class _Traits = char_traits<_ECharT>,
702 class _Allocator = allocator<_ECharT> >764 class _Allocator = allocator<_ECharT> >
765 _LIBCPP_HIDE_FROM_ABI
703 basic_string<_ECharT, _Traits, _Allocator>766 basic_string<_ECharT, _Traits, _Allocator>
704 string(const _Allocator& __a = _Allocator()) const {767 string(const _Allocator& __a = _Allocator()) const {
705 using _Str = basic_string<_ECharT, _Traits, _Allocator>;768 using _Str = basic_string<_ECharT, _Traits, _Allocator>;
...@@ -709,10 +772,10 @@ public:...@@ -709,10 +772,10 @@ public:
709 return __s;772 return __s;
710 }773 }
711774
712 _LIBCPP_INLINE_VISIBILITY _VSTD::string string() const {775 _LIBCPP_HIDE_FROM_ABI _VSTD::string string() const {
713 return string<char>();776 return string<char>();
714 }777 }
715 _LIBCPP_INLINE_VISIBILITY __u8_string u8string() const {778 _LIBCPP_HIDE_FROM_ABI __u8_string u8string() const {
716 using _CVT = __narrow_to_utf8<sizeof(wchar_t) * __CHAR_BIT__>;779 using _CVT = __narrow_to_utf8<sizeof(wchar_t) * __CHAR_BIT__>;
717 __u8_string __s;780 __u8_string __s;
718 __s.reserve(__pn_.size());781 __s.reserve(__pn_.size());
...@@ -720,16 +783,17 @@ public:...@@ -720,16 +783,17 @@ public:
720 return __s;783 return __s;
721 }784 }
722785
723 _LIBCPP_INLINE_VISIBILITY _VSTD::u16string u16string() const {786 _LIBCPP_HIDE_FROM_ABI _VSTD::u16string u16string() const {
724 return string<char16_t>();787 return string<char16_t>();
725 }788 }
726 _LIBCPP_INLINE_VISIBILITY _VSTD::u32string u32string() const {789 _LIBCPP_HIDE_FROM_ABI _VSTD::u32string u32string() const {
727 return string<char32_t>();790 return string<char32_t>();
728 }791 }
729792
730 // generic format observers793 // generic format observers
731 template <class _ECharT, class _Traits = char_traits<_ECharT>,794 template <class _ECharT, class _Traits = char_traits<_ECharT>,
732 class _Allocator = allocator<_ECharT> >795 class _Allocator = allocator<_ECharT> >
796 _LIBCPP_HIDE_FROM_ABI
733 basic_string<_ECharT, _Traits, _Allocator>797 basic_string<_ECharT, _Traits, _Allocator>
734 generic_string(const _Allocator& __a = _Allocator()) const {798 generic_string(const _Allocator& __a = _Allocator()) const {
735 using _Str = basic_string<_ECharT, _Traits, _Allocator>;799 using _Str = basic_string<_ECharT, _Traits, _Allocator>;
...@@ -742,9 +806,10 @@ public:...@@ -742,9 +806,10 @@ public:
742 return __s;806 return __s;
743 }807 }
744808
745 _VSTD::string generic_string() const { return generic_string<char>(); }809 _LIBCPP_HIDE_FROM_ABI _VSTD::string generic_string() const { return generic_string<char>(); }
746 _VSTD::u16string generic_u16string() const { return generic_string<char16_t>(); }810 _LIBCPP_HIDE_FROM_ABI _VSTD::u16string generic_u16string() const { return generic_string<char16_t>(); }
747 _VSTD::u32string generic_u32string() const { return generic_string<char32_t>(); }811 _LIBCPP_HIDE_FROM_ABI _VSTD::u32string generic_u32string() const { return generic_string<char32_t>(); }
812 _LIBCPP_HIDE_FROM_ABI
748 __u8_string generic_u8string() const {813 __u8_string generic_u8string() const {
749 __u8_string __s = u8string();814 __u8_string __s = u8string();
750 _VSTD::replace(__s.begin(), __s.end(), '\\', '/');815 _VSTD::replace(__s.begin(), __s.end(), '\\', '/');
...@@ -753,16 +818,17 @@ public:...@@ -753,16 +818,17 @@ public:
753#endif /* !_LIBCPP_HAS_NO_LOCALIZATION */818#endif /* !_LIBCPP_HAS_NO_LOCALIZATION */
754#else /* _LIBCPP_WIN32API */819#else /* _LIBCPP_WIN32API */
755820
756 _LIBCPP_INLINE_VISIBILITY _VSTD::string string() const { return __pn_; }821 _LIBCPP_HIDE_FROM_ABI _VSTD::string string() const { return __pn_; }
757#ifndef _LIBCPP_HAS_NO_CHAR8_T822#ifndef _LIBCPP_HAS_NO_CHAR8_T
758 _LIBCPP_INLINE_VISIBILITY _VSTD::u8string u8string() const { return _VSTD::u8string(__pn_.begin(), __pn_.end()); }823 _LIBCPP_HIDE_FROM_ABI _VSTD::u8string u8string() const { return _VSTD::u8string(__pn_.begin(), __pn_.end()); }
759#else824#else
760 _LIBCPP_INLINE_VISIBILITY _VSTD::string u8string() const { return __pn_; }825 _LIBCPP_HIDE_FROM_ABI _VSTD::string u8string() const { return __pn_; }
761#endif826#endif
762827
763#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)828#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
764 template <class _ECharT, class _Traits = char_traits<_ECharT>,829 template <class _ECharT, class _Traits = char_traits<_ECharT>,
765 class _Allocator = allocator<_ECharT> >830 class _Allocator = allocator<_ECharT> >
831 _LIBCPP_HIDE_FROM_ABI
766 basic_string<_ECharT, _Traits, _Allocator>832 basic_string<_ECharT, _Traits, _Allocator>
767 string(const _Allocator& __a = _Allocator()) const {833 string(const _Allocator& __a = _Allocator()) const {
768 using _CVT = __widen_from_utf8<sizeof(_ECharT) * __CHAR_BIT__>;834 using _CVT = __widen_from_utf8<sizeof(_ECharT) * __CHAR_BIT__>;
...@@ -774,39 +840,40 @@ public:...@@ -774,39 +840,40 @@ public:
774 }840 }
775841
776#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS842#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
777 _LIBCPP_INLINE_VISIBILITY _VSTD::wstring wstring() const {843 _LIBCPP_HIDE_FROM_ABI _VSTD::wstring wstring() const {
778 return string<wchar_t>();844 return string<wchar_t>();
779 }845 }
780#endif846#endif
781 _LIBCPP_INLINE_VISIBILITY _VSTD::u16string u16string() const {847 _LIBCPP_HIDE_FROM_ABI _VSTD::u16string u16string() const {
782 return string<char16_t>();848 return string<char16_t>();
783 }849 }
784 _LIBCPP_INLINE_VISIBILITY _VSTD::u32string u32string() const {850 _LIBCPP_HIDE_FROM_ABI _VSTD::u32string u32string() const {
785 return string<char32_t>();851 return string<char32_t>();
786 }852 }
787#endif /* !_LIBCPP_HAS_NO_LOCALIZATION */853#endif /* !_LIBCPP_HAS_NO_LOCALIZATION */
788854
789 // generic format observers855 // generic format observers
790 _VSTD::string generic_string() const { return __pn_; }856 _LIBCPP_HIDE_FROM_ABI _VSTD::string generic_string() const { return __pn_; }
791#ifndef _LIBCPP_HAS_NO_CHAR8_T857#ifndef _LIBCPP_HAS_NO_CHAR8_T
792 _VSTD::u8string generic_u8string() const { return _VSTD::u8string(__pn_.begin(), __pn_.end()); }858 _LIBCPP_HIDE_FROM_ABI _VSTD::u8string generic_u8string() const { return _VSTD::u8string(__pn_.begin(), __pn_.end()); }
793#else859#else
794 _VSTD::string generic_u8string() const { return __pn_; }860 _LIBCPP_HIDE_FROM_ABI _VSTD::string generic_u8string() const { return __pn_; }
795#endif861#endif
796862
797#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)863#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
798 template <class _ECharT, class _Traits = char_traits<_ECharT>,864 template <class _ECharT, class _Traits = char_traits<_ECharT>,
799 class _Allocator = allocator<_ECharT> >865 class _Allocator = allocator<_ECharT> >
866 _LIBCPP_HIDE_FROM_ABI
800 basic_string<_ECharT, _Traits, _Allocator>867 basic_string<_ECharT, _Traits, _Allocator>
801 generic_string(const _Allocator& __a = _Allocator()) const {868 generic_string(const _Allocator& __a = _Allocator()) const {
802 return string<_ECharT, _Traits, _Allocator>(__a);869 return string<_ECharT, _Traits, _Allocator>(__a);
803 }870 }
804871
805#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS872#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
806 _VSTD::wstring generic_wstring() const { return string<wchar_t>(); }873 _LIBCPP_HIDE_FROM_ABI _VSTD::wstring generic_wstring() const { return string<wchar_t>(); }
807#endif874#endif
808 _VSTD::u16string generic_u16string() const { return string<char16_t>(); }875 _LIBCPP_HIDE_FROM_ABI _VSTD::u16string generic_u16string() const { return string<char16_t>(); }
809 _VSTD::u32string generic_u32string() const { return string<char32_t>(); }876 _LIBCPP_HIDE_FROM_ABI _VSTD::u32string generic_u32string() const { return string<char32_t>(); }
810#endif /* !_LIBCPP_HAS_NO_LOCALIZATION */877#endif /* !_LIBCPP_HAS_NO_LOCALIZATION */
811#endif /* !_LIBCPP_WIN32API */878#endif /* !_LIBCPP_WIN32API */
812879
...@@ -823,77 +890,77 @@ private:...@@ -823,77 +890,77 @@ private:
823890
824public:891public:
825 // compare892 // compare
826 _LIBCPP_INLINE_VISIBILITY int compare(const path& __p) const noexcept {893 _LIBCPP_HIDE_FROM_ABI int compare(const path& __p) const noexcept {
827 return __compare(__p.__pn_);894 return __compare(__p.__pn_);
828 }895 }
829 _LIBCPP_INLINE_VISIBILITY int compare(const string_type& __s) const {896 _LIBCPP_HIDE_FROM_ABI int compare(const string_type& __s) const {
830 return __compare(__s);897 return __compare(__s);
831 }898 }
832 _LIBCPP_INLINE_VISIBILITY int compare(__string_view __s) const {899 _LIBCPP_HIDE_FROM_ABI int compare(__string_view __s) const {
833 return __compare(__s);900 return __compare(__s);
834 }901 }
835 _LIBCPP_INLINE_VISIBILITY int compare(const value_type* __s) const {902 _LIBCPP_HIDE_FROM_ABI int compare(const value_type* __s) const {
836 return __compare(__s);903 return __compare(__s);
837 }904 }
838905
839 // decomposition906 // decomposition
840 _LIBCPP_INLINE_VISIBILITY path root_name() const {907 _LIBCPP_HIDE_FROM_ABI path root_name() const {
841 return string_type(__root_name());908 return string_type(__root_name());
842 }909 }
843 _LIBCPP_INLINE_VISIBILITY path root_directory() const {910 _LIBCPP_HIDE_FROM_ABI path root_directory() const {
844 return string_type(__root_directory());911 return string_type(__root_directory());
845 }912 }
846 _LIBCPP_INLINE_VISIBILITY path root_path() const {913 _LIBCPP_HIDE_FROM_ABI path root_path() const {
847#if defined(_LIBCPP_WIN32API)914#if defined(_LIBCPP_WIN32API)
848 return string_type(__root_path_raw());915 return string_type(__root_path_raw());
849#else916#else
850 return root_name().append(string_type(__root_directory()));917 return root_name().append(string_type(__root_directory()));
851#endif918#endif
852 }919 }
853 _LIBCPP_INLINE_VISIBILITY path relative_path() const {920 _LIBCPP_HIDE_FROM_ABI path relative_path() const {
854 return string_type(__relative_path());921 return string_type(__relative_path());
855 }922 }
856 _LIBCPP_INLINE_VISIBILITY path parent_path() const {923 _LIBCPP_HIDE_FROM_ABI path parent_path() const {
857 return string_type(__parent_path());924 return string_type(__parent_path());
858 }925 }
859 _LIBCPP_INLINE_VISIBILITY path filename() const {926 _LIBCPP_HIDE_FROM_ABI path filename() const {
860 return string_type(__filename());927 return string_type(__filename());
861 }928 }
862 _LIBCPP_INLINE_VISIBILITY path stem() const { return string_type(__stem()); }929 _LIBCPP_HIDE_FROM_ABI path stem() const { return string_type(__stem()); }
863 _LIBCPP_INLINE_VISIBILITY path extension() const {930 _LIBCPP_HIDE_FROM_ABI path extension() const {
864 return string_type(__extension());931 return string_type(__extension());
865 }932 }
866933
867 // query934 // query
868 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY bool935 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool
869 empty() const noexcept {936 empty() const noexcept {
870 return __pn_.empty();937 return __pn_.empty();
871 }938 }
872939
873 _LIBCPP_INLINE_VISIBILITY bool has_root_name() const {940 _LIBCPP_HIDE_FROM_ABI bool has_root_name() const {
874 return !__root_name().empty();941 return !__root_name().empty();
875 }942 }
876 _LIBCPP_INLINE_VISIBILITY bool has_root_directory() const {943 _LIBCPP_HIDE_FROM_ABI bool has_root_directory() const {
877 return !__root_directory().empty();944 return !__root_directory().empty();
878 }945 }
879 _LIBCPP_INLINE_VISIBILITY bool has_root_path() const {946 _LIBCPP_HIDE_FROM_ABI bool has_root_path() const {
880 return !__root_path_raw().empty();947 return !__root_path_raw().empty();
881 }948 }
882 _LIBCPP_INLINE_VISIBILITY bool has_relative_path() const {949 _LIBCPP_HIDE_FROM_ABI bool has_relative_path() const {
883 return !__relative_path().empty();950 return !__relative_path().empty();
884 }951 }
885 _LIBCPP_INLINE_VISIBILITY bool has_parent_path() const {952 _LIBCPP_HIDE_FROM_ABI bool has_parent_path() const {
886 return !__parent_path().empty();953 return !__parent_path().empty();
887 }954 }
888 _LIBCPP_INLINE_VISIBILITY bool has_filename() const {955 _LIBCPP_HIDE_FROM_ABI bool has_filename() const {
889 return !__filename().empty();956 return !__filename().empty();
890 }957 }
891 _LIBCPP_INLINE_VISIBILITY bool has_stem() const { return !__stem().empty(); }958 _LIBCPP_HIDE_FROM_ABI bool has_stem() const { return !__stem().empty(); }
892 _LIBCPP_INLINE_VISIBILITY bool has_extension() const {959 _LIBCPP_HIDE_FROM_ABI bool has_extension() const {
893 return !__extension().empty();960 return !__extension().empty();
894 }961 }
895962
896 _LIBCPP_INLINE_VISIBILITY bool is_absolute() const {963 _LIBCPP_HIDE_FROM_ABI bool is_absolute() const {
897#if defined(_LIBCPP_WIN32API)964#if defined(_LIBCPP_WIN32API)
898 __string_view __root_name_str = __root_name();965 __string_view __root_name_str = __root_name();
899 __string_view __root_dir = __root_directory();966 __string_view __root_dir = __root_directory();
...@@ -917,13 +984,13 @@ public:...@@ -917,13 +984,13 @@ public:
917 return has_root_directory();984 return has_root_directory();
918#endif985#endif
919 }986 }
920 _LIBCPP_INLINE_VISIBILITY bool is_relative() const { return !is_absolute(); }987 _LIBCPP_HIDE_FROM_ABI bool is_relative() const { return !is_absolute(); }
921988
922 // relative paths989 // relative paths
923 path lexically_normal() const;990 path lexically_normal() const;
924 path lexically_relative(const path& __base) const;991 path lexically_relative(const path& __base) const;
925992
926 _LIBCPP_INLINE_VISIBILITY path lexically_proximate(const path& __base) const {993 _LIBCPP_HIDE_FROM_ABI path lexically_proximate(const path& __base) const {
927 path __result = this->lexically_relative(__base);994 path __result = this->lexically_relative(__base);
928 if (__result.native().empty())995 if (__result.native().empty())
929 return *this;996 return *this;
...@@ -939,7 +1006,7 @@ public:...@@ -939,7 +1006,7 @@ public:
9391006
940#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)1007#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
941 template <class _CharT, class _Traits>1008 template <class _CharT, class _Traits>
942 _LIBCPP_INLINE_VISIBILITY friend1009 _LIBCPP_HIDE_FROM_ABI friend
943 typename enable_if<is_same<_CharT, value_type>::value &&1010 typename enable_if<is_same<_CharT, value_type>::value &&
944 is_same<_Traits, char_traits<value_type> >::value,1011 is_same<_Traits, char_traits<value_type> >::value,
945 basic_ostream<_CharT, _Traits>&>::type1012 basic_ostream<_CharT, _Traits>&>::type
...@@ -949,7 +1016,7 @@ public:...@@ -949,7 +1016,7 @@ public:
949 }1016 }
9501017
951 template <class _CharT, class _Traits>1018 template <class _CharT, class _Traits>
952 _LIBCPP_INLINE_VISIBILITY friend1019 _LIBCPP_HIDE_FROM_ABI friend
953 typename enable_if<!is_same<_CharT, value_type>::value ||1020 typename enable_if<!is_same<_CharT, value_type>::value ||
954 !is_same<_Traits, char_traits<value_type> >::value,1021 !is_same<_Traits, char_traits<value_type> >::value,
955 basic_ostream<_CharT, _Traits>&>::type1022 basic_ostream<_CharT, _Traits>&>::type
...@@ -959,42 +1026,41 @@ public:...@@ -959,42 +1026,41 @@ public:
959 }1026 }
9601027
961 template <class _CharT, class _Traits>1028 template <class _CharT, class _Traits>
962 _LIBCPP_INLINE_VISIBILITY friend basic_istream<_CharT, _Traits>&1029 _LIBCPP_HIDE_FROM_ABI friend basic_istream<_CharT, _Traits>&
963 operator>>(basic_istream<_CharT, _Traits>& __is, path& __p) {1030 operator>>(basic_istream<_CharT, _Traits>& __is, path& __p) {
964 basic_string<_CharT, _Traits> __tmp;1031 basic_string<_CharT, _Traits> __tmp;
965 __is >> __quoted(__tmp);1032 __is >> _VSTD::__quoted(__tmp);
966 __p = __tmp;1033 __p = __tmp;
967 return __is;1034 return __is;
968 }1035 }
969#endif // !_LIBCPP_HAS_NO_LOCALIZATION1036#endif // !_LIBCPP_HAS_NO_LOCALIZATION
9701037
971 friend _LIBCPP_INLINE_VISIBILITY bool operator==(const path& __lhs, const path& __rhs) noexcept {1038 friend _LIBCPP_HIDE_FROM_ABI bool operator==(const path& __lhs, const path& __rhs) noexcept {
972 return __lhs.__compare(__rhs.__pn_) == 0;1039 return __lhs.__compare(__rhs.__pn_) == 0;
973 }1040 }
974 friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const path& __lhs, const path& __rhs) noexcept {1041 friend _LIBCPP_HIDE_FROM_ABI bool operator!=(const path& __lhs, const path& __rhs) noexcept {
975 return __lhs.__compare(__rhs.__pn_) != 0;1042 return __lhs.__compare(__rhs.__pn_) != 0;
976 }1043 }
977 friend _LIBCPP_INLINE_VISIBILITY bool operator<(const path& __lhs, const path& __rhs) noexcept {1044 friend _LIBCPP_HIDE_FROM_ABI bool operator<(const path& __lhs, const path& __rhs) noexcept {
978 return __lhs.__compare(__rhs.__pn_) < 0;1045 return __lhs.__compare(__rhs.__pn_) < 0;
979 }1046 }
980 friend _LIBCPP_INLINE_VISIBILITY bool operator<=(const path& __lhs, const path& __rhs) noexcept {1047 friend _LIBCPP_HIDE_FROM_ABI bool operator<=(const path& __lhs, const path& __rhs) noexcept {
981 return __lhs.__compare(__rhs.__pn_) <= 0;1048 return __lhs.__compare(__rhs.__pn_) <= 0;
982 }1049 }
983 friend _LIBCPP_INLINE_VISIBILITY bool operator>(const path& __lhs, const path& __rhs) noexcept {1050 friend _LIBCPP_HIDE_FROM_ABI bool operator>(const path& __lhs, const path& __rhs) noexcept {
984 return __lhs.__compare(__rhs.__pn_) > 0;1051 return __lhs.__compare(__rhs.__pn_) > 0;
985 }1052 }
986 friend _LIBCPP_INLINE_VISIBILITY bool operator>=(const path& __lhs, const path& __rhs) noexcept {1053 friend _LIBCPP_HIDE_FROM_ABI bool operator>=(const path& __lhs, const path& __rhs) noexcept {
987 return __lhs.__compare(__rhs.__pn_) >= 0;1054 return __lhs.__compare(__rhs.__pn_) >= 0;
988 }1055 }
9891056
990 friend _LIBCPP_INLINE_VISIBILITY path operator/(const path& __lhs,1057 friend _LIBCPP_HIDE_FROM_ABI path operator/(const path& __lhs, const path& __rhs) {
991 const path& __rhs) {
992 path __result(__lhs);1058 path __result(__lhs);
993 __result /= __rhs;1059 __result /= __rhs;
994 return __result;1060 return __result;
995 }1061 }
996private:1062private:
997 inline _LIBCPP_INLINE_VISIBILITY path&1063 inline _LIBCPP_HIDE_FROM_ABI path&
998 __assign_view(__string_view const& __s) noexcept {1064 __assign_view(__string_view const& __s) noexcept {
999 __pn_ = string_type(__s);1065 __pn_ = string_type(__s);
1000 return *this;1066 return *this;
...@@ -1002,7 +1068,7 @@ private:...@@ -1002,7 +1068,7 @@ private:
1002 string_type __pn_;1068 string_type __pn_;
1003};1069};
10041070
1005inline _LIBCPP_INLINE_VISIBILITY void swap(path& __lhs, path& __rhs) noexcept {1071inline _LIBCPP_HIDE_FROM_ABI void swap(path& __lhs, path& __rhs) noexcept {
1006 __lhs.swap(__rhs);1072 __lhs.swap(__rhs);
1007}1073}
10081074
lib/libcxx/include/__filesystem/path_iterator.h+5-1
...@@ -10,15 +10,19 @@...@@ -10,15 +10,19 @@
10#ifndef _LIBCPP___FILESYSTEM_PATH_ITERATOR_H10#ifndef _LIBCPP___FILESYSTEM_PATH_ITERATOR_H
11#define _LIBCPP___FILESYSTEM_PATH_ITERATOR_H11#define _LIBCPP___FILESYSTEM_PATH_ITERATOR_H
1212
13#include <__assert>
13#include <__availability>14#include <__availability>
14#include <__config>15#include <__config>
15#include <__debug>
16#include <__filesystem/path.h>16#include <__filesystem/path.h>
17#include <__iterator/iterator_traits.h>17#include <__iterator/iterator_traits.h>
18#include <cstddef>18#include <cstddef>
19#include <string>19#include <string>
20#include <string_view>20#include <string_view>
2121
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23# pragma GCC system_header
24#endif
25
22#ifndef _LIBCPP_CXX03_LANG26#ifndef _LIBCPP_CXX03_LANG
2327
24_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM28_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
lib/libcxx/include/__filesystem/perm_options.h+21-17
...@@ -13,6 +13,10 @@...@@ -13,6 +13,10 @@
13#include <__availability>13#include <__availability>
14#include <__config>14#include <__config>
1515
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header
18#endif
19
16#ifndef _LIBCPP_CXX03_LANG20#ifndef _LIBCPP_CXX03_LANG
1721
18_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM22_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
...@@ -27,41 +31,41 @@ enum class _LIBCPP_ENUM_VIS perm_options : unsigned char {...@@ -27,41 +31,41 @@ enum class _LIBCPP_ENUM_VIS perm_options : unsigned char {
27};31};
2832
29_LIBCPP_INLINE_VISIBILITY33_LIBCPP_INLINE_VISIBILITY
30inline constexpr perm_options operator&(perm_options _LHS, perm_options _RHS) {34inline constexpr perm_options operator&(perm_options __lhs, perm_options __rhs) {
31 return static_cast<perm_options>(static_cast<unsigned>(_LHS) &35 return static_cast<perm_options>(static_cast<unsigned>(__lhs) &
32 static_cast<unsigned>(_RHS));36 static_cast<unsigned>(__rhs));
33}37}
3438
35_LIBCPP_INLINE_VISIBILITY39_LIBCPP_INLINE_VISIBILITY
36inline constexpr perm_options operator|(perm_options _LHS, perm_options _RHS) {40inline constexpr perm_options operator|(perm_options __lhs, perm_options __rhs) {
37 return static_cast<perm_options>(static_cast<unsigned>(_LHS) |41 return static_cast<perm_options>(static_cast<unsigned>(__lhs) |
38 static_cast<unsigned>(_RHS));42 static_cast<unsigned>(__rhs));
39}43}
4044
41_LIBCPP_INLINE_VISIBILITY45_LIBCPP_INLINE_VISIBILITY
42inline constexpr perm_options operator^(perm_options _LHS, perm_options _RHS) {46inline constexpr perm_options operator^(perm_options __lhs, perm_options __rhs) {
43 return static_cast<perm_options>(static_cast<unsigned>(_LHS) ^47 return static_cast<perm_options>(static_cast<unsigned>(__lhs) ^
44 static_cast<unsigned>(_RHS));48 static_cast<unsigned>(__rhs));
45}49}
4650
47_LIBCPP_INLINE_VISIBILITY51_LIBCPP_INLINE_VISIBILITY
48inline constexpr perm_options operator~(perm_options _LHS) {52inline constexpr perm_options operator~(perm_options __lhs) {
49 return static_cast<perm_options>(~static_cast<unsigned>(_LHS));53 return static_cast<perm_options>(~static_cast<unsigned>(__lhs));
50}54}
5155
52_LIBCPP_INLINE_VISIBILITY56_LIBCPP_INLINE_VISIBILITY
53inline perm_options& operator&=(perm_options& _LHS, perm_options _RHS) {57inline perm_options& operator&=(perm_options& __lhs, perm_options __rhs) {
54 return _LHS = _LHS & _RHS;58 return __lhs = __lhs & __rhs;
55}59}
5660
57_LIBCPP_INLINE_VISIBILITY61_LIBCPP_INLINE_VISIBILITY
58inline perm_options& operator|=(perm_options& _LHS, perm_options _RHS) {62inline perm_options& operator|=(perm_options& __lhs, perm_options __rhs) {
59 return _LHS = _LHS | _RHS;63 return __lhs = __lhs | __rhs;
60}64}
6165
62_LIBCPP_INLINE_VISIBILITY66_LIBCPP_INLINE_VISIBILITY
63inline perm_options& operator^=(perm_options& _LHS, perm_options _RHS) {67inline perm_options& operator^=(perm_options& __lhs, perm_options __rhs) {
64 return _LHS = _LHS ^ _RHS;68 return __lhs = __lhs ^ __rhs;
65}69}
6670
67_LIBCPP_AVAILABILITY_FILESYSTEM_POP71_LIBCPP_AVAILABILITY_FILESYSTEM_POP
lib/libcxx/include/__filesystem/perms.h+18-14
...@@ -13,6 +13,10 @@...@@ -13,6 +13,10 @@
13#include <__availability>13#include <__availability>
14#include <__config>14#include <__config>
1515
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header
18#endif
19
16#ifndef _LIBCPP_CXX03_LANG20#ifndef _LIBCPP_CXX03_LANG
1721
18_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM22_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
...@@ -51,36 +55,36 @@ enum class _LIBCPP_ENUM_VIS perms : unsigned {...@@ -51,36 +55,36 @@ enum class _LIBCPP_ENUM_VIS perms : unsigned {
51};55};
5256
53_LIBCPP_INLINE_VISIBILITY57_LIBCPP_INLINE_VISIBILITY
54inline constexpr perms operator&(perms _LHS, perms _RHS) {58inline constexpr perms operator&(perms __lhs, perms __rhs) {
55 return static_cast<perms>(static_cast<unsigned>(_LHS) &59 return static_cast<perms>(static_cast<unsigned>(__lhs) &
56 static_cast<unsigned>(_RHS));60 static_cast<unsigned>(__rhs));
57}61}
5862
59_LIBCPP_INLINE_VISIBILITY63_LIBCPP_INLINE_VISIBILITY
60inline constexpr perms operator|(perms _LHS, perms _RHS) {64inline constexpr perms operator|(perms __lhs, perms __rhs) {
61 return static_cast<perms>(static_cast<unsigned>(_LHS) |65 return static_cast<perms>(static_cast<unsigned>(__lhs) |
62 static_cast<unsigned>(_RHS));66 static_cast<unsigned>(__rhs));
63}67}
6468
65_LIBCPP_INLINE_VISIBILITY69_LIBCPP_INLINE_VISIBILITY
66inline constexpr perms operator^(perms _LHS, perms _RHS) {70inline constexpr perms operator^(perms __lhs, perms __rhs) {
67 return static_cast<perms>(static_cast<unsigned>(_LHS) ^71 return static_cast<perms>(static_cast<unsigned>(__lhs) ^
68 static_cast<unsigned>(_RHS));72 static_cast<unsigned>(__rhs));
69}73}
7074
71_LIBCPP_INLINE_VISIBILITY75_LIBCPP_INLINE_VISIBILITY
72inline constexpr perms operator~(perms _LHS) {76inline constexpr perms operator~(perms __lhs) {
73 return static_cast<perms>(~static_cast<unsigned>(_LHS));77 return static_cast<perms>(~static_cast<unsigned>(__lhs));
74}78}
7579
76_LIBCPP_INLINE_VISIBILITY80_LIBCPP_INLINE_VISIBILITY
77inline perms& operator&=(perms& _LHS, perms _RHS) { return _LHS = _LHS & _RHS; }81inline perms& operator&=(perms& __lhs, perms __rhs) { return __lhs = __lhs & __rhs; }
7882
79_LIBCPP_INLINE_VISIBILITY83_LIBCPP_INLINE_VISIBILITY
80inline perms& operator|=(perms& _LHS, perms _RHS) { return _LHS = _LHS | _RHS; }84inline perms& operator|=(perms& __lhs, perms __rhs) { return __lhs = __lhs | __rhs; }
8185
82_LIBCPP_INLINE_VISIBILITY86_LIBCPP_INLINE_VISIBILITY
83inline perms& operator^=(perms& _LHS, perms _RHS) { return _LHS = _LHS ^ _RHS; }87inline perms& operator^=(perms& __lhs, perms __rhs) { return __lhs = __lhs ^ __rhs; }
8488
85_LIBCPP_AVAILABILITY_FILESYSTEM_POP89_LIBCPP_AVAILABILITY_FILESYSTEM_POP
8690
lib/libcxx/include/__filesystem/recursive_directory_iterator.h+6-2
...@@ -22,6 +22,10 @@...@@ -22,6 +22,10 @@
22#include <cstddef>22#include <cstddef>
23#include <system_error>23#include <system_error>
2424
25#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
26# pragma GCC system_header
27#endif
28
25#ifndef _LIBCPP_CXX03_LANG29#ifndef _LIBCPP_CXX03_LANG
2630
27_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM31_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
...@@ -164,7 +168,7 @@ _LIBCPP_AVAILABILITY_FILESYSTEM_POP...@@ -164,7 +168,7 @@ _LIBCPP_AVAILABILITY_FILESYSTEM_POP
164168
165_LIBCPP_END_NAMESPACE_FILESYSTEM169_LIBCPP_END_NAMESPACE_FILESYSTEM
166170
167#if !defined(_LIBCPP_HAS_NO_CONCEPTS)171#if _LIBCPP_STD_VER > 17
168172
169template <>173template <>
170_LIBCPP_AVAILABILITY_FILESYSTEM174_LIBCPP_AVAILABILITY_FILESYSTEM
...@@ -174,7 +178,7 @@ template <>...@@ -174,7 +178,7 @@ template <>
174_LIBCPP_AVAILABILITY_FILESYSTEM178_LIBCPP_AVAILABILITY_FILESYSTEM
175inline constexpr bool _VSTD::ranges::enable_view<_VSTD_FS::recursive_directory_iterator> = true;179inline constexpr bool _VSTD::ranges::enable_view<_VSTD_FS::recursive_directory_iterator> = true;
176180
177#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)181#endif // _LIBCPP_STD_VER > 17
178182
179#endif // _LIBCPP_CXX03_LANG183#endif // _LIBCPP_CXX03_LANG
180184
lib/libcxx/include/__filesystem/space_info.h+4
...@@ -14,6 +14,10 @@...@@ -14,6 +14,10 @@
14#include <__config>14#include <__config>
15#include <cstdint>15#include <cstdint>
1616
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header
19#endif
20
17#ifndef _LIBCPP_CXX03_LANG21#ifndef _LIBCPP_CXX03_LANG
1822
19_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM23_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
lib/libcxx/include/__filesystem/u8path.h+12
...@@ -10,11 +10,23 @@...@@ -10,11 +10,23 @@
10#ifndef _LIBCPP___FILESYSTEM_U8PATH_H10#ifndef _LIBCPP___FILESYSTEM_U8PATH_H
11#define _LIBCPP___FILESYSTEM_U8PATH_H11#define _LIBCPP___FILESYSTEM_U8PATH_H
1212
13#include <__algorithm/unwrap_iter.h>
13#include <__availability>14#include <__availability>
14#include <__config>15#include <__config>
15#include <__filesystem/path.h>16#include <__filesystem/path.h>
17#include <string>
16#include <type_traits>18#include <type_traits>
1719
20// Only required on Windows for __widen_from_utf8, and included conservatively
21// because it requires support for localization.
22#if defined(_LIBCPP_WIN32API)
23# include <locale>
24#endif
25
26#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
27# pragma GCC system_header
28#endif
29
18#ifndef _LIBCPP_CXX03_LANG30#ifndef _LIBCPP_CXX03_LANG
1931
20_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM32_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
lib/libcxx/include/__format/buffer.h created+369
...@@ -0,0 +1,369 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___FORMAT_BUFFER_H
11#define _LIBCPP___FORMAT_BUFFER_H
12
13#include <__algorithm/copy_n.h>
14#include <__algorithm/max.h>
15#include <__algorithm/min.h>
16#include <__algorithm/unwrap_iter.h>
17#include <__config>
18#include <__format/enable_insertable.h>
19#include <__format/format_to_n_result.h>
20#include <__format/formatter.h> // for __char_type TODO FMT Move the concept?
21#include <__iterator/back_insert_iterator.h>
22#include <__iterator/concepts.h>
23#include <__iterator/incrementable_traits.h>
24#include <__iterator/iterator_traits.h>
25#include <__iterator/wrap_iter.h>
26#include <__utility/move.h>
27#include <concepts>
28#include <cstddef>
29#include <type_traits>
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 > 17
41
42namespace __format {
43
44/// A "buffer" that handles writing to the proper iterator.
45///
46/// This helper is used together with the @ref back_insert_iterator to offer
47/// type-erasure for the formatting functions. This reduces the number to
48/// template instantiations.
49template <__formatter::__char_type _CharT>
50class _LIBCPP_TEMPLATE_VIS __output_buffer {
51public:
52 using value_type = _CharT;
53
54 template <class _Tp>
55 _LIBCPP_HIDE_FROM_ABI explicit __output_buffer(_CharT* __ptr,
56 size_t __capacity, _Tp* __obj)
57 : __ptr_(__ptr), __capacity_(__capacity),
58 __flush_([](_CharT* __p, size_t __size, void* __o) {
59 static_cast<_Tp*>(__o)->flush(__p, __size);
60 }),
61 __obj_(__obj) {}
62
63 _LIBCPP_HIDE_FROM_ABI void reset(_CharT* __ptr, size_t __capacity) {
64 __ptr_ = __ptr;
65 __capacity_ = __capacity;
66 }
67
68 _LIBCPP_HIDE_FROM_ABI auto make_output_iterator() {
69 return back_insert_iterator{*this};
70 }
71
72 // TODO FMT It would be nice to have an overload taking a
73 // basic_string_view<_CharT> and append it directly.
74 _LIBCPP_HIDE_FROM_ABI void push_back(_CharT __c) {
75 __ptr_[__size_++] = __c;
76
77 // Profiling showed flushing after adding is more efficient than flushing
78 // when entering the function.
79 if (__size_ == __capacity_)
80 flush();
81 }
82
83 _LIBCPP_HIDE_FROM_ABI void flush() {
84 __flush_(__ptr_, __size_, __obj_);
85 __size_ = 0;
86 }
87
88private:
89 _CharT* __ptr_;
90 size_t __capacity_;
91 size_t __size_{0};
92 void (*__flush_)(_CharT*, size_t, void*);
93 void* __obj_;
94};
95
96/// A storage using an internal buffer.
97///
98/// This storage is used when writing a single element to the output iterator
99/// is expensive.
100template <__formatter::__char_type _CharT>
101class _LIBCPP_TEMPLATE_VIS __internal_storage {
102public:
103 _LIBCPP_HIDE_FROM_ABI _CharT* begin() { return __buffer_; }
104
105 static constexpr size_t __buffer_size = 256 / sizeof(_CharT);
106
107private:
108 _CharT __buffer_[__buffer_size];
109};
110
111/// A storage writing directly to the storage.
112///
113/// This requires the storage to be a contiguous buffer of \a _CharT.
114/// Since the output is directly written to the underlying storage this class
115/// is just an empty class.
116template <__formatter::__char_type _CharT>
117class _LIBCPP_TEMPLATE_VIS __direct_storage {};
118
119template <class _OutIt, class _CharT>
120concept __enable_direct_output = __formatter::__char_type<_CharT> &&
121 (same_as<_OutIt, _CharT*>
122#ifndef _LIBCPP_ENABLE_DEBUG_MODE
123 || same_as<_OutIt, __wrap_iter<_CharT*>>
124#endif
125 );
126
127/// Write policy for directly writing to the underlying output.
128template <class _OutIt, __formatter::__char_type _CharT>
129class _LIBCPP_TEMPLATE_VIS __writer_direct {
130public:
131 _LIBCPP_HIDE_FROM_ABI explicit __writer_direct(_OutIt __out_it)
132 : __out_it_(__out_it) {}
133
134 _LIBCPP_HIDE_FROM_ABI auto out() { return __out_it_; }
135
136 _LIBCPP_HIDE_FROM_ABI void flush(_CharT*, size_t __size) {
137 // _OutIt can be a __wrap_iter<CharT*>. Therefore the original iterator
138 // is adjusted.
139 __out_it_ += __size;
140 }
141
142private:
143 _OutIt __out_it_;
144};
145
146/// Write policy for copying the buffer to the output.
147template <class _OutIt, __formatter::__char_type _CharT>
148class _LIBCPP_TEMPLATE_VIS __writer_iterator {
149public:
150 _LIBCPP_HIDE_FROM_ABI explicit __writer_iterator(_OutIt __out_it)
151 : __out_it_{_VSTD::move(__out_it)} {}
152
153 _LIBCPP_HIDE_FROM_ABI auto out() { return __out_it_; }
154
155 _LIBCPP_HIDE_FROM_ABI void flush(_CharT* __ptr, size_t __size) {
156 __out_it_ = _VSTD::copy_n(__ptr, __size, _VSTD::move(__out_it_));
157 }
158
159private:
160 _OutIt __out_it_;
161};
162
163/// Concept to see whether a \a _Container is insertable.
164///
165/// The concept is used to validate whether multiple calls to a
166/// \ref back_insert_iterator can be replace by a call to \c _Container::insert.
167///
168/// \note a \a _Container needs to opt-in to the concept by specializing
169/// \ref __enable_insertable.
170template <class _Container>
171concept __insertable =
172 __enable_insertable<_Container> && __formatter::__char_type<typename _Container::value_type> &&
173 requires(_Container& __t, add_pointer_t<typename _Container::value_type> __first,
174 add_pointer_t<typename _Container::value_type> __last) { __t.insert(__t.end(), __first, __last); };
175
176/// Extract the container type of a \ref back_insert_iterator.
177template <class _It>
178struct _LIBCPP_TEMPLATE_VIS __back_insert_iterator_container {
179 using type = void;
180};
181
182template <__insertable _Container>
183struct _LIBCPP_TEMPLATE_VIS __back_insert_iterator_container<back_insert_iterator<_Container>> {
184 using type = _Container;
185};
186
187/// Write policy for inserting the buffer in a container.
188template <class _Container>
189class _LIBCPP_TEMPLATE_VIS __writer_container {
190public:
191 using _CharT = typename _Container::value_type;
192
193 _LIBCPP_HIDE_FROM_ABI explicit __writer_container(back_insert_iterator<_Container> __out_it)
194 : __container_{__out_it.__get_container()} {}
195
196 _LIBCPP_HIDE_FROM_ABI auto out() { return back_inserter(*__container_); }
197
198 _LIBCPP_HIDE_FROM_ABI void flush(_CharT* __ptr, size_t __size) {
199 __container_->insert(__container_->end(), __ptr, __ptr + __size);
200 }
201
202private:
203 _Container* __container_;
204};
205
206/// Selects the type of the writer used for the output iterator.
207template <class _OutIt, class _CharT>
208class _LIBCPP_TEMPLATE_VIS __writer_selector {
209 using _Container = typename __back_insert_iterator_container<_OutIt>::type;
210
211public:
212 using type = conditional_t<!same_as<_Container, void>, __writer_container<_Container>,
213 conditional_t<__enable_direct_output<_OutIt, _CharT>, __writer_direct<_OutIt, _CharT>,
214 __writer_iterator<_OutIt, _CharT>>>;
215};
216
217/// The generic formatting buffer.
218template <class _OutIt, __formatter::__char_type _CharT>
219requires(output_iterator<_OutIt, const _CharT&>) class _LIBCPP_TEMPLATE_VIS
220 __format_buffer {
221 using _Storage =
222 conditional_t<__enable_direct_output<_OutIt, _CharT>,
223 __direct_storage<_CharT>, __internal_storage<_CharT>>;
224
225public:
226 _LIBCPP_HIDE_FROM_ABI explicit __format_buffer(_OutIt __out_it)
227 requires(same_as<_Storage, __internal_storage<_CharT>>)
228 : __output_(__storage_.begin(), __storage_.__buffer_size, this), __writer_(_VSTD::move(__out_it)) {}
229
230 _LIBCPP_HIDE_FROM_ABI explicit __format_buffer(_OutIt __out_it) requires(
231 same_as<_Storage, __direct_storage<_CharT>>)
232 : __output_(_VSTD::__unwrap_iter(__out_it), size_t(-1), this),
233 __writer_(_VSTD::move(__out_it)) {}
234
235 _LIBCPP_HIDE_FROM_ABI auto make_output_iterator() {
236 return __output_.make_output_iterator();
237 }
238
239 _LIBCPP_HIDE_FROM_ABI void flush(_CharT* __ptr, size_t __size) {
240 __writer_.flush(__ptr, __size);
241 }
242
243 _LIBCPP_HIDE_FROM_ABI _OutIt out() && {
244 __output_.flush();
245 return _VSTD::move(__writer_).out();
246 }
247
248private:
249 _LIBCPP_NO_UNIQUE_ADDRESS _Storage __storage_;
250 __output_buffer<_CharT> __output_;
251 typename __writer_selector<_OutIt, _CharT>::type __writer_;
252};
253
254/// A buffer that counts the number of insertions.
255///
256/// Since \ref formatted_size only needs to know the size, the output itself is
257/// discarded.
258template <__formatter::__char_type _CharT>
259class _LIBCPP_TEMPLATE_VIS __formatted_size_buffer {
260public:
261 _LIBCPP_HIDE_FROM_ABI auto make_output_iterator() { return __output_.make_output_iterator(); }
262
263 _LIBCPP_HIDE_FROM_ABI void flush(const _CharT*, size_t __size) { __size_ += __size; }
264
265 _LIBCPP_HIDE_FROM_ABI size_t result() && {
266 __output_.flush();
267 return __size_;
268 }
269
270private:
271 __internal_storage<_CharT> __storage_;
272 __output_buffer<_CharT> __output_{__storage_.begin(), __storage_.__buffer_size, this};
273 size_t __size_{0};
274};
275
276/// The base of a buffer that counts and limits the number of insertions.
277template <class _OutIt, __formatter::__char_type _CharT, bool>
278 requires(output_iterator<_OutIt, const _CharT&>)
279struct _LIBCPP_TEMPLATE_VIS __format_to_n_buffer_base {
280 using _Size = iter_difference_t<_OutIt>;
281
282public:
283 _LIBCPP_HIDE_FROM_ABI explicit __format_to_n_buffer_base(_OutIt __out_it, _Size __n)
284 : __writer_(_VSTD::move(__out_it)), __n_(_VSTD::max(_Size(0), __n)) {}
285
286 _LIBCPP_HIDE_FROM_ABI void flush(_CharT* __ptr, size_t __size) {
287 if (_Size(__size_) <= __n_)
288 __writer_.flush(__ptr, _VSTD::min(_Size(__size), __n_ - __size_));
289 __size_ += __size;
290 }
291
292protected:
293 __internal_storage<_CharT> __storage_;
294 __output_buffer<_CharT> __output_{__storage_.begin(), __storage_.__buffer_size, this};
295 typename __writer_selector<_OutIt, _CharT>::type __writer_;
296
297 _Size __n_;
298 _Size __size_{0};
299};
300
301/// The base of a buffer that counts and limits the number of insertions.
302///
303/// This version is used when \c __enable_direct_output<_OutIt, _CharT> == true.
304///
305/// This class limits the size available the the direct writer so it will not
306/// exceed the maximum number of code units.
307template <class _OutIt, __formatter::__char_type _CharT>
308 requires(output_iterator<_OutIt, const _CharT&>)
309class _LIBCPP_TEMPLATE_VIS __format_to_n_buffer_base<_OutIt, _CharT, true> {
310 using _Size = iter_difference_t<_OutIt>;
311
312public:
313 _LIBCPP_HIDE_FROM_ABI explicit __format_to_n_buffer_base(_OutIt __out_it, _Size __n)
314 : __output_(_VSTD::__unwrap_iter(__out_it), __n, this), __writer_(_VSTD::move(__out_it)) {
315 if (__n <= 0) [[unlikely]]
316 __output_.reset(__storage_.begin(), __storage_.__buffer_size);
317 }
318
319 _LIBCPP_HIDE_FROM_ABI void flush(_CharT* __ptr, size_t __size) {
320 // A flush to the direct writer happens in two occasions:
321 // - The format function has written the maximum number of allowed code
322 // units. At this point it's no longer valid to write to this writer. So
323 // switch to the internal storage. This internal storage doesn't need to
324 // be written anywhere so the flush for that storage writes no output.
325 // - The format_to_n function is finished. In this case there's no need to
326 // switch the buffer, but for simplicity the buffers are still switched.
327 // When the __n <= 0 the constructor already switched the buffers.
328 if (__size_ == 0 && __ptr != __storage_.begin()) {
329 __writer_.flush(__ptr, __size);
330 __output_.reset(__storage_.begin(), __storage_.__buffer_size);
331 }
332
333 __size_ += __size;
334 }
335
336protected:
337 __internal_storage<_CharT> __storage_;
338 __output_buffer<_CharT> __output_;
339 __writer_direct<_OutIt, _CharT> __writer_;
340
341 _Size __size_{0};
342};
343
344/// The buffer that counts and limits the number of insertions.
345template <class _OutIt, __formatter::__char_type _CharT>
346 requires(output_iterator<_OutIt, const _CharT&>)
347struct _LIBCPP_TEMPLATE_VIS __format_to_n_buffer final
348 : public __format_to_n_buffer_base< _OutIt, _CharT, __enable_direct_output<_OutIt, _CharT>> {
349 using _Base = __format_to_n_buffer_base<_OutIt, _CharT, __enable_direct_output<_OutIt, _CharT>>;
350 using _Size = iter_difference_t<_OutIt>;
351
352public:
353 _LIBCPP_HIDE_FROM_ABI explicit __format_to_n_buffer(_OutIt __out_it, _Size __n) : _Base(_VSTD::move(__out_it), __n) {}
354 _LIBCPP_HIDE_FROM_ABI auto make_output_iterator() { return this->__output_.make_output_iterator(); }
355
356 _LIBCPP_HIDE_FROM_ABI format_to_n_result<_OutIt> result() && {
357 this->__output_.flush();
358 return {_VSTD::move(this->__writer_).out(), this->__size_};
359 }
360};
361} // namespace __format
362
363#endif //_LIBCPP_STD_VER > 17
364
365_LIBCPP_END_NAMESPACE_STD
366
367_LIBCPP_POP_MACROS
368
369#endif // _LIBCPP___FORMAT_BUFFER_H
lib/libcxx/include/__format/concepts.h created+53
...@@ -0,0 +1,53 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___FORMAT_CONCEPTS_H
11#define _LIBCPP___FORMAT_CONCEPTS_H
12
13#include <__concepts/same_as.h>
14#include <__concepts/semiregular.h>
15#include <__config>
16#include <__format/format_fwd.h>
17#include <__format/format_parse_context.h>
18#include <type_traits>
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#if _LIBCPP_STD_VER > 17
27
28// The output iterator isn't specified. A formatter should accept any
29// output_iterator. This iterator is a minimal iterator to test the concept.
30// (Note testing for (w)format_context would be a valid choice, but requires
31// selecting the proper one depending on the type of _CharT.)
32template <class _CharT>
33using __fmt_iter_for = _CharT*;
34
35// The concept is based on P2286R6
36// It lacks the const of __cf as required by, the not yet accepted, LWG-3636.
37// The current formatters can't be easily adapted, but that is WIP.
38// TODO FMT properly implement this concepts once accepted.
39template <class _Tp, class _CharT>
40concept __formattable = (semiregular<formatter<remove_cvref_t<_Tp>, _CharT>>) &&
41 requires(formatter<remove_cvref_t<_Tp>, _CharT> __f,
42 formatter<remove_cvref_t<_Tp>, _CharT> __cf, _Tp __t,
43 basic_format_context<__fmt_iter_for<_CharT>, _CharT> __fc,
44 basic_format_parse_context<_CharT> __pc) {
45 { __f.parse(__pc) } -> same_as<typename basic_format_parse_context<_CharT>::iterator>;
46 { __cf.format(__t, __fc) } -> same_as<__fmt_iter_for<_CharT>>;
47 };
48
49#endif //_LIBCPP_STD_VER > 17
50
51_LIBCPP_END_NAMESPACE_STD
52
53#endif // _LIBCPP___FORMAT_CONCEPTS_H
lib/libcxx/include/__format/enable_insertable.h created+35
...@@ -0,0 +1,35 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___FORMAT_ENABLE_INSERTABLE_H
11#define _LIBCPP___FORMAT_ENABLE_INSERTABLE_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#if _LIBCPP_STD_VER > 17
22
23namespace __format {
24
25/// Opt-in to enable \ref __insertable for a \a _Container.
26template <class _Container>
27inline constexpr bool __enable_insertable = false;
28
29} // namespace __format
30
31#endif //_LIBCPP_STD_VER > 17
32
33_LIBCPP_END_NAMESPACE_STD
34
35#endif // _LIBCPP___FORMAT_ENABLE_INSERTABLE_H
lib/libcxx/include/__format/extended_grapheme_cluster_table.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// WARNING, this entire header is generated by
11// utiles/generate_extended_grapheme_cluster_table.py
12// DO NOT MODIFY!
13
14// UNICODE, INC. LICENSE AGREEMENT - DATA FILES AND SOFTWARE
15//
16// See Terms of Use <https://www.unicode.org/copyright.html>
17// for definitions of Unicode Inc.'s Data Files and Software.
18//
19// NOTICE TO USER: Carefully read the following legal agreement.
20// BY DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING UNICODE INC.'S
21// DATA FILES ("DATA FILES"), AND/OR SOFTWARE ("SOFTWARE"),
22// YOU UNEQUIVOCALLY ACCEPT, AND AGREE TO BE BOUND BY, ALL OF THE
23// TERMS AND CONDITIONS OF THIS AGREEMENT.
24// IF YOU DO NOT AGREE, DO NOT DOWNLOAD, INSTALL, COPY, DISTRIBUTE OR USE
25// THE DATA FILES OR SOFTWARE.
26//
27// COPYRIGHT AND PERMISSION NOTICE
28//
29// Copyright (c) 1991-2022 Unicode, Inc. All rights reserved.
30// Distributed under the Terms of Use in https://www.unicode.org/copyright.html.
31//
32// Permission is hereby granted, free of charge, to any person obtaining
33// a copy of the Unicode data files and any associated documentation
34// (the "Data Files") or Unicode software and any associated documentation
35// (the "Software") to deal in the Data Files or Software
36// without restriction, including without limitation the rights to use,
37// copy, modify, merge, publish, distribute, and/or sell copies of
38// the Data Files or Software, and to permit persons to whom the Data Files
39// or Software are furnished to do so, provided that either
40// (a) this copyright and permission notice appear with all copies
41// of the Data Files or Software, or
42// (b) this copyright and permission notice appear in associated
43// Documentation.
44//
45// THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF
46// ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
47// WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
48// NONINFRINGEMENT OF THIRD PARTY RIGHTS.
49// IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS
50// NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL
51// DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
52// DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
53// TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
54// PERFORMANCE OF THE DATA FILES OR SOFTWARE.
55//
56// Except as contained in this notice, the name of a copyright holder
57// shall not be used in advertising or otherwise to promote the sale,
58// use or other dealings in these Data Files or Software without prior
59// written authorization of the copyright holder.
60
61#ifndef _LIBCPP___FORMAT_EXTENDED_GRAPHEME_CLUSTER_TABLE_H
62#define _LIBCPP___FORMAT_EXTENDED_GRAPHEME_CLUSTER_TABLE_H
63
64#include <__algorithm/upper_bound.h>
65#include <__config>
66#include <__iterator/access.h>
67#include <cstddef>
68#include <cstdint>
69
70#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
71# pragma GCC system_header
72#endif
73
74_LIBCPP_BEGIN_NAMESPACE_STD
75
76#if _LIBCPP_STD_VER > 17
77
78namespace __extended_grapheme_custer_property_boundary {
79
80enum class __property : uint8_t {
81 // Values generated from the data files.
82 __CR,
83 __Control,
84 __Extend,
85 __Extended_Pictographic,
86 __L,
87 __LF,
88 __LV,
89 __LVT,
90 __Prepend,
91 __Regional_Indicator,
92 __SpacingMark,
93 __T,
94 __V,
95 __ZWJ,
96
97 // The properies below aren't stored in the "database".
98
99 // Text position properties.
100 __sot,
101 __eot,
102
103 // The code unit has none of above properties.
104 __none
105};
106
107/// The entries of the extended grapheme cluster bondary property table.
108///
109/// The data is generated from
110/// - https://www.unicode.org/Public/UCD/latest/ucd/auxiliary/GraphemeBreakProperty.txt
111/// - https://www.unicode.org/Public/UCD/latest/ucd/emoji/emoji-data.txt
112///
113/// The data has 3 values
114/// - bits [0, 3] The property. One of the values generated form the datafiles
115/// of \ref __property
116/// - bits [4, 10] The size of the range.
117/// - bits [11, 31] The lower bound code point of the range. The upper bound of
118/// the range is lower bound + size.
119///
120/// The 7 bits for the size allow a maximum range of 128 elements. Some ranges
121/// in the Unicode tables are larger. They are stored in multiple consecutive
122/// ranges in the data table. An alternative would be to store the sizes in a
123/// separate 16-bit value. The original MSVC STL code had such an approach, but
124/// this approach uses less space for the data and is about 4% faster in the
125/// following benchmark.
126/// libcxx/benchmarks/std_format_spec_string_unicode.bench.cpp
127inline constexpr uint32_t __entries[1480] = {
128 0x00000091, 0x00005005, 0x00005811, 0x00006800, 0x00007111, 0x0003fa01, 0x00054803, 0x00056801, 0x00057003,
129 0x001806f2, 0x00241862, 0x002c8ac2, 0x002df802, 0x002e0812, 0x002e2012, 0x002e3802, 0x00300058, 0x003080a2,
130 0x0030e001, 0x00325942, 0x00338002, 0x0036b062, 0x0036e808, 0x0036f852, 0x00373812, 0x00375032, 0x00387808,
131 0x00388802, 0x003981a2, 0x003d30a2, 0x003f5882, 0x003fe802, 0x0040b032, 0x0040d882, 0x00412822, 0x00414842,
132 0x0042c822, 0x00448018, 0x0044c072, 0x00465172, 0x00471008, 0x004719f2, 0x0048180a, 0x0049d002, 0x0049d80a,
133 0x0049e002, 0x0049f02a, 0x004a0872, 0x004a483a, 0x004a6802, 0x004a701a, 0x004a8862, 0x004b1012, 0x004c0802,
134 0x004c101a, 0x004de002, 0x004df002, 0x004df81a, 0x004e0832, 0x004e381a, 0x004e581a, 0x004e6802, 0x004eb802,
135 0x004f1012, 0x004ff002, 0x00500812, 0x0050180a, 0x0051e002, 0x0051f02a, 0x00520812, 0x00523812, 0x00525822,
136 0x00528802, 0x00538012, 0x0053a802, 0x00540812, 0x0054180a, 0x0055e002, 0x0055f02a, 0x00560842, 0x00563812,
137 0x0056480a, 0x0056581a, 0x00566802, 0x00571012, 0x0057d052, 0x00580802, 0x0058101a, 0x0059e002, 0x0059f012,
138 0x005a000a, 0x005a0832, 0x005a381a, 0x005a581a, 0x005a6802, 0x005aa822, 0x005b1012, 0x005c1002, 0x005df002,
139 0x005df80a, 0x005e0002, 0x005e081a, 0x005e302a, 0x005e502a, 0x005e6802, 0x005eb802, 0x00600002, 0x0060082a,
140 0x00602002, 0x0061e002, 0x0061f022, 0x0062083a, 0x00623022, 0x00625032, 0x0062a812, 0x00631012, 0x00640802,
141 0x0064101a, 0x0065e002, 0x0065f00a, 0x0065f802, 0x0066001a, 0x00661002, 0x0066181a, 0x00663002, 0x0066381a,
142 0x0066501a, 0x00666012, 0x0066a812, 0x00671012, 0x00680012, 0x0068101a, 0x0069d812, 0x0069f002, 0x0069f81a,
143 0x006a0832, 0x006a302a, 0x006a502a, 0x006a6802, 0x006a7008, 0x006ab802, 0x006b1012, 0x006c0802, 0x006c101a,
144 0x006e5002, 0x006e7802, 0x006e801a, 0x006e9022, 0x006eb002, 0x006ec06a, 0x006ef802, 0x006f901a, 0x00718802,
145 0x0071980a, 0x0071a062, 0x00723872, 0x00758802, 0x0075980a, 0x0075a082, 0x00764052, 0x0078c012, 0x0079a802,
146 0x0079b802, 0x0079c802, 0x0079f01a, 0x007b88d2, 0x007bf80a, 0x007c0042, 0x007c3012, 0x007c68a2, 0x007cca32,
147 0x007e3002, 0x00816832, 0x0081880a, 0x00819052, 0x0081c812, 0x0081d81a, 0x0081e812, 0x0082b01a, 0x0082c012,
148 0x0082f022, 0x00838832, 0x00841002, 0x0084200a, 0x00842812, 0x00846802, 0x0084e802, 0x008805f4, 0x008b047c,
149 0x008d457b, 0x009ae822, 0x00b89022, 0x00b8a80a, 0x00b99012, 0x00b9a00a, 0x00ba9012, 0x00bb9012, 0x00bda012,
150 0x00bdb00a, 0x00bdb862, 0x00bdf07a, 0x00be3002, 0x00be381a, 0x00be48a2, 0x00bee802, 0x00c05822, 0x00c07001,
151 0x00c07802, 0x00c42812, 0x00c54802, 0x00c90022, 0x00c9183a, 0x00c93812, 0x00c9482a, 0x00c9801a, 0x00c99002,
152 0x00c9985a, 0x00c9c822, 0x00d0b812, 0x00d0c81a, 0x00d0d802, 0x00d2a80a, 0x00d2b002, 0x00d2b80a, 0x00d2c062,
153 0x00d30002, 0x00d31002, 0x00d32872, 0x00d3685a, 0x00d39892, 0x00d3f802, 0x00d581e2, 0x00d80032, 0x00d8200a,
154 0x00d9a062, 0x00d9d80a, 0x00d9e002, 0x00d9e84a, 0x00da1002, 0x00da181a, 0x00db5882, 0x00dc0012, 0x00dc100a,
155 0x00dd080a, 0x00dd1032, 0x00dd301a, 0x00dd4012, 0x00dd500a, 0x00dd5822, 0x00df3002, 0x00df380a, 0x00df4012,
156 0x00df502a, 0x00df6802, 0x00df700a, 0x00df7822, 0x00df901a, 0x00e1207a, 0x00e16072, 0x00e1a01a, 0x00e1b012,
157 0x00e68022, 0x00e6a0c2, 0x00e7080a, 0x00e71062, 0x00e76802, 0x00e7a002, 0x00e7b80a, 0x00e7c012, 0x00ee03f2,
158 0x01005801, 0x01006002, 0x0100680d, 0x01007011, 0x01014061, 0x0101e003, 0x01024803, 0x010300f1, 0x01068202,
159 0x01091003, 0x0109c803, 0x010ca053, 0x010d4813, 0x0118d013, 0x01194003, 0x011c4003, 0x011e7803, 0x011f48a3,
160 0x011fc023, 0x01261003, 0x012d5013, 0x012db003, 0x012e0003, 0x012fd833, 0x01300053, 0x013038b3, 0x0130a713,
161 0x01348753, 0x013840a3, 0x0138a003, 0x0138b003, 0x0138e803, 0x01390803, 0x01394003, 0x01399813, 0x013a2003,
162 0x013a3803, 0x013a6003, 0x013a7003, 0x013a9823, 0x013ab803, 0x013b1843, 0x013ca823, 0x013d0803, 0x013d8003,
163 0x013df803, 0x0149a013, 0x01582823, 0x0158d813, 0x015a8003, 0x015aa803, 0x01677822, 0x016bf802, 0x016f01f2,
164 0x01815052, 0x01818003, 0x0181e803, 0x0184c812, 0x0194b803, 0x0194c803, 0x05337832, 0x0533a092, 0x0534f012,
165 0x05378012, 0x05401002, 0x05403002, 0x05405802, 0x0541181a, 0x05412812, 0x0541380a, 0x05416002, 0x0544001a,
166 0x0545a0fa, 0x05462012, 0x05470112, 0x0547f802, 0x05493072, 0x054a38a2, 0x054a901a, 0x054b01c4, 0x054c0022,
167 0x054c180a, 0x054d9802, 0x054da01a, 0x054db032, 0x054dd01a, 0x054de012, 0x054df02a, 0x054f2802, 0x05514852,
168 0x0551781a, 0x05518812, 0x0551981a, 0x0551a812, 0x05521802, 0x05526002, 0x0552680a, 0x0553e002, 0x05558002,
169 0x05559022, 0x0555b812, 0x0555f012, 0x05560802, 0x0557580a, 0x05576012, 0x0557701a, 0x0557a80a, 0x0557b002,
170 0x055f181a, 0x055f2802, 0x055f301a, 0x055f4002, 0x055f481a, 0x055f600a, 0x055f6802, 0x05600006, 0x056009a7,
171 0x0560e006, 0x0560e9a7, 0x0561c006, 0x0561c9a7, 0x0562a006, 0x0562a9a7, 0x05638006, 0x056389a7, 0x05646006,
172 0x056469a7, 0x05654006, 0x056549a7, 0x05662006, 0x056629a7, 0x05670006, 0x056709a7, 0x0567e006, 0x0567e9a7,
173 0x0568c006, 0x0568c9a7, 0x0569a006, 0x0569a9a7, 0x056a8006, 0x056a89a7, 0x056b6006, 0x056b69a7, 0x056c4006,
174 0x056c49a7, 0x056d2006, 0x056d29a7, 0x056e0006, 0x056e09a7, 0x056ee006, 0x056ee9a7, 0x056fc006, 0x056fc9a7,
175 0x0570a006, 0x0570a9a7, 0x05718006, 0x057189a7, 0x05726006, 0x057269a7, 0x05734006, 0x057349a7, 0x05742006,
176 0x057429a7, 0x05750006, 0x057509a7, 0x0575e006, 0x0575e9a7, 0x0576c006, 0x0576c9a7, 0x0577a006, 0x0577a9a7,
177 0x05788006, 0x057889a7, 0x05796006, 0x057969a7, 0x057a4006, 0x057a49a7, 0x057b2006, 0x057b29a7, 0x057c0006,
178 0x057c09a7, 0x057ce006, 0x057ce9a7, 0x057dc006, 0x057dc9a7, 0x057ea006, 0x057ea9a7, 0x057f8006, 0x057f89a7,
179 0x05806006, 0x058069a7, 0x05814006, 0x058149a7, 0x05822006, 0x058229a7, 0x05830006, 0x058309a7, 0x0583e006,
180 0x0583e9a7, 0x0584c006, 0x0584c9a7, 0x0585a006, 0x0585a9a7, 0x05868006, 0x058689a7, 0x05876006, 0x058769a7,
181 0x05884006, 0x058849a7, 0x05892006, 0x058929a7, 0x058a0006, 0x058a09a7, 0x058ae006, 0x058ae9a7, 0x058bc006,
182 0x058bc9a7, 0x058ca006, 0x058ca9a7, 0x058d8006, 0x058d89a7, 0x058e6006, 0x058e69a7, 0x058f4006, 0x058f49a7,
183 0x05902006, 0x059029a7, 0x05910006, 0x059109a7, 0x0591e006, 0x0591e9a7, 0x0592c006, 0x0592c9a7, 0x0593a006,
184 0x0593a9a7, 0x05948006, 0x059489a7, 0x05956006, 0x059569a7, 0x05964006, 0x059649a7, 0x05972006, 0x059729a7,
185 0x05980006, 0x059809a7, 0x0598e006, 0x0598e9a7, 0x0599c006, 0x0599c9a7, 0x059aa006, 0x059aa9a7, 0x059b8006,
186 0x059b89a7, 0x059c6006, 0x059c69a7, 0x059d4006, 0x059d49a7, 0x059e2006, 0x059e29a7, 0x059f0006, 0x059f09a7,
187 0x059fe006, 0x059fe9a7, 0x05a0c006, 0x05a0c9a7, 0x05a1a006, 0x05a1a9a7, 0x05a28006, 0x05a289a7, 0x05a36006,
188 0x05a369a7, 0x05a44006, 0x05a449a7, 0x05a52006, 0x05a529a7, 0x05a60006, 0x05a609a7, 0x05a6e006, 0x05a6e9a7,
189 0x05a7c006, 0x05a7c9a7, 0x05a8a006, 0x05a8a9a7, 0x05a98006, 0x05a989a7, 0x05aa6006, 0x05aa69a7, 0x05ab4006,
190 0x05ab49a7, 0x05ac2006, 0x05ac29a7, 0x05ad0006, 0x05ad09a7, 0x05ade006, 0x05ade9a7, 0x05aec006, 0x05aec9a7,
191 0x05afa006, 0x05afa9a7, 0x05b08006, 0x05b089a7, 0x05b16006, 0x05b169a7, 0x05b24006, 0x05b249a7, 0x05b32006,
192 0x05b329a7, 0x05b40006, 0x05b409a7, 0x05b4e006, 0x05b4e9a7, 0x05b5c006, 0x05b5c9a7, 0x05b6a006, 0x05b6a9a7,
193 0x05b78006, 0x05b789a7, 0x05b86006, 0x05b869a7, 0x05b94006, 0x05b949a7, 0x05ba2006, 0x05ba29a7, 0x05bb0006,
194 0x05bb09a7, 0x05bbe006, 0x05bbe9a7, 0x05bcc006, 0x05bcc9a7, 0x05bda006, 0x05bda9a7, 0x05be8006, 0x05be89a7,
195 0x05bf6006, 0x05bf69a7, 0x05c04006, 0x05c049a7, 0x05c12006, 0x05c129a7, 0x05c20006, 0x05c209a7, 0x05c2e006,
196 0x05c2e9a7, 0x05c3c006, 0x05c3c9a7, 0x05c4a006, 0x05c4a9a7, 0x05c58006, 0x05c589a7, 0x05c66006, 0x05c669a7,
197 0x05c74006, 0x05c749a7, 0x05c82006, 0x05c829a7, 0x05c90006, 0x05c909a7, 0x05c9e006, 0x05c9e9a7, 0x05cac006,
198 0x05cac9a7, 0x05cba006, 0x05cba9a7, 0x05cc8006, 0x05cc89a7, 0x05cd6006, 0x05cd69a7, 0x05ce4006, 0x05ce49a7,
199 0x05cf2006, 0x05cf29a7, 0x05d00006, 0x05d009a7, 0x05d0e006, 0x05d0e9a7, 0x05d1c006, 0x05d1c9a7, 0x05d2a006,
200 0x05d2a9a7, 0x05d38006, 0x05d389a7, 0x05d46006, 0x05d469a7, 0x05d54006, 0x05d549a7, 0x05d62006, 0x05d629a7,
201 0x05d70006, 0x05d709a7, 0x05d7e006, 0x05d7e9a7, 0x05d8c006, 0x05d8c9a7, 0x05d9a006, 0x05d9a9a7, 0x05da8006,
202 0x05da89a7, 0x05db6006, 0x05db69a7, 0x05dc4006, 0x05dc49a7, 0x05dd2006, 0x05dd29a7, 0x05de0006, 0x05de09a7,
203 0x05dee006, 0x05dee9a7, 0x05dfc006, 0x05dfc9a7, 0x05e0a006, 0x05e0a9a7, 0x05e18006, 0x05e189a7, 0x05e26006,
204 0x05e269a7, 0x05e34006, 0x05e349a7, 0x05e42006, 0x05e429a7, 0x05e50006, 0x05e509a7, 0x05e5e006, 0x05e5e9a7,
205 0x05e6c006, 0x05e6c9a7, 0x05e7a006, 0x05e7a9a7, 0x05e88006, 0x05e889a7, 0x05e96006, 0x05e969a7, 0x05ea4006,
206 0x05ea49a7, 0x05eb2006, 0x05eb29a7, 0x05ec0006, 0x05ec09a7, 0x05ece006, 0x05ece9a7, 0x05edc006, 0x05edc9a7,
207 0x05eea006, 0x05eea9a7, 0x05ef8006, 0x05ef89a7, 0x05f06006, 0x05f069a7, 0x05f14006, 0x05f149a7, 0x05f22006,
208 0x05f229a7, 0x05f30006, 0x05f309a7, 0x05f3e006, 0x05f3e9a7, 0x05f4c006, 0x05f4c9a7, 0x05f5a006, 0x05f5a9a7,
209 0x05f68006, 0x05f689a7, 0x05f76006, 0x05f769a7, 0x05f84006, 0x05f849a7, 0x05f92006, 0x05f929a7, 0x05fa0006,
210 0x05fa09a7, 0x05fae006, 0x05fae9a7, 0x05fbc006, 0x05fbc9a7, 0x05fca006, 0x05fca9a7, 0x05fd8006, 0x05fd89a7,
211 0x05fe6006, 0x05fe69a7, 0x05ff4006, 0x05ff49a7, 0x06002006, 0x060029a7, 0x06010006, 0x060109a7, 0x0601e006,
212 0x0601e9a7, 0x0602c006, 0x0602c9a7, 0x0603a006, 0x0603a9a7, 0x06048006, 0x060489a7, 0x06056006, 0x060569a7,
213 0x06064006, 0x060649a7, 0x06072006, 0x060729a7, 0x06080006, 0x060809a7, 0x0608e006, 0x0608e9a7, 0x0609c006,
214 0x0609c9a7, 0x060aa006, 0x060aa9a7, 0x060b8006, 0x060b89a7, 0x060c6006, 0x060c69a7, 0x060d4006, 0x060d49a7,
215 0x060e2006, 0x060e29a7, 0x060f0006, 0x060f09a7, 0x060fe006, 0x060fe9a7, 0x0610c006, 0x0610c9a7, 0x0611a006,
216 0x0611a9a7, 0x06128006, 0x061289a7, 0x06136006, 0x061369a7, 0x06144006, 0x061449a7, 0x06152006, 0x061529a7,
217 0x06160006, 0x061609a7, 0x0616e006, 0x0616e9a7, 0x0617c006, 0x0617c9a7, 0x0618a006, 0x0618a9a7, 0x06198006,
218 0x061989a7, 0x061a6006, 0x061a69a7, 0x061b4006, 0x061b49a7, 0x061c2006, 0x061c29a7, 0x061d0006, 0x061d09a7,
219 0x061de006, 0x061de9a7, 0x061ec006, 0x061ec9a7, 0x061fa006, 0x061fa9a7, 0x06208006, 0x062089a7, 0x06216006,
220 0x062169a7, 0x06224006, 0x062249a7, 0x06232006, 0x062329a7, 0x06240006, 0x062409a7, 0x0624e006, 0x0624e9a7,
221 0x0625c006, 0x0625c9a7, 0x0626a006, 0x0626a9a7, 0x06278006, 0x062789a7, 0x06286006, 0x062869a7, 0x06294006,
222 0x062949a7, 0x062a2006, 0x062a29a7, 0x062b0006, 0x062b09a7, 0x062be006, 0x062be9a7, 0x062cc006, 0x062cc9a7,
223 0x062da006, 0x062da9a7, 0x062e8006, 0x062e89a7, 0x062f6006, 0x062f69a7, 0x06304006, 0x063049a7, 0x06312006,
224 0x063129a7, 0x06320006, 0x063209a7, 0x0632e006, 0x0632e9a7, 0x0633c006, 0x0633c9a7, 0x0634a006, 0x0634a9a7,
225 0x06358006, 0x063589a7, 0x06366006, 0x063669a7, 0x06374006, 0x063749a7, 0x06382006, 0x063829a7, 0x06390006,
226 0x063909a7, 0x0639e006, 0x0639e9a7, 0x063ac006, 0x063ac9a7, 0x063ba006, 0x063ba9a7, 0x063c8006, 0x063c89a7,
227 0x063d6006, 0x063d69a7, 0x063e4006, 0x063e49a7, 0x063f2006, 0x063f29a7, 0x06400006, 0x064009a7, 0x0640e006,
228 0x0640e9a7, 0x0641c006, 0x0641c9a7, 0x0642a006, 0x0642a9a7, 0x06438006, 0x064389a7, 0x06446006, 0x064469a7,
229 0x06454006, 0x064549a7, 0x06462006, 0x064629a7, 0x06470006, 0x064709a7, 0x0647e006, 0x0647e9a7, 0x0648c006,
230 0x0648c9a7, 0x0649a006, 0x0649a9a7, 0x064a8006, 0x064a89a7, 0x064b6006, 0x064b69a7, 0x064c4006, 0x064c49a7,
231 0x064d2006, 0x064d29a7, 0x064e0006, 0x064e09a7, 0x064ee006, 0x064ee9a7, 0x064fc006, 0x064fc9a7, 0x0650a006,
232 0x0650a9a7, 0x06518006, 0x065189a7, 0x06526006, 0x065269a7, 0x06534006, 0x065349a7, 0x06542006, 0x065429a7,
233 0x06550006, 0x065509a7, 0x0655e006, 0x0655e9a7, 0x0656c006, 0x0656c9a7, 0x0657a006, 0x0657a9a7, 0x06588006,
234 0x065889a7, 0x06596006, 0x065969a7, 0x065a4006, 0x065a49a7, 0x065b2006, 0x065b29a7, 0x065c0006, 0x065c09a7,
235 0x065ce006, 0x065ce9a7, 0x065dc006, 0x065dc9a7, 0x065ea006, 0x065ea9a7, 0x065f8006, 0x065f89a7, 0x06606006,
236 0x066069a7, 0x06614006, 0x066149a7, 0x06622006, 0x066229a7, 0x06630006, 0x066309a7, 0x0663e006, 0x0663e9a7,
237 0x0664c006, 0x0664c9a7, 0x0665a006, 0x0665a9a7, 0x06668006, 0x066689a7, 0x06676006, 0x066769a7, 0x06684006,
238 0x066849a7, 0x06692006, 0x066929a7, 0x066a0006, 0x066a09a7, 0x066ae006, 0x066ae9a7, 0x066bc006, 0x066bc9a7,
239 0x066ca006, 0x066ca9a7, 0x066d8006, 0x066d89a7, 0x066e6006, 0x066e69a7, 0x066f4006, 0x066f49a7, 0x06702006,
240 0x067029a7, 0x06710006, 0x067109a7, 0x0671e006, 0x0671e9a7, 0x0672c006, 0x0672c9a7, 0x0673a006, 0x0673a9a7,
241 0x06748006, 0x067489a7, 0x06756006, 0x067569a7, 0x06764006, 0x067649a7, 0x06772006, 0x067729a7, 0x06780006,
242 0x067809a7, 0x0678e006, 0x0678e9a7, 0x0679c006, 0x0679c9a7, 0x067aa006, 0x067aa9a7, 0x067b8006, 0x067b89a7,
243 0x067c6006, 0x067c69a7, 0x067d4006, 0x067d49a7, 0x067e2006, 0x067e29a7, 0x067f0006, 0x067f09a7, 0x067fe006,
244 0x067fe9a7, 0x0680c006, 0x0680c9a7, 0x0681a006, 0x0681a9a7, 0x06828006, 0x068289a7, 0x06836006, 0x068369a7,
245 0x06844006, 0x068449a7, 0x06852006, 0x068529a7, 0x06860006, 0x068609a7, 0x0686e006, 0x0686e9a7, 0x0687c006,
246 0x0687c9a7, 0x0688a006, 0x0688a9a7, 0x06898006, 0x068989a7, 0x068a6006, 0x068a69a7, 0x068b4006, 0x068b49a7,
247 0x068c2006, 0x068c29a7, 0x068d0006, 0x068d09a7, 0x068de006, 0x068de9a7, 0x068ec006, 0x068ec9a7, 0x068fa006,
248 0x068fa9a7, 0x06908006, 0x069089a7, 0x06916006, 0x069169a7, 0x06924006, 0x069249a7, 0x06932006, 0x069329a7,
249 0x06940006, 0x069409a7, 0x0694e006, 0x0694e9a7, 0x0695c006, 0x0695c9a7, 0x0696a006, 0x0696a9a7, 0x06978006,
250 0x069789a7, 0x06986006, 0x069869a7, 0x06994006, 0x069949a7, 0x069a2006, 0x069a29a7, 0x069b0006, 0x069b09a7,
251 0x069be006, 0x069be9a7, 0x069cc006, 0x069cc9a7, 0x069da006, 0x069da9a7, 0x069e8006, 0x069e89a7, 0x069f6006,
252 0x069f69a7, 0x06a04006, 0x06a049a7, 0x06a12006, 0x06a129a7, 0x06a20006, 0x06a209a7, 0x06a2e006, 0x06a2e9a7,
253 0x06a3c006, 0x06a3c9a7, 0x06a4a006, 0x06a4a9a7, 0x06a58006, 0x06a589a7, 0x06a66006, 0x06a669a7, 0x06a74006,
254 0x06a749a7, 0x06a82006, 0x06a829a7, 0x06a90006, 0x06a909a7, 0x06a9e006, 0x06a9e9a7, 0x06aac006, 0x06aac9a7,
255 0x06aba006, 0x06aba9a7, 0x06ac8006, 0x06ac89a7, 0x06ad6006, 0x06ad69a7, 0x06ae4006, 0x06ae49a7, 0x06af2006,
256 0x06af29a7, 0x06b00006, 0x06b009a7, 0x06b0e006, 0x06b0e9a7, 0x06b1c006, 0x06b1c9a7, 0x06b2a006, 0x06b2a9a7,
257 0x06b38006, 0x06b389a7, 0x06b46006, 0x06b469a7, 0x06b54006, 0x06b549a7, 0x06b62006, 0x06b629a7, 0x06b70006,
258 0x06b709a7, 0x06b7e006, 0x06b7e9a7, 0x06b8c006, 0x06b8c9a7, 0x06b9a006, 0x06b9a9a7, 0x06ba8006, 0x06ba89a7,
259 0x06bb6006, 0x06bb69a7, 0x06bc4006, 0x06bc49a7, 0x06bd816c, 0x06be5b0b, 0x07d8f002, 0x07f000f2, 0x07f100f2,
260 0x07f7f801, 0x07fcf012, 0x07ff80b1, 0x080fe802, 0x08170002, 0x081bb042, 0x08500822, 0x08502812, 0x08506032,
261 0x0851c022, 0x0851f802, 0x08572812, 0x08692032, 0x08755812, 0x087a30a2, 0x087c1032, 0x0880000a, 0x08800802,
262 0x0880100a, 0x0881c0e2, 0x08838002, 0x08839812, 0x0883f822, 0x0884100a, 0x0885802a, 0x08859832, 0x0885b81a,
263 0x0885c812, 0x0885e808, 0x08861002, 0x08866808, 0x08880022, 0x08893842, 0x0889600a, 0x08896872, 0x088a281a,
264 0x088b9802, 0x088c0012, 0x088c100a, 0x088d982a, 0x088db082, 0x088df81a, 0x088e1018, 0x088e4832, 0x088e700a,
265 0x088e7802, 0x0891602a, 0x08917822, 0x0891901a, 0x0891a002, 0x0891a80a, 0x0891b012, 0x0891f002, 0x0896f802,
266 0x0897002a, 0x08971872, 0x08980012, 0x0898101a, 0x0899d812, 0x0899f002, 0x0899f80a, 0x089a0002, 0x089a083a,
267 0x089a381a, 0x089a582a, 0x089ab802, 0x089b101a, 0x089b3062, 0x089b8042, 0x08a1a82a, 0x08a1c072, 0x08a2001a,
268 0x08a21022, 0x08a2280a, 0x08a23002, 0x08a2f002, 0x08a58002, 0x08a5881a, 0x08a59852, 0x08a5c80a, 0x08a5d002,
269 0x08a5d81a, 0x08a5e802, 0x08a5f00a, 0x08a5f812, 0x08a6080a, 0x08a61012, 0x08ad7802, 0x08ad801a, 0x08ad9032,
270 0x08adc03a, 0x08ade012, 0x08adf00a, 0x08adf812, 0x08aee012, 0x08b1802a, 0x08b19872, 0x08b1d81a, 0x08b1e802,
271 0x08b1f00a, 0x08b1f812, 0x08b55802, 0x08b5600a, 0x08b56802, 0x08b5701a, 0x08b58052, 0x08b5b00a, 0x08b5b802,
272 0x08b8e822, 0x08b91032, 0x08b9300a, 0x08b93842, 0x08c1602a, 0x08c17882, 0x08c1c00a, 0x08c1c812, 0x08c98002,
273 0x08c9884a, 0x08c9b81a, 0x08c9d812, 0x08c9e80a, 0x08c9f002, 0x08c9f808, 0x08ca000a, 0x08ca0808, 0x08ca100a,
274 0x08ca1802, 0x08ce882a, 0x08cea032, 0x08ced012, 0x08cee03a, 0x08cf0002, 0x08cf200a, 0x08d00892, 0x08d19852,
275 0x08d1c80a, 0x08d1d008, 0x08d1d832, 0x08d23802, 0x08d28852, 0x08d2b81a, 0x08d2c822, 0x08d42058, 0x08d450c2,
276 0x08d4b80a, 0x08d4c012, 0x08e1780a, 0x08e18062, 0x08e1c052, 0x08e1f00a, 0x08e1f802, 0x08e49152, 0x08e5480a,
277 0x08e55062, 0x08e5880a, 0x08e59012, 0x08e5a00a, 0x08e5a812, 0x08e98852, 0x08e9d002, 0x08e9e012, 0x08e9f862,
278 0x08ea3008, 0x08ea3802, 0x08ec504a, 0x08ec8012, 0x08ec981a, 0x08eca802, 0x08ecb00a, 0x08ecb802, 0x08f79812,
279 0x08f7a81a, 0x09a18081, 0x0b578042, 0x0b598062, 0x0b7a7802, 0x0b7a8b6a, 0x0b7c7832, 0x0b7f2002, 0x0b7f801a,
280 0x0de4e812, 0x0de50031, 0x0e7802d2, 0x0e798162, 0x0e8b2802, 0x0e8b300a, 0x0e8b3822, 0x0e8b680a, 0x0e8b7042,
281 0x0e8b9871, 0x0e8bd872, 0x0e8c2862, 0x0e8d5032, 0x0e921022, 0x0ed00362, 0x0ed1db12, 0x0ed3a802, 0x0ed42002,
282 0x0ed4d842, 0x0ed508e2, 0x0f000062, 0x0f004102, 0x0f00d862, 0x0f011812, 0x0f013042, 0x0f098062, 0x0f157002,
283 0x0f176032, 0x0f468062, 0x0f4a2062, 0x0f8007f3, 0x0f8407f3, 0x0f886823, 0x0f897803, 0x0f8b6053, 0x0f8bf013,
284 0x0f8c7003, 0x0f8c8893, 0x0f8d6b83, 0x0f8f3199, 0x0f9008e3, 0x0f90d003, 0x0f917803, 0x0f919083, 0x0f91e033,
285 0x0f924ff3, 0x0f964ff3, 0x0f9a4ff3, 0x0f9e4b13, 0x0f9fd842, 0x0fa007f3, 0x0fa407f3, 0x0fa803d3, 0x0faa37f3,
286 0x0fae37f3, 0x0fb23093, 0x0fb407f3, 0x0fbba0b3, 0x0fbeaaa3, 0x0fc06033, 0x0fc24073, 0x0fc2d053, 0x0fc44073,
287 0x0fc57513, 0x0fc862e3, 0x0fc9e093, 0x0fca3ff3, 0x0fce3ff3, 0x0fd23ff3, 0x0fd63b83, 0x0fe007f3, 0x0fe407f3,
288 0x0fe807f3, 0x0fec07f3, 0x0ff007f3, 0x0ff407f3, 0x0ff807f3, 0x0ffc07d3, 0x700001f1, 0x700105f2, 0x700407f1,
289 0x700807f2, 0x700c06f2, 0x700f87f1, 0x701387f1, 0x701787f1, 0x701b87f1, 0x701f87f1, 0x702387f1, 0x702787f1,
290 0x702b87f1, 0x702f87f1, 0x703387f1, 0x703787f1, 0x703b87f1, 0x703f87f1, 0x704387f1, 0x704787f1, 0x704b87f1,
291 0x704f87f1, 0x705387f1, 0x705787f1, 0x705b87f1, 0x705f87f1, 0x706387f1, 0x706787f1, 0x706b87f1, 0x706f87f1,
292 0x707387f1, 0x707787f1, 0x707b87f1, 0x707f80f1};
293
294/// Returns the extended grapheme cluster bondary property of a code point.
295[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __property __get_property(const char32_t __code_point) noexcept {
296 // TODO FMT use std::ranges::upper_bound.
297
298 // The algorithm searches for the upper bound of the range and, when found,
299 // steps back one entry. This algorithm is used since the code point can be
300 // anywhere in the range. After a lower bound is found the next step is to
301 // compare whether the code unit is indeed in the range.
302 //
303 // Since the entry contains a code unit, size, and property the code point
304 // being sought needs to be adjusted. Just shifting the code point to the
305 // proper position doesn't work; suppose an entry has property 0, size 1,
306 // and lower bound 3. This results in the entry 0x1810.
307 // When searching for code point 3 it will search for 0x1800, find 0x1810
308 // and moves to the previous entry. Thus the lower bound value will never
309 // be found.
310 // The simple solution is to set the bits belonging to the property and
311 // size. Then the upper bound for code point 3 will return the entry after
312 // 0x1810. After moving to the previous entry the algorithm arrives at the
313 // correct entry.
314 ptrdiff_t __i = std::upper_bound(__entries, std::end(__entries), (__code_point << 11) | 0x7ffu) - __entries;
315 if (__i == 0)
316 return __property::__none;
317
318 --__i;
319 uint32_t __upper_bound = (__entries[__i] >> 11) + ((__entries[__i] >> 4) & 0x7f);
320 if (__code_point <= __upper_bound)
321 return static_cast<__property>(__entries[__i] & 0xf);
322
323 return __property::__none;
324}
325
326} // namespace __extended_grapheme_custer_property_boundary
327
328#endif //_LIBCPP_STD_VER > 17
329
330_LIBCPP_END_NAMESPACE_STD
331
332#endif // _LIBCPP___FORMAT_EXTENDED_GRAPHEME_CLUSTER_TABLE_H
lib/libcxx/include/__format/format_arg.h+152-172
...@@ -10,39 +10,41 @@...@@ -10,39 +10,41 @@
10#ifndef _LIBCPP___FORMAT_FORMAT_ARG_H10#ifndef _LIBCPP___FORMAT_FORMAT_ARG_H
11#define _LIBCPP___FORMAT_FORMAT_ARG_H11#define _LIBCPP___FORMAT_FORMAT_ARG_H
1212
13#include <__assert>
13#include <__concepts/arithmetic.h>14#include <__concepts/arithmetic.h>
14#include <__config>15#include <__config>
15#include <__format/format_error.h>16#include <__format/format_error.h>
16#include <__format/format_fwd.h>17#include <__format/format_fwd.h>
17#include <__format/format_parse_context.h>18#include <__format/format_parse_context.h>
18#include <__functional_base>19#include <__functional/invoke.h>
19#include <__memory/addressof.h>20#include <__memory/addressof.h>
21#include <__utility/forward.h>
22#include <__utility/unreachable.h>
20#include <__variant/monostate.h>23#include <__variant/monostate.h>
21#include <string>24#include <string>
22#include <string_view>25#include <string_view>
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_LIBCPP_PUSH_MACROS
29#include <__undef_macros>
30
31_LIBCPP_BEGIN_NAMESPACE_STD31_LIBCPP_BEGIN_NAMESPACE_STD
3232
33#if _LIBCPP_STD_VER > 1733#if _LIBCPP_STD_VER > 17
3434
35// TODO FMT Remove this once we require compilers with proper C++20 support.
36// If the compiler has no concepts support, the format header will be disabled.
37// Without concepts support enable_if needs to be used and that too much effort
38// to support compilers with partial C++20 support.
39#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
40
41namespace __format {35namespace __format {
42/// The type stored in @ref basic_format_arg.36/// The type stored in @ref basic_format_arg.
43///37///
44/// @note The 128-bit types are unconditionally in the list to avoid the values38/// @note The 128-bit types are unconditionally in the list to avoid the values
45/// of the enums to depend on the availability of 128-bit integers.39/// of the enums to depend on the availability of 128-bit integers.
40///
41/// @note The value is stored as a 5-bit value in the __packed_arg_t_bits. This
42/// limits the maximum number of elements to 32.
43/// When modifying update the test
44/// test/libcxx/utilities/format/format.arguments/format.arg/arg_t.compile.pass.cpp
45/// It could be packed in 4-bits but that means a new type directly becomes an
46/// ABI break. The packed type is 64-bit so this reduces the maximum number of
47/// packed elements from 16 to 12.
46enum class _LIBCPP_ENUM_VIS __arg_t : uint8_t {48enum class _LIBCPP_ENUM_VIS __arg_t : uint8_t {
47 __none,49 __none,
48 __boolean,50 __boolean,
...@@ -61,58 +63,158 @@ enum class _LIBCPP_ENUM_VIS __arg_t : uint8_t {...@@ -61,58 +63,158 @@ enum class _LIBCPP_ENUM_VIS __arg_t : uint8_t {
61 __ptr,63 __ptr,
62 __handle64 __handle
63};65};
66
67inline constexpr unsigned __packed_arg_t_bits = 5;
68inline constexpr uint8_t __packed_arg_t_mask = 0x1f;
69
70inline constexpr unsigned __packed_types_storage_bits = 64;
71inline constexpr unsigned __packed_types_max = __packed_types_storage_bits / __packed_arg_t_bits;
72
73_LIBCPP_HIDE_FROM_ABI
74constexpr bool __use_packed_format_arg_store(size_t __size) { return __size <= __packed_types_max; }
75
76_LIBCPP_HIDE_FROM_ABI
77constexpr __arg_t __get_packed_type(uint64_t __types, size_t __id) {
78 _LIBCPP_ASSERT(__id <= __packed_types_max, "");
79
80 if (__id > 0)
81 __types >>= __id * __packed_arg_t_bits;
82
83 return static_cast<__format::__arg_t>(__types & __packed_arg_t_mask);
84}
85
64} // namespace __format86} // namespace __format
6587
66template <class _Visitor, class _Context>88template <class _Visitor, class _Context>
67_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT decltype(auto)89_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT decltype(auto) visit_format_arg(_Visitor&& __vis,
68visit_format_arg(_Visitor&& __vis, basic_format_arg<_Context> __arg) {90 basic_format_arg<_Context> __arg) {
69 switch (__arg.__type_) {91 switch (__arg.__type_) {
70 case __format::__arg_t::__none:92 case __format::__arg_t::__none:
71 return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), monostate{});93 return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__monostate_);
72 case __format::__arg_t::__boolean:94 case __format::__arg_t::__boolean:
73 return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__boolean);95 return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__boolean_);
74 case __format::__arg_t::__char_type:96 case __format::__arg_t::__char_type:
75 return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__char_type);97 return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__char_type_);
76 case __format::__arg_t::__int:98 case __format::__arg_t::__int:
77 return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__int);99 return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__int_);
78 case __format::__arg_t::__long_long:100 case __format::__arg_t::__long_long:
79 return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__long_long);101 return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__long_long_);
80 case __format::__arg_t::__i128:102 case __format::__arg_t::__i128:
81#ifndef _LIBCPP_HAS_NO_INT128103# ifndef _LIBCPP_HAS_NO_INT128
82 return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__i128);104 return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__i128_);
83#else105# else
84 _LIBCPP_UNREACHABLE();106 __libcpp_unreachable();
85#endif107# endif
86 case __format::__arg_t::__unsigned:108 case __format::__arg_t::__unsigned:
87 return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__unsigned);109 return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__unsigned_);
88 case __format::__arg_t::__unsigned_long_long:110 case __format::__arg_t::__unsigned_long_long:
89 return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis),111 return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__unsigned_long_long_);
90 __arg.__unsigned_long_long);
91 case __format::__arg_t::__u128:112 case __format::__arg_t::__u128:
92#ifndef _LIBCPP_HAS_NO_INT128113# ifndef _LIBCPP_HAS_NO_INT128
93 return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__u128);114 return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__u128_);
94#else115# else
95 _LIBCPP_UNREACHABLE();116 __libcpp_unreachable();
96#endif117# endif
97 case __format::__arg_t::__float:118 case __format::__arg_t::__float:
98 return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__float);119 return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__float_);
99 case __format::__arg_t::__double:120 case __format::__arg_t::__double:
100 return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__double);121 return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__double_);
101 case __format::__arg_t::__long_double:122 case __format::__arg_t::__long_double:
102 return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__long_double);123 return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__long_double_);
103 case __format::__arg_t::__const_char_type_ptr:124 case __format::__arg_t::__const_char_type_ptr:
104 return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis),125 return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__const_char_type_ptr_);
105 __arg.__const_char_type_ptr);
106 case __format::__arg_t::__string_view:126 case __format::__arg_t::__string_view:
107 return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__string_view);127 return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__string_view_);
108 case __format::__arg_t::__ptr:128 case __format::__arg_t::__ptr:
109 return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__ptr);129 return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__ptr_);
110 case __format::__arg_t::__handle:130 case __format::__arg_t::__handle:
111 return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__handle);131 return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis),
132 typename basic_format_arg<_Context>::handle{__arg.__value_.__handle_});
112 }133 }
113 _LIBCPP_UNREACHABLE();134
135 __libcpp_unreachable();
114}136}
115137
138/// Contains the values used in basic_format_arg.
139///
140/// This is a separate type so it's possible to store the values and types in
141/// separate arrays.
142template <class _Context>
143class __basic_format_arg_value {
144 using _CharT = typename _Context::char_type;
145
146public:
147 /// Contains the implementation for basic_format_arg::handle.
148 struct __handle {
149 template <class _Tp>
150 _LIBCPP_HIDE_FROM_ABI explicit __handle(_Tp&& __v) noexcept
151 : __ptr_(_VSTD::addressof(__v)),
152 __format_([](basic_format_parse_context<_CharT>& __parse_ctx, _Context& __ctx, const void* __ptr) {
153 using _Dp = remove_cvref_t<_Tp>;
154 using _Formatter = typename _Context::template formatter_type<_Dp>;
155 constexpr bool __const_formattable =
156 requires { _Formatter().format(declval<const _Dp&>(), declval<_Context&>()); };
157 using _Qp = conditional_t<__const_formattable, const _Dp, _Dp>;
158
159 static_assert(__const_formattable || !is_const_v<remove_reference_t<_Tp>>, "Mandated by [format.arg]/18");
160
161 _Formatter __f;
162 __parse_ctx.advance_to(__f.parse(__parse_ctx));
163 __ctx.advance_to(__f.format(*const_cast<_Qp*>(static_cast<const _Dp*>(__ptr)), __ctx));
164 }) {}
165
166 const void* __ptr_;
167 void (*__format_)(basic_format_parse_context<_CharT>&, _Context&, const void*);
168 };
169
170 union {
171 monostate __monostate_;
172 bool __boolean_;
173 _CharT __char_type_;
174 int __int_;
175 unsigned __unsigned_;
176 long long __long_long_;
177 unsigned long long __unsigned_long_long_;
178# ifndef _LIBCPP_HAS_NO_INT128
179 __int128_t __i128_;
180 __uint128_t __u128_;
181# endif
182 float __float_;
183 double __double_;
184 long double __long_double_;
185 const _CharT* __const_char_type_ptr_;
186 basic_string_view<_CharT> __string_view_;
187 const void* __ptr_;
188 __handle __handle_;
189 };
190
191 // These constructors contain the exact storage type used. If adjustments are
192 // required, these will be done in __create_format_arg.
193
194 _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value() noexcept : __monostate_() {}
195 _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(bool __value) noexcept : __boolean_(__value) {}
196 _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(_CharT __value) noexcept : __char_type_(__value) {}
197 _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(int __value) noexcept : __int_(__value) {}
198 _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(unsigned __value) noexcept : __unsigned_(__value) {}
199 _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(long long __value) noexcept : __long_long_(__value) {}
200 _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(unsigned long long __value) noexcept
201 : __unsigned_long_long_(__value) {}
202# ifndef _LIBCPP_HAS_NO_INT128
203 _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(__int128_t __value) noexcept : __i128_(__value) {}
204 _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(__uint128_t __value) noexcept : __u128_(__value) {}
205# endif
206 _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(float __value) noexcept : __float_(__value) {}
207 _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(double __value) noexcept : __double_(__value) {}
208 _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(long double __value) noexcept : __long_double_(__value) {}
209 _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(const _CharT* __value) noexcept : __const_char_type_ptr_(__value) {}
210 _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(basic_string_view<_CharT> __value) noexcept
211 : __string_view_(__value) {}
212 _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(const void* __value) noexcept : __ptr_(__value) {}
213 _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(__handle __value) noexcept
214 // TODO FMT Investigate why it doesn't work without the forward.
215 : __handle_(std::forward<__handle>(__value)) {}
216};
217
116template <class _Context>218template <class _Context>
117class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_arg {219class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_arg {
118public:220public:
...@@ -139,154 +241,32 @@ private:...@@ -139,154 +241,32 @@ private:
139 // .format(declval<const T&>(), declval<Context&>())241 // .format(declval<const T&>(), declval<Context&>())
140 // shall be well-formed when treated as an unevaluated operand.242 // shall be well-formed when treated as an unevaluated operand.
141243
142 template <class _Ctx, class... _Args>244public:
143 _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT friend __format_arg_store<_Ctx, _Args...>245 __basic_format_arg_value<_Context> __value_;
144 make_format_args(const _Args&...);
145
146 template <class _Visitor, class _Ctx>
147 _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT friend decltype(auto)
148 visit_format_arg(_Visitor&& __vis, basic_format_arg<_Ctx> __arg);
149
150 union {
151 bool __boolean;
152 char_type __char_type;
153 int __int;
154 unsigned __unsigned;
155 long long __long_long;
156 unsigned long long __unsigned_long_long;
157#ifndef _LIBCPP_HAS_NO_INT128
158 __int128_t __i128;
159 __uint128_t __u128;
160#endif
161 float __float;
162 double __double;
163 long double __long_double;
164 const char_type* __const_char_type_ptr;
165 basic_string_view<char_type> __string_view;
166 const void* __ptr;
167 handle __handle;
168 };
169 __format::__arg_t __type_;246 __format::__arg_t __type_;
170247
171 _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(bool __v) noexcept248 _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(__format::__arg_t __type,
172 : __boolean(__v), __type_(__format::__arg_t::__boolean) {}249 __basic_format_arg_value<_Context> __value) noexcept
173250 : __value_(__value), __type_(__type) {}
174 template <class _Tp>
175 _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(_Tp __v) noexcept
176 requires(same_as<_Tp, char_type> ||
177 (same_as<_Tp, char> && same_as<char_type, wchar_t>))
178 : __char_type(__v), __type_(__format::__arg_t::__char_type) {}
179
180 template <__libcpp_signed_integer _Tp>
181 _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(_Tp __v) noexcept {
182 if constexpr (sizeof(_Tp) <= sizeof(int)) {
183 __int = static_cast<int>(__v);
184 __type_ = __format::__arg_t::__int;
185 } else if constexpr (sizeof(_Tp) <= sizeof(long long)) {
186 __long_long = static_cast<long long>(__v);
187 __type_ = __format::__arg_t::__long_long;
188 }
189#ifndef _LIBCPP_HAS_NO_INT128
190 else if constexpr (sizeof(_Tp) == sizeof(__int128_t)) {
191 __i128 = __v;
192 __type_ = __format::__arg_t::__i128;
193 }
194#endif
195 else
196 static_assert(sizeof(_Tp) == 0, "An unsupported signed integer was used");
197 }
198
199 template <__libcpp_unsigned_integer _Tp>
200 _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(_Tp __v) noexcept {
201 if constexpr (sizeof(_Tp) <= sizeof(unsigned)) {
202 __unsigned = static_cast<unsigned>(__v);
203 __type_ = __format::__arg_t::__unsigned;
204 } else if constexpr (sizeof(_Tp) <= sizeof(unsigned long long)) {
205 __unsigned_long_long = static_cast<unsigned long long>(__v);
206 __type_ = __format::__arg_t::__unsigned_long_long;
207 }
208#ifndef _LIBCPP_HAS_NO_INT128
209 else if constexpr (sizeof(_Tp) == sizeof(__int128_t)) {
210 __u128 = __v;
211 __type_ = __format::__arg_t::__u128;
212 }
213#endif
214 else
215 static_assert(sizeof(_Tp) == 0,
216 "An unsupported unsigned integer was used");
217 }
218
219 _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(float __v) noexcept
220 : __float(__v), __type_(__format::__arg_t::__float) {}
221
222 _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(double __v) noexcept
223 : __double(__v), __type_(__format::__arg_t::__double) {}
224
225 _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(long double __v) noexcept
226 : __long_double(__v), __type_(__format::__arg_t::__long_double) {}
227
228 // Note not a 'noexcept' function.
229 _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(const char_type* __s)
230 : __const_char_type_ptr(__s),
231 __type_(__format::__arg_t::__const_char_type_ptr) {
232 _LIBCPP_ASSERT(__s, "Used a nullptr argument to initialize a C-string");
233 }
234
235 template <class _Traits>
236 _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(
237 basic_string_view<char_type, _Traits> __s) noexcept
238 : __string_view{__s.data(), __s.size()},
239 __type_(__format::__arg_t::__string_view) {}
240
241 template <class _Traits, class _Allocator>
242 _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(
243 const basic_string<char_type, _Traits, _Allocator>& __s) noexcept
244 : __string_view{__s.data(), __s.size()},
245 __type_(__format::__arg_t::__string_view) {}
246
247 _LIBCPP_HIDE_FROM_ABI
248 explicit basic_format_arg(nullptr_t) noexcept
249 : __ptr(nullptr), __type_(__format::__arg_t::__ptr) {}
250
251 template <class _Tp>
252 requires is_void_v<_Tp> _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(_Tp* __p) noexcept
253 : __ptr(__p), __type_(__format::__arg_t::__ptr) {}
254
255 template <class _Tp>
256 _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(const _Tp& __v) noexcept
257 : __handle(__v), __type_(__format::__arg_t::__handle) {}
258};251};
259252
260template <class _Context>253template <class _Context>
261class _LIBCPP_TEMPLATE_VIS basic_format_arg<_Context>::handle {254class _LIBCPP_TEMPLATE_VIS basic_format_arg<_Context>::handle {
262 friend class basic_format_arg<_Context>;
263
264public:255public:
265 _LIBCPP_HIDE_FROM_ABI256 _LIBCPP_HIDE_FROM_ABI
266 void format(basic_format_parse_context<char_type>& __parse_ctx, _Context& __ctx) const {257 void format(basic_format_parse_context<char_type>& __parse_ctx, _Context& __ctx) const {
267 __format_(__parse_ctx, __ctx, __ptr_);258 __handle_.__format_(__parse_ctx, __ctx, __handle_.__ptr_);
268 }259 }
269260
261 _LIBCPP_HIDE_FROM_ABI explicit handle(typename __basic_format_arg_value<_Context>::__handle& __handle) noexcept
262 : __handle_(__handle) {}
263
270private:264private:
271 const void* __ptr_;265 typename __basic_format_arg_value<_Context>::__handle& __handle_;
272 void (*__format_)(basic_format_parse_context<char_type>&, _Context&, const void*);
273
274 template <class _Tp>
275 _LIBCPP_HIDE_FROM_ABI explicit handle(const _Tp& __v) noexcept
276 : __ptr_(_VSTD::addressof(__v)),
277 __format_([](basic_format_parse_context<char_type>& __parse_ctx, _Context& __ctx, const void* __ptr) {
278 typename _Context::template formatter_type<_Tp> __f;
279 __parse_ctx.advance_to(__f.parse(__parse_ctx));
280 __ctx.advance_to(__f.format(*static_cast<const _Tp*>(__ptr), __ctx));
281 }) {}
282};266};
283267
284#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
285
286#endif //_LIBCPP_STD_VER > 17268#endif //_LIBCPP_STD_VER > 17
287269
288_LIBCPP_END_NAMESPACE_STD270_LIBCPP_END_NAMESPACE_STD
289271
290_LIBCPP_POP_MACROS
291
292#endif // _LIBCPP___FORMAT_FORMAT_ARG_H272#endif // _LIBCPP___FORMAT_FORMAT_ARG_H
lib/libcxx/include/__format/format_arg_store.h created+253
...@@ -0,0 +1,253 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___FORMAT_FORMAT_ARG_STORE_H
11#define _LIBCPP___FORMAT_FORMAT_ARG_STORE_H
12
13#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
14# pragma GCC system_header
15#endif
16
17#include <__concepts/arithmetic.h>
18#include <__concepts/same_as.h>
19#include <__config>
20#include <__format/concepts.h>
21#include <__format/format_arg.h>
22#include <cstring>
23#include <string>
24#include <string_view>
25#include <type_traits>
26
27_LIBCPP_BEGIN_NAMESPACE_STD
28
29#if _LIBCPP_STD_VER > 17
30
31namespace __format {
32
33/// \returns The @c __arg_t based on the type of the formatting argument.
34///
35/// \pre \c __formattable<_Tp, typename _Context::char_type>
36template <class _Context, class _Tp>
37consteval __arg_t __determine_arg_t();
38
39// Boolean
40template <class, same_as<bool> _Tp>
41consteval __arg_t __determine_arg_t() {
42 return __arg_t::__boolean;
43}
44
45// Char
46template <class _Context, same_as<typename _Context::char_type> _Tp>
47consteval __arg_t __determine_arg_t() {
48 return __arg_t::__char_type;
49}
50# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
51template <class _Context, class _CharT>
52 requires(same_as<typename _Context::char_type, wchar_t> && same_as<_CharT, char>)
53consteval __arg_t __determine_arg_t() {
54 return __arg_t::__char_type;
55}
56# endif
57
58// Signed integers
59template <class, __libcpp_signed_integer _Tp>
60consteval __arg_t __determine_arg_t() {
61 if constexpr (sizeof(_Tp) <= sizeof(int))
62 return __arg_t::__int;
63 else if constexpr (sizeof(_Tp) <= sizeof(long long))
64 return __arg_t::__long_long;
65# ifndef _LIBCPP_HAS_NO_INT128
66 else if constexpr (sizeof(_Tp) == sizeof(__int128_t))
67 return __arg_t::__i128;
68# endif
69 else
70 static_assert(sizeof(_Tp) == 0, "an unsupported signed integer was used");
71}
72
73// Unsigned integers
74template <class, __libcpp_unsigned_integer _Tp>
75consteval __arg_t __determine_arg_t() {
76 if constexpr (sizeof(_Tp) <= sizeof(unsigned))
77 return __arg_t::__unsigned;
78 else if constexpr (sizeof(_Tp) <= sizeof(unsigned long long))
79 return __arg_t::__unsigned_long_long;
80# ifndef _LIBCPP_HAS_NO_INT128
81 else if constexpr (sizeof(_Tp) == sizeof(__uint128_t))
82 return __arg_t::__u128;
83# endif
84 else
85 static_assert(sizeof(_Tp) == 0, "an unsupported unsigned integer was used");
86}
87
88// Floating-point
89template <class, same_as<float> _Tp>
90consteval __arg_t __determine_arg_t() {
91 return __arg_t::__float;
92}
93template <class, same_as<double> _Tp>
94consteval __arg_t __determine_arg_t() {
95 return __arg_t::__double;
96}
97template <class, same_as<long double> _Tp>
98consteval __arg_t __determine_arg_t() {
99 return __arg_t::__long_double;
100}
101
102// Char pointer
103template <class _Context, class _Tp>
104 requires(same_as<typename _Context::char_type*, _Tp> || same_as<const typename _Context::char_type*, _Tp>)
105consteval __arg_t __determine_arg_t() {
106 return __arg_t::__const_char_type_ptr;
107}
108
109// Char array
110template <class _Context, class _Tp>
111 requires(is_array_v<_Tp> && same_as<_Tp, typename _Context::char_type[extent_v<_Tp>]>)
112consteval __arg_t __determine_arg_t() {
113 return __arg_t::__string_view;
114}
115
116// String view
117template <class _Context, class _Tp>
118 requires(same_as<typename _Context::char_type, typename _Tp::value_type> &&
119 same_as<_Tp, basic_string_view<typename _Tp::value_type, typename _Tp::traits_type>>)
120consteval __arg_t __determine_arg_t() {
121 return __arg_t::__string_view;
122}
123
124// String
125template <class _Context, class _Tp>
126 requires(
127 same_as<typename _Context::char_type, typename _Tp::value_type> &&
128 same_as<_Tp, basic_string<typename _Tp::value_type, typename _Tp::traits_type, typename _Tp::allocator_type>>)
129consteval __arg_t __determine_arg_t() {
130 return __arg_t::__string_view;
131}
132
133// Pointers
134template <class, class _Ptr>
135 requires(same_as<_Ptr, void*> || same_as<_Ptr, const void*> || same_as<_Ptr, nullptr_t>)
136consteval __arg_t __determine_arg_t() {
137 return __arg_t::__ptr;
138}
139
140// Handle
141//
142// Note this version can't be constrained avoiding ambiguous overloads.
143// That means it can be instantiated by disabled formatters. To solve this, a
144// constrained version for not formattable formatters is added. That overload
145// is marked as deleted to fail creating a storage type for disabled formatters.
146template <class _Context, class _Tp>
147consteval __arg_t __determine_arg_t() {
148 return __arg_t::__handle;
149}
150
151template <class _Context, class _Tp>
152 requires(!__formattable<_Tp, typename _Context::char_type>)
153consteval __arg_t __determine_arg_t() = delete;
154
155template <class _Context, class _Tp>
156_LIBCPP_HIDE_FROM_ABI basic_format_arg<_Context> __create_format_arg(_Tp&& __value) noexcept {
157 constexpr __arg_t __arg = __determine_arg_t<_Context, remove_cvref_t<_Tp>>();
158 static_assert(__arg != __arg_t::__none);
159
160 // Not all types can be used to directly initialize the
161 // __basic_format_arg_value. First handle all types needing adjustment, the
162 // final else requires no adjustment.
163 if constexpr (__arg == __arg_t::__char_type)
164 // On some platforms initializing a wchar_t from a char is a narrowing
165 // conversion.
166 return basic_format_arg<_Context>{__arg, static_cast<typename _Context::char_type>(__value)};
167 else if constexpr (__arg == __arg_t::__int)
168 return basic_format_arg<_Context>{__arg, static_cast<int>(__value)};
169 else if constexpr (__arg == __arg_t::__long_long)
170 return basic_format_arg<_Context>{__arg, static_cast<long long>(__value)};
171 else if constexpr (__arg == __arg_t::__unsigned)
172 return basic_format_arg<_Context>{__arg, static_cast<unsigned>(__value)};
173 else if constexpr (__arg == __arg_t::__unsigned_long_long)
174 return basic_format_arg<_Context>{__arg, static_cast<unsigned long long>(__value)};
175 else if constexpr (__arg == __arg_t::__string_view)
176 // Using std::size on a character array will add the NUL-terminator to the size.
177 if constexpr (is_array_v<remove_cvref_t<_Tp>>)
178 return basic_format_arg<_Context>{
179 __arg, basic_string_view<typename _Context::char_type>{__value, extent_v<remove_cvref_t<_Tp>> - 1}};
180 else
181 // When the _Traits or _Allocator are different an implicit conversion will
182 // fail.
183 return basic_format_arg<_Context>{
184 __arg, basic_string_view<typename _Context::char_type>{__value.data(), __value.size()}};
185 else if constexpr (__arg == __arg_t::__ptr)
186 return basic_format_arg<_Context>{__arg, static_cast<const void*>(__value)};
187 else if constexpr (__arg == __arg_t::__handle)
188 return basic_format_arg<_Context>{
189 __arg, typename __basic_format_arg_value<_Context>::__handle{_VSTD::forward<_Tp>(__value)}};
190 else
191 return basic_format_arg<_Context>{__arg, __value};
192}
193
194template <class _Context, class... _Args>
195_LIBCPP_HIDE_FROM_ABI void __create_packed_storage(uint64_t& __types, __basic_format_arg_value<_Context>* __values,
196 _Args&&... __args) noexcept {
197 int __shift = 0;
198 (
199 [&] {
200 basic_format_arg<_Context> __arg = __create_format_arg<_Context>(__args);
201 if (__shift != 0)
202 __types |= static_cast<uint64_t>(__arg.__type_) << __shift;
203 else
204 // Assigns the initial value.
205 __types = static_cast<uint64_t>(__arg.__type_);
206 __shift += __packed_arg_t_bits;
207 *__values++ = __arg.__value_;
208 }(),
209 ...);
210}
211
212template <class _Context, class... _Args>
213_LIBCPP_HIDE_FROM_ABI void __store_basic_format_arg(basic_format_arg<_Context>* __data, _Args&&... __args) noexcept {
214 ([&] { *__data++ = __create_format_arg<_Context>(__args); }(), ...);
215}
216
217template <class _Context, size_t N>
218struct __packed_format_arg_store {
219 __basic_format_arg_value<_Context> __values_[N];
220 uint64_t __types_;
221};
222
223template <class _Context, size_t N>
224struct __unpacked_format_arg_store {
225 basic_format_arg<_Context> __args_[N];
226};
227
228} // namespace __format
229
230template <class _Context, class... _Args>
231struct _LIBCPP_TEMPLATE_VIS __format_arg_store {
232 _LIBCPP_HIDE_FROM_ABI
233 __format_arg_store(_Args&... __args) noexcept {
234 if constexpr (sizeof...(_Args) != 0) {
235 if constexpr (__format::__use_packed_format_arg_store(sizeof...(_Args)))
236 __format::__create_packed_storage(__storage.__types_, __storage.__values_, __args...);
237 else
238 __format::__store_basic_format_arg<_Context>(__storage.__args_, __args...);
239 }
240 }
241
242 using _Storage = conditional_t<__format::__use_packed_format_arg_store(sizeof...(_Args)),
243 __format::__packed_format_arg_store<_Context, sizeof...(_Args)>,
244 __format::__unpacked_format_arg_store<_Context, sizeof...(_Args)>>;
245
246 _Storage __storage;
247};
248
249#endif //_LIBCPP_STD_VER > 17
250
251_LIBCPP_END_NAMESPACE_STD
252
253#endif // _LIBCPP___FORMAT_FORMAT_ARG_STORE_H
lib/libcxx/include/__format/format_args.h+33-25
...@@ -12,60 +12,68 @@...@@ -12,60 +12,68 @@
1212
13#include <__availability>13#include <__availability>
14#include <__config>14#include <__config>
15#include <__format/format_arg.h>
16#include <__format/format_arg_store.h>
15#include <__format/format_fwd.h>17#include <__format/format_fwd.h>
16#include <cstddef>18#include <cstddef>
19#include <cstdint>
1720
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19#pragma GCC system_header22# pragma GCC system_header
20#endif23#endif
2124
22_LIBCPP_PUSH_MACROS
23#include <__undef_macros>
24
25_LIBCPP_BEGIN_NAMESPACE_STD25_LIBCPP_BEGIN_NAMESPACE_STD
2626
27#if _LIBCPP_STD_VER > 1727#if _LIBCPP_STD_VER > 17
2828
29// TODO FMT Remove this once we require compilers with proper C++20 support.
30// If the compiler has no concepts support, the format header will be disabled.
31// Without concepts support enable_if needs to be used and that too much effort
32// to support compilers with partial C++20 support.
33#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
34
35template <class _Context>29template <class _Context>
36class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_args {30class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_args {
37public:31public:
38 // TODO FMT Implement [format.args]/5
39 // [Note 1: Implementations are encouraged to optimize the representation of
40 // basic_format_args for small number of formatting arguments by storing
41 // indices of type alternatives separately from values and packing the
42 // former. - end note]
43 // Note: Change __format_arg_store to use a built-in array.
44 _LIBCPP_HIDE_FROM_ABI basic_format_args() noexcept = default;32 _LIBCPP_HIDE_FROM_ABI basic_format_args() noexcept = default;
4533
46 template <class... _Args>34 template <class... _Args>
47 _LIBCPP_HIDE_FROM_ABI basic_format_args(35 _LIBCPP_HIDE_FROM_ABI basic_format_args(const __format_arg_store<_Context, _Args...>& __store) noexcept
48 const __format_arg_store<_Context, _Args...>& __store) noexcept36 : __size_(sizeof...(_Args)) {
49 : __size_(sizeof...(_Args)), __data_(__store.__args.data()) {}37 if constexpr (sizeof...(_Args) != 0) {
38 if constexpr (__format::__use_packed_format_arg_store(sizeof...(_Args))) {
39 __values_ = __store.__storage.__values_;
40 __types_ = __store.__storage.__types_;
41 } else
42 __args_ = __store.__storage.__args_;
43 }
44 }
5045
51 _LIBCPP_HIDE_FROM_ABI46 _LIBCPP_HIDE_FROM_ABI
52 basic_format_arg<_Context> get(size_t __id) const noexcept {47 basic_format_arg<_Context> get(size_t __id) const noexcept {
53 return __id < __size_ ? __data_[__id] : basic_format_arg<_Context>{};48 if (__id >= __size_)
49 return basic_format_arg<_Context>{};
50
51 if (__format::__use_packed_format_arg_store(__size_))
52 return basic_format_arg<_Context>{__format::__get_packed_type(__types_, __id), __values_[__id]};
53
54 return __args_[__id];
54 }55 }
5556
56 _LIBCPP_HIDE_FROM_ABI size_t __size() const noexcept { return __size_; }57 _LIBCPP_HIDE_FROM_ABI size_t __size() const noexcept { return __size_; }
5758
58private:59private:
59 size_t __size_{0};60 size_t __size_{0};
60 const basic_format_arg<_Context>* __data_{nullptr};61 // [format.args]/5
62 // [Note 1: Implementations are encouraged to optimize the representation of
63 // basic_format_args for small number of formatting arguments by storing
64 // indices of type alternatives separately from values and packing the
65 // former. - end note]
66 union {
67 struct {
68 const __basic_format_arg_value<_Context>* __values_;
69 uint64_t __types_;
70 };
71 const basic_format_arg<_Context>* __args_;
72 };
61};73};
6274
63#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
64
65#endif //_LIBCPP_STD_VER > 1775#endif //_LIBCPP_STD_VER > 17
6676
67_LIBCPP_END_NAMESPACE_STD77_LIBCPP_END_NAMESPACE_STD
6878
69_LIBCPP_POP_MACROS
70
71#endif // _LIBCPP___FORMAT_FORMAT_ARGS_H79#endif // _LIBCPP___FORMAT_FORMAT_ARGS_H
lib/libcxx/include/__format/format_context.h+10-24
...@@ -12,11 +12,14 @@...@@ -12,11 +12,14 @@
1212
13#include <__availability>13#include <__availability>
14#include <__config>14#include <__config>
15#include <__format/buffer.h>
15#include <__format/format_args.h>16#include <__format/format_args.h>
16#include <__format/format_fwd.h>17#include <__format/format_fwd.h>
17#include <__iterator/back_insert_iterator.h>18#include <__iterator/back_insert_iterator.h>
18#include <__iterator/concepts.h>19#include <__iterator/concepts.h>
20#include <__utility/move.h>
19#include <concepts>21#include <concepts>
22#include <cstddef>
2023
21#ifndef _LIBCPP_HAS_NO_LOCALIZATION24#ifndef _LIBCPP_HAS_NO_LOCALIZATION
22#include <locale>25#include <locale>
...@@ -24,22 +27,13 @@...@@ -24,22 +27,13 @@
24#endif27#endif
2528
26#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)29#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
27#pragma GCC system_header30# pragma GCC system_header
28#endif31#endif
2932
30_LIBCPP_PUSH_MACROS
31#include <__undef_macros>
32
33_LIBCPP_BEGIN_NAMESPACE_STD33_LIBCPP_BEGIN_NAMESPACE_STD
3434
35#if _LIBCPP_STD_VER > 1735#if _LIBCPP_STD_VER > 17
3636
37// TODO FMT Remove this once we require compilers with proper C++20 support.
38// If the compiler has no concepts support, the format header will be disabled.
39// Without concepts support enable_if needs to be used and that too much effort
40// to support compilers with partial C++20 support.
41#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
42
43template <class _OutIt, class _CharT>37template <class _OutIt, class _CharT>
44requires output_iterator<_OutIt, const _CharT&>38requires output_iterator<_OutIt, const _CharT&>
45class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_context;39class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_context;
...@@ -69,16 +63,12 @@ __format_context_create(...@@ -69,16 +63,12 @@ __format_context_create(
69}63}
70#endif64#endif
7165
72// TODO FMT Implement [format.context]/466using format_context =
73// [Note 1: For a given type charT, implementations are encouraged to provide a67 basic_format_context<back_insert_iterator<__format::__output_buffer<char>>,
74// single instantiation of basic_format_context for appending to68 char>;
75// basic_string<charT>, vector<charT>, or any other container with contiguous
76// storage by wrapping those in temporary objects with a uniform interface
77// (such as a span<charT>) and polymorphic reallocation. - end note]
78
79using format_context = basic_format_context<back_insert_iterator<string>, char>;
80#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS69#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
81using wformat_context = basic_format_context<back_insert_iterator<wstring>, wchar_t>;70using wformat_context = basic_format_context<
71 back_insert_iterator<__format::__output_buffer<wchar_t>>, wchar_t>;
82#endif72#endif
8373
84template <class _OutIt, class _CharT>74template <class _OutIt, class _CharT>
...@@ -101,7 +91,7 @@ public:...@@ -101,7 +91,7 @@ public:
101 basic_format_context& operator=(const basic_format_context&) = delete;91 basic_format_context& operator=(const basic_format_context&) = delete;
10292
103 _LIBCPP_HIDE_FROM_ABI basic_format_arg<basic_format_context>93 _LIBCPP_HIDE_FROM_ABI basic_format_arg<basic_format_context>
104 arg(size_t __id) const {94 arg(size_t __id) const noexcept {
105 return __args_.get(__id);95 return __args_.get(__id);
106 }96 }
107#ifndef _LIBCPP_HAS_NO_LOCALIZATION97#ifndef _LIBCPP_HAS_NO_LOCALIZATION
...@@ -154,12 +144,8 @@ private:...@@ -154,12 +144,8 @@ private:
154#endif144#endif
155};145};
156146
157#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
158
159#endif //_LIBCPP_STD_VER > 17147#endif //_LIBCPP_STD_VER > 17
160148
161_LIBCPP_END_NAMESPACE_STD149_LIBCPP_END_NAMESPACE_STD
162150
163_LIBCPP_POP_MACROS
164
165#endif // _LIBCPP___FORMAT_FORMAT_CONTEXT_H151#endif // _LIBCPP___FORMAT_FORMAT_CONTEXT_H
lib/libcxx/include/__format/format_error.h+1-1
...@@ -18,7 +18,7 @@...@@ -18,7 +18,7 @@
18#endif18#endif
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
22#endif22#endif
2323
24_LIBCPP_BEGIN_NAMESPACE_STD24_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__format/format_fwd.h+4-21
...@@ -13,44 +13,27 @@...@@ -13,44 +13,27 @@
13#include <__availability>13#include <__availability>
14#include <__config>14#include <__config>
15#include <__iterator/concepts.h>15#include <__iterator/concepts.h>
16#include <__utility/forward.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
20#endif19#endif
2120
22_LIBCPP_PUSH_MACROS
23#include <__undef_macros>
24
25_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2622
27#if _LIBCPP_STD_VER > 1723#if _LIBCPP_STD_VER > 17
2824
29// TODO FMT Remove this once we require compilers with proper C++20 support.
30// If the compiler has no concepts support, the format header will be disabled.
31// Without concepts support enable_if needs to be used and that too much effort
32// to support compilers with partial C++20 support.
33#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
34
35template <class _Context>25template <class _Context>
36class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_arg;26class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_arg;
3727
38template <class _Context, class... _Args>28template <class _OutIt, class _CharT>
39struct _LIBCPP_TEMPLATE_VIS __format_arg_store;29 requires output_iterator<_OutIt, const _CharT&>
4030class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_context;
41template <class _Ctx, class... _Args>
42_LIBCPP_HIDE_FROM_ABI __format_arg_store<_Ctx, _Args...>
43make_format_args(const _Args&...);
4431
45template <class _Tp, class _CharT = char>32template <class _Tp, class _CharT = char>
46struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter;33struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter;
4734
48#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
49
50#endif //_LIBCPP_STD_VER > 1735#endif //_LIBCPP_STD_VER > 17
5136
52_LIBCPP_END_NAMESPACE_STD37_LIBCPP_END_NAMESPACE_STD
5338
54_LIBCPP_POP_MACROS
55
56#endif // _LIBCPP___FORMAT_FORMAT_FWD_H39#endif // _LIBCPP___FORMAT_FORMAT_FWD_H
lib/libcxx/include/__format/format_parse_context.h+1-9
...@@ -15,19 +15,13 @@...@@ -15,19 +15,13 @@
15#include <string_view>15#include <string_view>
1616
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header18# pragma GCC system_header
19#endif19#endif
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
23#if _LIBCPP_STD_VER > 1723#if _LIBCPP_STD_VER > 17
2424
25// TODO FMT Remove this once we require compilers with proper C++20 support.
26// If the compiler has no concepts support, the format header will be disabled.
27// Without concepts support enable_if needs to be used and that too much effort
28// to support compilers with partial C++20 support.
29#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
30
31template <class _CharT>25template <class _CharT>
32class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_parse_context {26class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_parse_context {
33public:27public:
...@@ -100,8 +94,6 @@ using format_parse_context = basic_format_parse_context<char>;...@@ -100,8 +94,6 @@ using format_parse_context = basic_format_parse_context<char>;
100using wformat_parse_context = basic_format_parse_context<wchar_t>;94using wformat_parse_context = basic_format_parse_context<wchar_t>;
101#endif95#endif
10296
103#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
104
105#endif //_LIBCPP_STD_VER > 1797#endif //_LIBCPP_STD_VER > 17
10698
107_LIBCPP_END_NAMESPACE_STD99_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__format/format_string.h+2-10
...@@ -10,26 +10,20 @@...@@ -10,26 +10,20 @@
10#ifndef _LIBCPP___FORMAT_FORMAT_STRING_H10#ifndef _LIBCPP___FORMAT_FORMAT_STRING_H
11#define _LIBCPP___FORMAT_FORMAT_STRING_H11#define _LIBCPP___FORMAT_FORMAT_STRING_H
1212
13#include <__assert>
13#include <__config>14#include <__config>
14#include <__debug>
15#include <__format/format_error.h>15#include <__format/format_error.h>
16#include <cstddef>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)
20#pragma GCC system_header20# pragma GCC system_header
21#endif21#endif
2222
23_LIBCPP_BEGIN_NAMESPACE_STD23_LIBCPP_BEGIN_NAMESPACE_STD
2424
25#if _LIBCPP_STD_VER > 1725#if _LIBCPP_STD_VER > 17
2626
27// TODO FMT Remove this once we require compilers with proper C++20 support.
28// If the compiler has no concepts support, the format header will be disabled.
29// Without concepts support enable_if needs to be used and that too much effort
30// to support compilers with partial C++20 support.
31#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
32
33namespace __format {27namespace __format {
3428
35template <class _CharT>29template <class _CharT>
...@@ -160,8 +154,6 @@ __parse_arg_id(const _CharT* __begin, const _CharT* __end, auto& __parse_ctx) {...@@ -160,8 +154,6 @@ __parse_arg_id(const _CharT* __begin, const _CharT* __end, auto& __parse_ctx) {
160154
161} // namespace __format155} // namespace __format
162156
163#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
164
165#endif //_LIBCPP_STD_VER > 17157#endif //_LIBCPP_STD_VER > 17
166158
167_LIBCPP_END_NAMESPACE_STD159_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__format/format_to_n_result.h-7
...@@ -21,19 +21,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -21,19 +21,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2121
22#if _LIBCPP_STD_VER > 1722#if _LIBCPP_STD_VER > 17
2323
24// TODO FMT Remove this once we require compilers with proper C++20 support.
25// If the compiler has no concepts support, the format header will be disabled.
26// Without concepts support enable_if needs to be used and that too much effort
27// to support compilers with partial C++20 support.
28#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
29
30template <class _OutIt>24template <class _OutIt>
31struct _LIBCPP_TEMPLATE_VIS format_to_n_result {25struct _LIBCPP_TEMPLATE_VIS format_to_n_result {
32 _OutIt out;26 _OutIt out;
33 iter_difference_t<_OutIt> size;27 iter_difference_t<_OutIt> size;
34};28};
3529
36#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
37#endif //_LIBCPP_STD_VER > 1730#endif //_LIBCPP_STD_VER > 17
3831
39_LIBCPP_END_NAMESPACE_STD32_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__format/formatter.h+2-238
...@@ -10,34 +10,19 @@...@@ -10,34 +10,19 @@
10#ifndef _LIBCPP___FORMAT_FORMATTER_H10#ifndef _LIBCPP___FORMAT_FORMATTER_H
11#define _LIBCPP___FORMAT_FORMATTER_H11#define _LIBCPP___FORMAT_FORMATTER_H
1212
13#include <__algorithm/copy.h>
14#include <__algorithm/fill_n.h>
15#include <__availability>13#include <__availability>
14#include <__concepts/same_as.h>
16#include <__config>15#include <__config>
17#include <__format/format_error.h>
18#include <__format/format_fwd.h>16#include <__format/format_fwd.h>
19#include <__format/format_string.h>
20#include <__format/parser_std_format_spec.h>
21#include <concepts>
22#include <string_view>
2317
24#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
25#pragma GCC system_header19# pragma GCC system_header
26#endif20#endif
2721
28_LIBCPP_PUSH_MACROS
29#include <__undef_macros>
30
31_LIBCPP_BEGIN_NAMESPACE_STD22_LIBCPP_BEGIN_NAMESPACE_STD
3223
33#if _LIBCPP_STD_VER > 1724#if _LIBCPP_STD_VER > 17
3425
35// TODO FMT Remove this once we require compilers with proper C++20 support.
36// If the compiler has no concepts support, the format header will be disabled.
37// Without concepts support enable_if needs to be used and that too much effort
38// to support compilers with partial C++20 support.
39#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
40
41/// The default formatter template.26/// The default formatter template.
42///27///
43/// [format.formatter.spec]/528/// [format.formatter.spec]/5
...@@ -54,237 +39,16 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter {...@@ -54,237 +39,16 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter {
54 formatter& operator=(const formatter&) = delete;39 formatter& operator=(const formatter&) = delete;
55};40};
5641
57namespace __format_spec {
58
59_LIBCPP_HIDE_FROM_ABI inline char* __insert_sign(char* __buf, bool __negative,
60 _Flags::_Sign __sign) {
61 if (__negative)
62 *__buf++ = '-';
63 else
64 switch (__sign) {
65 case _Flags::_Sign::__default:
66 case _Flags::_Sign::__minus:
67 // No sign added.
68 break;
69 case _Flags::_Sign::__plus:
70 *__buf++ = '+';
71 break;
72 case _Flags::_Sign::__space:
73 *__buf++ = ' ';
74 break;
75 }
76
77 return __buf;
78}
79
80_LIBCPP_HIDE_FROM_ABI constexpr char __hex_to_upper(char c) {
81 switch (c) {
82 case 'a':
83 return 'A';
84 case 'b':
85 return 'B';
86 case 'c':
87 return 'C';
88 case 'd':
89 return 'D';
90 case 'e':
91 return 'E';
92 case 'f':
93 return 'F';
94 }
95 return c;
96}
97
98} // namespace __format_spec
99
100namespace __formatter {42namespace __formatter {
10143
102/** The character types that formatters are specialized for. */44/** The character types that formatters are specialized for. */
103template <class _CharT>45template <class _CharT>
104concept __char_type = same_as<_CharT, char> || same_as<_CharT, wchar_t>;46concept __char_type = same_as<_CharT, char> || same_as<_CharT, wchar_t>;
10547
106struct _LIBCPP_TEMPLATE_VIS __padding_size_result {
107 size_t __before;
108 size_t __after;
109};
110
111_LIBCPP_HIDE_FROM_ABI constexpr __padding_size_result
112__padding_size(size_t __size, size_t __width,
113 __format_spec::_Flags::_Alignment __align) {
114 _LIBCPP_ASSERT(__width > __size,
115 "Don't call this function when no padding is required");
116 _LIBCPP_ASSERT(
117 __align != __format_spec::_Flags::_Alignment::__default,
118 "Caller should adjust the default to the value required by the type");
119
120 size_t __fill = __width - __size;
121 switch (__align) {
122 case __format_spec::_Flags::_Alignment::__default:
123 _LIBCPP_UNREACHABLE();
124
125 case __format_spec::_Flags::_Alignment::__left:
126 return {0, __fill};
127
128 case __format_spec::_Flags::_Alignment::__center: {
129 // The extra padding is divided per [format.string.std]/3
130 // __before = floor(__fill, 2);
131 // __after = ceil(__fill, 2);
132 size_t __before = __fill / 2;
133 size_t __after = __fill - __before;
134 return {__before, __after};
135 }
136 case __format_spec::_Flags::_Alignment::__right:
137 return {__fill, 0};
138 }
139 _LIBCPP_UNREACHABLE();
140}
141
142/**
143 * Writes the input to the output with the required padding.
144 *
145 * Since the output column width is specified the function can be used for
146 * ASCII and Unicode input.
147 *
148 * @pre [@a __first, @a __last) is a valid range.
149 * @pre @a __size <= @a __width. Using this function when this pre-condition
150 * doesn't hold incurs an unwanted overhead.
151 *
152 * @param __out_it The output iterator to write to.
153 * @param __first Pointer to the first element to write.
154 * @param __last Pointer beyond the last element to write.
155 * @param __size The (estimated) output column width. When the elements
156 * to be written are ASCII the following condition holds
157 * @a __size == @a __last - @a __first.
158 * @param __width The number of output columns to write.
159 * @param __fill The character used for the alignment of the output.
160 * TODO FMT Will probably change to support Unicode grapheme
161 * cluster.
162 * @param __alignment The requested alignment.
163 *
164 * @returns An iterator pointing beyond the last element written.
165 *
166 * @note The type of the elements in range [@a __first, @a __last) can differ
167 * from the type of @a __fill. Integer output uses @c std::to_chars for its
168 * conversion, which means the [@a __first, @a __last) always contains elements
169 * of the type @c char.
170 */
171template <class _CharT, class _Fill>
172_LIBCPP_HIDE_FROM_ABI auto
173__write(output_iterator<const _CharT&> auto __out_it, const _CharT* __first,
174 const _CharT* __last, size_t __size, size_t __width, _Fill __fill,
175 __format_spec::_Flags::_Alignment __alignment) -> decltype(__out_it) {
176
177 _LIBCPP_ASSERT(__first <= __last, "Not a valid range");
178 _LIBCPP_ASSERT(__size < __width, "Precondition failure");
179
180 __padding_size_result __padding =
181 __padding_size(__size, __width, __alignment);
182 __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __padding.__before, __fill);
183 __out_it = _VSTD::copy(__first, __last, _VSTD::move(__out_it));
184 return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after, __fill);
185}
186
187/**
188 * @overload
189 *
190 * Writes additional zero's for the precision before the exponent.
191 * This is used when the precision requested in the format string is larger
192 * than the maximum precision of the floating-point type. These precision
193 * digits are always 0.
194 *
195 * @param __exponent The location of the exponent character.
196 * @param __num_trailing_zeros The number of 0's to write before the exponent
197 * character.
198 */
199template <class _CharT, class _Fill>
200_LIBCPP_HIDE_FROM_ABI auto __write(output_iterator<const _CharT&> auto __out_it, const _CharT* __first,
201 const _CharT* __last, size_t __size, size_t __width, _Fill __fill,
202 __format_spec::_Flags::_Alignment __alignment, const _CharT* __exponent,
203 size_t __num_trailing_zeros) -> decltype(__out_it) {
204 _LIBCPP_ASSERT(__first <= __last, "Not a valid range");
205 _LIBCPP_ASSERT(__num_trailing_zeros > 0, "The overload not writing trailing zeros should have been used");
206
207 __padding_size_result __padding = __padding_size(__size + __num_trailing_zeros, __width, __alignment);
208 __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __padding.__before, __fill);
209 __out_it = _VSTD::copy(__first, __exponent, _VSTD::move(__out_it));
210 __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __num_trailing_zeros, _CharT('0'));
211 __out_it = _VSTD::copy(__exponent, __last, _VSTD::move(__out_it));
212 return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after, __fill);
213}
214
215/**
216 * @overload
217 *
218 * Uses a transformation operation before writing an element.
219 *
220 * TODO FMT Fill will probably change to support Unicode grapheme cluster.
221 */
222template <class _CharT, class _UnaryOperation, class _Fill>
223_LIBCPP_HIDE_FROM_ABI auto
224__write(output_iterator<const _CharT&> auto __out_it, const _CharT* __first,
225 const _CharT* __last, size_t __size, _UnaryOperation __op,
226 size_t __width, _Fill __fill,
227 __format_spec::_Flags::_Alignment __alignment) -> decltype(__out_it) {
228
229 _LIBCPP_ASSERT(__first <= __last, "Not a valid range");
230 _LIBCPP_ASSERT(__size < __width, "Precondition failure");
231
232 __padding_size_result __padding =
233 __padding_size(__size, __width, __alignment);
234 __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __padding.__before, __fill);
235 __out_it = _VSTD::transform(__first, __last, _VSTD::move(__out_it), __op);
236 return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after, __fill);
237}
238
239/**
240 * Writes Unicode input to the output with the required padding.
241 *
242 * This function does almost the same as the @ref __write function, but handles
243 * the width estimation of the Unicode input.
244 *
245 * @param __str The range [@a __first, @a __last).
246 * @param __precision The width to truncate the input string to, use @c -1 for
247 * no limit.
248 */
249template <class _CharT, class _Fill>
250_LIBCPP_HIDE_FROM_ABI auto
251__write_unicode(output_iterator<const _CharT&> auto __out_it,
252 basic_string_view<_CharT> __str, ptrdiff_t __width,
253 ptrdiff_t __precision, _Fill __fill,
254 __format_spec::_Flags::_Alignment __alignment)
255 -> decltype(__out_it) {
256
257 // This value changes when there Unicode column width limits the output
258 // size.
259 auto __last = __str.end();
260 if (__width != 0 || __precision != -1) {
261 __format_spec::__string_alignment<_CharT> __format_traits =
262 __format_spec::__get_string_alignment(__str.begin(), __str.end(),
263 __width, __precision);
264
265 if (__format_traits.__align)
266 return __write(_VSTD::move(__out_it), __str.begin(),
267 __format_traits.__last, __format_traits.__size, __width,
268 __fill, __alignment);
269
270 // No alignment required update the output based on the precision.
271 // This might be the same as __str.end().
272 __last = __format_traits.__last;
273 }
274
275 // Copy the input to the output. The output size might be limited by the
276 // precision.
277 return _VSTD::copy(__str.begin(), __last, _VSTD::move(__out_it));
278}
279
280} // namespace __formatter48} // namespace __formatter
28149
282#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
283
284#endif //_LIBCPP_STD_VER > 1750#endif //_LIBCPP_STD_VER > 17
28551
286_LIBCPP_END_NAMESPACE_STD52_LIBCPP_END_NAMESPACE_STD
28753
288_LIBCPP_POP_MACROS
289
290#endif // _LIBCPP___FORMAT_FORMATTER_H54#endif // _LIBCPP___FORMAT_FORMATTER_H
lib/libcxx/include/__format/formatter_bool.h+33-102
...@@ -10,136 +10,67 @@...@@ -10,136 +10,67 @@
10#ifndef _LIBCPP___FORMAT_FORMATTER_BOOL_H10#ifndef _LIBCPP___FORMAT_FORMATTER_BOOL_H
11#define _LIBCPP___FORMAT_FORMATTER_BOOL_H11#define _LIBCPP___FORMAT_FORMATTER_BOOL_H
1212
13#include <__algorithm/copy.h>
13#include <__availability>14#include <__availability>
14#include <__config>15#include <__config>
16#include <__debug>
15#include <__format/format_error.h>17#include <__format/format_error.h>
16#include <__format/format_fwd.h>18#include <__format/format_fwd.h>
19#include <__format/format_parse_context.h>
17#include <__format/formatter.h>20#include <__format/formatter.h>
18#include <__format/formatter_integral.h>21#include <__format/formatter_integral.h>
19#include <__format/parser_std_format_spec.h>22#include <__format/parser_std_format_spec.h>
23#include <__utility/unreachable.h>
20#include <string_view>24#include <string_view>
2125
22#ifndef _LIBCPP_HAS_NO_LOCALIZATION26#ifndef _LIBCPP_HAS_NO_LOCALIZATION
23#include <locale>27# include <locale>
24#endif28#endif
2529
26#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)30#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
27#pragma GCC system_header31# pragma GCC system_header
28#endif32#endif
2933
30_LIBCPP_BEGIN_NAMESPACE_STD34_LIBCPP_BEGIN_NAMESPACE_STD
3135
32#if _LIBCPP_STD_VER > 1736#if _LIBCPP_STD_VER > 17
3337
34// TODO FMT Remove this once we require compilers with proper C++20 support.38template <__formatter::__char_type _CharT>
35// If the compiler has no concepts support, the format header will be disabled.39struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<bool, _CharT> {
36// Without concepts support enable_if needs to be used and that too much effort
37// to support compilers with partial C++20 support.
38#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
39
40namespace __format_spec {
41
42template <class _CharT>
43class _LIBCPP_TEMPLATE_VIS __parser_bool : public __parser_integral<_CharT> {
44public:40public:
45 _LIBCPP_HIDE_FROM_ABI constexpr auto parse(auto& __parse_ctx)41 _LIBCPP_HIDE_FROM_ABI constexpr auto
46 -> decltype(__parse_ctx.begin()) {42 parse(basic_format_parse_context<_CharT>& __parse_ctx) -> decltype(__parse_ctx.begin()) {
47 auto __it = __parser_integral<_CharT>::__parse(__parse_ctx);43 auto __result = __parser_.__parse(__parse_ctx, __format_spec::__fields_integral);
4844 __format_spec::__process_parsed_bool(__parser_);
49 switch (this->__type) {45 return __result;
50 case _Flags::_Type::__default:46 }
51 this->__type = _Flags::_Type::__string;
52 [[fallthrough]];
53 case _Flags::_Type::__string:
54 this->__handle_bool();
55 break;
56
57 case _Flags::_Type::__char:
58 this->__handle_char();
59 break;
6047
61 case _Flags::_Type::__binary_lower_case:48 _LIBCPP_HIDE_FROM_ABI auto format(bool __value, auto& __ctx) const -> decltype(__ctx.out()) {
62 case _Flags::_Type::__binary_upper_case:49 switch (__parser_.__type_) {
63 case _Flags::_Type::__octal:50 case __format_spec::__type::__default:
64 case _Flags::_Type::__decimal:51 case __format_spec::__type::__string:
65 case _Flags::_Type::__hexadecimal_lower_case:52 return __formatter::__format_bool(__value, __ctx, __parser_.__get_parsed_std_specifications(__ctx));
66 case _Flags::_Type::__hexadecimal_upper_case:53
67 this->__handle_integer();54 case __format_spec::__type::__binary_lower_case:
68 break;55 case __format_spec::__type::__binary_upper_case:
56 case __format_spec::__type::__octal:
57 case __format_spec::__type::__decimal:
58 case __format_spec::__type::__hexadecimal_lower_case:
59 case __format_spec::__type::__hexadecimal_upper_case:
60 // Promotes bool to an integral type. This reduces the number of
61 // instantiations of __format_integer reducing code size.
62 return __formatter::__format_integer(
63 static_cast<unsigned>(__value), __ctx, __parser_.__get_parsed_std_specifications(__ctx));
6964
70 default:65 default:
71 __throw_format_error(66 _LIBCPP_ASSERT(false, "The parse function should have validated the type");
72 "The format-spec type has a type not supported for a bool argument");67 __libcpp_unreachable();
73 }68 }
74
75 return __it;
76 }69 }
77};
78
79template <class _CharT>
80struct _LIBCPP_TEMPLATE_VIS __bool_strings;
81
82template <>
83struct _LIBCPP_TEMPLATE_VIS __bool_strings<char> {
84 static constexpr string_view __true{"true"};
85 static constexpr string_view __false{"false"};
86};
87
88#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
89template <>
90struct _LIBCPP_TEMPLATE_VIS __bool_strings<wchar_t> {
91 static constexpr wstring_view __true{L"true"};
92 static constexpr wstring_view __false{L"false"};
93};
94#endif
9570
96template <class _CharT>71 __format_spec::__parser<_CharT> __parser_;
97using __formatter_bool = __formatter_integral<__parser_bool<_CharT>>;
98
99} //namespace __format_spec
100
101// [format.formatter.spec]/2.3
102// For each charT, for each cv-unqualified arithmetic type ArithmeticT other
103// than char, wchar_t, char8_t, char16_t, or char32_t, a specialization
104
105template <__formatter::__char_type _CharT>
106struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<bool, _CharT>
107 : public __format_spec::__formatter_bool<_CharT> {
108 using _Base = __format_spec::__formatter_bool<_CharT>;
109
110 _LIBCPP_HIDE_FROM_ABI auto format(bool __value, auto& __ctx)
111 -> decltype(__ctx.out()) {
112 if (this->__type != __format_spec::_Flags::_Type::__string)
113 return _Base::format(static_cast<unsigned char>(__value), __ctx);
114
115 if (this->__width_needs_substitution())
116 this->__substitute_width_arg_id(__ctx.arg(this->__width));
117
118#ifndef _LIBCPP_HAS_NO_LOCALIZATION
119 if (this->__locale_specific_form) {
120 const auto& __np = use_facet<numpunct<_CharT>>(__ctx.locale());
121 basic_string<_CharT> __str = __value ? __np.truename() : __np.falsename();
122 return __formatter::__write_unicode(
123 __ctx.out(), basic_string_view<_CharT>{__str}, this->__width, -1,
124 this->__fill, this->__alignment);
125 }
126#endif
127 basic_string_view<_CharT> __str =
128 __value ? __format_spec::__bool_strings<_CharT>::__true
129 : __format_spec::__bool_strings<_CharT>::__false;
130
131 // The output only uses ASCII so every character is one column.
132 unsigned __size = __str.size();
133 if (__size >= this->__width)
134 return _VSTD::copy(__str.begin(), __str.end(), __ctx.out());
135
136 return __formatter::__write(__ctx.out(), __str.begin(), __str.end(), __size,
137 this->__width, this->__fill, this->__alignment);
138 }
139};72};
14073
141#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
142
143#endif //_LIBCPP_STD_VER > 1774#endif //_LIBCPP_STD_VER > 17
14475
145_LIBCPP_END_NAMESPACE_STD76_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__format/formatter_char.h+40-60
...@@ -11,91 +11,71 @@...@@ -11,91 +11,71 @@
11#define _LIBCPP___FORMAT_FORMATTER_CHAR_H11#define _LIBCPP___FORMAT_FORMATTER_CHAR_H
1212
13#include <__availability>13#include <__availability>
14#include <__concepts/same_as.h>
14#include <__config>15#include <__config>
15#include <__format/format_error.h>
16#include <__format/format_fwd.h>16#include <__format/format_fwd.h>
17#include <__format/format_parse_context.h>
17#include <__format/formatter.h>18#include <__format/formatter.h>
18#include <__format/formatter_integral.h>19#include <__format/formatter_integral.h>
20#include <__format/formatter_output.h>
19#include <__format/parser_std_format_spec.h>21#include <__format/parser_std_format_spec.h>
22#include <__type_traits/conditional.h>
23#include <__type_traits/is_signed.h>
2024
21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)25#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
22#pragma GCC system_header26# pragma GCC system_header
23#endif27#endif
2428
25_LIBCPP_BEGIN_NAMESPACE_STD29_LIBCPP_BEGIN_NAMESPACE_STD
2630
27#if _LIBCPP_STD_VER > 1731#if _LIBCPP_STD_VER > 17
2832
29// TODO FMT Remove this once we require compilers with proper C++20 support.33template <__formatter::__char_type _CharT>
30// If the compiler has no concepts support, the format header will be disabled.34struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT __formatter_char {
31// Without concepts support enable_if needs to be used and that too much effort
32// to support compilers with partial C++20 support.
33#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
34
35namespace __format_spec {
36
37template <class _CharT>
38class _LIBCPP_TEMPLATE_VIS __parser_char : public __parser_integral<_CharT> {
39public:35public:
40 _LIBCPP_HIDE_FROM_ABI constexpr auto parse(auto& __parse_ctx)36 _LIBCPP_HIDE_FROM_ABI constexpr auto
41 -> decltype(__parse_ctx.begin()) {37 parse(basic_format_parse_context<_CharT>& __parse_ctx) -> decltype(__parse_ctx.begin()) {
42 auto __it = __parser_integral<_CharT>::__parse(__parse_ctx);38 auto __result = __parser_.__parse(__parse_ctx, __format_spec::__fields_integral);
4339 __format_spec::__process_parsed_char(__parser_);
44 switch (this->__type) {40 return __result;
45 case _Flags::_Type::__default:
46 this->__type = _Flags::_Type::__char;
47 [[fallthrough]];
48 case _Flags::_Type::__char:
49 this->__handle_char();
50 break;
51
52 case _Flags::_Type::__binary_lower_case:
53 case _Flags::_Type::__binary_upper_case:
54 case _Flags::_Type::__octal:
55 case _Flags::_Type::__decimal:
56 case _Flags::_Type::__hexadecimal_lower_case:
57 case _Flags::_Type::__hexadecimal_upper_case:
58 this->__handle_integer();
59 break;
60
61 default:
62 __throw_format_error(
63 "The format-spec type has a type not supported for a char argument");
64 }
65
66 return __it;
67 }41 }
68};
6942
70template <class _CharT>43 _LIBCPP_HIDE_FROM_ABI auto format(_CharT __value, auto& __ctx) const -> decltype(__ctx.out()) {
71using __formatter_char = __formatter_integral<__parser_char<_CharT>>;44 if (__parser_.__type_ == __format_spec::__type::__default || __parser_.__type_ == __format_spec::__type::__char)
45 return __formatter::__format_char(__value, __ctx.out(), __parser_.__get_parsed_std_specifications(__ctx));
46
47 if constexpr (sizeof(_CharT) <= sizeof(int))
48 // Promotes _CharT to an integral type. This reduces the number of
49 // instantiations of __format_integer reducing code size.
50 return __formatter::__format_integer(
51 static_cast<conditional_t<is_signed_v<_CharT>, int, unsigned>>(__value),
52 __ctx,
53 __parser_.__get_parsed_std_specifications(__ctx));
54 else
55 return __formatter::__format_integer(__value, __ctx, __parser_.__get_parsed_std_specifications(__ctx));
56 }
7257
73} // namespace __format_spec58 _LIBCPP_HIDE_FROM_ABI auto format(char __value, auto& __ctx) const -> decltype(__ctx.out())
59 requires(same_as<_CharT, wchar_t>)
60 {
61 return format(static_cast<wchar_t>(__value), __ctx);
62 }
7463
75// [format.formatter.spec]/2.1 The specializations64 __format_spec::__parser<_CharT> __parser_;
65};
7666
77template <>67template <>
78struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<char, char>68struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<char, char> : public __formatter_char<char> {};
79 : public __format_spec::__formatter_char<char> {};
8069
81#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS70# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
82template <>71template <>
83struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<char, wchar_t>72struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<char, wchar_t> : public __formatter_char<wchar_t> {};
84 : public __format_spec::__formatter_char<wchar_t> {
85 using _Base = __format_spec::__formatter_char<wchar_t>;
8673
87 _LIBCPP_HIDE_FROM_ABI auto format(char __value, auto& __ctx)74template <>
88 -> decltype(__ctx.out()) {75struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<wchar_t, wchar_t> : public __formatter_char<wchar_t> {
89 return _Base::format(static_cast<wchar_t>(__value), __ctx);
90 }
91};76};
9277
93template <>78# endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
94struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT
95 formatter<wchar_t, wchar_t>
96 : public __format_spec::__formatter_char<wchar_t> {};
97#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
98#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
9979
100#endif //_LIBCPP_STD_VER > 1780#endif //_LIBCPP_STD_VER > 17
10181
lib/libcxx/include/__format/formatter_floating_point.h+216-212
...@@ -18,17 +18,18 @@...@@ -18,17 +18,18 @@
18#include <__algorithm/rotate.h>18#include <__algorithm/rotate.h>
19#include <__algorithm/transform.h>19#include <__algorithm/transform.h>
20#include <__concepts/arithmetic.h>20#include <__concepts/arithmetic.h>
21#include <__concepts/same_as.h>
21#include <__config>22#include <__config>
22#include <__debug>
23#include <__format/format_error.h>
24#include <__format/format_fwd.h>23#include <__format/format_fwd.h>
25#include <__format/format_string.h>24#include <__format/format_parse_context.h>
26#include <__format/formatter.h>25#include <__format/formatter.h>
27#include <__format/formatter_integral.h>26#include <__format/formatter_integral.h>
27#include <__format/formatter_output.h>
28#include <__format/parser_std_format_spec.h>28#include <__format/parser_std_format_spec.h>
29#include <__memory/allocator.h>
29#include <__utility/move.h>30#include <__utility/move.h>
31#include <__utility/unreachable.h>
30#include <charconv>32#include <charconv>
31#include <cmath>
3233
33#ifndef _LIBCPP_HAS_NO_LOCALIZATION34#ifndef _LIBCPP_HAS_NO_LOCALIZATION
34# include <locale>35# include <locale>
...@@ -45,13 +46,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -45,13 +46,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
4546
46#if _LIBCPP_STD_VER > 1747#if _LIBCPP_STD_VER > 17
4748
48// TODO FMT Remove this once we require compilers with proper C++20 support.49namespace __formatter {
49// If the compiler has no concepts support, the format header will be disabled.
50// Without concepts support enable_if needs to be used and that too much effort
51// to support compilers with partial C++20 support.
52# if !defined(_LIBCPP_HAS_NO_CONCEPTS)
53
54namespace __format_spec {
5550
56template <floating_point _Tp>51template <floating_point _Tp>
57_LIBCPP_HIDE_FROM_ABI char* __to_buffer(char* __first, char* __last, _Tp __value) {52_LIBCPP_HIDE_FROM_ABI char* __to_buffer(char* __first, char* __last, _Tp __value) {
...@@ -167,7 +162,7 @@ public:...@@ -167,7 +162,7 @@ public:
167 __precision_ = _Traits::__max_fractional;162 __precision_ = _Traits::__max_fractional;
168 }163 }
169164
170 __size_ = __format_spec::__float_buffer_size<_Fp>(__precision_);165 __size_ = __formatter::__float_buffer_size<_Fp>(__precision_);
171 if (__size_ > _Traits::__stack_buffer_size)166 if (__size_ > _Traits::__stack_buffer_size)
172 // The allocated buffer's contents don't need initialization.167 // The allocated buffer's contents don't need initialization.
173 __begin_ = allocator<char>{}.allocate(__size_);168 __begin_ = allocator<char>{}.allocate(__size_);
...@@ -236,9 +231,9 @@ _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_default(const __float_buffe...@@ -236,9 +231,9 @@ _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_default(const __float_buffe
236 char* __integral) {231 char* __integral) {
237 __float_result __result;232 __float_result __result;
238 __result.__integral = __integral;233 __result.__integral = __integral;
239 __result.__last = __format_spec::__to_buffer(__integral, __buffer.end(), __value);234 __result.__last = __formatter::__to_buffer(__integral, __buffer.end(), __value);
240235
241 __result.__exponent = __format_spec::__find_exponent(__result.__integral, __result.__last);236 __result.__exponent = __formatter::__find_exponent(__result.__integral, __result.__last);
242237
243 // Constrains:238 // Constrains:
244 // - There's at least one decimal digit before the radix point.239 // - There's at least one decimal digit before the radix point.
...@@ -267,9 +262,9 @@ _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_hexadecimal_lower_case(cons...@@ -267,9 +262,9 @@ _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_hexadecimal_lower_case(cons
267 __float_result __result;262 __float_result __result;
268 __result.__integral = __integral;263 __result.__integral = __integral;
269 if (__precision == -1)264 if (__precision == -1)
270 __result.__last = __format_spec::__to_buffer(__integral, __buffer.end(), __value, chars_format::hex);265 __result.__last = __formatter::__to_buffer(__integral, __buffer.end(), __value, chars_format::hex);
271 else266 else
272 __result.__last = __format_spec::__to_buffer(__integral, __buffer.end(), __value, chars_format::hex, __precision);267 __result.__last = __formatter::__to_buffer(__integral, __buffer.end(), __value, chars_format::hex, __precision);
273268
274 // H = one or more hex-digits269 // H = one or more hex-digits
275 // S = sign270 // S = sign
...@@ -318,7 +313,7 @@ _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_hexadecimal_upper_case(cons...@@ -318,7 +313,7 @@ _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_hexadecimal_upper_case(cons
318 _Tp __value, int __precision,313 _Tp __value, int __precision,
319 char* __integral) {314 char* __integral) {
320 __float_result __result =315 __float_result __result =
321 __format_spec::__format_buffer_hexadecimal_lower_case(__buffer, __value, __precision, __integral);316 __formatter::__format_buffer_hexadecimal_lower_case(__buffer, __value, __precision, __integral);
322 _VSTD::transform(__result.__integral, __result.__exponent, __result.__integral, __hex_to_upper);317 _VSTD::transform(__result.__integral, __result.__exponent, __result.__integral, __hex_to_upper);
323 *__result.__exponent = 'P';318 *__result.__exponent = 'P';
324 return __result;319 return __result;
...@@ -331,13 +326,13 @@ _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_scientific_lower_case(const...@@ -331,13 +326,13 @@ _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_scientific_lower_case(const
331 __float_result __result;326 __float_result __result;
332 __result.__integral = __integral;327 __result.__integral = __integral;
333 __result.__last =328 __result.__last =
334 __format_spec::__to_buffer(__integral, __buffer.end(), __value, chars_format::scientific, __precision);329 __formatter::__to_buffer(__integral, __buffer.end(), __value, chars_format::scientific, __precision);
335330
336 char* __first = __integral + 1;331 char* __first = __integral + 1;
337 _LIBCPP_ASSERT(__first != __result.__last, "No exponent present");332 _LIBCPP_ASSERT(__first != __result.__last, "No exponent present");
338 if (*__first == '.') {333 if (*__first == '.') {
339 __result.__radix_point = __first;334 __result.__radix_point = __first;
340 __result.__exponent = __format_spec::__find_exponent(__first + 1, __result.__last);335 __result.__exponent = __formatter::__find_exponent(__first + 1, __result.__last);
341 } else {336 } else {
342 __result.__radix_point = __result.__last;337 __result.__radix_point = __result.__last;
343 __result.__exponent = __first;338 __result.__exponent = __first;
...@@ -357,7 +352,7 @@ _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_scientific_upper_case(const...@@ -357,7 +352,7 @@ _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_scientific_upper_case(const
357 _Tp __value, int __precision,352 _Tp __value, int __precision,
358 char* __integral) {353 char* __integral) {
359 __float_result __result =354 __float_result __result =
360 __format_spec::__format_buffer_scientific_lower_case(__buffer, __value, __precision, __integral);355 __formatter::__format_buffer_scientific_lower_case(__buffer, __value, __precision, __integral);
361 *__result.__exponent = 'E';356 *__result.__exponent = 'E';
362 return __result;357 return __result;
363}358}
...@@ -367,7 +362,7 @@ _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_fixed(const __float_buffer<...@@ -367,7 +362,7 @@ _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_fixed(const __float_buffer<
367 int __precision, char* __integral) {362 int __precision, char* __integral) {
368 __float_result __result;363 __float_result __result;
369 __result.__integral = __integral;364 __result.__integral = __integral;
370 __result.__last = __format_spec::__to_buffer(__integral, __buffer.end(), __value, chars_format::fixed, __precision);365 __result.__last = __formatter::__to_buffer(__integral, __buffer.end(), __value, chars_format::fixed, __precision);
371366
372 // When there's no precision there's no radix point.367 // When there's no precision there's no radix point.
373 // Else the radix point is placed at __precision + 1 from the end.368 // Else the radix point is placed at __precision + 1 from the end.
...@@ -393,14 +388,14 @@ _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_general_lower_case(__float_...@@ -393,14 +388,14 @@ _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_general_lower_case(__float_
393388
394 __float_result __result;389 __float_result __result;
395 __result.__integral = __integral;390 __result.__integral = __integral;
396 __result.__last = __format_spec::__to_buffer(__integral, __buffer.end(), __value, chars_format::general, __precision);391 __result.__last = __formatter::__to_buffer(__integral, __buffer.end(), __value, chars_format::general, __precision);
397392
398 char* __first = __integral + 1;393 char* __first = __integral + 1;
399 if (__first == __result.__last) {394 if (__first == __result.__last) {
400 __result.__radix_point = __result.__last;395 __result.__radix_point = __result.__last;
401 __result.__exponent = __result.__last;396 __result.__exponent = __result.__last;
402 } else {397 } else {
403 __result.__exponent = __format_spec::__find_exponent(__first, __result.__last);398 __result.__exponent = __formatter::__find_exponent(__first, __result.__last);
404 if (__result.__exponent != __result.__last)399 if (__result.__exponent != __result.__last)
405 // In scientific mode if there's a radix point it will always be after400 // In scientific mode if there's a radix point it will always be after
406 // the first digit. (This is the position __first points at).401 // the first digit. (This is the position __first points at).
...@@ -426,19 +421,79 @@ _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_general_lower_case(__float_...@@ -426,19 +421,79 @@ _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_general_lower_case(__float_
426template <class _Fp, class _Tp>421template <class _Fp, class _Tp>
427_LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_general_upper_case(__float_buffer<_Fp>& __buffer, _Tp __value,422_LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_general_upper_case(__float_buffer<_Fp>& __buffer, _Tp __value,
428 int __precision, char* __integral) {423 int __precision, char* __integral) {
429 __float_result __result =424 __float_result __result = __formatter::__format_buffer_general_lower_case(__buffer, __value, __precision, __integral);
430 __format_spec::__format_buffer_general_lower_case(__buffer, __value, __precision, __integral);
431 if (__result.__exponent != __result.__last)425 if (__result.__exponent != __result.__last)
432 *__result.__exponent = 'E';426 *__result.__exponent = 'E';
433 return __result;427 return __result;
434}428}
435429
436# ifndef _LIBCPP_HAS_NO_LOCALIZATION430/// Fills the buffer with the data based on the requested formatting.
431///
432/// This function, when needed, turns the characters to upper case and
433/// determines the "interesting" locations which are returned to the caller.
434///
435/// This means the caller never has to convert the contents of the buffer to
436/// upper case or search for radix points and the location of the exponent.
437/// This gives a bit of overhead. The original code didn't do that, but due
438/// to the number of possible additional work needed to turn this number to
439/// the proper output the code was littered with tests for upper cases and
440/// searches for radix points and exponents.
441/// - When a precision larger than the type's precision is selected
442/// additional zero characters need to be written before the exponent.
443/// - alternate form needs to add a radix point when not present.
444/// - localization needs to do grouping in the integral part.
445template <class _Fp, class _Tp>
446// TODO FMT _Fp should just be _Tp when to_chars has proper long double support.
447_LIBCPP_HIDE_FROM_ABI __float_result __format_buffer(
448 __float_buffer<_Fp>& __buffer,
449 _Tp __value,
450 bool __negative,
451 bool __has_precision,
452 __format_spec::__sign __sign,
453 __format_spec::__type __type) {
454 char* __first = __formatter::__insert_sign(__buffer.begin(), __negative, __sign);
455 switch (__type) {
456 case __format_spec::__type::__default:
457 return __formatter::__format_buffer_default(__buffer, __value, __first);
458
459 case __format_spec::__type::__hexfloat_lower_case:
460 return __formatter::__format_buffer_hexadecimal_lower_case(
461 __buffer, __value, __has_precision ? __buffer.__precision() : -1, __first);
462
463 case __format_spec::__type::__hexfloat_upper_case:
464 return __formatter::__format_buffer_hexadecimal_upper_case(
465 __buffer, __value, __has_precision ? __buffer.__precision() : -1, __first);
466
467 case __format_spec::__type::__scientific_lower_case:
468 return __formatter::__format_buffer_scientific_lower_case(__buffer, __value, __buffer.__precision(), __first);
469
470 case __format_spec::__type::__scientific_upper_case:
471 return __formatter::__format_buffer_scientific_upper_case(__buffer, __value, __buffer.__precision(), __first);
472
473 case __format_spec::__type::__fixed_lower_case:
474 case __format_spec::__type::__fixed_upper_case:
475 return __formatter::__format_buffer_fixed(__buffer, __value, __buffer.__precision(), __first);
476
477 case __format_spec::__type::__general_lower_case:
478 return __formatter::__format_buffer_general_lower_case(__buffer, __value, __buffer.__precision(), __first);
479
480 case __format_spec::__type::__general_upper_case:
481 return __formatter::__format_buffer_general_upper_case(__buffer, __value, __buffer.__precision(), __first);
482
483 default:
484 _LIBCPP_ASSERT(false, "The parser should have validated the type");
485 __libcpp_unreachable();
486 }
487}
488
489# ifndef _LIBCPP_HAS_NO_LOCALIZATION
437template <class _OutIt, class _Fp, class _CharT>490template <class _OutIt, class _Fp, class _CharT>
438_LIBCPP_HIDE_FROM_ABI _OutIt __format_locale_specific_form(_OutIt __out_it, const __float_buffer<_Fp>& __buffer,491_LIBCPP_HIDE_FROM_ABI _OutIt __format_locale_specific_form(
439 const __float_result& __result, _VSTD::locale __loc,492 _OutIt __out_it,
440 size_t __width, _Flags::_Alignment __alignment,493 const __float_buffer<_Fp>& __buffer,
441 _CharT __fill) {494 const __float_result& __result,
495 _VSTD::locale __loc,
496 __format_spec::__parsed_specifications<_CharT> __specs) {
442 const auto& __np = use_facet<numpunct<_CharT>>(__loc);497 const auto& __np = use_facet<numpunct<_CharT>>(__loc);
443 string __grouping = __np.grouping();498 string __grouping = __np.grouping();
444 char* __first = __result.__integral;499 char* __first = __result.__integral;
...@@ -450,29 +505,30 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __format_locale_specific_form(_OutIt __out_it, cons...@@ -450,29 +505,30 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __format_locale_specific_form(_OutIt __out_it, cons
450 if (__digits <= __grouping[0])505 if (__digits <= __grouping[0])
451 __grouping.clear();506 __grouping.clear();
452 else507 else
453 __grouping = __determine_grouping(__digits, __grouping);508 __grouping = __formatter::__determine_grouping(__digits, __grouping);
454 }509 }
455510
456 size_t __size = __result.__last - __buffer.begin() + // Formatted string511 ptrdiff_t __size =
457 __buffer.__num_trailing_zeros() + // Not yet rendered zeros512 __result.__last - __buffer.begin() + // Formatted string
458 __grouping.size() - // Grouping contains one513 __buffer.__num_trailing_zeros() + // Not yet rendered zeros
459 !__grouping.empty(); // additional character514 __grouping.size() - // Grouping contains one
515 !__grouping.empty(); // additional character
460516
461 __formatter::__padding_size_result __padding = {0, 0};517 __formatter::__padding_size_result __padding = {0, 0};
462 bool __zero_padding = __alignment == _Flags::_Alignment::__default;518 bool __zero_padding = __specs.__alignment_ == __format_spec::__alignment::__zero_padding;
463 if (__size < __width) {519 if (__size < __specs.__width_) {
464 if (__zero_padding) {520 if (__zero_padding) {
465 __alignment = _Flags::_Alignment::__right;521 __specs.__alignment_ = __format_spec::__alignment::__right;
466 __fill = _CharT('0');522 __specs.__fill_ = _CharT('0');
467 }523 }
468524
469 __padding = __formatter::__padding_size(__size, __width, __alignment);525 __padding = __formatter::__padding_size(__size, __specs.__width_, __specs.__alignment_);
470 }526 }
471527
472 // sign and (zero padding or alignment)528 // sign and (zero padding or alignment)
473 if (__zero_padding && __first != __buffer.begin())529 if (__zero_padding && __first != __buffer.begin())
474 *__out_it++ = *__buffer.begin();530 *__out_it++ = *__buffer.begin();
475 __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __padding.__before, __fill);531 __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __padding.__before_, __specs.__fill_);
476 if (!__zero_padding && __first != __buffer.begin())532 if (!__zero_padding && __first != __buffer.begin())
477 *__out_it++ = *__buffer.begin();533 *__out_it++ = *__buffer.begin();
478534
...@@ -513,200 +569,148 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __format_locale_specific_form(_OutIt __out_it, cons...@@ -513,200 +569,148 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __format_locale_specific_form(_OutIt __out_it, cons
513 __out_it = _VSTD::copy(__result.__exponent, __result.__last, _VSTD::move(__out_it));569 __out_it = _VSTD::copy(__result.__exponent, __result.__last, _VSTD::move(__out_it));
514570
515 // alignment571 // alignment
516 return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after, __fill);572 return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after_, __specs.__fill_);
573}
574# endif // _LIBCPP_HAS_NO_LOCALIZATION
575
576template <class _OutIt, class _CharT>
577_LIBCPP_HIDE_FROM_ABI _OutIt __format_floating_point_non_finite(
578 _OutIt __out_it, __format_spec::__parsed_specifications<_CharT> __specs, bool __negative, bool __isnan) {
579 char __buffer[4];
580 char* __last = __formatter::__insert_sign(__buffer, __negative, __specs.__std_.__sign_);
581
582 // to_chars can return inf, infinity, nan, and nan(n-char-sequence).
583 // The format library requires inf and nan.
584 // All in one expression to avoid dangling references.
585 bool __upper_case =
586 __specs.__std_.__type_ == __format_spec::__type::__hexfloat_upper_case ||
587 __specs.__std_.__type_ == __format_spec::__type::__scientific_upper_case ||
588 __specs.__std_.__type_ == __format_spec::__type::__fixed_upper_case ||
589 __specs.__std_.__type_ == __format_spec::__type::__general_upper_case;
590 __last = _VSTD::copy_n(&("infnanINFNAN"[6 * __upper_case + 3 * __isnan]), 3, __last);
591
592 // [format.string.std]/13
593 // A zero (0) character preceding the width field pads the field with
594 // leading zeros (following any indication of sign or base) to the field
595 // width, except when applied to an infinity or NaN.
596 if (__specs.__alignment_ == __format_spec::__alignment::__zero_padding)
597 __specs.__alignment_ = __format_spec::__alignment::__right;
598
599 return __formatter::__write(__buffer, __last, _VSTD::move(__out_it), __specs);
517}600}
518601
519# endif // _LIBCPP_HAS_NO_LOCALIZATION602template <floating_point _Tp, class _CharT>
520603_LIBCPP_HIDE_FROM_ABI auto
521template <__formatter::__char_type _CharT>604__format_floating_point(_Tp __value, auto& __ctx, __format_spec::__parsed_specifications<_CharT> __specs)
522class _LIBCPP_TEMPLATE_VIS __formatter_floating_point : public __parser_floating_point<_CharT> {605 -> decltype(__ctx.out()) {
523public:606 bool __negative = _VSTD::signbit(__value);
524 template <floating_point _Tp>
525 _LIBCPP_HIDE_FROM_ABI auto format(_Tp __value, auto& __ctx) -> decltype(__ctx.out()) {
526 if (this->__width_needs_substitution())
527 this->__substitute_width_arg_id(__ctx.arg(this->__width));
528
529 bool __negative = _VSTD::signbit(__value);
530
531 if (!_VSTD::isfinite(__value)) [[unlikely]]
532 return __format_non_finite(__ctx.out(), __negative, _VSTD::isnan(__value));
533
534 bool __has_precision = this->__has_precision_field();
535 if (this->__precision_needs_substitution())
536 this->__substitute_precision_arg_id(__ctx.arg(this->__precision));
537
538 // Depending on the std-format-spec string the sign and the value
539 // might not be outputted together:
540 // - zero-padding may insert additional '0' characters.
541 // Therefore the value is processed as a non negative value.
542 // The function @ref __insert_sign will insert a '-' when the value was
543 // negative.
544
545 if (__negative)
546 __value = _VSTD::copysign(__value, +1.0);
547
548 // TODO FMT _Fp should just be _Tp when to_chars has proper long double support.
549 using _Fp = conditional_t<same_as<_Tp, long double>, double, _Tp>;
550 // Force the type of the precision to avoid -1 to become an unsigned value.
551 __float_buffer<_Fp> __buffer(__has_precision ? int(this->__precision) : -1);
552 __float_result __result = __format_buffer(__buffer, __value, __negative, __has_precision);
553
554 if (this->__alternate_form && __result.__radix_point == __result.__last) {
555 *__result.__last++ = '.';
556
557 // When there is an exponent the point needs to be moved before the
558 // exponent. When there's no exponent the rotate does nothing. Since
559 // rotate tests whether the operation is a nop, call it unconditionally.
560 _VSTD::rotate(__result.__exponent, __result.__last - 1, __result.__last);
561 __result.__radix_point = __result.__exponent;
562
563 // The radix point is always placed before the exponent.
564 // - No exponent needs to point to the new last.
565 // - An exponent needs to move one position to the right.
566 // So it's safe to increment the value unconditionally.
567 ++__result.__exponent;
568 }
569607
570# ifndef _LIBCPP_HAS_NO_LOCALIZATION608 if (!_VSTD::isfinite(__value)) [[unlikely]]
571 if (this->__locale_specific_form)609 return __formatter::__format_floating_point_non_finite(__ctx.out(), __specs, __negative, _VSTD::isnan(__value));
572 return __format_spec::__format_locale_specific_form(__ctx.out(), __buffer, __result, __ctx.locale(),
573 this->__width, this->__alignment, this->__fill);
574# endif
575
576 ptrdiff_t __size = __result.__last - __buffer.begin();
577 int __num_trailing_zeros = __buffer.__num_trailing_zeros();
578 if (__size + __num_trailing_zeros >= this->__width) {
579 if (__num_trailing_zeros && __result.__exponent != __result.__last)
580 // Insert trailing zeros before exponent character.
581 return _VSTD::copy(__result.__exponent, __result.__last,
582 _VSTD::fill_n(_VSTD::copy(__buffer.begin(), __result.__exponent, __ctx.out()),
583 __num_trailing_zeros, _CharT('0')));
584
585 return _VSTD::fill_n(_VSTD::copy(__buffer.begin(), __result.__last, __ctx.out()), __num_trailing_zeros,
586 _CharT('0'));
587 }
588610
589 auto __out_it = __ctx.out();611 // Depending on the std-format-spec string the sign and the value
590 char* __first = __buffer.begin();612 // might not be outputted together:
591 if (this->__alignment == _Flags::_Alignment::__default) {613 // - zero-padding may insert additional '0' characters.
592 // When there is a sign output it before the padding. Note the __size614 // Therefore the value is processed as a non negative value.
593 // doesn't need any adjustment, regardless whether the sign is written615 // The function @ref __insert_sign will insert a '-' when the value was
594 // here or in __formatter::__write.616 // negative.
595 if (__first != __result.__integral)
596 *__out_it++ = *__first++;
597 // After the sign is written, zero padding is the same a right alignment
598 // with '0'.
599 this->__alignment = _Flags::_Alignment::__right;
600 this->__fill = _CharT('0');
601 }
602617
603 if (__num_trailing_zeros)618 if (__negative)
604 return __formatter::__write(_VSTD::move(__out_it), __first, __result.__last, __size, this->__width, this->__fill,619 __value = -__value;
605 this->__alignment, __result.__exponent, __num_trailing_zeros);
606620
607 return __formatter::__write(_VSTD::move(__out_it), __first, __result.__last, __size, this->__width, this->__fill,621 // TODO FMT _Fp should just be _Tp when to_chars has proper long double support.
608 this->__alignment);622 using _Fp = conditional_t<same_as<_Tp, long double>, double, _Tp>;
623 // Force the type of the precision to avoid -1 to become an unsigned value.
624 __float_buffer<_Fp> __buffer(__specs.__precision_);
625 __float_result __result = __formatter::__format_buffer(
626 __buffer, __value, __negative, (__specs.__has_precision()), __specs.__std_.__sign_, __specs.__std_.__type_);
627
628 if (__specs.__std_.__alternate_form_ && __result.__radix_point == __result.__last) {
629 *__result.__last++ = '.';
630
631 // When there is an exponent the point needs to be moved before the
632 // exponent. When there's no exponent the rotate does nothing. Since
633 // rotate tests whether the operation is a nop, call it unconditionally.
634 _VSTD::rotate(__result.__exponent, __result.__last - 1, __result.__last);
635 __result.__radix_point = __result.__exponent;
636
637 // The radix point is always placed before the exponent.
638 // - No exponent needs to point to the new last.
639 // - An exponent needs to move one position to the right.
640 // So it's safe to increment the value unconditionally.
641 ++__result.__exponent;
609 }642 }
610643
611private:644# ifndef _LIBCPP_HAS_NO_LOCALIZATION
612 template <class _OutIt>645 if (__specs.__std_.__locale_specific_form_)
613 _LIBCPP_HIDE_FROM_ABI _OutIt __format_non_finite(_OutIt __out_it, bool __negative, bool __isnan) {646 return __formatter::__format_locale_specific_form(__ctx.out(), __buffer, __result, __ctx.locale(), __specs);
614 char __buffer[4];647# endif
615 char* __last = __insert_sign(__buffer, __negative, this->__sign);648
616649 ptrdiff_t __size = __result.__last - __buffer.begin();
617 // to_char can return inf, infinity, nan, and nan(n-char-sequence).650 int __num_trailing_zeros = __buffer.__num_trailing_zeros();
618 // The format library requires inf and nan.651 if (__size + __num_trailing_zeros >= __specs.__width_) {
619 // All in one expression to avoid dangling references.652 if (__num_trailing_zeros && __result.__exponent != __result.__last)
620 __last = _VSTD::copy_n(&("infnanINFNAN"[6 * (this->__type == _Flags::_Type::__float_hexadecimal_upper_case ||653 // Insert trailing zeros before exponent character.
621 this->__type == _Flags::_Type::__scientific_upper_case ||654 return _VSTD::copy(
622 this->__type == _Flags::_Type::__fixed_upper_case ||655 __result.__exponent,
623 this->__type == _Flags::_Type::__general_upper_case) +656 __result.__last,
624 3 * __isnan]),657 _VSTD::fill_n(
625 3, __last);658 _VSTD::copy(__buffer.begin(), __result.__exponent, __ctx.out()), __num_trailing_zeros, _CharT('0')));
626659
627 // [format.string.std]/13660 return _VSTD::fill_n(
628 // A zero (0) character preceding the width field pads the field with661 _VSTD::copy(__buffer.begin(), __result.__last, __ctx.out()), __num_trailing_zeros, _CharT('0'));
629 // leading zeros (following any indication of sign or base) to the field
630 // width, except when applied to an infinity or NaN.
631 if (this->__alignment == _Flags::_Alignment::__default)
632 this->__alignment = _Flags::_Alignment::__right;
633
634 ptrdiff_t __size = __last - __buffer;
635 if (__size >= this->__width)
636 return _VSTD::copy_n(__buffer, __size, _VSTD::move(__out_it));
637
638 return __formatter::__write(_VSTD::move(__out_it), __buffer, __last, __size, this->__width, this->__fill,
639 this->__alignment);
640 }662 }
641663
642 /// Fills the buffer with the data based on the requested formatting.664 auto __out_it = __ctx.out();
643 ///665 char* __first = __buffer.begin();
644 /// This function, when needed, turns the characters to upper case and666 if (__specs.__alignment_ == __format_spec::__alignment ::__zero_padding) {
645 /// determines the "interesting" locations which are returned to the caller.667 // When there is a sign output it before the padding. Note the __size
646 ///668 // doesn't need any adjustment, regardless whether the sign is written
647 /// This means the caller never has to convert the contents of the buffer to669 // here or in __formatter::__write.
648 /// upper case or search for radix points and the location of the exponent.670 if (__first != __result.__integral)
649 /// This gives a bit of overhead. The original code didn't do that, but due671 *__out_it++ = *__first++;
650 /// to the number of possible additional work needed to turn this number to672 // After the sign is written, zero padding is the same a right alignment
651 /// the proper output the code was littered with tests for upper cases and673 // with '0'.
652 /// searches for radix points and exponents.674 __specs.__alignment_ = __format_spec::__alignment::__right;
653 /// - When a precision larger than the type's precision is selected675 __specs.__fill_ = _CharT('0');
654 /// additional zero characters need to be written before the exponent.676 }
655 /// - alternate form needs to add a radix point when not present.
656 /// - localization needs to do grouping in the integral part.
657 template <class _Fp, class _Tp>
658 // TODO FMT _Fp should just be _Tp when to_chars has proper long double support.
659 _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer(__float_buffer<_Fp>& __buffer, _Tp __value, bool __negative,
660 bool __has_precision) {
661 char* __first = __insert_sign(__buffer.begin(), __negative, this->__sign);
662 switch (this->__type) {
663 case _Flags::_Type::__default:
664 return __format_spec::__format_buffer_default(__buffer, __value, __first);
665
666 case _Flags::_Type::__float_hexadecimal_lower_case:
667 return __format_spec::__format_buffer_hexadecimal_lower_case(
668 __buffer, __value, __has_precision ? __buffer.__precision() : -1, __first);
669
670 case _Flags::_Type::__float_hexadecimal_upper_case:
671 return __format_spec::__format_buffer_hexadecimal_upper_case(
672 __buffer, __value, __has_precision ? __buffer.__precision() : -1, __first);
673
674 case _Flags::_Type::__scientific_lower_case:
675 return __format_spec::__format_buffer_scientific_lower_case(__buffer, __value, __buffer.__precision(), __first);
676677
677 case _Flags::_Type::__scientific_upper_case:678 if (__num_trailing_zeros)
678 return __format_spec::__format_buffer_scientific_upper_case(__buffer, __value, __buffer.__precision(), __first);679 return __formatter::__write_using_trailing_zeros(
680 __first, __result.__last, _VSTD::move(__out_it), __specs, __size, __result.__exponent, __num_trailing_zeros);
679681
680 case _Flags::_Type::__fixed_lower_case:682 return __formatter::__write(__first, __result.__last, _VSTD::move(__out_it), __specs, __size);
681 case _Flags::_Type::__fixed_upper_case:683}
682 return __format_spec::__format_buffer_fixed(__buffer, __value, __buffer.__precision(), __first);
683684
684 case _Flags::_Type::__general_lower_case:685} // namespace __formatter
685 return __format_spec::__format_buffer_general_lower_case(__buffer, __value, __buffer.__precision(), __first);
686686
687 case _Flags::_Type::__general_upper_case:687template <__formatter::__char_type _CharT>
688 return __format_spec::__format_buffer_general_upper_case(__buffer, __value, __buffer.__precision(), __first);688struct _LIBCPP_TEMPLATE_VIS __formatter_floating_point {
689public:
690 _LIBCPP_HIDE_FROM_ABI constexpr auto
691 parse(basic_format_parse_context<_CharT>& __parse_ctx) -> decltype(__parse_ctx.begin()) {
692 auto __result = __parser_.__parse(__parse_ctx, __format_spec::__fields_floating_point);
693 __format_spec::__process_parsed_floating_point(__parser_);
694 return __result;
695 }
689696
690 default:697 template <floating_point _Tp>
691 _LIBCPP_ASSERT(false, "The parser should have validated the type");698 _LIBCPP_HIDE_FROM_ABI auto format(_Tp __value, auto& __ctx) const -> decltype(__ctx.out()) {
692 _LIBCPP_UNREACHABLE();699 return __formatter::__format_floating_point(__value, __ctx, __parser_.__get_parsed_std_specifications(__ctx));
693 }
694 }700 }
695};
696701
697} //namespace __format_spec702 __format_spec::__parser<_CharT> __parser_;
703};
698704
699template <__formatter::__char_type _CharT>705template <__formatter::__char_type _CharT>
700struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<float, _CharT>706struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<float, _CharT>
701 : public __format_spec::__formatter_floating_point<_CharT> {};707 : public __formatter_floating_point<_CharT> {};
702template <__formatter::__char_type _CharT>708template <__formatter::__char_type _CharT>
703struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<double, _CharT>709struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<double, _CharT>
704 : public __format_spec::__formatter_floating_point<_CharT> {};710 : public __formatter_floating_point<_CharT> {};
705template <__formatter::__char_type _CharT>711template <__formatter::__char_type _CharT>
706struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<long double, _CharT>712struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<long double, _CharT>
707 : public __format_spec::__formatter_floating_point<_CharT> {};713 : public __formatter_floating_point<_CharT> {};
708
709# endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
710714
711#endif //_LIBCPP_STD_VER > 17715#endif //_LIBCPP_STD_VER > 17
712716
lib/libcxx/include/__format/formatter_integer.h+54-117
...@@ -11,160 +11,97 @@...@@ -11,160 +11,97 @@
11#define _LIBCPP___FORMAT_FORMATTER_INTEGER_H11#define _LIBCPP___FORMAT_FORMATTER_INTEGER_H
1212
13#include <__availability>13#include <__availability>
14#include <__concepts/arithmetic.h>
14#include <__config>15#include <__config>
15#include <__format/format_error.h>
16#include <__format/format_fwd.h>16#include <__format/format_fwd.h>
17#include <__format/format_parse_context.h>
17#include <__format/formatter.h>18#include <__format/formatter.h>
18#include <__format/formatter_integral.h>19#include <__format/formatter_integral.h>
20#include <__format/formatter_output.h>
19#include <__format/parser_std_format_spec.h>21#include <__format/parser_std_format_spec.h>
20#include <limits>22#include <__type_traits/make_32_64_or_128_bit.h>
23#include <type_traits>
2124
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)25#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23#pragma GCC system_header26# pragma GCC system_header
24#endif27#endif
2528
26_LIBCPP_PUSH_MACROS29 _LIBCPP_BEGIN_NAMESPACE_STD
27#include <__undef_macros>
28
29_LIBCPP_BEGIN_NAMESPACE_STD
3030
31#if _LIBCPP_STD_VER > 1731#if _LIBCPP_STD_VER > 17
3232
33// TODO FMT Remove this once we require compilers with proper C++20 support.33 template <__formatter::__char_type _CharT>
34// If the compiler has no concepts support, the format header will be disabled.34 struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT __formatter_integer {
35// Without concepts support enable_if needs to be used and that too much effort
36// to support compilers with partial C++20 support.
37#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
38
39namespace __format_spec {
4035
41template <class _CharT>
42class _LIBCPP_TEMPLATE_VIS __parser_integer : public __parser_integral<_CharT> {
43public:36public:
44 _LIBCPP_HIDE_FROM_ABI constexpr auto parse(auto& __parse_ctx)37 _LIBCPP_HIDE_FROM_ABI constexpr auto
45 -> decltype(__parse_ctx.begin()) {38 parse(basic_format_parse_context<_CharT>& __parse_ctx) -> decltype(__parse_ctx.begin()) {
46 auto __it = __parser_integral<_CharT>::__parse(__parse_ctx);39 auto __result = __parser_.__parse(__parse_ctx, __format_spec::__fields_integral);
4740 __format_spec::__process_parsed_integer(__parser_);
48 switch (this->__type) {41 return __result;
49 case _Flags::_Type::__default:
50 this->__type = _Flags::_Type::__decimal;
51 [[fallthrough]];
52
53 case _Flags::_Type::__binary_lower_case:
54 case _Flags::_Type::__binary_upper_case:
55 case _Flags::_Type::__octal:
56 case _Flags::_Type::__decimal:
57 case _Flags::_Type::__hexadecimal_lower_case:
58 case _Flags::_Type::__hexadecimal_upper_case:
59 this->__handle_integer();
60 break;
61
62 case _Flags::_Type::__char:
63 this->__handle_char();
64 break;
65
66 default:
67 __throw_format_error("The format-spec type has a type not supported for "
68 "an integer argument");
69 }
70 return __it;
71 }42 }
72};
7343
74template <class _CharT>44 template <integral _Tp>
75using __formatter_integer = __formatter_integral<__parser_integer<_CharT>>;45 _LIBCPP_HIDE_FROM_ABI auto format(_Tp __value, auto& __ctx) const -> decltype(__ctx.out()) {
46 __format_spec::__parsed_specifications<_CharT> __specs = __parser_.__get_parsed_std_specifications(__ctx);
47
48 if (__specs.__std_.__type_ == __format_spec::__type::__char)
49 return __formatter::__format_char(__value, __ctx.out(), __specs);
7650
77} // namespace __format_spec51 using _Type = __make_32_64_or_128_bit_t<_Tp>;
52 static_assert(!is_same<_Type, void>::value, "unsupported integral type used in __formatter_integer::__format");
7853
79// [format.formatter.spec]/2.354 // Reduce the number of instantiation of the integer formatter
80// For each charT, for each cv-unqualified arithmetic type ArithmeticT other55 return __formatter::__format_integer(static_cast<_Type>(__value), __ctx, __specs);
81// than char, wchar_t, char8_t, char16_t, or char32_t, a specialization56 }
57
58 __format_spec::__parser<_CharT> __parser_;
59};
8260
83// Signed integral types.61// Signed integral types.
84template <__formatter::__char_type _CharT>62template <__formatter::__char_type _CharT>
85struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT63struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<signed char, _CharT>
86 formatter<signed char, _CharT>64 : public __formatter_integer<_CharT> {};
87 : public __format_spec::__formatter_integer<_CharT> {};
88template <__formatter::__char_type _CharT>65template <__formatter::__char_type _CharT>
89struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<short, _CharT>66struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<short, _CharT> : public __formatter_integer<_CharT> {
90 : public __format_spec::__formatter_integer<_CharT> {};67};
91template <__formatter::__char_type _CharT>68template <__formatter::__char_type _CharT>
92struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<int, _CharT>69struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<int, _CharT> : public __formatter_integer<_CharT> {};
93 : public __format_spec::__formatter_integer<_CharT> {};
94template <__formatter::__char_type _CharT>70template <__formatter::__char_type _CharT>
95struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<long, _CharT>71struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<long, _CharT> : public __formatter_integer<_CharT> {};
96 : public __format_spec::__formatter_integer<_CharT> {};
97template <__formatter::__char_type _CharT>72template <__formatter::__char_type _CharT>
98struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT73struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<long long, _CharT>
99 formatter<long long, _CharT>74 : public __formatter_integer<_CharT> {};
100 : public __format_spec::__formatter_integer<_CharT> {};75# ifndef _LIBCPP_HAS_NO_INT128
101#ifndef _LIBCPP_HAS_NO_INT128
102template <__formatter::__char_type _CharT>76template <__formatter::__char_type _CharT>
103struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT77struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<__int128_t, _CharT>
104 formatter<__int128_t, _CharT>78 : public __formatter_integer<_CharT> {};
105 : public __format_spec::__formatter_integer<_CharT> {79# endif
106 using _Base = __format_spec::__formatter_integer<_CharT>;
107
108 _LIBCPP_HIDE_FROM_ABI auto format(__int128_t __value, auto& __ctx)
109 -> decltype(__ctx.out()) {
110 // TODO FMT Implement full 128 bit support.
111 using _To = long long;
112 if (__value < numeric_limits<_To>::min() ||
113 __value > numeric_limits<_To>::max())
114 __throw_format_error("128-bit value is outside of implemented range");
115
116 return _Base::format(static_cast<_To>(__value), __ctx);
117 }
118};
119#endif
12080
121// Unsigned integral types.81// Unsigned integral types.
122template <__formatter::__char_type _CharT>82template <__formatter::__char_type _CharT>
123struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT83struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<unsigned char, _CharT>
124 formatter<unsigned char, _CharT>84 : public __formatter_integer<_CharT> {};
125 : public __format_spec::__formatter_integer<_CharT> {};
126template <__formatter::__char_type _CharT>85template <__formatter::__char_type _CharT>
127struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT86struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<unsigned short, _CharT>
128 formatter<unsigned short, _CharT>87 : public __formatter_integer<_CharT> {};
129 : public __format_spec::__formatter_integer<_CharT> {};
130template <__formatter::__char_type _CharT>88template <__formatter::__char_type _CharT>
131struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT89struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<unsigned, _CharT>
132 formatter<unsigned, _CharT>90 : public __formatter_integer<_CharT> {};
133 : public __format_spec::__formatter_integer<_CharT> {};
134template <__formatter::__char_type _CharT>91template <__formatter::__char_type _CharT>
135struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT92struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<unsigned long, _CharT>
136 formatter<unsigned long, _CharT>93 : public __formatter_integer<_CharT> {};
137 : public __format_spec::__formatter_integer<_CharT> {};
138template <__formatter::__char_type _CharT>94template <__formatter::__char_type _CharT>
139struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT95struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<unsigned long long, _CharT>
140 formatter<unsigned long long, _CharT>96 : public __formatter_integer<_CharT> {};
141 : public __format_spec::__formatter_integer<_CharT> {};97# ifndef _LIBCPP_HAS_NO_INT128
142#ifndef _LIBCPP_HAS_NO_INT128
143template <__formatter::__char_type _CharT>98template <__formatter::__char_type _CharT>
144struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT99struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<__uint128_t, _CharT>
145 formatter<__uint128_t, _CharT>100 : public __formatter_integer<_CharT> {};
146 : public __format_spec::__formatter_integer<_CharT> {101# endif
147 using _Base = __format_spec::__formatter_integer<_CharT>;
148
149 _LIBCPP_HIDE_FROM_ABI auto format(__uint128_t __value, auto& __ctx)
150 -> decltype(__ctx.out()) {
151 // TODO FMT Implement full 128 bit support.
152 using _To = unsigned long long;
153 if (__value < numeric_limits<_To>::min() ||
154 __value > numeric_limits<_To>::max())
155 __throw_format_error("128-bit value is outside of implemented range");
156
157 return _Base::format(static_cast<_To>(__value), __ctx);
158 }
159};
160#endif
161
162#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
163102
164#endif //_LIBCPP_STD_VER > 17103#endif //_LIBCPP_STD_VER > 17
165104
166_LIBCPP_END_NAMESPACE_STD105_LIBCPP_END_NAMESPACE_STD
167106
168_LIBCPP_POP_MACROS
169
170#endif // _LIBCPP___FORMAT_FORMATTER_INTEGER_H107#endif // _LIBCPP___FORMAT_FORMATTER_INTEGER_H
lib/libcxx/include/__format/formatter_integral.h+254-355
...@@ -10,27 +10,24 @@...@@ -10,27 +10,24 @@
10#ifndef _LIBCPP___FORMAT_FORMATTER_INTEGRAL_H10#ifndef _LIBCPP___FORMAT_FORMATTER_INTEGRAL_H
11#define _LIBCPP___FORMAT_FORMATTER_INTEGRAL_H11#define _LIBCPP___FORMAT_FORMATTER_INTEGRAL_H
1212
13#include <__algorithm/copy.h>13#include <__concepts/arithmetic.h>
14#include <__algorithm/copy_n.h>14#include <__concepts/same_as.h>
15#include <__algorithm/fill_n.h>
16#include <__algorithm/transform.h>
17#include <__config>15#include <__config>
18#include <__format/format_error.h>16#include <__format/format_error.h>
19#include <__format/format_fwd.h>17#include <__format/formatter.h> // for __char_type TODO FMT Move the concept?
20#include <__format/formatter.h>18#include <__format/formatter_output.h>
21#include <__format/parser_std_format_spec.h>19#include <__format/parser_std_format_spec.h>
22#include <array>20#include <__utility/unreachable.h>
23#include <charconv>21#include <charconv>
24#include <concepts>
25#include <limits>22#include <limits>
26#include <string>23#include <string>
2724
28#ifndef _LIBCPP_HAS_NO_LOCALIZATION25#ifndef _LIBCPP_HAS_NO_LOCALIZATION
29#include <locale>26# include <locale>
30#endif27#endif
3128
32#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)29#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
33#pragma GCC system_header30# pragma GCC system_header
34#endif31#endif
3532
36_LIBCPP_PUSH_MACROS33_LIBCPP_PUSH_MACROS
...@@ -40,97 +37,30 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -40,97 +37,30 @@ _LIBCPP_BEGIN_NAMESPACE_STD
4037
41#if _LIBCPP_STD_VER > 1738#if _LIBCPP_STD_VER > 17
4239
43// TODO FMT Remove this once we require compilers with proper C++20 support.40namespace __formatter {
44// If the compiler has no concepts support, the format header will be disabled.
45// Without concepts support enable_if needs to be used and that too much effort
46// to support compilers with partial C++20 support.
47#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
4841
49/**42//
50 * Integral formatting classes.43// Generic
51 *44//
52 * There are two types used here:
53 * * C++-type, the type as used in C++.
54 * * format-type, the output type specified in the std-format-spec.
55 *
56 * Design of the integral formatters consists of several layers.
57 * * @ref __parser_integral The basic std-format-spec parser for all integral
58 * classes. This parser does the basic sanity checks. It also contains some
59 * helper functions that are nice to have available for all parsers.
60 * * A C++-type specific parser. These parsers must derive from
61 * @ref __parser_integral. Their task is to validate whether the parsed
62 * std-format-spec is valid for the C++-type and selected format-type. After
63 * validation they need to make sure all members are properly set. For
64 * example, when the alignment hasn't changed it needs to set the proper
65 * default alignment for the format-type. The following parsers are available:
66 * - @ref __parser_integer
67 * - @ref __parser_char
68 * - @ref __parser_bool
69 * * A general formatter for all integral types @ref __formatter_integral. This
70 * formatter can handle all formatting of integers and characters. The class
71 * derives from the proper formatter.
72 * Note the boolean string format-type isn't supported in this class.
73 * * A typedef C++-type group combining the @ref __formatter_integral with a
74 * parser:
75 * * @ref __formatter_integer
76 * * @ref __formatter_char
77 * * @ref __formatter_bool
78 * * Then every C++-type has its own formatter specializations. They inherit
79 * from the C++-type group typedef. Most specializations need nothing else.
80 * Others need some additional specializations in this class.
81 */
82namespace __format_spec {
83
84/** Wrapper around @ref to_chars, returning the output pointer. */
85template <integral _Tp>
86_LIBCPP_HIDE_FROM_ABI char* __to_buffer(char* __first, char* __last,
87 _Tp __value, int __base) {
88 // TODO FMT Evaluate code overhead due to not calling the internal function
89 // directly. (Should be zero overhead.)
90 to_chars_result __r = _VSTD::to_chars(__first, __last, __value, __base);
91 _LIBCPP_ASSERT(__r.ec == errc(0), "Internal buffer too small");
92 return __r.ptr;
93}
94
95/**
96 * Helper to determine the buffer size to output a integer in Base @em x.
97 *
98 * There are several overloads for the supported bases. The function uses the
99 * base as template argument so it can be used in a constant expression.
100 */
101template <unsigned_integral _Tp, size_t _Base>
102_LIBCPP_HIDE_FROM_ABI constexpr size_t __buffer_size() noexcept
103 requires(_Base == 2) {
104 return numeric_limits<_Tp>::digits // The number of binary digits.
105 + 2 // Reserve space for the '0[Bb]' prefix.
106 + 1; // Reserve space for the sign.
107}
108
109template <unsigned_integral _Tp, size_t _Base>
110_LIBCPP_HIDE_FROM_ABI constexpr size_t __buffer_size() noexcept
111 requires(_Base == 8) {
112 return numeric_limits<_Tp>::digits // The number of binary digits.
113 / 3 // Adjust to octal.
114 + 1 // Turn floor to ceil.
115 + 1 // Reserve space for the '0' prefix.
116 + 1; // Reserve space for the sign.
117}
11845
119template <unsigned_integral _Tp, size_t _Base>46_LIBCPP_HIDE_FROM_ABI inline char* __insert_sign(char* __buf, bool __negative, __format_spec::__sign __sign) {
120_LIBCPP_HIDE_FROM_ABI constexpr size_t __buffer_size() noexcept47 if (__negative)
121 requires(_Base == 10) {48 *__buf++ = '-';
122 return numeric_limits<_Tp>::digits10 // The floored value.49 else
123 + 1 // Turn floor to ceil.50 switch (__sign) {
124 + 1; // Reserve space for the sign.51 case __format_spec::__sign::__default:
125}52 case __format_spec::__sign::__minus:
53 // No sign added.
54 break;
55 case __format_spec::__sign::__plus:
56 *__buf++ = '+';
57 break;
58 case __format_spec::__sign::__space:
59 *__buf++ = ' ';
60 break;
61 }
12662
127template <unsigned_integral _Tp, size_t _Base>63 return __buf;
128_LIBCPP_HIDE_FROM_ABI constexpr size_t __buffer_size() noexcept
129 requires(_Base == 16) {
130 return numeric_limits<_Tp>::digits // The number of binary digits.
131 / 4 // Adjust to hexadecimal.
132 + 2 // Reserve space for the '0[Xx]' prefix.
133 + 1; // Reserve space for the sign.
134}64}
13565
136/**66/**
...@@ -148,8 +78,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr size_t __buffer_size() noexcept...@@ -148,8 +78,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr size_t __buffer_size() noexcept
148 * @note The grouping field of the locale is always a @c std::string,78 * @note The grouping field of the locale is always a @c std::string,
149 * regardless whether the @c std::numpunct's type is @c char or @c wchar_t.79 * regardless whether the @c std::numpunct's type is @c char or @c wchar_t.
150 */80 */
151_LIBCPP_HIDE_FROM_ABI inline string81_LIBCPP_HIDE_FROM_ABI inline string __determine_grouping(ptrdiff_t __size, const string& __grouping) {
152__determine_grouping(ptrdiff_t __size, const string& __grouping) {
153 _LIBCPP_ASSERT(!__grouping.empty() && __size > __grouping[0],82 _LIBCPP_ASSERT(!__grouping.empty() && __size > __grouping[0],
154 "The slow grouping formatting is used while there will be no "83 "The slow grouping formatting is used while there will be no "
155 "separators written");84 "separators written");
...@@ -176,283 +105,253 @@ __determine_grouping(ptrdiff_t __size, const string& __grouping) {...@@ -176,283 +105,253 @@ __determine_grouping(ptrdiff_t __size, const string& __grouping) {
176 }105 }
177 }106 }
178107
179 _LIBCPP_UNREACHABLE();108 __libcpp_unreachable();
180}109}
181110
182template <class _Parser>111//
183requires __formatter::__char_type<typename _Parser::char_type>112// Char
184class _LIBCPP_TEMPLATE_VIS __formatter_integral : public _Parser {113//
185public:
186 using _CharT = typename _Parser::char_type;
187
188 template <integral _Tp>
189 _LIBCPP_HIDE_FROM_ABI auto format(_Tp __value, auto& __ctx)
190 -> decltype(__ctx.out()) {
191 if (this->__width_needs_substitution())
192 this->__substitute_width_arg_id(__ctx.arg(this->__width));
193
194 if (this->__type == _Flags::_Type::__char)
195 return __format_as_char(__value, __ctx);
196114
197 if constexpr (unsigned_integral<_Tp>)115template <__formatter::__char_type _CharT>
198 return __format_unsigned_integral(__value, false, __ctx);116_LIBCPP_HIDE_FROM_ABI auto __format_char(
199 else {117 integral auto __value,
200 // Depending on the std-format-spec string the sign and the value118 output_iterator<const _CharT&> auto __out_it,
201 // might not be outputted together:119 __format_spec::__parsed_specifications<_CharT> __specs) -> decltype(__out_it) {
202 // - alternate form may insert a prefix string.120 using _Tp = decltype(__value);
203 // - zero-padding may insert additional '0' characters.121 if constexpr (!same_as<_CharT, _Tp>) {
204 // Therefore the value is processed as a positive unsigned value.122 // cmp_less and cmp_greater can't be used for character types.
205 // The function @ref __insert_sign will a '-' when the value was negative.123 if constexpr (signed_integral<_CharT> == signed_integral<_Tp>) {
206 auto __r = __to_unsigned_like(__value);124 if (__value < numeric_limits<_CharT>::min() || __value > numeric_limits<_CharT>::max())
207 bool __negative = __value < 0;125 std::__throw_format_error("Integral value outside the range of the char type");
208 if (__negative)126 } else if constexpr (signed_integral<_CharT>) {
209 __r = __complement(__r);127 // _CharT is signed _Tp is unsigned
210128 if (__value > static_cast<make_unsigned_t<_CharT>>(numeric_limits<_CharT>::max()))
211 return __format_unsigned_integral(__r, __negative, __ctx);129 std::__throw_format_error("Integral value outside the range of the char type");
130 } else {
131 // _CharT is unsigned _Tp is signed
132 if (__value < 0 || static_cast<make_unsigned_t<_Tp>>(__value) > numeric_limits<_CharT>::max())
133 std::__throw_format_error("Integral value outside the range of the char type");
212 }134 }
213 }135 }
214136
215private:137 const auto __c = static_cast<_CharT>(__value);
216 /** Generic formatting for format-type c. */138 return __formatter::__write(_VSTD::addressof(__c), _VSTD::addressof(__c) + 1, _VSTD::move(__out_it), __specs);
217 _LIBCPP_HIDE_FROM_ABI auto __format_as_char(integral auto __value,139}
218 auto& __ctx)
219 -> decltype(__ctx.out()) {
220 if (this->__alignment == _Flags::_Alignment::__default)
221 this->__alignment = _Flags::_Alignment::__right;
222
223 using _Tp = decltype(__value);
224 if constexpr (!same_as<_CharT, _Tp>) {
225 // cmp_less and cmp_greater can't be used for character types.
226 if constexpr (signed_integral<_CharT> == signed_integral<_Tp>) {
227 if (__value < numeric_limits<_CharT>::min() ||
228 __value > numeric_limits<_CharT>::max())
229 __throw_format_error(
230 "Integral value outside the range of the char type");
231 } else if constexpr (signed_integral<_CharT>) {
232 // _CharT is signed _Tp is unsigned
233 if (__value >
234 static_cast<make_unsigned_t<_CharT>>(numeric_limits<_CharT>::max()))
235 __throw_format_error(
236 "Integral value outside the range of the char type");
237 } else {
238 // _CharT is unsigned _Tp is signed
239 if (__value < 0 || static_cast<make_unsigned_t<_Tp>>(__value) >
240 numeric_limits<_CharT>::max())
241 __throw_format_error(
242 "Integral value outside the range of the char type");
243 }
244 }
245140
246 const auto __c = static_cast<_CharT>(__value);141//
247 return __write(_VSTD::addressof(__c), _VSTD::addressof(__c) + 1,142// Integer
248 __ctx.out());143//
249 }
250144
251 /**145/** Wrapper around @ref to_chars, returning the output pointer. */
252 * Generic formatting for format-type bBdoxX.146template <integral _Tp>
253 *147_LIBCPP_HIDE_FROM_ABI char* __to_buffer(char* __first, char* __last, _Tp __value, int __base) {
254 * This small wrapper allocates a buffer with the required size. Then calls148 // TODO FMT Evaluate code overhead due to not calling the internal function
255 * the real formatter with the buffer and the prefix for the base.149 // directly. (Should be zero overhead.)
256 */150 to_chars_result __r = _VSTD::to_chars(__first, __last, __value, __base);
257 _LIBCPP_HIDE_FROM_ABI auto151 _LIBCPP_ASSERT(__r.ec == errc(0), "Internal buffer too small");
258 __format_unsigned_integral(unsigned_integral auto __value, bool __negative,152 return __r.ptr;
259 auto& __ctx) -> decltype(__ctx.out()) {153}
260 switch (this->__type) {
261 case _Flags::_Type::__binary_lower_case: {
262 array<char, __buffer_size<decltype(__value), 2>()> __array;
263 return __format_unsigned_integral(__array.begin(), __array.end(), __value,
264 __negative, 2, __ctx, "0b");
265 }
266 case _Flags::_Type::__binary_upper_case: {
267 array<char, __buffer_size<decltype(__value), 2>()> __array;
268 return __format_unsigned_integral(__array.begin(), __array.end(), __value,
269 __negative, 2, __ctx, "0B");
270 }
271 case _Flags::_Type::__octal: {
272 // Octal is special; if __value == 0 there's no prefix.
273 array<char, __buffer_size<decltype(__value), 8>()> __array;
274 return __format_unsigned_integral(__array.begin(), __array.end(), __value,
275 __negative, 8, __ctx,
276 __value != 0 ? "0" : nullptr);
277 }
278 case _Flags::_Type::__decimal: {
279 array<char, __buffer_size<decltype(__value), 10>()> __array;
280 return __format_unsigned_integral(__array.begin(), __array.end(), __value,
281 __negative, 10, __ctx, nullptr);
282 }
283 case _Flags::_Type::__hexadecimal_lower_case: {
284 array<char, __buffer_size<decltype(__value), 16>()> __array;
285 return __format_unsigned_integral(__array.begin(), __array.end(), __value,
286 __negative, 16, __ctx, "0x");
287 }
288 case _Flags::_Type::__hexadecimal_upper_case: {
289 array<char, __buffer_size<decltype(__value), 16>()> __array;
290 return __format_unsigned_integral(__array.begin(), __array.end(), __value,
291 __negative, 16, __ctx, "0X");
292 }
293 default:
294 _LIBCPP_ASSERT(false, "The parser should have validated the type");
295 _LIBCPP_UNREACHABLE();
296 }
297 }
298154
299 template <class _Tp>155/**
300 requires(same_as<char, _Tp> || same_as<wchar_t, _Tp>) _LIBCPP_HIDE_FROM_ABI156 * Helper to determine the buffer size to output a integer in Base @em x.
301 auto __write(const _Tp* __first, const _Tp* __last, auto __out_it)157 *
302 -> decltype(__out_it) {158 * There are several overloads for the supported bases. The function uses the
159 * base as template argument so it can be used in a constant expression.
160 */
161template <unsigned_integral _Tp, size_t _Base>
162consteval size_t __buffer_size() noexcept
163 requires(_Base == 2)
164{
165 return numeric_limits<_Tp>::digits // The number of binary digits.
166 + 2 // Reserve space for the '0[Bb]' prefix.
167 + 1; // Reserve space for the sign.
168}
303169
304 unsigned __size = __last - __first;170template <unsigned_integral _Tp, size_t _Base>
305 if (this->__type != _Flags::_Type::__hexadecimal_upper_case) [[likely]] {171consteval size_t __buffer_size() noexcept
306 if (__size >= this->__width)172 requires(_Base == 8)
307 return _VSTD::copy(__first, __last, _VSTD::move(__out_it));173{
174 return numeric_limits<_Tp>::digits // The number of binary digits.
175 / 3 // Adjust to octal.
176 + 1 // Turn floor to ceil.
177 + 1 // Reserve space for the '0' prefix.
178 + 1; // Reserve space for the sign.
179}
308180
309 return __formatter::__write(_VSTD::move(__out_it), __first, __last,181template <unsigned_integral _Tp, size_t _Base>
310 __size, this->__width, this->__fill,182consteval size_t __buffer_size() noexcept
311 this->__alignment);183 requires(_Base == 10)
312 }184{
185 return numeric_limits<_Tp>::digits10 // The floored value.
186 + 1 // Turn floor to ceil.
187 + 1; // Reserve space for the sign.
188}
189
190template <unsigned_integral _Tp, size_t _Base>
191consteval size_t __buffer_size() noexcept
192 requires(_Base == 16)
193{
194 return numeric_limits<_Tp>::digits // The number of binary digits.
195 / 4 // Adjust to hexadecimal.
196 + 2 // Reserve space for the '0[Xx]' prefix.
197 + 1; // Reserve space for the sign.
198}
313199
314 // this->__type == _Flags::_Type::__hexadecimal_upper_case200template <unsigned_integral _Tp, class _CharT>
315 // This means all characters in the range [a-f] need to be changed to their201_LIBCPP_HIDE_FROM_ABI auto __format_integer(
316 // uppercase representation. The transformation is done as transformation202 _Tp __value,
317 // in the output routine instead of before. This avoids another pass over203 auto& __ctx,
318 // the data.204 __format_spec::__parsed_specifications<_CharT> __specs,
319 // TODO FMT See whether it's possible to do this transformation during the205 bool __negative,
320 // conversion. (This probably requires changing std::to_chars' alphabet.)206 char* __begin,
321 if (__size >= this->__width)207 char* __end,
322 return _VSTD::transform(__first, __last, _VSTD::move(__out_it),208 const char* __prefix,
323 __hex_to_upper);209 int __base) -> decltype(__ctx.out()) {
324210 char* __first = __formatter::__insert_sign(__begin, __negative, __specs.__std_.__sign_);
325 return __formatter::__write(_VSTD::move(__out_it), __first, __last, __size,211 if (__specs.__std_.__alternate_form_ && __prefix)
326 __hex_to_upper, this->__width, this->__fill,212 while (*__prefix)
327 this->__alignment);213 *__first++ = *__prefix++;
214
215 char* __last = __formatter::__to_buffer(__first, __end, __value, __base);
216
217# ifndef _LIBCPP_HAS_NO_LOCALIZATION
218 if (__specs.__std_.__locale_specific_form_) {
219 const auto& __np = use_facet<numpunct<_CharT>>(__ctx.locale());
220 string __grouping = __np.grouping();
221 ptrdiff_t __size = __last - __first;
222 // Writing the grouped form has more overhead than the normal output
223 // routines. If there will be no separators written the locale-specific
224 // form is identical to the normal routine. Test whether to grouped form
225 // is required.
226 if (!__grouping.empty() && __size > __grouping[0])
227 return __formatter::__write_using_decimal_separators(
228 __ctx.out(),
229 __begin,
230 __first,
231 __last,
232 __formatter::__determine_grouping(__size, __grouping),
233 __np.thousands_sep(),
234 __specs);
235 }
236# endif
237 auto __out_it = __ctx.out();
238 if (__specs.__alignment_ != __format_spec::__alignment::__zero_padding)
239 __first = __begin;
240 else {
241 // __buf contains [sign][prefix]data
242 // ^ location of __first
243 // The zero padding is done like:
244 // - Write [sign][prefix]
245 // - Write data right aligned with '0' as fill character.
246 __out_it = _VSTD::copy(__begin, __first, _VSTD::move(__out_it));
247 __specs.__alignment_ = __format_spec::__alignment::__right;
248 __specs.__fill_ = _CharT('0');
249 int32_t __size = __first - __begin;
250
251 __specs.__width_ -= _VSTD::min(__size, __specs.__width_);
328 }252 }
329253
330 _LIBCPP_HIDE_FROM_ABI auto254 if (__specs.__std_.__type_ != __format_spec::__type::__hexadecimal_upper_case) [[likely]]
331 __format_unsigned_integral(char* __begin, char* __end,255 return __formatter::__write(__first, __last, __ctx.out(), __specs);
332 unsigned_integral auto __value, bool __negative,256
333 int __base, auto& __ctx, const char* __prefix)257 return __formatter::__write_transformed(__first, __last, __ctx.out(), __specs, __formatter::__hex_to_upper);
334 -> decltype(__ctx.out()) {258}
335 char* __first = __insert_sign(__begin, __negative, this->__sign);
336 if (this->__alternate_form && __prefix)
337 while (*__prefix)
338 *__first++ = *__prefix++;
339
340 char* __last = __to_buffer(__first, __end, __value, __base);
341#ifndef _LIBCPP_HAS_NO_LOCALIZATION
342 if (this->__locale_specific_form) {
343 const auto& __np = use_facet<numpunct<_CharT>>(__ctx.locale());
344 string __grouping = __np.grouping();
345 ptrdiff_t __size = __last - __first;
346 // Writing the grouped form has more overhead than the normal output
347 // routines. If there will be no separators written the locale-specific
348 // form is identical to the normal routine. Test whether to grouped form
349 // is required.
350 if (!__grouping.empty() && __size > __grouping[0])
351 return __format_grouping(__ctx.out(), __begin, __first, __last,
352 __determine_grouping(__size, __grouping),
353 __np.thousands_sep());
354 }
355#endif
356 auto __out_it = __ctx.out();
357 if (this->__alignment != _Flags::_Alignment::__default)
358 __first = __begin;
359 else {
360 // __buf contains [sign][prefix]data
361 // ^ location of __first
362 // The zero padding is done like:
363 // - Write [sign][prefix]
364 // - Write data right aligned with '0' as fill character.
365 __out_it = _VSTD::copy(__begin, __first, _VSTD::move(__out_it));
366 this->__alignment = _Flags::_Alignment::__right;
367 this->__fill = _CharT('0');
368 uint32_t __size = __first - __begin;
369 this->__width -= _VSTD::min(__size, this->__width);
370 }
371259
372 return __write(__first, __last, _VSTD::move(__out_it));260template <unsigned_integral _Tp, class _CharT>
261_LIBCPP_HIDE_FROM_ABI auto __format_integer(
262 _Tp __value, auto& __ctx, __format_spec::__parsed_specifications<_CharT> __specs, bool __negative = false)
263 -> decltype(__ctx.out()) {
264 switch (__specs.__std_.__type_) {
265 case __format_spec::__type::__binary_lower_case: {
266 array<char, __formatter::__buffer_size<decltype(__value), 2>()> __array;
267 return __formatter::__format_integer(__value, __ctx, __specs, __negative, __array.begin(), __array.end(), "0b", 2);
268 }
269 case __format_spec::__type::__binary_upper_case: {
270 array<char, __formatter::__buffer_size<decltype(__value), 2>()> __array;
271 return __formatter::__format_integer(__value, __ctx, __specs, __negative, __array.begin(), __array.end(), "0B", 2);
272 }
273 case __format_spec::__type::__octal: {
274 // Octal is special; if __value == 0 there's no prefix.
275 array<char, __formatter::__buffer_size<decltype(__value), 8>()> __array;
276 return __formatter::__format_integer(
277 __value, __ctx, __specs, __negative, __array.begin(), __array.end(), __value != 0 ? "0" : nullptr, 8);
278 }
279 case __format_spec::__type::__default:
280 case __format_spec::__type::__decimal: {
281 array<char, __formatter::__buffer_size<decltype(__value), 10>()> __array;
282 return __formatter::__format_integer(
283 __value, __ctx, __specs, __negative, __array.begin(), __array.end(), nullptr, 10);
284 }
285 case __format_spec::__type::__hexadecimal_lower_case: {
286 array<char, __formatter::__buffer_size<decltype(__value), 16>()> __array;
287 return __formatter::__format_integer(__value, __ctx, __specs, __negative, __array.begin(), __array.end(), "0x", 16);
288 }
289 case __format_spec::__type::__hexadecimal_upper_case: {
290 array<char, __formatter::__buffer_size<decltype(__value), 16>()> __array;
291 return __formatter::__format_integer(__value, __ctx, __specs, __negative, __array.begin(), __array.end(), "0X", 16);
292 }
293 default:
294 _LIBCPP_ASSERT(false, "The parse function should have validated the type");
295 __libcpp_unreachable();
373 }296 }
297}
374298
375#ifndef _LIBCPP_HAS_NO_LOCALIZATION299template <signed_integral _Tp, class _CharT>
376 /** Format's the locale-specific form's groupings. */300_LIBCPP_HIDE_FROM_ABI auto
377 template <class _OutIt, class _CharT>301__format_integer(_Tp __value, auto& __ctx, __format_spec::__parsed_specifications<_CharT> __specs)
378 _LIBCPP_HIDE_FROM_ABI _OutIt302 -> decltype(__ctx.out()) {
379 __format_grouping(_OutIt __out_it, const char* __begin, const char* __first,303 // Depending on the std-format-spec string the sign and the value
380 const char* __last, string&& __grouping, _CharT __sep) {304 // might not be outputted together:
381305 // - alternate form may insert a prefix string.
382 // TODO FMT This function duplicates some functionality of the normal306 // - zero-padding may insert additional '0' characters.
383 // output routines. Evaluate whether these parts can be efficiently307 // Therefore the value is processed as a positive unsigned value.
384 // combined with the existing routines.308 // The function @ref __insert_sign will a '-' when the value was negative.
385309 auto __r = std::__to_unsigned_like(__value);
386 unsigned __size = (__first - __begin) + // [sign][prefix]310 bool __negative = __value < 0;
387 (__last - __first) + // data311 if (__negative)
388 (__grouping.size() - 1); // number of separator characters312 __r = __complement(__r);
389313
390 __formatter::__padding_size_result __padding = {0, 0};314 return __formatter::__format_integer(__r, __ctx, __specs, __negative);
391 if (this->__alignment == _Flags::_Alignment::__default) {315}
392 // Write [sign][prefix].
393 __out_it = _VSTD::copy(__begin, __first, _VSTD::move(__out_it));
394
395 if (this->__width > __size) {
396 // Write zero padding.
397 __padding.__before = this->__width - __size;
398 __out_it = _VSTD::fill_n(_VSTD::move(__out_it), this->__width - __size,
399 _CharT('0'));
400 }
401 } else {
402 if (this->__width > __size) {
403 // Determine padding and write padding.
404 __padding = __formatter::__padding_size(__size, this->__width,
405 this->__alignment);
406
407 __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __padding.__before,
408 this->__fill);
409 }
410 // Write [sign][prefix].
411 __out_it = _VSTD::copy(__begin, __first, _VSTD::move(__out_it));
412 }
413316
414 auto __r = __grouping.rbegin();317//
415 auto __e = __grouping.rend() - 1;318// Formatter arithmetic (bool)
416 _LIBCPP_ASSERT(__r != __e, "The slow grouping formatting is used while "319//
417 "there will be no separators written.");
418 // The output is divided in small groups of numbers to write:
419 // - A group before the first separator.
420 // - A separator and a group, repeated for the number of separators.
421 // - A group after the last separator.
422 // This loop achieves that process by testing the termination condition
423 // midway in the loop.
424 //
425 // TODO FMT This loop evaluates the loop invariant `this->__type !=
426 // _Flags::_Type::__hexadecimal_upper_case` for every iteration. (This test
427 // happens in the __write call.) Benchmark whether making two loops and
428 // hoisting the invariant is worth the effort.
429 while (true) {
430 if (this->__type == _Flags::_Type::__hexadecimal_upper_case) {
431 __last = __first + *__r;
432 __out_it = _VSTD::transform(__first, __last, _VSTD::move(__out_it),
433 __hex_to_upper);
434 __first = __last;
435 } else {
436 __out_it = _VSTD::copy_n(__first, *__r, _VSTD::move(__out_it));
437 __first += *__r;
438 }
439
440 if (__r == __e)
441 break;
442
443 ++__r;
444 *__out_it++ = __sep;
445 }
446320
447 return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after,321template <class _CharT>
448 this->__fill);322struct _LIBCPP_TEMPLATE_VIS __bool_strings;
449 }323
450#endif // _LIBCPP_HAS_NO_LOCALIZATION324template <>
325struct _LIBCPP_TEMPLATE_VIS __bool_strings<char> {
326 static constexpr string_view __true{"true"};
327 static constexpr string_view __false{"false"};
451};328};
452329
453} // namespace __format_spec330# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
331template <>
332struct _LIBCPP_TEMPLATE_VIS __bool_strings<wchar_t> {
333 static constexpr wstring_view __true{L"true"};
334 static constexpr wstring_view __false{L"false"};
335};
336# endif
337
338template <class _CharT>
339_LIBCPP_HIDE_FROM_ABI auto
340__format_bool(bool __value, auto& __ctx, __format_spec::__parsed_specifications<_CharT> __specs)
341 -> decltype(__ctx.out()) {
342# ifndef _LIBCPP_HAS_NO_LOCALIZATION
343 if (__specs.__std_.__locale_specific_form_) {
344 const auto& __np = use_facet<numpunct<_CharT>>(__ctx.locale());
345 basic_string<_CharT> __str = __value ? __np.truename() : __np.falsename();
346 return __formatter::__write_string_no_precision(basic_string_view<_CharT>{__str}, __ctx.out(), __specs);
347 }
348# endif
349 basic_string_view<_CharT> __str =
350 __value ? __formatter::__bool_strings<_CharT>::__true : __formatter::__bool_strings<_CharT>::__false;
351 return __formatter::__write(__str.begin(), __str.end(), __ctx.out(), __specs);
352}
454353
455#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)354} // namespace __formatter
456355
457#endif //_LIBCPP_STD_VER > 17356#endif //_LIBCPP_STD_VER > 17
458357
lib/libcxx/include/__format/formatter_output.h created+308
...@@ -0,0 +1,308 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___FORMAT_FORMATTER_OUTPUT_H
11#define _LIBCPP___FORMAT_FORMATTER_OUTPUT_H
12
13#include <__algorithm/copy.h>
14#include <__algorithm/copy_n.h>
15#include <__algorithm/fill_n.h>
16#include <__algorithm/transform.h>
17#include <__config>
18#include <__format/formatter.h>
19#include <__format/parser_std_format_spec.h>
20#include <__format/unicode.h>
21#include <__utility/move.h>
22#include <__utility/unreachable.h>
23#include <cstddef>
24#include <string>
25#include <string_view>
26
27#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
28# pragma GCC system_header
29#endif
30
31_LIBCPP_BEGIN_NAMESPACE_STD
32
33#if _LIBCPP_STD_VER > 17
34
35namespace __formatter {
36
37_LIBCPP_HIDE_FROM_ABI constexpr char __hex_to_upper(char __c) {
38 switch (__c) {
39 case 'a':
40 return 'A';
41 case 'b':
42 return 'B';
43 case 'c':
44 return 'C';
45 case 'd':
46 return 'D';
47 case 'e':
48 return 'E';
49 case 'f':
50 return 'F';
51 }
52 return __c;
53}
54
55struct _LIBCPP_TYPE_VIS __padding_size_result {
56 size_t __before_;
57 size_t __after_;
58};
59
60_LIBCPP_HIDE_FROM_ABI constexpr __padding_size_result
61__padding_size(size_t __size, size_t __width, __format_spec::__alignment __align) {
62 _LIBCPP_ASSERT(__width > __size, "don't call this function when no padding is required");
63 _LIBCPP_ASSERT(
64 __align != __format_spec::__alignment::__zero_padding, "the caller should have handled the zero-padding");
65
66 size_t __fill = __width - __size;
67 switch (__align) {
68 case __format_spec::__alignment::__zero_padding:
69 __libcpp_unreachable();
70
71 case __format_spec::__alignment::__left:
72 return {0, __fill};
73
74 case __format_spec::__alignment::__center: {
75 // The extra padding is divided per [format.string.std]/3
76 // __before = floor(__fill, 2);
77 // __after = ceil(__fill, 2);
78 size_t __before = __fill / 2;
79 size_t __after = __fill - __before;
80 return {__before, __after};
81 }
82 case __format_spec::__alignment::__default:
83 case __format_spec::__alignment::__right:
84 return {__fill, 0};
85 }
86 __libcpp_unreachable();
87}
88
89template <class _OutIt, class _CharT>
90_LIBCPP_HIDE_FROM_ABI _OutIt __write_using_decimal_separators(_OutIt __out_it, const char* __begin, const char* __first,
91 const char* __last, string&& __grouping, _CharT __sep,
92 __format_spec::__parsed_specifications<_CharT> __specs) {
93 int __size = (__first - __begin) + // [sign][prefix]
94 (__last - __first) + // data
95 (__grouping.size() - 1); // number of separator characters
96
97 __padding_size_result __padding = {0, 0};
98 if (__specs.__alignment_ == __format_spec::__alignment::__zero_padding) {
99 // Write [sign][prefix].
100 __out_it = _VSTD::copy(__begin, __first, _VSTD::move(__out_it));
101
102 if (__specs.__width_ > __size) {
103 // Write zero padding.
104 __padding.__before_ = __specs.__width_ - __size;
105 __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __specs.__width_ - __size, _CharT('0'));
106 }
107 } else {
108 if (__specs.__width_ > __size) {
109 // Determine padding and write padding.
110 __padding = __padding_size(__size, __specs.__width_, __specs.__alignment_);
111
112 __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __padding.__before_, __specs.__fill_);
113 }
114 // Write [sign][prefix].
115 __out_it = _VSTD::copy(__begin, __first, _VSTD::move(__out_it));
116 }
117
118 auto __r = __grouping.rbegin();
119 auto __e = __grouping.rend() - 1;
120 _LIBCPP_ASSERT(__r != __e, "The slow grouping formatting is used while "
121 "there will be no separators written.");
122 // The output is divided in small groups of numbers to write:
123 // - A group before the first separator.
124 // - A separator and a group, repeated for the number of separators.
125 // - A group after the last separator.
126 // This loop achieves that process by testing the termination condition
127 // midway in the loop.
128 //
129 // TODO FMT This loop evaluates the loop invariant `__parser.__type !=
130 // _Flags::_Type::__hexadecimal_upper_case` for every iteration. (This test
131 // happens in the __write call.) Benchmark whether making two loops and
132 // hoisting the invariant is worth the effort.
133 while (true) {
134 if (__specs.__std_.__type_ == __format_spec::__type::__hexadecimal_upper_case) {
135 __last = __first + *__r;
136 __out_it = _VSTD::transform(__first, __last, _VSTD::move(__out_it), __hex_to_upper);
137 __first = __last;
138 } else {
139 __out_it = _VSTD::copy_n(__first, *__r, _VSTD::move(__out_it));
140 __first += *__r;
141 }
142
143 if (__r == __e)
144 break;
145
146 ++__r;
147 *__out_it++ = __sep;
148 }
149
150 return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after_, __specs.__fill_);
151}
152
153/// Writes the input to the output with the required padding.
154///
155/// Since the output column width is specified the function can be used for
156/// ASCII and Unicode output.
157///
158/// \pre [\a __first, \a __last) is a valid range.
159/// \pre \a __size <= \a __width. Using this function when this pre-condition
160/// doesn't hold incurs an unwanted overhead.
161///
162/// \param __first Pointer to the first element to write.
163/// \param __last Pointer beyond the last element to write.
164/// \param __out_it The output iterator to write to.
165/// \param __specs The parsed formatting specifications.
166/// \param __size The (estimated) output column width. When the elements
167/// to be written are ASCII the following condition holds
168/// \a __size == \a __last - \a __first.
169///
170/// \returns An iterator pointing beyond the last element written.
171///
172/// \note The type of the elements in range [\a __first, \a __last) can differ
173/// from the type of \a __specs. Integer output uses \c std::to_chars for its
174/// conversion, which means the [\a __first, \a __last) always contains elements
175/// of the type \c char.
176template <class _CharT, class _ParserCharT>
177_LIBCPP_HIDE_FROM_ABI auto __write(
178 const _CharT* __first,
179 const _CharT* __last,
180 output_iterator<const _CharT&> auto __out_it,
181 __format_spec::__parsed_specifications<_ParserCharT> __specs,
182 ptrdiff_t __size) -> decltype(__out_it) {
183 _LIBCPP_ASSERT(__first <= __last, "Not a valid range");
184
185 if (__size >= __specs.__width_)
186 return _VSTD::copy(__first, __last, _VSTD::move(__out_it));
187
188 __padding_size_result __padding = __formatter::__padding_size(__size, __specs.__width_, __specs.__std_.__alignment_);
189 __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __padding.__before_, __specs.__fill_);
190 __out_it = _VSTD::copy(__first, __last, _VSTD::move(__out_it));
191 return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after_, __specs.__fill_);
192}
193
194/// \overload
195///
196/// Calls the function above where \a __size = \a __last - \a __first.
197template <class _CharT, class _ParserCharT>
198_LIBCPP_HIDE_FROM_ABI auto __write(const _CharT* __first, const _CharT* __last,
199 output_iterator<const _CharT&> auto __out_it,
200 __format_spec::__parsed_specifications<_ParserCharT> __specs) -> decltype(__out_it) {
201 return __write(__first, __last, _VSTD::move(__out_it), __specs, __last - __first);
202}
203
204template <class _CharT, class _ParserCharT, class _UnaryOperation>
205_LIBCPP_HIDE_FROM_ABI auto __write_transformed(const _CharT* __first, const _CharT* __last,
206 output_iterator<const _CharT&> auto __out_it,
207 __format_spec::__parsed_specifications<_ParserCharT> __specs,
208 _UnaryOperation __op) -> decltype(__out_it) {
209 _LIBCPP_ASSERT(__first <= __last, "Not a valid range");
210
211 ptrdiff_t __size = __last - __first;
212 if (__size >= __specs.__width_)
213 return _VSTD::transform(__first, __last, _VSTD::move(__out_it), __op);
214
215 __padding_size_result __padding = __padding_size(__size, __specs.__width_, __specs.__alignment_);
216 __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __padding.__before_, __specs.__fill_);
217 __out_it = _VSTD::transform(__first, __last, _VSTD::move(__out_it), __op);
218 return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after_, __specs.__fill_);
219}
220
221/// Writes additional zero's for the precision before the exponent.
222/// This is used when the precision requested in the format string is larger
223/// than the maximum precision of the floating-point type. These precision
224/// digits are always 0.
225///
226/// \param __exponent The location of the exponent character.
227/// \param __num_trailing_zeros The number of 0's to write before the exponent
228/// character.
229template <class _CharT, class _ParserCharT>
230_LIBCPP_HIDE_FROM_ABI auto __write_using_trailing_zeros(
231 const _CharT* __first,
232 const _CharT* __last,
233 output_iterator<const _CharT&> auto __out_it,
234 __format_spec::__parsed_specifications<_ParserCharT> __specs,
235 size_t __size,
236 const _CharT* __exponent,
237 size_t __num_trailing_zeros) -> decltype(__out_it) {
238 _LIBCPP_ASSERT(__first <= __last, "Not a valid range");
239 _LIBCPP_ASSERT(__num_trailing_zeros > 0, "The overload not writing trailing zeros should have been used");
240
241 __padding_size_result __padding =
242 __padding_size(__size + __num_trailing_zeros, __specs.__width_, __specs.__alignment_);
243 __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __padding.__before_, __specs.__fill_);
244 __out_it = _VSTD::copy(__first, __exponent, _VSTD::move(__out_it));
245 __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __num_trailing_zeros, _CharT('0'));
246 __out_it = _VSTD::copy(__exponent, __last, _VSTD::move(__out_it));
247 return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after_, __specs.__fill_);
248}
249
250/// Writes a string using format's width estimation algorithm.
251///
252/// \pre !__specs.__has_precision()
253///
254/// \note When \c _LIBCPP_HAS_NO_UNICODE is defined the function assumes the
255/// input is ASCII.
256template <class _CharT>
257_LIBCPP_HIDE_FROM_ABI auto __write_string_no_precision(
258 basic_string_view<_CharT> __str,
259 output_iterator<const _CharT&> auto __out_it,
260 __format_spec::__parsed_specifications<_CharT> __specs) -> decltype(__out_it) {
261 _LIBCPP_ASSERT(!__specs.__has_precision(), "use __write_string");
262
263 // No padding -> copy the string
264 if (!__specs.__has_width())
265 return _VSTD::copy(__str.begin(), __str.end(), _VSTD::move(__out_it));
266
267 // Note when the estimated width is larger than size there's no padding. So
268 // there's no reason to get the real size when the estimate is larger than or
269 // equal to the minimum field width.
270 size_t __size =
271 __format_spec::__estimate_column_width(__str, __specs.__width_, __format_spec::__column_width_rounding::__up)
272 .__width_;
273
274 return __formatter::__write(__str.begin(), __str.end(), _VSTD::move(__out_it), __specs, __size);
275}
276
277template <class _CharT>
278_LIBCPP_HIDE_FROM_ABI int __truncate(basic_string_view<_CharT>& __str, int __precision) {
279 __format_spec::__column_width_result<_CharT> __result =
280 __format_spec::__estimate_column_width(__str, __precision, __format_spec::__column_width_rounding::__down);
281 __str = basic_string_view<_CharT>{__str.begin(), __result.__last_};
282 return __result.__width_;
283}
284
285/// Writes a string using format's width estimation algorithm.
286///
287/// \note When \c _LIBCPP_HAS_NO_UNICODE is defined the function assumes the
288/// input is ASCII.
289template <class _CharT>
290_LIBCPP_HIDE_FROM_ABI auto __write_string(
291 basic_string_view<_CharT> __str,
292 output_iterator<const _CharT&> auto __out_it,
293 __format_spec::__parsed_specifications<_CharT> __specs) -> decltype(__out_it) {
294 if (!__specs.__has_precision())
295 return __formatter::__write_string_no_precision(__str, _VSTD::move(__out_it), __specs);
296
297 int __size = __formatter::__truncate(__str, __specs.__precision_);
298
299 return __write(__str.begin(), __str.end(), _VSTD::move(__out_it), __specs, __size);
300}
301
302} // namespace __formatter
303
304#endif //_LIBCPP_STD_VER > 17
305
306_LIBCPP_END_NAMESPACE_STD
307
308#endif // _LIBCPP___FORMAT_FORMATTER_OUTPUT_H
lib/libcxx/include/__format/formatter_pointer.h+22-40
...@@ -10,17 +10,15 @@...@@ -10,17 +10,15 @@
10#ifndef _LIBCPP___FORMAT_FORMATTER_POINTER_H10#ifndef _LIBCPP___FORMAT_FORMATTER_POINTER_H
11#define _LIBCPP___FORMAT_FORMATTER_POINTER_H11#define _LIBCPP___FORMAT_FORMATTER_POINTER_H
1212
13#include <__algorithm/copy.h>
14#include <__availability>13#include <__availability>
15#include <__config>14#include <__config>
16#include <__debug>
17#include <__format/format_error.h>
18#include <__format/format_fwd.h>15#include <__format/format_fwd.h>
16#include <__format/format_parse_context.h>
19#include <__format/formatter.h>17#include <__format/formatter.h>
20#include <__format/formatter_integral.h>18#include <__format/formatter_integral.h>
19#include <__format/formatter_output.h>
21#include <__format/parser_std_format_spec.h>20#include <__format/parser_std_format_spec.h>
22#include <__iterator/access.h>21#include <cstddef>
23#include <__nullptr>
24#include <cstdint>22#include <cstdint>
2523
26#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)24#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -31,41 +29,27 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -31,41 +29,27 @@ _LIBCPP_BEGIN_NAMESPACE_STD
3129
32#if _LIBCPP_STD_VER > 1730#if _LIBCPP_STD_VER > 17
3331
34// TODO FMT Remove this once we require compilers with proper C++20 support.
35// If the compiler has no concepts support, the format header will be disabled.
36// Without concepts support enable_if needs to be used and that too much effort
37// to support compilers with partial C++20 support.
38# if !defined(_LIBCPP_HAS_NO_CONCEPTS)
39
40namespace __format_spec {
41
42template <__formatter::__char_type _CharT>32template <__formatter::__char_type _CharT>
43class _LIBCPP_TEMPLATE_VIS __formatter_pointer : public __parser_pointer<_CharT> {33struct _LIBCPP_TEMPLATE_VIS __formatter_pointer {
44public:34public:
45 _LIBCPP_HIDE_FROM_ABI auto format(const void* __ptr, auto& __ctx) -> decltype(__ctx.out()) {35 constexpr __formatter_pointer() { __parser_.__alignment_ = __format_spec::__alignment::__right; }
46 _LIBCPP_ASSERT(this->__alignment != _Flags::_Alignment::__default,
47 "The call to parse should have updated the alignment");
48 if (this->__width_needs_substitution())
49 this->__substitute_width_arg_id(__ctx.arg(this->__width));
5036
51 // This code looks a lot like the code to format a hexadecimal integral,37 _LIBCPP_HIDE_FROM_ABI constexpr auto
52 // but that code isn't public. Making that code public requires some38 parse(basic_format_parse_context<_CharT>& __parse_ctx) -> decltype(__parse_ctx.begin()) {
53 // refactoring.39 auto __result = __parser_.__parse(__parse_ctx, __format_spec::__fields_pointer);
54 // TODO FMT Remove code duplication.40 __format_spec::__process_display_type_pointer(__parser_.__type_);
55 char __buffer[2 + 2 * sizeof(uintptr_t)];41 return __result;
56 __buffer[0] = '0';42 }
57 __buffer[1] = 'x';
58 char* __last = __to_buffer(__buffer + 2, _VSTD::end(__buffer), reinterpret_cast<uintptr_t>(__ptr), 16);
59
60 unsigned __size = __last - __buffer;
61 if (__size >= this->__width)
62 return _VSTD::copy(__buffer, __last, __ctx.out());
6343
64 return __formatter::__write(__ctx.out(), __buffer, __last, __size, this->__width, this->__fill, this->__alignment);44 _LIBCPP_HIDE_FROM_ABI auto format(const void* __ptr, auto& __ctx) const -> decltype(__ctx.out()) {
45 __format_spec::__parsed_specifications<_CharT> __specs = __parser_.__get_parsed_std_specifications(__ctx);
46 __specs.__std_.__alternate_form_ = true;
47 __specs.__std_.__type_ = __format_spec::__type::__hexadecimal_lower_case;
48 return __formatter::__format_integer(reinterpret_cast<uintptr_t>(__ptr), __ctx, __specs);
65 }49 }
66};
6750
68} // namespace __format_spec51 __format_spec::__parser<_CharT> __parser_;
52};
6953
70// [format.formatter.spec]/2.454// [format.formatter.spec]/2.4
71// For each charT, the pointer type specializations template<>55// For each charT, the pointer type specializations template<>
...@@ -74,15 +58,13 @@ public:...@@ -74,15 +58,13 @@ public:
74// - template<> struct formatter<const void*, charT>;58// - template<> struct formatter<const void*, charT>;
75template <__formatter::__char_type _CharT>59template <__formatter::__char_type _CharT>
76struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<nullptr_t, _CharT>60struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<nullptr_t, _CharT>
77 : public __format_spec::__formatter_pointer<_CharT> {};61 : public __formatter_pointer<_CharT> {};
78template <__formatter::__char_type _CharT>62template <__formatter::__char_type _CharT>
79struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<void*, _CharT>63struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<void*, _CharT> : public __formatter_pointer<_CharT> {
80 : public __format_spec::__formatter_pointer<_CharT> {};64};
81template <__formatter::__char_type _CharT>65template <__formatter::__char_type _CharT>
82struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<const void*, _CharT>66struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<const void*, _CharT>
83 : public __format_spec::__formatter_pointer<_CharT> {};67 : public __formatter_pointer<_CharT> {};
84
85# endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
8668
87#endif //_LIBCPP_STD_VER > 1769#endif //_LIBCPP_STD_VER > 17
8870
lib/libcxx/include/__format/formatter_string.h+51-68
...@@ -10,68 +10,49 @@...@@ -10,68 +10,49 @@
10#ifndef _LIBCPP___FORMAT_FORMATTER_STRING_H10#ifndef _LIBCPP___FORMAT_FORMATTER_STRING_H
11#define _LIBCPP___FORMAT_FORMATTER_STRING_H11#define _LIBCPP___FORMAT_FORMATTER_STRING_H
1212
13#include <__availability>
13#include <__config>14#include <__config>
14#include <__format/format_error.h>
15#include <__format/format_fwd.h>15#include <__format/format_fwd.h>
16#include <__format/format_string.h>16#include <__format/format_parse_context.h>
17#include <__format/formatter.h>17#include <__format/formatter.h>
18#include <__format/formatter_output.h>
18#include <__format/parser_std_format_spec.h>19#include <__format/parser_std_format_spec.h>
20#include <__utility/move.h>
21#include <string>
19#include <string_view>22#include <string_view>
2023
21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)24#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
22#pragma GCC system_header25# pragma GCC system_header
23#endif26#endif
2427
25_LIBCPP_PUSH_MACROS
26#include <__undef_macros>
27
28_LIBCPP_BEGIN_NAMESPACE_STD28_LIBCPP_BEGIN_NAMESPACE_STD
2929
30#if _LIBCPP_STD_VER > 1730#if _LIBCPP_STD_VER > 17
3131
32// TODO FMT Remove this once we require compilers with proper C++20 support.
33// If the compiler has no concepts support, the format header will be disabled.
34// Without concepts support enable_if needs to be used and that too much effort
35// to support compilers with partial C++20 support.
36#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
37
38namespace __format_spec {
39
40template <__formatter::__char_type _CharT>32template <__formatter::__char_type _CharT>
41class _LIBCPP_TEMPLATE_VIS __formatter_string : public __parser_string<_CharT> {33struct _LIBCPP_TEMPLATE_VIS __formatter_string {
42public:34public:
43 _LIBCPP_HIDE_FROM_ABI auto format(basic_string_view<_CharT> __str,35 _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx)
44 auto& __ctx) -> decltype(__ctx.out()) {36 -> decltype(__parse_ctx.begin()) {
4537 auto __result = __parser_.__parse(__parse_ctx, __format_spec::__fields_string);
46 _LIBCPP_ASSERT(this->__alignment != _Flags::_Alignment::__default,38 __format_spec::__process_display_type_string(__parser_.__type_);
47 "The parser should not use these defaults");39 return __result;
48
49 if (this->__width_needs_substitution())
50 this->__substitute_width_arg_id(__ctx.arg(this->__width));
51
52 if (this->__precision_needs_substitution())
53 this->__substitute_precision_arg_id(__ctx.arg(this->__precision));
54
55 return __formatter::__write_unicode(
56 __ctx.out(), __str, this->__width,
57 this->__has_precision_field() ? this->__precision : -1, this->__fill,
58 this->__alignment);
59 }40 }
60};
6141
62} //namespace __format_spec42 _LIBCPP_HIDE_FROM_ABI auto format(basic_string_view<_CharT> __str, auto& __ctx) const -> decltype(__ctx.out()) {
43 return __formatter::__write_string(__str, __ctx.out(), __parser_.__get_parsed_std_specifications(__ctx));
44 }
6345
64// [format.formatter.spec]/2.2 For each charT, the string type specializations46 __format_spec::__parser<_CharT> __parser_;
47};
6548
66// Formatter const char*.49// Formatter const char*.
67template <__formatter::__char_type _CharT>50template <__formatter::__char_type _CharT>
68struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT51struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<const _CharT*, _CharT>
69 formatter<const _CharT*, _CharT>52 : public __formatter_string<_CharT> {
70 : public __format_spec::__formatter_string<_CharT> {53 using _Base = __formatter_string<_CharT>;
71 using _Base = __format_spec::__formatter_string<_CharT>;
7254
73 _LIBCPP_HIDE_FROM_ABI auto format(const _CharT* __str, auto& __ctx)55 _LIBCPP_HIDE_FROM_ABI auto format(const _CharT* __str, auto& __ctx) const -> decltype(__ctx.out()) {
74 -> decltype(__ctx.out()) {
75 _LIBCPP_ASSERT(__str, "The basic_format_arg constructor should have "56 _LIBCPP_ASSERT(__str, "The basic_format_arg constructor should have "
76 "prevented an invalid pointer.");57 "prevented an invalid pointer.");
7758
...@@ -86,8 +67,9 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT...@@ -86,8 +67,9 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT
86 // now these optimizations aren't implemented. Instead the base class67 // now these optimizations aren't implemented. Instead the base class
87 // handles these options.68 // handles these options.
88 // TODO FMT Implement these improvements.69 // TODO FMT Implement these improvements.
89 if (this->__has_width_field() || this->__has_precision_field())70 __format_spec::__parsed_specifications<_CharT> __specs = _Base::__parser_.__get_parsed_std_specifications(__ctx);
90 return _Base::format(__str, __ctx);71 if (__specs.__has_width() || __specs.__has_precision())
72 return __formatter::__write_string(basic_string_view<_CharT>{__str}, __ctx.out(), __specs);
9173
92 // No formatting required, copy the string to the output.74 // No formatting required, copy the string to the output.
93 auto __out_it = __ctx.out();75 auto __out_it = __ctx.out();
...@@ -99,40 +81,46 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT...@@ -99,40 +81,46 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT
9981
100// Formatter char*.82// Formatter char*.
101template <__formatter::__char_type _CharT>83template <__formatter::__char_type _CharT>
102struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT84struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<_CharT*, _CharT>
103 formatter<_CharT*, _CharT> : public formatter<const _CharT*, _CharT> {85 : public formatter<const _CharT*, _CharT> {
104 using _Base = formatter<const _CharT*, _CharT>;86 using _Base = formatter<const _CharT*, _CharT>;
10587
106 _LIBCPP_HIDE_FROM_ABI auto format(_CharT* __str, auto& __ctx)88 _LIBCPP_HIDE_FROM_ABI auto format(_CharT* __str, auto& __ctx) const -> decltype(__ctx.out()) {
107 -> decltype(__ctx.out()) {
108 return _Base::format(__str, __ctx);89 return _Base::format(__str, __ctx);
109 }90 }
110};91};
11192
93// Formatter char[].
94template <__formatter::__char_type _CharT, size_t _Size>
95struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<_CharT[_Size], _CharT>
96 : public __formatter_string<_CharT> {
97 using _Base = __formatter_string<_CharT>;
98
99 _LIBCPP_HIDE_FROM_ABI auto format(_CharT __str[_Size], auto& __ctx) const -> decltype(__ctx.out()) {
100 return _Base::format(basic_string_view<_CharT>(__str, _Size), __ctx);
101 }
102};
103
112// Formatter const char[].104// Formatter const char[].
113template <__formatter::__char_type _CharT, size_t _Size>105template <__formatter::__char_type _CharT, size_t _Size>
114struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT106struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<const _CharT[_Size], _CharT>
115 formatter<const _CharT[_Size], _CharT>107 : public __formatter_string<_CharT> {
116 : public __format_spec::__formatter_string<_CharT> {108 using _Base = __formatter_string<_CharT>;
117 using _Base = __format_spec::__formatter_string<_CharT>;
118109
119 _LIBCPP_HIDE_FROM_ABI auto format(const _CharT __str[_Size], auto& __ctx)110 _LIBCPP_HIDE_FROM_ABI auto format(const _CharT __str[_Size], auto& __ctx) const -> decltype(__ctx.out()) {
120 -> decltype(__ctx.out()) {
121 return _Base::format(basic_string_view<_CharT>(__str, _Size), __ctx);111 return _Base::format(basic_string_view<_CharT>(__str, _Size), __ctx);
122 }112 }
123};113};
124114
125// Formatter std::string.115// Formatter std::string.
126template <__formatter::__char_type _CharT, class _Traits, class _Allocator>116template <__formatter::__char_type _CharT, class _Traits, class _Allocator>
127struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT117struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<basic_string<_CharT, _Traits, _Allocator>, _CharT>
128 formatter<basic_string<_CharT, _Traits, _Allocator>, _CharT>118 : public __formatter_string<_CharT> {
129 : public __format_spec::__formatter_string<_CharT> {119 using _Base = __formatter_string<_CharT>;
130 using _Base = __format_spec::__formatter_string<_CharT>;
131120
132 _LIBCPP_HIDE_FROM_ABI auto121 _LIBCPP_HIDE_FROM_ABI auto format(const basic_string<_CharT, _Traits, _Allocator>& __str, auto& __ctx) const
133 format(const basic_string<_CharT, _Traits, _Allocator>& __str, auto& __ctx)
134 -> decltype(__ctx.out()) {122 -> decltype(__ctx.out()) {
135 // drop _Traits and _Allocator123 // Drop _Traits and _Allocator to have one std::basic_string formatter.
136 return _Base::format(basic_string_view<_CharT>(__str.data(), __str.size()), __ctx);124 return _Base::format(basic_string_view<_CharT>(__str.data(), __str.size()), __ctx);
137 }125 }
138};126};
...@@ -140,23 +128,18 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT...@@ -140,23 +128,18 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT
140// Formatter std::string_view.128// Formatter std::string_view.
141template <__formatter::__char_type _CharT, class _Traits>129template <__formatter::__char_type _CharT, class _Traits>
142struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<basic_string_view<_CharT, _Traits>, _CharT>130struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<basic_string_view<_CharT, _Traits>, _CharT>
143 : public __format_spec::__formatter_string<_CharT> {131 : public __formatter_string<_CharT> {
144 using _Base = __format_spec::__formatter_string<_CharT>;132 using _Base = __formatter_string<_CharT>;
145133
146 _LIBCPP_HIDE_FROM_ABI auto134 _LIBCPP_HIDE_FROM_ABI auto format(basic_string_view<_CharT, _Traits> __str, auto& __ctx) const
147 format(basic_string_view<_CharT, _Traits> __str, auto& __ctx)
148 -> decltype(__ctx.out()) {135 -> decltype(__ctx.out()) {
149 // drop _Traits136 // Drop _Traits to have one std::basic_string_view formatter.
150 return _Base::format(basic_string_view<_CharT>(__str.data(), __str.size()), __ctx);137 return _Base::format(basic_string_view<_CharT>(__str.data(), __str.size()), __ctx);
151 }138 }
152};139};
153140
154#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
155
156#endif //_LIBCPP_STD_VER > 17141#endif //_LIBCPP_STD_VER > 17
157142
158_LIBCPP_END_NAMESPACE_STD143_LIBCPP_END_NAMESPACE_STD
159144
160_LIBCPP_POP_MACROS
161
162#endif // _LIBCPP___FORMAT_FORMATTER_STRING_H145#endif // _LIBCPP___FORMAT_FORMATTER_STRING_H
lib/libcxx/include/__format/parser_std_format_spec.h+677-1169
...@@ -10,21 +10,31 @@...@@ -10,21 +10,31 @@
10#ifndef _LIBCPP___FORMAT_PARSER_STD_FORMAT_SPEC_H10#ifndef _LIBCPP___FORMAT_PARSER_STD_FORMAT_SPEC_H
11#define _LIBCPP___FORMAT_PARSER_STD_FORMAT_SPEC_H11#define _LIBCPP___FORMAT_PARSER_STD_FORMAT_SPEC_H
1212
13/// \file Contains the std-format-spec parser.
14///
15/// Most of the code can be reused in the chrono-format-spec.
16/// This header has some support for the chrono-format-spec since it doesn't
17/// affect the std-format-spec.
18
13#include <__algorithm/find_if.h>19#include <__algorithm/find_if.h>
14#include <__algorithm/min.h>20#include <__algorithm/min.h>
21#include <__assert>
15#include <__config>22#include <__config>
16#include <__debug>23#include <__debug>
17#include <__format/format_arg.h>24#include <__format/format_arg.h>
18#include <__format/format_error.h>25#include <__format/format_error.h>
26#include <__format/format_parse_context.h>
19#include <__format/format_string.h>27#include <__format/format_string.h>
28#include <__format/unicode.h>
20#include <__variant/monostate.h>29#include <__variant/monostate.h>
21#include <bit>30#include <bit>
22#include <concepts>31#include <concepts>
23#include <cstdint>32#include <cstdint>
33#include <string_view>
24#include <type_traits>34#include <type_traits>
2535
26#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)36#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
27# pragma GCC system_header37# pragma GCC system_header
28#endif38#endif
2939
30_LIBCPP_PUSH_MACROS40_LIBCPP_PUSH_MACROS
...@@ -34,174 +44,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -34,174 +44,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD
3444
35#if _LIBCPP_STD_VER > 1745#if _LIBCPP_STD_VER > 17
3646
37// TODO FMT Remove this once we require compilers with proper C++20 support.
38// If the compiler has no concepts support, the format header will be disabled.
39// Without concepts support enable_if needs to be used and that too much effort
40// to support compilers with partial C++20 support.
41# if !defined(_LIBCPP_HAS_NO_CONCEPTS)
42
43namespace __format_spec {47namespace __format_spec {
4448
45/**
46 * Contains the flags for the std-format-spec.
47 *
48 * Some format-options can only be used for specific C++types and may depend on
49 * the selected format-type.
50 * * The C++type filtering can be done using the proper policies for
51 * @ref __parser_std.
52 * * The format-type filtering needs to be done post parsing in the parser
53 * derived from @ref __parser_std.
54 */
55class _LIBCPP_TYPE_VIS _Flags {
56public:
57 enum class _LIBCPP_ENUM_VIS _Alignment : uint8_t {
58 /**
59 * No alignment is set in the format string.
60 *
61 * Zero-padding is ignored when an alignment is selected.
62 * The default alignment depends on the selected format-type.
63 */
64 __default,
65 __left,
66 __center,
67 __right
68 };
69 enum class _LIBCPP_ENUM_VIS _Sign : uint8_t {
70 /**
71 * No sign is set in the format string.
72 *
73 * The sign isn't allowed for certain format-types. By using this value
74 * it's possible to detect whether or not the user explicitly set the sign
75 * flag. For formatting purposes it behaves the same as @ref __minus.
76 */
77 __default,
78 __minus,
79 __plus,
80 __space
81 };
82
83 _Alignment __alignment : 2 {_Alignment::__default};
84 _Sign __sign : 2 {_Sign::__default};
85 uint8_t __alternate_form : 1 {false};
86 uint8_t __zero_padding : 1 {false};
87 uint8_t __locale_specific_form : 1 {false};
88
89 enum class _LIBCPP_ENUM_VIS _Type : uint8_t {
90 __default,
91 __string,
92 __binary_lower_case,
93 __binary_upper_case,
94 __octal,
95 __decimal,
96 __hexadecimal_lower_case,
97 __hexadecimal_upper_case,
98 __pointer,
99 __char,
100 __float_hexadecimal_lower_case,
101 __float_hexadecimal_upper_case,
102 __scientific_lower_case,
103 __scientific_upper_case,
104 __fixed_lower_case,
105 __fixed_upper_case,
106 __general_lower_case,
107 __general_upper_case
108 };
109
110 _Type __type{_Type::__default};
111};
112
113namespace __detail {
114template <class _CharT>
115_LIBCPP_HIDE_FROM_ABI constexpr bool
116__parse_alignment(_CharT __c, _Flags& __flags) noexcept {
117 switch (__c) {
118 case _CharT('<'):
119 __flags.__alignment = _Flags::_Alignment::__left;
120 return true;
121
122 case _CharT('^'):
123 __flags.__alignment = _Flags::_Alignment::__center;
124 return true;
125
126 case _CharT('>'):
127 __flags.__alignment = _Flags::_Alignment::__right;
128 return true;
129 }
130 return false;
131}
132} // namespace __detail
133
134template <class _CharT>
135class _LIBCPP_TEMPLATE_VIS __parser_fill_align {
136public:
137 // TODO FMT The standard doesn't specify this character is a Unicode
138 // character. Validate what fmt and MSVC have implemented.
139 _CharT __fill{_CharT(' ')};
140
141protected:
142 _LIBCPP_HIDE_FROM_ABI constexpr const _CharT*
143 __parse(const _CharT* __begin, const _CharT* __end, _Flags& __flags) {
144 _LIBCPP_ASSERT(__begin != __end,
145 "When called with an empty input the function will cause "
146 "undefined behavior by evaluating data not in the input");
147 if (__begin + 1 != __end) {
148 if (__detail::__parse_alignment(*(__begin + 1), __flags)) {
149 if (*__begin == _CharT('{') || *__begin == _CharT('}'))
150 __throw_format_error(
151 "The format-spec fill field contains an invalid character");
152 __fill = *__begin;
153 return __begin + 2;
154 }
155 }
156
157 if (__detail::__parse_alignment(*__begin, __flags))
158 return __begin + 1;
159
160 return __begin;
161 }
162};
163
164template <class _CharT>
165_LIBCPP_HIDE_FROM_ABI constexpr const _CharT*
166__parse_sign(const _CharT* __begin, _Flags& __flags) noexcept {
167 switch (*__begin) {
168 case _CharT('-'):
169 __flags.__sign = _Flags::_Sign::__minus;
170 break;
171 case _CharT('+'):
172 __flags.__sign = _Flags::_Sign::__plus;
173 break;
174 case _CharT(' '):
175 __flags.__sign = _Flags::_Sign::__space;
176 break;
177 default:
178 return __begin;
179 }
180 return __begin + 1;
181}
182
183template <class _CharT>
184_LIBCPP_HIDE_FROM_ABI constexpr const _CharT*
185__parse_alternate_form(const _CharT* __begin, _Flags& __flags) noexcept {
186 if (*__begin == _CharT('#')) {
187 __flags.__alternate_form = true;
188 ++__begin;
189 }
190
191 return __begin;
192}
193
194template <class _CharT>
195_LIBCPP_HIDE_FROM_ABI constexpr const _CharT*
196__parse_zero_padding(const _CharT* __begin, _Flags& __flags) noexcept {
197 if (*__begin == _CharT('0')) {
198 __flags.__zero_padding = true;
199 ++__begin;
200 }
201
202 return __begin;
203}
204
205template <class _CharT>49template <class _CharT>
206_LIBCPP_HIDE_FROM_ABI constexpr __format::__parse_number_result< _CharT>50_LIBCPP_HIDE_FROM_ABI constexpr __format::__parse_number_result< _CharT>
207__parse_arg_id(const _CharT* __begin, const _CharT* __end, auto& __parse_ctx) {51__parse_arg_id(const _CharT* __begin, const _CharT* __end, auto& __parse_ctx) {
...@@ -222,7 +66,7 @@ __parse_arg_id(const _CharT* __begin, const _CharT* __end, auto& __parse_ctx) {...@@ -222,7 +66,7 @@ __parse_arg_id(const _CharT* __begin, const _CharT* __end, auto& __parse_ctx) {
22266
223template <class _Context>67template <class _Context>
224_LIBCPP_HIDE_FROM_ABI constexpr uint32_t68_LIBCPP_HIDE_FROM_ABI constexpr uint32_t
225__substitute_arg_id(basic_format_arg<_Context> __arg) {69__substitute_arg_id(basic_format_arg<_Context> __format_arg) {
226 return visit_format_arg(70 return visit_format_arg(
227 [](auto __arg) -> uint32_t {71 [](auto __arg) -> uint32_t {
228 using _Type = decltype(__arg);72 using _Type = decltype(__arg);
...@@ -246,803 +90,638 @@ __substitute_arg_id(basic_format_arg<_Context> __arg) {...@@ -246,803 +90,638 @@ __substitute_arg_id(basic_format_arg<_Context> __arg) {
246 __throw_format_error("A format-spec arg-id replacement argument "90 __throw_format_error("A format-spec arg-id replacement argument "
247 "isn't an integral type");91 "isn't an integral type");
248 },92 },
249 __arg);93 __format_arg);
250}94}
25195
252class _LIBCPP_TYPE_VIS __parser_width {96/// These fields are a filter for which elements to parse.
253public:97///
254 /** Contains a width or an arg-id. */98/// They default to false so when a new field is added it needs to be opted in
255 uint32_t __width : 31 {0};99/// explicitly.
256 /** Determines whether the value stored is a width or an arg-id. */100struct __fields {
257 uint32_t __width_as_arg : 1 {0};101 uint8_t __sign_ : 1 {false};
258102 uint8_t __alternate_form_ : 1 {false};
259protected:103 uint8_t __zero_padding_ : 1 {false};
260 /**104 uint8_t __precision_ : 1 {false};
261 * Does the supplied std-format-spec contain a width field?105 uint8_t __locale_specific_form_ : 1 {false};
262 *106 uint8_t __type_ : 1 {false};
263 * When the field isn't present there's no padding required. This can be used107};
264 * to optimize the formatting.
265 */
266 constexpr bool __has_width_field() const noexcept {
267 return __width_as_arg || __width;
268 }
269
270 /**
271 * Does the supplied width field contain an arg-id?
272 *
273 * If @c true the formatter needs to call @ref __substitute_width_arg_id.
274 */
275 constexpr bool __width_needs_substitution() const noexcept {
276 return __width_as_arg;
277 }
278
279 template <class _CharT>
280 _LIBCPP_HIDE_FROM_ABI constexpr const _CharT*
281 __parse(const _CharT* __begin, const _CharT* __end, auto& __parse_ctx) {
282 if (*__begin == _CharT('0'))
283 __throw_format_error(
284 "A format-spec width field shouldn't have a leading zero");
285
286 if (*__begin == _CharT('{')) {
287 __format::__parse_number_result __r =
288 __parse_arg_id(++__begin, __end, __parse_ctx);
289 __width = __r.__value;
290 __width_as_arg = 1;
291 return __r.__ptr;
292 }
293108
294 if (*__begin < _CharT('0') || *__begin > _CharT('9'))109// By not placing this constant in the formatter class it's not duplicated for
295 return __begin;110// char and wchar_t.
111inline constexpr __fields __fields_integral{
112 .__sign_ = true,
113 .__alternate_form_ = true,
114 .__zero_padding_ = true,
115 .__locale_specific_form_ = true,
116 .__type_ = true};
117inline constexpr __fields __fields_floating_point{
118 .__sign_ = true,
119 .__alternate_form_ = true,
120 .__zero_padding_ = true,
121 .__precision_ = true,
122 .__locale_specific_form_ = true,
123 .__type_ = true};
124inline constexpr __fields __fields_string{.__precision_ = true, .__type_ = true};
125inline constexpr __fields __fields_pointer{.__type_ = true};
126
127enum class _LIBCPP_ENUM_VIS __alignment : uint8_t {
128 /// No alignment is set in the format string.
129 __default,
130 __left,
131 __center,
132 __right,
133 __zero_padding
134};
296135
297 __format::__parse_number_result __r =136enum class _LIBCPP_ENUM_VIS __sign : uint8_t {
298 __format::__parse_number(__begin, __end);137 /// No sign is set in the format string.
299 __width = __r.__value;138 ///
300 _LIBCPP_ASSERT(__width != 0,139 /// The sign isn't allowed for certain format-types. By using this value
301 "A zero value isn't allowed and should be impossible, "140 /// it's possible to detect whether or not the user explicitly set the sign
302 "due to validations in this function");141 /// flag. For formatting purposes it behaves the same as \ref __minus.
303 return __r.__ptr;142 __default,
304 }143 __minus,
144 __plus,
145 __space
146};
305147
306 _LIBCPP_HIDE_FROM_ABI constexpr void __substitute_width_arg_id(auto __arg) {148enum class _LIBCPP_ENUM_VIS __type : uint8_t {
307 _LIBCPP_ASSERT(__width_as_arg == 1,149 __default,
308 "Substitute width called when no substitution is required");150 __string,
309151 __binary_lower_case,
310 // The clearing of the flag isn't required but looks better when debugging152 __binary_upper_case,
311 // the code.153 __octal,
312 __width_as_arg = 0;154 __decimal,
313 __width = __substitute_arg_id(__arg);155 __hexadecimal_lower_case,
314 if (__width == 0)156 __hexadecimal_upper_case,
315 __throw_format_error(157 __pointer,
316 "A format-spec width field replacement should have a positive value");158 __char,
317 }159 __hexfloat_lower_case,
160 __hexfloat_upper_case,
161 __scientific_lower_case,
162 __scientific_upper_case,
163 __fixed_lower_case,
164 __fixed_upper_case,
165 __general_lower_case,
166 __general_upper_case
318};167};
319168
320class _LIBCPP_TYPE_VIS __parser_precision {169struct __std {
321public:170 __alignment __alignment_ : 3;
322 /** Contains a precision or an arg-id. */171 __sign __sign_ : 2;
323 uint32_t __precision : 31 {__format::__number_max};172 bool __alternate_form_ : 1;
324 /**173 bool __locale_specific_form_ : 1;
325 * Determines whether the value stored is a precision or an arg-id.174 __type __type_;
326 *175};
327 * @note Since @ref __precision == @ref __format::__number_max is a valid
328 * value, the default value contains an arg-id of INT32_MAX. (This number of
329 * arguments isn't supported by compilers.) This is used to detect whether
330 * the std-format-spec contains a precision field.
331 */
332 uint32_t __precision_as_arg : 1 {1};
333
334protected:
335 /**
336 * Does the supplied std-format-spec contain a precision field?
337 *
338 * When the field isn't present there's no truncating required. This can be
339 * used to optimize the formatting.
340 */
341 constexpr bool __has_precision_field() const noexcept {
342
343 return __precision_as_arg == 0 || // Contains a value?
344 __precision != __format::__number_max; // The arg-id is valid?
345 }
346176
347 /**177struct __chrono {
348 * Does the supplied precision field contain an arg-id?178 __alignment __alignment_ : 3;
349 *179 bool __weekday_name_ : 1;
350 * If @c true the formatter needs to call @ref __substitute_precision_arg_id.180 bool __month_name_ : 1;
351 */181};
352 constexpr bool __precision_needs_substitution() const noexcept {
353 return __precision_as_arg && __precision != __format::__number_max;
354 }
355182
356 template <class _CharT>183/// Contains the parsed formatting specifications.
357 _LIBCPP_HIDE_FROM_ABI constexpr const _CharT*184///
358 __parse(const _CharT* __begin, const _CharT* __end, auto& __parse_ctx) {185/// This contains information for both the std-format-spec and the
359 if (*__begin != _CharT('.'))186/// chrono-format-spec. This results in some unused members for both
360 return __begin;187/// specifications. However these unused members don't increase the size
188/// of the structure.
189///
190/// This struct doesn't cross ABI boundaries so its layout doesn't need to be
191/// kept stable.
192template <class _CharT>
193struct __parsed_specifications {
194 union {
195 // The field __alignment_ is the first element in __std_ and __chrono_.
196 // This allows the code to always inspect this value regards which member
197 // of the union is the active member [class.union.general]/2.
198 //
199 // This is needed since the generic output routines handle the alignment of
200 // the output.
201 __alignment __alignment_ : 3;
202 __std __std_;
203 __chrono __chrono_;
204 };
361205
362 ++__begin;206 /// The requested width.
363 if (__begin == __end)207 ///
364 __throw_format_error("End of input while parsing format-spec precision");208 /// When the format-spec used an arg-id for this field it has already been
209 /// replaced with the value of that arg-id.
210 int32_t __width_;
365211
366 if (*__begin == _CharT('{')) {212 /// The requested precision.
367 __format::__parse_number_result __arg_id =213 ///
368 __parse_arg_id(++__begin, __end, __parse_ctx);214 /// When the format-spec used an arg-id for this field it has already been
369 _LIBCPP_ASSERT(__arg_id.__value != __format::__number_max,215 /// replaced with the value of that arg-id.
370 "Unsupported number of arguments, since this number of "216 int32_t __precision_;
371 "arguments is used a special value");
372 __precision = __arg_id.__value;
373 return __arg_id.__ptr;
374 }
375217
376 if (*__begin < _CharT('0') || *__begin > _CharT('9'))218 _CharT __fill_;
377 __throw_format_error(
378 "The format-spec precision field doesn't contain a value or arg-id");
379
380 __format::__parse_number_result __r =
381 __format::__parse_number(__begin, __end);
382 __precision = __r.__value;
383 __precision_as_arg = 0;
384 return __r.__ptr;
385 }
386219
387 _LIBCPP_HIDE_FROM_ABI constexpr void __substitute_precision_arg_id(220 _LIBCPP_HIDE_FROM_ABI constexpr bool __has_width() const { return __width_ > 0; }
388 auto __arg) {
389 _LIBCPP_ASSERT(
390 __precision_as_arg == 1 && __precision != __format::__number_max,
391 "Substitute precision called when no substitution is required");
392221
393 // The clearing of the flag isn't required but looks better when debugging222 _LIBCPP_HIDE_FROM_ABI constexpr bool __has_precision() const { return __precision_ >= 0; }
394 // the code.
395 __precision_as_arg = 0;
396 __precision = __substitute_arg_id(__arg);
397 }
398};223};
399224
225// Validate the struct is small and cheap to copy since the struct is passed by
226// value in formatting functions.
227static_assert(sizeof(__parsed_specifications<char>) == 16);
228static_assert(is_trivially_copyable_v<__parsed_specifications<char>>);
229# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
230static_assert(sizeof(__parsed_specifications<wchar_t>) == 16);
231static_assert(is_trivially_copyable_v<__parsed_specifications<wchar_t>>);
232# endif
233
234/// The parser for the std-format-spec.
235///
236/// Note this class is a member of std::formatter specializations. It's
237/// expected developers will create their own formatter specializations that
238/// inherit from the std::formatter specializations. This means this class
239/// must be ABI stable. To aid the stability the unused bits in the class are
240/// set to zero. That way they can be repurposed if a future revision of the
241/// Standards adds new fields to std-format-spec.
400template <class _CharT>242template <class _CharT>
401_LIBCPP_HIDE_FROM_ABI constexpr const _CharT*243class _LIBCPP_TEMPLATE_VIS __parser {
402__parse_locale_specific_form(const _CharT* __begin, _Flags& __flags) noexcept {
403 if (*__begin == _CharT('L')) {
404 __flags.__locale_specific_form = true;
405 ++__begin;
406 }
407
408 return __begin;
409}
410
411template <class _CharT>
412_LIBCPP_HIDE_FROM_ABI constexpr const _CharT*
413__parse_type(const _CharT* __begin, _Flags& __flags) {
414
415 // Determines the type. It does not validate whether the selected type is
416 // valid. Most formatters have optional fields that are only allowed for
417 // certain types. These parsers need to do validation after the type has
418 // been parsed. So its easier to implement the validation for all types in
419 // the specific parse function.
420 switch (*__begin) {
421 case 'A':
422 __flags.__type = _Flags::_Type::__float_hexadecimal_upper_case;
423 break;
424 case 'B':
425 __flags.__type = _Flags::_Type::__binary_upper_case;
426 break;
427 case 'E':
428 __flags.__type = _Flags::_Type::__scientific_upper_case;
429 break;
430 case 'F':
431 __flags.__type = _Flags::_Type::__fixed_upper_case;
432 break;
433 case 'G':
434 __flags.__type = _Flags::_Type::__general_upper_case;
435 break;
436 case 'X':
437 __flags.__type = _Flags::_Type::__hexadecimal_upper_case;
438 break;
439 case 'a':
440 __flags.__type = _Flags::_Type::__float_hexadecimal_lower_case;
441 break;
442 case 'b':
443 __flags.__type = _Flags::_Type::__binary_lower_case;
444 break;
445 case 'c':
446 __flags.__type = _Flags::_Type::__char;
447 break;
448 case 'd':
449 __flags.__type = _Flags::_Type::__decimal;
450 break;
451 case 'e':
452 __flags.__type = _Flags::_Type::__scientific_lower_case;
453 break;
454 case 'f':
455 __flags.__type = _Flags::_Type::__fixed_lower_case;
456 break;
457 case 'g':
458 __flags.__type = _Flags::_Type::__general_lower_case;
459 break;
460 case 'o':
461 __flags.__type = _Flags::_Type::__octal;
462 break;
463 case 'p':
464 __flags.__type = _Flags::_Type::__pointer;
465 break;
466 case 's':
467 __flags.__type = _Flags::_Type::__string;
468 break;
469 case 'x':
470 __flags.__type = _Flags::_Type::__hexadecimal_lower_case;
471 break;
472 default:
473 return __begin;
474 }
475 return ++__begin;
476}
477
478/**
479 * Process the parsed alignment and zero-padding state of arithmetic types.
480 *
481 * [format.string.std]/13
482 * If the 0 character and an align option both appear, the 0 character is
483 * ignored.
484 *
485 * For the formatter a @ref __default alignment means zero-padding.
486 */
487_LIBCPP_HIDE_FROM_ABI constexpr void __process_arithmetic_alignment(_Flags& __flags) {
488 __flags.__zero_padding &= __flags.__alignment == _Flags::_Alignment::__default;
489 if (!__flags.__zero_padding && __flags.__alignment == _Flags::_Alignment::__default)
490 __flags.__alignment = _Flags::_Alignment::__right;
491}
492
493/**
494 * The parser for the std-format-spec.
495 *
496 * [format.string.std]/1 specifies the std-format-spec:
497 * fill-and-align sign # 0 width precision L type
498 *
499 * All these fields are optional. Whether these fields can be used depend on:
500 * - The type supplied to the format string.
501 * E.g. A string never uses the sign field so the field may not be set.
502 * This constrain is validated by the parsers in this file.
503 * - The supplied value for the optional type field.
504 * E.g. A int formatted as decimal uses the sign field.
505 * When formatted as a char the sign field may no longer be set.
506 * This constrain isn't validated by the parsers in this file.
507 *
508 * The base classes are ordered to minimize the amount of padding.
509 *
510 * This implements the parser for the string types.
511 */
512template <class _CharT>
513class _LIBCPP_TEMPLATE_VIS __parser_string
514 : public __parser_width, // provides __width(|as_arg)
515 public __parser_precision, // provides __precision(|as_arg)
516 public __parser_fill_align<_CharT>, // provides __fill and uses __flags
517 public _Flags // provides __flags
518{
519public:244public:
520 using char_type = _CharT;245 _LIBCPP_HIDE_FROM_ABI constexpr auto __parse(basic_format_parse_context<_CharT>& __parse_ctx, __fields __fields)
246 -> decltype(__parse_ctx.begin()) {
521247
522 _LIBCPP_HIDE_FROM_ABI constexpr __parser_string() {248 const _CharT* __begin = __parse_ctx.begin();
523 this->__alignment = _Flags::_Alignment::__left;249 const _CharT* __end = __parse_ctx.end();
524 }250 if (__begin == __end)
251 return __begin;
525252
526 /**253 if (__parse_fill_align(__begin, __end) && __begin == __end)
527 * The low-level std-format-spec parse function.254 return __begin;
528 *
529 * @pre __begin points at the beginning of the std-format-spec. This means
530 * directly after the ':'.
531 * @pre The std-format-spec parses the entire input, or the first unmatched
532 * character is a '}'.
533 *
534 * @returns The iterator pointing at the last parsed character.
535 */
536 _LIBCPP_HIDE_FROM_ABI constexpr auto parse(auto& __parse_ctx)
537 -> decltype(__parse_ctx.begin()) {
538 auto __it = __parse(__parse_ctx);
539 __process_display_type();
540 return __it;
541 }
542255
543private:256 if (__fields.__sign_ && __parse_sign(__begin) && __begin == __end)
544 /**257 return __begin;
545 * Parses the std-format-spec.
546 *
547 * @throws __throw_format_error When @a __parse_ctx contains an ill-formed
548 * std-format-spec.
549 *
550 * @returns An iterator to the end of input or point at the closing '}'.
551 */
552 _LIBCPP_HIDE_FROM_ABI constexpr auto __parse(auto& __parse_ctx)
553 -> decltype(__parse_ctx.begin()) {
554258
555 auto __begin = __parse_ctx.begin();259 if (__fields.__alternate_form_ && __parse_alternate_form(__begin) && __begin == __end)
556 auto __end = __parse_ctx.end();
557 if (__begin == __end)
558 return __begin;260 return __begin;
559261
560 __begin = __parser_fill_align<_CharT>::__parse(__begin, __end,262 if (__fields.__zero_padding_ && __parse_zero_padding(__begin) && __begin == __end)
561 static_cast<_Flags&>(*this));
562 if (__begin == __end)
563 return __begin;263 return __begin;
564264
565 __begin = __parser_width::__parse(__begin, __end, __parse_ctx);265 if (__parse_width(__begin, __end, __parse_ctx) && __begin == __end)
566 if (__begin == __end)
567 return __begin;266 return __begin;
568267
569 __begin = __parser_precision::__parse(__begin, __end, __parse_ctx);268 if (__fields.__precision_ && __parse_precision(__begin, __end, __parse_ctx) && __begin == __end)
570 if (__begin == __end)269 return __begin;
270
271 if (__fields.__locale_specific_form_ && __parse_locale_specific_form(__begin) && __begin == __end)
571 return __begin;272 return __begin;
572273
573 __begin = __parse_type(__begin, static_cast<_Flags&>(*this));274 if (__fields.__type_) {
275 __parse_type(__begin);
574276
575 if (__begin != __end && *__begin != _CharT('}'))277 // When __type_ is false the calling parser is expected to do additional
576 __throw_format_error(278 // parsing. In that case that parser should do the end of format string
577 "The format-spec should consume the input or end with a '}'");279 // validation.
280 if (__begin != __end && *__begin != _CharT('}'))
281 __throw_format_error("The format-spec should consume the input or end with a '}'");
282 }
578283
579 return __begin;284 return __begin;
580 }285 }
581286
582 /** Processes the parsed std-format-spec based on the parsed display type. */287 /// \returns the `__parsed_specifications` with the resolved dynamic sizes..
583 _LIBCPP_HIDE_FROM_ABI constexpr void __process_display_type() {288 _LIBCPP_HIDE_FROM_ABI
584 switch (this->__type) {289 __parsed_specifications<_CharT> __get_parsed_std_specifications(auto& __ctx) const {
585 case _Flags::_Type::__default:290 return __parsed_specifications<_CharT>{
586 case _Flags::_Type::__string:291 .__std_ =
587 break;292 __std{.__alignment_ = __alignment_,
293 .__sign_ = __sign_,
294 .__alternate_form_ = __alternate_form_,
295 .__locale_specific_form_ = __locale_specific_form_,
296 .__type_ = __type_},
297 .__width_{__get_width(__ctx)},
298 .__precision_{__get_precision(__ctx)},
299 .__fill_{__fill_}};
300 }
301
302 __alignment __alignment_ : 3 {__alignment::__default};
303 __sign __sign_ : 2 {__sign::__default};
304 bool __alternate_form_ : 1 {false};
305 bool __locale_specific_form_ : 1 {false};
306 bool __reserved_0_ : 1 {false};
307 __type __type_{__type::__default};
308
309 // These two flags are used for formatting chrono. Since the struct has
310 // padding space left it's added to this structure.
311 bool __weekday_name_ : 1 {false};
312 bool __month_name_ : 1 {false};
313
314 uint8_t __reserved_1_ : 6 {0};
315 uint8_t __reserved_2_ : 6 {0};
316 // These two flags are only used internally and not part of the
317 // __parsed_specifications. Therefore put them at the end.
318 bool __width_as_arg_ : 1 {false};
319 bool __precision_as_arg_ : 1 {false};
320
321 /// The requested width, either the value or the arg-id.
322 int32_t __width_{0};
323
324 /// The requested precision, either the value or the arg-id.
325 int32_t __precision_{-1};
326
327 // LWG 3576 will probably change this to always accept a Unicode code point
328 // To avoid changing the size with that change align the field so when it
329 // becomes 32-bit its alignment will remain the same. That also means the
330 // size will remain the same. (D2572 addresses the solution for LWG 3576.)
331 _CharT __fill_{_CharT(' ')};
588332
589 default:333private:
590 __throw_format_error("The format-spec type has a type not supported for "334 _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_alignment(_CharT __c) {
591 "a string argument");335 switch (__c) {
336 case _CharT('<'):
337 __alignment_ = __alignment::__left;
338 return true;
339
340 case _CharT('^'):
341 __alignment_ = __alignment::__center;
342 return true;
343
344 case _CharT('>'):
345 __alignment_ = __alignment::__right;
346 return true;
592 }347 }
348 return false;
593 }349 }
594};
595
596/**
597 * The parser for the std-format-spec.
598 *
599 * This implements the parser for the integral types. This includes the
600 * character type and boolean type.
601 *
602 * See @ref __parser_string.
603 */
604template <class _CharT>
605class _LIBCPP_TEMPLATE_VIS __parser_integral
606 : public __parser_width, // provides __width(|as_arg)
607 public __parser_fill_align<_CharT>, // provides __fill and uses __flags
608 public _Flags // provides __flags
609{
610public:
611 using char_type = _CharT;
612
613protected:
614 /**
615 * The low-level std-format-spec parse function.
616 *
617 * @pre __begin points at the beginning of the std-format-spec. This means
618 * directly after the ':'.
619 * @pre The std-format-spec parses the entire input, or the first unmatched
620 * character is a '}'.
621 *
622 * @returns The iterator pointing at the last parsed character.
623 */
624 _LIBCPP_HIDE_FROM_ABI constexpr auto __parse(auto& __parse_ctx)
625 -> decltype(__parse_ctx.begin()) {
626 auto __begin = __parse_ctx.begin();
627 auto __end = __parse_ctx.end();
628 if (__begin == __end)
629 return __begin;
630350
631 __begin = __parser_fill_align<_CharT>::__parse(__begin, __end,351 _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_fill_align(const _CharT*& __begin, const _CharT* __end) {
632 static_cast<_Flags&>(*this));352 _LIBCPP_ASSERT(__begin != __end, "when called with an empty input the function will cause "
633 if (__begin == __end)353 "undefined behavior by evaluating data not in the input");
634 return __begin;354 if (__begin + 1 != __end) {
635355 if (__parse_alignment(*(__begin + 1))) {
636 __begin = __parse_sign(__begin, static_cast<_Flags&>(*this));356 if (*__begin == _CharT('{') || *__begin == _CharT('}'))
637 if (__begin == __end)357 __throw_format_error("The format-spec fill field contains an invalid character");
638 return __begin;
639
640 __begin = __parse_alternate_form(__begin, static_cast<_Flags&>(*this));
641 if (__begin == __end)
642 return __begin;
643358
644 __begin = __parse_zero_padding(__begin, static_cast<_Flags&>(*this));359 __fill_ = *__begin;
645 if (__begin == __end)360 __begin += 2;
646 return __begin;361 return true;
362 }
363 }
647364
648 __begin = __parser_width::__parse(__begin, __end, __parse_ctx);365 if (!__parse_alignment(*__begin))
649 if (__begin == __end)366 return false;
650 return __begin;
651367
652 __begin =368 ++__begin;
653 __parse_locale_specific_form(__begin, static_cast<_Flags&>(*this));369 return true;
654 if (__begin == __end)370 }
655 return __begin;
656371
657 __begin = __parse_type(__begin, static_cast<_Flags&>(*this));372 _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_sign(const _CharT*& __begin) {
373 switch (*__begin) {
374 case _CharT('-'):
375 __sign_ = __sign::__minus;
376 break;
377 case _CharT('+'):
378 __sign_ = __sign::__plus;
379 break;
380 case _CharT(' '):
381 __sign_ = __sign::__space;
382 break;
383 default:
384 return false;
385 }
386 ++__begin;
387 return true;
388 }
658389
659 if (__begin != __end && *__begin != _CharT('}'))390 _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_alternate_form(const _CharT*& __begin) {
660 __throw_format_error(391 if (*__begin != _CharT('#'))
661 "The format-spec should consume the input or end with a '}'");392 return false;
662393
663 return __begin;394 __alternate_form_ = true;
395 ++__begin;
396 return true;
664 }397 }
665398
666 /** Handles the post-parsing updates for the integer types. */399 _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_zero_padding(const _CharT*& __begin) {
667 _LIBCPP_HIDE_FROM_ABI constexpr void __handle_integer() noexcept {400 if (*__begin != _CharT('0'))
668 __process_arithmetic_alignment(static_cast<_Flags&>(*this));401 return false;
669 }
670402
671 /**403 if (__alignment_ == __alignment::__default)
672 * Handles the post-parsing updates for the character types.404 __alignment_ = __alignment::__zero_padding;
673 *405 ++__begin;
674 * Sets the alignment and validates the format flags set for a character type.406 return true;
675 *
676 * At the moment the validation for a character and a Boolean behave the
677 * same, but this may change in the future.
678 * Specifically at the moment the locale-specific form is allowed for the
679 * char output type, but it has no effect on the output.
680 */
681 _LIBCPP_HIDE_FROM_ABI constexpr void __handle_char() { __handle_bool(); }
682
683 /**
684 * Handles the post-parsing updates for the Boolean types.
685 *
686 * Sets the alignment and validates the format flags set for a Boolean type.
687 */
688 _LIBCPP_HIDE_FROM_ABI constexpr void __handle_bool() {
689 if (this->__sign != _Flags::_Sign::__default)
690 __throw_format_error("A sign field isn't allowed in this format-spec");
691
692 if (this->__alternate_form)
693 __throw_format_error(
694 "An alternate form field isn't allowed in this format-spec");
695
696 if (this->__zero_padding)
697 __throw_format_error(
698 "A zero-padding field isn't allowed in this format-spec");
699
700 if (this->__alignment == _Flags::_Alignment::__default)
701 this->__alignment = _Flags::_Alignment::__left;
702 }407 }
703};
704408
705/**409 _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_width(const _CharT*& __begin, const _CharT* __end, auto& __parse_ctx) {
706 * The parser for the std-format-spec.410 if (*__begin == _CharT('0'))
707 *411 __throw_format_error("A format-spec width field shouldn't have a leading zero");
708 * This implements the parser for the floating-point types.
709 *
710 * See @ref __parser_string.
711 */
712template <class _CharT>
713class _LIBCPP_TEMPLATE_VIS __parser_floating_point
714 : public __parser_width, // provides __width(|as_arg)
715 public __parser_precision, // provides __precision(|as_arg)
716 public __parser_fill_align<_CharT>, // provides __fill and uses __flags
717 public _Flags // provides __flags
718{
719public:
720 using char_type = _CharT;
721
722 /**
723 * The low-level std-format-spec parse function.
724 *
725 * @pre __begin points at the beginning of the std-format-spec. This means
726 * directly after the ':'.
727 * @pre The std-format-spec parses the entire input, or the first unmatched
728 * character is a '}'.
729 *
730 * @returns The iterator pointing at the last parsed character.
731 */
732 _LIBCPP_HIDE_FROM_ABI constexpr auto parse(auto& __parse_ctx)
733 -> decltype(__parse_ctx.begin()) {
734 auto __it = __parse(__parse_ctx);
735 __process_arithmetic_alignment(static_cast<_Flags&>(*this));
736 __process_display_type();
737 return __it;
738 }
739protected:
740 /**
741 * The low-level std-format-spec parse function.
742 *
743 * @pre __begin points at the beginning of the std-format-spec. This means
744 * directly after the ':'.
745 * @pre The std-format-spec parses the entire input, or the first unmatched
746 * character is a '}'.
747 *
748 * @returns The iterator pointing at the last parsed character.
749 */
750 _LIBCPP_HIDE_FROM_ABI constexpr auto __parse(auto& __parse_ctx)
751 -> decltype(__parse_ctx.begin()) {
752 auto __begin = __parse_ctx.begin();
753 auto __end = __parse_ctx.end();
754 if (__begin == __end)
755 return __begin;
756412
757 __begin = __parser_fill_align<_CharT>::__parse(__begin, __end,413 if (*__begin == _CharT('{')) {
758 static_cast<_Flags&>(*this));414 __format::__parse_number_result __r = __format_spec::__parse_arg_id(++__begin, __end, __parse_ctx);
759 if (__begin == __end)415 __width_as_arg_ = true;
760 return __begin;416 __width_ = __r.__value;
417 __begin = __r.__ptr;
418 return true;
419 }
761420
762 __begin = __parse_sign(__begin, static_cast<_Flags&>(*this));421 if (*__begin < _CharT('0') || *__begin > _CharT('9'))
763 if (__begin == __end)422 return false;
764 return __begin;
765423
766 __begin = __parse_alternate_form(__begin, static_cast<_Flags&>(*this));424 __format::__parse_number_result __r = __format::__parse_number(__begin, __end);
767 if (__begin == __end)425 __width_ = __r.__value;
768 return __begin;426 _LIBCPP_ASSERT(__width_ != 0, "A zero value isn't allowed and should be impossible, "
427 "due to validations in this function");
428 __begin = __r.__ptr;
429 return true;
430 }
769431
770 __begin = __parse_zero_padding(__begin, static_cast<_Flags&>(*this));432 _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_precision(const _CharT*& __begin, const _CharT* __end,
771 if (__begin == __end)433 auto& __parse_ctx) {
772 return __begin;434 if (*__begin != _CharT('.'))
435 return false;
773436
774 __begin = __parser_width::__parse(__begin, __end, __parse_ctx);437 ++__begin;
775 if (__begin == __end)438 if (__begin == __end)
776 return __begin;439 __throw_format_error("End of input while parsing format-spec precision");
777440
778 __begin = __parser_precision::__parse(__begin, __end, __parse_ctx);441 if (*__begin == _CharT('{')) {
779 if (__begin == __end)442 __format::__parse_number_result __arg_id = __format_spec::__parse_arg_id(++__begin, __end, __parse_ctx);
780 return __begin;443 __precision_as_arg_ = true;
444 __precision_ = __arg_id.__value;
445 __begin = __arg_id.__ptr;
446 return true;
447 }
781448
782 __begin =449 if (*__begin < _CharT('0') || *__begin > _CharT('9'))
783 __parse_locale_specific_form(__begin, static_cast<_Flags&>(*this));450 __throw_format_error("The format-spec precision field doesn't contain a value or arg-id");
784 if (__begin == __end)
785 return __begin;
786451
787 __begin = __parse_type(__begin, static_cast<_Flags&>(*this));452 __format::__parse_number_result __r = __format::__parse_number(__begin, __end);
453 __precision_ = __r.__value;
454 __precision_as_arg_ = false;
455 __begin = __r.__ptr;
456 return true;
457 }
788458
789 if (__begin != __end && *__begin != _CharT('}'))459 _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_locale_specific_form(const _CharT*& __begin) {
790 __throw_format_error(460 if (*__begin != _CharT('L'))
791 "The format-spec should consume the input or end with a '}'");461 return false;
792462
793 return __begin;463 __locale_specific_form_ = true;
464 ++__begin;
465 return true;
794 }466 }
795467
796 /** Processes the parsed std-format-spec based on the parsed display type. */468 _LIBCPP_HIDE_FROM_ABI constexpr void __parse_type(const _CharT*& __begin) {
797 _LIBCPP_HIDE_FROM_ABI constexpr void __process_display_type() {469 // Determines the type. It does not validate whether the selected type is
798 switch (this->__type) {470 // valid. Most formatters have optional fields that are only allowed for
799 case _Flags::_Type::__default:471 // certain types. These parsers need to do validation after the type has
800 // When no precision specified then it keeps default since that472 // been parsed. So its easier to implement the validation for all types in
801 // formatting differs from the other types.473 // the specific parse function.
802 if (this->__has_precision_field())474 switch (*__begin) {
803 this->__type = _Flags::_Type::__general_lower_case;475 case 'A':
476 __type_ = __type::__hexfloat_upper_case;
804 break;477 break;
805 case _Flags::_Type::__float_hexadecimal_lower_case:478 case 'B':
806 case _Flags::_Type::__float_hexadecimal_upper_case:479 __type_ = __type::__binary_upper_case;
807 // Precision specific behavior will be handled later.
808 break;480 break;
809 case _Flags::_Type::__scientific_lower_case:481 case 'E':
810 case _Flags::_Type::__scientific_upper_case:482 __type_ = __type::__scientific_upper_case;
811 case _Flags::_Type::__fixed_lower_case:483 break;
812 case _Flags::_Type::__fixed_upper_case:484 case 'F':
813 case _Flags::_Type::__general_lower_case:485 __type_ = __type::__fixed_upper_case;
814 case _Flags::_Type::__general_upper_case:486 break;
815 if (!this->__has_precision_field()) {487 case 'G':
816 // Set the default precision for the call to to_chars.488 __type_ = __type::__general_upper_case;
817 this->__precision = 6;489 break;
818 this->__precision_as_arg = false;490 case 'X':
819 }491 __type_ = __type::__hexadecimal_upper_case;
492 break;
493 case 'a':
494 __type_ = __type::__hexfloat_lower_case;
495 break;
496 case 'b':
497 __type_ = __type::__binary_lower_case;
498 break;
499 case 'c':
500 __type_ = __type::__char;
501 break;
502 case 'd':
503 __type_ = __type::__decimal;
504 break;
505 case 'e':
506 __type_ = __type::__scientific_lower_case;
507 break;
508 case 'f':
509 __type_ = __type::__fixed_lower_case;
510 break;
511 case 'g':
512 __type_ = __type::__general_lower_case;
513 break;
514 case 'o':
515 __type_ = __type::__octal;
516 break;
517 case 'p':
518 __type_ = __type::__pointer;
519 break;
520 case 's':
521 __type_ = __type::__string;
522 break;
523 case 'x':
524 __type_ = __type::__hexadecimal_lower_case;
820 break;525 break;
821
822 default:526 default:
823 __throw_format_error("The format-spec type has a type not supported for "527 return;
824 "a floating-point argument");
825 }528 }
529 ++__begin;
826 }530 }
827};
828531
829/**532 _LIBCPP_HIDE_FROM_ABI
830 * The parser for the std-format-spec.533 int32_t __get_width(auto& __ctx) const {
831 *534 if (!__width_as_arg_)
832 * This implements the parser for the pointer types.535 return __width_;
833 *
834 * See @ref __parser_string.
835 */
836template <class _CharT>
837class _LIBCPP_TEMPLATE_VIS __parser_pointer : public __parser_width, // provides __width(|as_arg)
838 public __parser_fill_align<_CharT>, // provides __fill and uses __flags
839 public _Flags // provides __flags
840{
841public:
842 using char_type = _CharT;
843536
844 _LIBCPP_HIDE_FROM_ABI constexpr __parser_pointer() {537 int32_t __result = __format_spec::__substitute_arg_id(__ctx.arg(__width_));
845 // Implements LWG3612 Inconsistent pointer alignment in std::format.538 if (__result == 0)
846 // The issue's current status is "Tentatively Ready" and libc++ status is539 __throw_format_error("A format-spec width field replacement should have a positive value");
847 // still experimental.540 return __result;
848 //
849 // TODO FMT Validate this with the final resolution of LWG3612.
850 this->__alignment = _Flags::_Alignment::__right;
851 }541 }
852542
853 /**543 _LIBCPP_HIDE_FROM_ABI
854 * The low-level std-format-spec parse function.544 int32_t __get_precision(auto& __ctx) const {
855 *545 if (!__precision_as_arg_)
856 * @pre __begin points at the beginning of the std-format-spec. This means546 return __precision_;
857 * directly after the ':'.547
858 * @pre The std-format-spec parses the entire input, or the first unmatched548 return __format_spec::__substitute_arg_id(__ctx.arg(__precision_));
859 * character is a '}'.
860 *
861 * @returns The iterator pointing at the last parsed character.
862 */
863 _LIBCPP_HIDE_FROM_ABI constexpr auto parse(auto& __parse_ctx) -> decltype(__parse_ctx.begin()) {
864 auto __it = __parse(__parse_ctx);
865 __process_display_type();
866 return __it;
867 }549 }
550};
868551
869protected:552// Validates whether the reserved bitfields don't change the size.
870 /**553static_assert(sizeof(__parser<char>) == 16);
871 * The low-level std-format-spec parse function.554# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
872 *555static_assert(sizeof(__parser<wchar_t>) == 16);
873 * @pre __begin points at the beginning of the std-format-spec. This means556# endif
874 * directly after the ':'.
875 * @pre The std-format-spec parses the entire input, or the first unmatched
876 * character is a '}'.
877 *
878 * @returns The iterator pointing at the last parsed character.
879 */
880 _LIBCPP_HIDE_FROM_ABI constexpr auto __parse(auto& __parse_ctx) -> decltype(__parse_ctx.begin()) {
881 auto __begin = __parse_ctx.begin();
882 auto __end = __parse_ctx.end();
883 if (__begin == __end)
884 return __begin;
885557
886 __begin = __parser_fill_align<_CharT>::__parse(__begin, __end, static_cast<_Flags&>(*this));558_LIBCPP_HIDE_FROM_ABI constexpr void __process_display_type_string(__format_spec::__type __type) {
887 if (__begin == __end)559 switch (__type) {
888 return __begin;560 case __format_spec::__type::__default:
561 case __format_spec::__type::__string:
562 break;
889563
890 // An integer presentation type isn't defined in the Standard.564 default:
891 // Since a pointer is formatted as an integer it can be argued it's an565 std::__throw_format_error("The format-spec type has a type not supported for a string argument");
892 // integer presentation type. However there are two LWG-issues asserting it566 }
893 // isn't an integer presentation type:567}
894 // - LWG3612 Inconsistent pointer alignment in std::format
895 // - LWG3644 std::format does not define "integer presentation type"
896 //
897 // There's a paper to make additional clarifications on the status of
898 // formatting pointers and proposes additional fields to be valid. That
899 // paper hasn't been reviewed by the Committee yet.
900 // - P2510 Formatting pointers
901 //
902 // The current implementation assumes formatting pointers isn't covered by
903 // "integer presentation type".
904 // TODO FMT Apply the LWG-issues/papers after approval/rejection by the Committee.
905568
906 __begin = __parser_width::__parse(__begin, __end, __parse_ctx);569template <class _CharT>
907 if (__begin == __end)570_LIBCPP_HIDE_FROM_ABI constexpr void __process_display_type_bool_string(__parser<_CharT>& __parser) {
908 return __begin;571 if (__parser.__sign_ != __sign::__default)
572 std::__throw_format_error("A sign field isn't allowed in this format-spec");
909573
910 __begin = __parse_type(__begin, static_cast<_Flags&>(*this));574 if (__parser.__alternate_form_)
575 std::__throw_format_error("An alternate form field isn't allowed in this format-spec");
911576
912 if (__begin != __end && *__begin != _CharT('}'))577 if (__parser.__alignment_ == __alignment::__zero_padding)
913 __throw_format_error("The format-spec should consume the input or end with a '}'");578 std::__throw_format_error("A zero-padding field isn't allowed in this format-spec");
914579
915 return __begin;580 if (__parser.__alignment_ == __alignment::__default)
916 }581 __parser.__alignment_ = __alignment::__left;
582}
917583
918 /** Processes the parsed std-format-spec based on the parsed display type. */584template <class _CharT>
919 _LIBCPP_HIDE_FROM_ABI constexpr void __process_display_type() {585_LIBCPP_HIDE_FROM_ABI constexpr void __process_display_type_char(__parser<_CharT>& __parser) {
920 switch (this->__type) {586 __format_spec::__process_display_type_bool_string(__parser);
921 case _Flags::_Type::__default:587}
922 this->__type = _Flags::_Type::__pointer;
923 break;
924 case _Flags::_Type::__pointer:
925 break;
926 default:
927 __throw_format_error("The format-spec type has a type not supported for a pointer argument");
928 }
929 }
930};
931588
932/** Helper struct returned from @ref __get_string_alignment. */
933template <class _CharT>589template <class _CharT>
934struct _LIBCPP_TEMPLATE_VIS __string_alignment {590_LIBCPP_HIDE_FROM_ABI constexpr void __process_parsed_bool(__parser<_CharT>& __parser) {
935 /** Points beyond the last character to write to the output. */591 switch (__parser.__type_) {
936 const _CharT* __last;592 case __format_spec::__type::__default:
937 /**593 case __format_spec::__type::__string:
938 * The estimated number of columns in the output or 0.594 __format_spec::__process_display_type_bool_string(__parser);
939 *595 break;
940 * Only when the output needs to be aligned it's required to know the exact
941 * number of columns in the output. So if the formatted output has only a
942 * minimum width the exact size isn't important. It's only important to know
943 * the minimum has been reached. The minimum width is the width specified in
944 * the format-spec.
945 *
946 * For example in this code @code std::format("{:10}", MyString); @endcode
947 * the width estimation can stop once the algorithm has determined the output
948 * width is 10 columns.
949 *
950 * So if:
951 * * @ref __align == @c true the @ref __size is the estimated number of
952 * columns required.
953 * * @ref __align == @c false the @ref __size is the estimated number of
954 * columns required or 0 when the estimation algorithm stopped prematurely.
955 */
956 ptrdiff_t __size;
957 /**
958 * Does the output need to be aligned.
959 *
960 * When alignment is needed the output algorithm needs to add the proper
961 * padding. Else the output algorithm just needs to copy the input up to
962 * @ref __last.
963 */
964 bool __align;
965};
966596
967#ifndef _LIBCPP_HAS_NO_UNICODE597 case __format_spec::__type::__binary_lower_case:
968namespace __detail {598 case __format_spec::__type::__binary_upper_case:
599 case __format_spec::__type::__octal:
600 case __format_spec::__type::__decimal:
601 case __format_spec::__type::__hexadecimal_lower_case:
602 case __format_spec::__type::__hexadecimal_upper_case:
603 break;
604
605 default:
606 std::__throw_format_error("The format-spec type has a type not supported for a bool argument");
607 }
608}
969609
970/**
971 * Unicode column width estimates.
972 *
973 * Unicode can be stored in several formats: UTF-8, UTF-16, and UTF-32.
974 * Depending on format the relation between the number of code units stored and
975 * the number of output columns differs. The first relation is the number of
976 * code units forming a code point. (The text assumes the code units are
977 * unsigned.)
978 * - UTF-8 The number of code units is between one and four. The first 127
979 * Unicode code points match the ASCII character set. When the highest bit is
980 * set it means the code point has more than one code unit.
981 * - UTF-16: The number of code units is between 1 and 2. When the first
982 * code unit is in the range [0xd800,0xdfff) it means the code point uses two
983 * code units.
984 * - UTF-32: The number of code units is always one.
985 *
986 * The code point to the number of columns isn't well defined. The code uses the
987 * estimations defined in [format.string.std]/11. This list might change in the
988 * future.
989 *
990 * The algorithm of @ref __get_string_alignment uses two different scanners:
991 * - The simple scanner @ref __estimate_column_width_fast. This scanner assumes
992 * 1 code unit is 1 column. This scanner stops when it can't be sure the
993 * assumption is valid:
994 * - UTF-8 when the code point is encoded in more than 1 code unit.
995 * - UTF-16 and UTF-32 when the first multi-column code point is encountered.
996 * (The code unit's value is lower than 0xd800 so the 2 code unit encoding
997 * is irrelevant for this scanner.)
998 * Due to these assumptions the scanner is faster than the full scanner. It
999 * can process all text only containing ASCII. For UTF-16/32 it can process
1000 * most (all?) European languages. (Note the set it can process might be
1001 * reduced in the future, due to updates in the scanning rules.)
1002 * - The full scanner @ref __estimate_column_width. This scanner, if needed,
1003 * converts multiple code units into one code point then converts the code
1004 * point to a column width.
1005 *
1006 * See also:
1007 * - [format.string.general]/11
1008 * - https://en.wikipedia.org/wiki/UTF-8#Encoding
1009 * - https://en.wikipedia.org/wiki/UTF-16#U+D800_to_U+DFFF
1010 */
1011
1012/**
1013 * The first 2 column code point.
1014 *
1015 * This is the point where the fast UTF-16/32 scanner needs to stop processing.
1016 */
1017inline constexpr uint32_t __two_column_code_point = 0x1100;
1018
1019/** Helper concept for an UTF-8 character type. */
1020template <class _CharT>610template <class _CharT>
1021concept __utf8_character = same_as<_CharT, char> || same_as<_CharT, char8_t>;611_LIBCPP_HIDE_FROM_ABI constexpr void __process_parsed_char(__parser<_CharT>& __parser) {
612 switch (__parser.__type_) {
613 case __format_spec::__type::__default:
614 case __format_spec::__type::__char:
615 __format_spec::__process_display_type_char(__parser);
616 break;
617
618 case __format_spec::__type::__binary_lower_case:
619 case __format_spec::__type::__binary_upper_case:
620 case __format_spec::__type::__octal:
621 case __format_spec::__type::__decimal:
622 case __format_spec::__type::__hexadecimal_lower_case:
623 case __format_spec::__type::__hexadecimal_upper_case:
624 break;
625
626 default:
627 std::__throw_format_error("The format-spec type has a type not supported for a char argument");
628 }
629}
1022630
1023/** Helper concept for an UTF-16 character type. */
1024template <class _CharT>631template <class _CharT>
1025concept __utf16_character = (same_as<_CharT, wchar_t> && sizeof(wchar_t) == 2) || same_as<_CharT, char16_t>;632_LIBCPP_HIDE_FROM_ABI constexpr void __process_parsed_integer(__parser<_CharT>& __parser) {
633 switch (__parser.__type_) {
634 case __format_spec::__type::__default:
635 case __format_spec::__type::__binary_lower_case:
636 case __format_spec::__type::__binary_upper_case:
637 case __format_spec::__type::__octal:
638 case __format_spec::__type::__decimal:
639 case __format_spec::__type::__hexadecimal_lower_case:
640 case __format_spec::__type::__hexadecimal_upper_case:
641 break;
642
643 case __format_spec::__type::__char:
644 __format_spec::__process_display_type_char(__parser);
645 break;
646
647 default:
648 std::__throw_format_error("The format-spec type has a type not supported for an integer argument");
649 }
650}
1026651
1027/** Helper concept for an UTF-32 character type. */
1028template <class _CharT>652template <class _CharT>
1029concept __utf32_character = (same_as<_CharT, wchar_t> && sizeof(wchar_t) == 4) || same_as<_CharT, char32_t>;653_LIBCPP_HIDE_FROM_ABI constexpr void __process_parsed_floating_point(__parser<_CharT>& __parser) {
654 switch (__parser.__type_) {
655 case __format_spec::__type::__default:
656 // When no precision specified then it keeps default since that
657 // formatting differs from the other types.
658 if (__parser.__precision_as_arg_ || __parser.__precision_ != -1)
659 __parser.__type_ = __format_spec::__type::__general_lower_case;
660 break;
661 case __format_spec::__type::__hexfloat_lower_case:
662 case __format_spec::__type::__hexfloat_upper_case:
663 // Precision specific behavior will be handled later.
664 break;
665 case __format_spec::__type::__scientific_lower_case:
666 case __format_spec::__type::__scientific_upper_case:
667 case __format_spec::__type::__fixed_lower_case:
668 case __format_spec::__type::__fixed_upper_case:
669 case __format_spec::__type::__general_lower_case:
670 case __format_spec::__type::__general_upper_case:
671 if (!__parser.__precision_as_arg_ && __parser.__precision_ == -1)
672 // Set the default precision for the call to to_chars.
673 __parser.__precision_ = 6;
674 break;
675
676 default:
677 std::__throw_format_error("The format-spec type has a type not supported for a floating-point argument");
678 }
679}
680
681_LIBCPP_HIDE_FROM_ABI constexpr void __process_display_type_pointer(__format_spec::__type __type) {
682 switch (__type) {
683 case __format_spec::__type::__default:
684 case __format_spec::__type::__pointer:
685 break;
686
687 default:
688 std::__throw_format_error("The format-spec type has a type not supported for a pointer argument");
689 }
690}
1030691
1031/** Helper concept for an UTF-16 or UTF-32 character type. */
1032template <class _CharT>692template <class _CharT>
1033concept __utf16_or_32_character = __utf16_character<_CharT> || __utf32_character<_CharT>;693struct __column_width_result {
1034694 /// The number of output columns.
1035/**695 size_t __width_;
1036 * Converts a code point to the column width.696 /// One beyond the last code unit used in the estimation.
1037 *697 ///
1038 * The estimations are conforming to [format.string.general]/11698 /// This limits the original output to fit in the wanted number of columns.
1039 *699 const _CharT* __last_;
1040 * This version expects a value less than 0x1'0000, which is a 3-byte UTF-8700};
1041 * character.701
1042 */702/// Since a column width can be two it's possible that the requested column
1043_LIBCPP_HIDE_FROM_ABI inline constexpr int __column_width_3(uint32_t __c) noexcept {703/// width can't be achieved. Depending on the intended usage the policy can be
1044 _LIBCPP_ASSERT(__c < 0x1'0000,704/// selected.
1045 "Use __column_width_4 or __column_width for larger values");705/// - When used as precision the maximum width may not be exceeded and the
706/// result should be "rounded down" to the previous boundary.
707/// - When used as a width we're done once the minimum is reached, but
708/// exceeding is not an issue. Rounding down is an issue since that will
709/// result in writing fill characters. Therefore the result needs to be
710/// "rounded up".
711enum class __column_width_rounding { __down, __up };
712
713# ifndef _LIBCPP_HAS_NO_UNICODE
714
715namespace __detail {
716
717/// Converts a code point to the column width.
718///
719/// The estimations are conforming to [format.string.general]/11
720///
721/// This version expects a value less than 0x1'0000, which is a 3-byte UTF-8
722/// character.
723_LIBCPP_HIDE_FROM_ABI constexpr int __column_width_3(uint32_t __c) noexcept {
724 _LIBCPP_ASSERT(__c < 0x10000, "Use __column_width_4 or __column_width for larger values");
1046725
1047 // clang-format off726 // clang-format off
1048 return 1 + (__c >= 0x1100 && (__c <= 0x115f ||727 return 1 + (__c >= 0x1100 && (__c <= 0x115f ||
...@@ -1059,15 +738,12 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr int __column_width_3(uint32_t __c) noexce...@@ -1059,15 +738,12 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr int __column_width_3(uint32_t __c) noexce
1059 // clang-format on738 // clang-format on
1060}739}
1061740
1062/**741/// @overload
1063 * @overload742///
1064 *743/// This version expects a value greater than or equal to 0x1'0000, which is a
1065 * This version expects a value greater than or equal to 0x1'0000, which is a744/// 4-byte UTF-8 character.
1066 * 4-byte UTF-8 character.745_LIBCPP_HIDE_FROM_ABI constexpr int __column_width_4(uint32_t __c) noexcept {
1067 */746 _LIBCPP_ASSERT(__c >= 0x10000, "Use __column_width_3 or __column_width for smaller values");
1068_LIBCPP_HIDE_FROM_ABI inline constexpr int __column_width_4(uint32_t __c) noexcept {
1069 _LIBCPP_ASSERT(__c >= 0x1'0000,
1070 "Use __column_width_3 or __column_width for smaller values");
1071747
1072 // clang-format off748 // clang-format off
1073 return 1 + (__c >= 0x1'f300 && (__c <= 0x1'f64f ||749 return 1 + (__c >= 0x1'f300 && (__c <= 0x1'f64f ||
...@@ -1078,316 +754,148 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr int __column_width_4(uint32_t __c) noexce...@@ -1078,316 +754,148 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr int __column_width_4(uint32_t __c) noexce
1078 // clang-format on754 // clang-format on
1079}755}
1080756
1081/**757/// @overload
1082 * @overload758///
1083 *759/// The general case, accepting all values.
1084 * The general case, accepting all values.760_LIBCPP_HIDE_FROM_ABI constexpr int __column_width(uint32_t __c) noexcept {
1085 */761 if (__c < 0x10000)
1086_LIBCPP_HIDE_FROM_ABI inline constexpr int __column_width(uint32_t __c) noexcept {762 return __detail::__column_width_3(__c);
1087 if (__c < 0x1'0000)
1088 return __column_width_3(__c);
1089763
1090 return __column_width_4(__c);764 return __detail::__column_width_4(__c);
1091}
1092
1093/**
1094 * Estimate the column width for the UTF-8 sequence using the fast algorithm.
1095 */
1096template <__utf8_character _CharT>
1097_LIBCPP_HIDE_FROM_ABI constexpr const _CharT*
1098__estimate_column_width_fast(const _CharT* __first,
1099 const _CharT* __last) noexcept {
1100 return _VSTD::find_if(__first, __last,
1101 [](unsigned char __c) { return __c & 0x80; });
1102}
1103
1104/**
1105 * @overload
1106 *
1107 * The implementation for UTF-16/32.
1108 */
1109template <__utf16_or_32_character _CharT>
1110_LIBCPP_HIDE_FROM_ABI constexpr const _CharT*
1111__estimate_column_width_fast(const _CharT* __first,
1112 const _CharT* __last) noexcept {
1113 return _VSTD::find_if(__first, __last,
1114 [](uint32_t __c) { return __c >= 0x1100; });
1115}765}
1116766
1117template <class _CharT>767template <class _CharT>
1118struct _LIBCPP_TEMPLATE_VIS __column_width_result {768_LIBCPP_HIDE_FROM_ABI constexpr __column_width_result<_CharT> __estimate_column_width_grapheme_clustering(
1119 /** The number of output columns. */769 const _CharT* __first, const _CharT* __last, size_t __maximum, __column_width_rounding __rounding) noexcept {
1120 size_t __width;770 __unicode::__extended_grapheme_cluster_view<_CharT> __view{__first, __last};
1121 /**
1122 * The last parsed element.
1123 *
1124 * This limits the original output to fit in the wanted number of columns.
1125 */
1126 const _CharT* __ptr;
1127};
1128
1129/**
1130 * Small helper to determine the width of malformed Unicode.
1131 *
1132 * @note This function's only needed for UTF-8. During scanning UTF-8 there
1133 * are multiple place where it can be detected that the Unicode is malformed.
1134 * UTF-16 only requires 1 test and UTF-32 requires no testing.
1135 */
1136template <__utf8_character _CharT>
1137_LIBCPP_HIDE_FROM_ABI constexpr __column_width_result<_CharT>
1138__estimate_column_width_malformed(const _CharT* __first, const _CharT* __last,
1139 size_t __maximum, size_t __result) noexcept {
1140 size_t __size = __last - __first;
1141 size_t __n = _VSTD::min(__size, __maximum);
1142 return {__result + __n, __first + __n};
1143}
1144771
1145/**772 __column_width_result<_CharT> __result{0, __first};
1146 * Determines the number of output columns needed to render the input.773 while (__result.__last_ != __last && __result.__width_ <= __maximum) {
1147 *774 typename __unicode::__extended_grapheme_cluster_view<_CharT>::__cluster __cluster = __view.__consume();
1148 * @note When the scanner encounters malformed Unicode it acts as-if every code775 int __width = __detail::__column_width(__cluster.__code_point_);
1149 * unit at the end of the input is one output column. It's expected the output
1150 * terminal will replace these malformed code units with a one column
1151 * replacement characters.
1152 *
1153 * @param __first Points to the first element of the input range.
1154 * @param __last Points beyond the last element of the input range.
1155 * @param __maximum The maximum number of output columns. The returned number
1156 * of estimated output columns will not exceed this value.
1157 */
1158template <__utf8_character _CharT>
1159_LIBCPP_HIDE_FROM_ABI constexpr __column_width_result<_CharT>
1160__estimate_column_width(const _CharT* __first, const _CharT* __last,
1161 size_t __maximum) noexcept {
1162 size_t __result = 0;
1163
1164 while (__first != __last) {
1165 // Based on the number of leading 1 bits the number of code units in the
1166 // code point can be determined. See
1167 // https://en.wikipedia.org/wiki/UTF-8#Encoding
1168 switch (_VSTD::countl_one(static_cast<unsigned char>(*__first))) {
1169 case 0: // 1-code unit encoding: all 1 column
1170 ++__result;
1171 ++__first;
1172 break;
1173776
1174 case 2: // 2-code unit encoding: all 1 column777 // When the next entry would exceed the maximum width the previous width
1175 // Malformed Unicode.778 // might be returned. For example when a width of 100 is requested the
1176 if (__last - __first < 2) [[unlikely]]779 // returned width might be 99, since the next code point has an estimated
1177 return __estimate_column_width_malformed(__first, __last, __maximum,780 // column width of 2. This depends on the rounding flag.
1178 __result);781 // When the maximum is exceeded the loop will abort the next iteration.
1179 __first += 2;782 if (__rounding == __column_width_rounding::__down && __result.__width_ + __width > __maximum)
1180 ++__result;783 return __result;
1181 break;
1182784
1183 case 3: // 3-code unit encoding: either 1 or 2 columns785 __result.__width_ += __width;
1184 // Malformed Unicode.786 __result.__last_ = __cluster.__last_;
1185 if (__last - __first < 3) [[unlikely]]
1186 return __estimate_column_width_malformed(__first, __last, __maximum,
1187 __result);
1188 {
1189 uint32_t __c = static_cast<unsigned char>(*__first++) & 0x0f;
1190 __c <<= 6;
1191 __c |= static_cast<unsigned char>(*__first++) & 0x3f;
1192 __c <<= 6;
1193 __c |= static_cast<unsigned char>(*__first++) & 0x3f;
1194 __result += __column_width_3(__c);
1195 if (__result > __maximum)
1196 return {__result - 2, __first - 3};
1197 }
1198 break;
1199 case 4: // 4-code unit encoding: either 1 or 2 columns
1200 // Malformed Unicode.
1201 if (__last - __first < 4) [[unlikely]]
1202 return __estimate_column_width_malformed(__first, __last, __maximum,
1203 __result);
1204 {
1205 uint32_t __c = static_cast<unsigned char>(*__first++) & 0x07;
1206 __c <<= 6;
1207 __c |= static_cast<unsigned char>(*__first++) & 0x3f;
1208 __c <<= 6;
1209 __c |= static_cast<unsigned char>(*__first++) & 0x3f;
1210 __c <<= 6;
1211 __c |= static_cast<unsigned char>(*__first++) & 0x3f;
1212 __result += __column_width_4(__c);
1213 if (__result > __maximum)
1214 return {__result - 2, __first - 4};
1215 }
1216 break;
1217 default:
1218 // Malformed Unicode.
1219 return __estimate_column_width_malformed(__first, __last, __maximum,
1220 __result);
1221 }
1222
1223 if (__result >= __maximum)
1224 return {__result, __first};
1225 }787 }
1226 return {__result, __first};
1227}
1228788
1229template <__utf16_character _CharT>789 return __result;
1230_LIBCPP_HIDE_FROM_ABI constexpr __column_width_result<_CharT>
1231__estimate_column_width(const _CharT* __first, const _CharT* __last,
1232 size_t __maximum) noexcept {
1233 size_t __result = 0;
1234
1235 while (__first != __last) {
1236 uint32_t __c = *__first;
1237 // Is the code unit part of a surrogate pair? See
1238 // https://en.wikipedia.org/wiki/UTF-16#U+D800_to_U+DFFF
1239 if (__c >= 0xd800 && __c <= 0xDfff) {
1240 // Malformed Unicode.
1241 if (__last - __first < 2) [[unlikely]]
1242 return {__result + 1, __first + 1};
1243
1244 __c -= 0xd800;
1245 __c <<= 10;
1246 __c += (*(__first + 1) - 0xdc00);
1247 __c += 0x10'000;
1248
1249 __result += __column_width_4(__c);
1250 if (__result > __maximum)
1251 return {__result - 2, __first};
1252 __first += 2;
1253 } else {
1254 __result += __column_width_3(__c);
1255 if (__result > __maximum)
1256 return {__result - 2, __first};
1257 ++__first;
1258 }
1259
1260 if (__result >= __maximum)
1261 return {__result, __first};
1262 }
1263
1264 return {__result, __first};
1265}
1266
1267template <__utf32_character _CharT>
1268_LIBCPP_HIDE_FROM_ABI constexpr __column_width_result<_CharT>
1269__estimate_column_width(const _CharT* __first, const _CharT* __last,
1270 size_t __maximum) noexcept {
1271 size_t __result = 0;
1272
1273 while (__first != __last) {
1274 wchar_t __c = *__first;
1275 __result += __column_width(__c);
1276
1277 if (__result > __maximum)
1278 return {__result - 2, __first};
1279
1280 ++__first;
1281 if (__result >= __maximum)
1282 return {__result, __first};
1283 }
1284
1285 return {__result, __first};
1286}790}
1287791
1288} // namespace __detail792} // namespace __detail
1289793
794// Unicode can be stored in several formats: UTF-8, UTF-16, and UTF-32.
795// Depending on format the relation between the number of code units stored and
796// the number of output columns differs. The first relation is the number of
797// code units forming a code point. (The text assumes the code units are
798// unsigned.)
799// - UTF-8 The number of code units is between one and four. The first 127
800// Unicode code points match the ASCII character set. When the highest bit is
801// set it means the code point has more than one code unit.
802// - UTF-16: The number of code units is between 1 and 2. When the first
803// code unit is in the range [0xd800,0xdfff) it means the code point uses two
804// code units.
805// - UTF-32: The number of code units is always one.
806//
807// The code point to the number of columns is specified in
808// [format.string.std]/11. This list might change in the future.
809//
810// Another thing to be taken into account is Grapheme clustering. This means
811// that in some cases multiple code points are combined one element in the
812// output. For example:
813// - an ASCII character with a combined diacritical mark
814// - an emoji with a skin tone modifier
815// - a group of combined people emoji to create a family
816// - a combination of flag emoji
817//
818// See also:
819// - [format.string.general]/11
820// - https://en.wikipedia.org/wiki/UTF-8#Encoding
821// - https://en.wikipedia.org/wiki/UTF-16#U+D800_to_U+DFFF
822
823_LIBCPP_HIDE_FROM_ABI constexpr bool __is_ascii(char32_t __c) { return __c < 0x80; }
824
825/// Determines the number of output columns needed to render the input.
826///
827/// \note When the scanner encounters malformed Unicode it acts as-if every
828/// code unit is a one column code point. Typically a terminal uses the same
829/// strategy and replaces every malformed code unit with a one column
830/// replacement character.
831///
832/// \param __first Points to the first element of the input range.
833/// \param __last Points beyond the last element of the input range.
834/// \param __maximum The maximum number of output columns. The returned number
835/// of estimated output columns will not exceed this value.
836/// \param __rounding Selects the rounding method.
837/// \c __down result.__width_ <= __maximum
838/// \c __up result.__width_ <= __maximum + 1
1290template <class _CharT>839template <class _CharT>
1291_LIBCPP_HIDE_FROM_ABI constexpr __string_alignment<_CharT>840_LIBCPP_HIDE_FROM_ABI constexpr __column_width_result<_CharT> __estimate_column_width(
1292__get_string_alignment(const _CharT* __first, const _CharT* __last,841 basic_string_view<_CharT> __str, size_t __maximum, __column_width_rounding __rounding) noexcept {
1293 ptrdiff_t __width, ptrdiff_t __precision) noexcept {842 // The width estimation is done in two steps:
1294 _LIBCPP_ASSERT(__width != 0 || __precision != -1,843 // - Quickly process for the ASCII part. ASCII has the following properties
1295 "The function has no effect and shouldn't be used");844 // - One code unit is one code point
1296845 // - Every code point has an estimated width of one
1297 // TODO FMT There might be more optimizations possible:846 // - When needed it will a Unicode Grapheme clustering algorithm to find
1298 // If __precision == __format::__number_max and the encoding is:847 // the proper place for truncation.
1299 // * UTF-8 : 4 * (__last - __first) >= __width848
1300 // * UTF-16 : 2 * (__last - __first) >= __width849 if (__str.empty() || __maximum == 0)
1301 // * UTF-32 : (__last - __first) >= __width850 return {0, __str.begin()};
1302 // In these cases it's certain the output is at least the requested width.851
1303 // It's unknown how often this happens in practice. For now the improvement852 // ASCII has one caveat; when an ASCII character is followed by a non-ASCII
1304 // isn't implemented.853 // character they might be part of an extended grapheme cluster. For example:
1305854 // an ASCII letter and a COMBINING ACUTE ACCENT
1306 /*855 // The truncate should happen after the COMBINING ACUTE ACCENT. Therefore we
1307 * First assume there are no special Unicode code units in the input.856 // need to scan one code unit beyond the requested precision. When this code
1308 * - Apply the precision (this may reduce the size of the input). When857 // unit is non-ASCII we omit the current code unit and let the Grapheme
1309 * __precison == -1 this step is omitted.858 // clustering algorithm do its work.
1310 * - Scan for special code units in the input.859 const _CharT* __it = __str.begin();
1311 * If our assumption was correct the __pos will be at the end of the input.860 if (__is_ascii(*__it)) {
1312 */861 do {
1313 const ptrdiff_t __length = __last - __first;862 --__maximum;
1314 const _CharT* __limit =863 ++__it;
1315 __first +864 if (__it == __str.end())
1316 (__precision == -1 ? __length : _VSTD::min(__length, __precision));865 return {__str.size(), __str.end()};
1317 ptrdiff_t __size = __limit - __first;866
1318 const _CharT* __pos =867 if (__maximum == 0) {
1319 __detail::__estimate_column_width_fast(__first, __limit);868 if (__is_ascii(*__it))
1320869 return {static_cast<size_t>(__it - __str.begin()), __it};
1321 if (__pos == __limit)870
1322 return {__limit, __size, __size < __width};871 break;
1323872 }
1324 /*873 } while (__is_ascii(*__it));
1325 * Our assumption was wrong, there are special Unicode code units.874 --__it;
1326 * The range [__first, __pos) contains a set of code units with the875 ++__maximum;
1327 * following property:
1328 * Every _CharT in the range will be rendered in 1 column.
1329 *
1330 * If there's no maximum width and the parsed size already exceeds the
1331 * minimum required width. The real size isn't important. So bail out.
1332 */
1333 if (__precision == -1 && (__pos - __first) >= __width)
1334 return {__last, 0, false};
1335
1336 /* If there's a __precision, truncate the output to that width. */
1337 ptrdiff_t __prefix = __pos - __first;
1338 if (__precision != -1) {
1339 _LIBCPP_ASSERT(__precision > __prefix, "Logic error.");
1340 auto __lengh_info = __detail::__estimate_column_width(
1341 __pos, __last, __precision - __prefix);
1342 __size = __lengh_info.__width + __prefix;
1343 return {__lengh_info.__ptr, __size, __size < __width};
1344 }876 }
1345877
1346 /* Else use __width to determine the number of required padding characters. */878 ptrdiff_t __ascii_size = __it - __str.begin();
1347 _LIBCPP_ASSERT(__width > __prefix, "Logic error.");879 __column_width_result __result =
1348 /*880 __detail::__estimate_column_width_grapheme_clustering(__it, __str.end(), __maximum, __rounding);
1349 * The column width is always one or two columns. For the precision the wanted
1350 * column width is the maximum, for the width it's the minimum. Using the
1351 * width estimation with its truncating behavior will result in the wrong
1352 * result in the following case:
1353 * - The last code unit processed requires two columns and exceeds the
1354 * maximum column width.
1355 * By increasing the __maximum by one avoids this issue. (It means it may
1356 * pass one code point more than required to determine the proper result;
1357 * that however isn't a problem for the algorithm.)
1358 */
1359 size_t __maximum = 1 + __width - __prefix;
1360 auto __lengh_info =
1361 __detail::__estimate_column_width(__pos, __last, __maximum);
1362 if (__lengh_info.__ptr != __last) {
1363 // Consumed the width number of code units. The exact size of the string
1364 // is unknown. We only know we don't need to align the output.
1365 _LIBCPP_ASSERT(static_cast<ptrdiff_t>(__lengh_info.__width + __prefix) >=
1366 __width,
1367 "Logic error");
1368 return {__last, 0, false};
1369 }
1370881
1371 __size = __lengh_info.__width + __prefix;882 __result.__width_ += __ascii_size;
1372 return {__last, __size, __size < __width};883 return __result;
1373}884}
1374#else // _LIBCPP_HAS_NO_UNICODE885# else // !defined(_LIBCPP_HAS_NO_UNICODE)
1375template <class _CharT>886template <class _CharT>
1376_LIBCPP_HIDE_FROM_ABI constexpr __string_alignment<_CharT>887_LIBCPP_HIDE_FROM_ABI constexpr __column_width_result<_CharT>
1377__get_string_alignment(const _CharT* __first, const _CharT* __last,888__estimate_column_width(basic_string_view<_CharT> __str, size_t __maximum, __column_width_rounding) noexcept {
1378 ptrdiff_t __width, ptrdiff_t __precision) noexcept {889 // When Unicode isn't supported assume ASCII and every code unit is one code
1379 const ptrdiff_t __length = __last - __first;890 // point. In ASCII the estimated column width is always one. Thus there's no
1380 const _CharT* __limit =891 // need for rounding.
1381 __first +892 size_t __width_ = _VSTD::min(__str.size(), __maximum);
1382 (__precision == -1 ? __length : _VSTD::min(__length, __precision));893 return {__width_, __str.begin() + __width_};
1383 ptrdiff_t __size = __limit - __first;
1384 return {__limit, __size, __size < __width};
1385}894}
1386#endif // _LIBCPP_HAS_NO_UNICODE
1387895
1388} // namespace __format_spec896# endif // !defined(_LIBCPP_HAS_NO_UNICODE)
1389897
1390# endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)898} // namespace __format_spec
1391899
1392#endif //_LIBCPP_STD_VER > 17900#endif //_LIBCPP_STD_VER > 17
1393901
lib/libcxx/include/__format/unicode.h created+339
...@@ -0,0 +1,339 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___FORMAT_UNICODE_H
11#define _LIBCPP___FORMAT_UNICODE_H
12
13#include <__assert>
14#include <__config>
15#include <__format/extended_grapheme_cluster_table.h>
16#include <__utility/unreachable.h>
17#include <bit>
18
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20# pragma GCC system_header
21#endif
22
23_LIBCPP_BEGIN_NAMESPACE_STD
24
25#if _LIBCPP_STD_VER > 17
26
27# ifndef _LIBCPP_HAS_NO_UNICODE
28
29/// Implements the grapheme cluster boundary rules
30///
31/// These rules are used to implement format's width estimation as stated in
32/// [format.string.std]/11
33///
34/// The Standard refers to UAX \#29 for Unicode 12.0.0
35/// https://www.unicode.org/reports/tr29/#Grapheme_Cluster_Boundary_Rules
36///
37/// The data tables used are
38/// https://www.unicode.org/Public/UCD/latest/ucd/auxiliary/GraphemeBreakProperty.txt
39/// https://www.unicode.org/Public/UCD/latest/ucd/emoji/emoji-data.txt
40/// https://www.unicode.org/Public/UCD/latest/ucd/auxiliary/GraphemeBreakTest.txt (for testing only)
41
42namespace __unicode {
43
44inline constexpr char32_t __replacement_character = U'\ufffd';
45
46_LIBCPP_HIDE_FROM_ABI constexpr bool __is_continuation(const char* __char, int __count) {
47 do {
48 if ((*__char & 0b1000'0000) != 0b1000'0000)
49 return false;
50 --__count;
51 ++__char;
52 } while (__count);
53 return true;
54}
55
56/// Helper class to extract a code unit from a Unicode character range.
57///
58/// The stored range is a view. There are multiple specialization for different
59/// character types.
60template <class _CharT>
61class __code_point_view;
62
63/// UTF-8 specialization.
64template <>
65class __code_point_view<char> {
66public:
67 _LIBCPP_HIDE_FROM_ABI constexpr explicit __code_point_view(const char* __first, const char* __last)
68 : __first_(__first), __last_(__last) {}
69
70 _LIBCPP_HIDE_FROM_ABI constexpr bool __at_end() const noexcept { return __first_ == __last_; }
71 _LIBCPP_HIDE_FROM_ABI constexpr const char* __position() const noexcept { return __first_; }
72
73 _LIBCPP_HIDE_FROM_ABI constexpr char32_t __consume() noexcept {
74 _LIBCPP_ASSERT(__first_ != __last_, "can't move beyond the end of input");
75
76 // Based on the number of leading 1 bits the number of code units in the
77 // code point can be determined. See
78 // https://en.wikipedia.org/wiki/UTF-8#Encoding
79 switch (_VSTD::countl_one(static_cast<unsigned char>(*__first_))) {
80 case 0:
81 return *__first_++;
82
83 case 2:
84 if (__last_ - __first_ < 2 || !__unicode::__is_continuation(__first_ + 1, 1)) [[unlikely]]
85 break;
86 else {
87 char32_t __value = static_cast<unsigned char>(*__first_++) & 0x1f;
88 __value <<= 6;
89 __value |= static_cast<unsigned char>(*__first_++) & 0x3f;
90 return __value;
91 }
92
93 case 3:
94 if (__last_ - __first_ < 3 || !__unicode::__is_continuation(__first_ + 1, 2)) [[unlikely]]
95 break;
96 else {
97 char32_t __value = static_cast<unsigned char>(*__first_++) & 0x0f;
98 __value <<= 6;
99 __value |= static_cast<unsigned char>(*__first_++) & 0x3f;
100 __value <<= 6;
101 __value |= static_cast<unsigned char>(*__first_++) & 0x3f;
102 return __value;
103 }
104
105 case 4:
106 if (__last_ - __first_ < 4 || !__unicode::__is_continuation(__first_ + 1, 3)) [[unlikely]]
107 break;
108 else {
109 char32_t __value = static_cast<unsigned char>(*__first_++) & 0x07;
110 __value <<= 6;
111 __value |= static_cast<unsigned char>(*__first_++) & 0x3f;
112 __value <<= 6;
113 __value |= static_cast<unsigned char>(*__first_++) & 0x3f;
114 __value <<= 6;
115 __value |= static_cast<unsigned char>(*__first_++) & 0x3f;
116 return __value;
117 }
118 }
119 // An invalid number of leading ones can be garbage or a code unit in the
120 // middle of a code point. By consuming one code unit the parser may get
121 // "in sync" after a few code units.
122 ++__first_;
123 return __replacement_character;
124 }
125
126private:
127 const char* __first_;
128 const char* __last_;
129};
130
131# ifndef TEST_HAS_NO_WIDE_CHARACTERS
132/// This specialization depends on the size of wchar_t
133/// - 2 UTF-16 (for example Windows and AIX)
134/// - 4 UTF-32 (for example Linux)
135template <>
136class __code_point_view<wchar_t> {
137public:
138 _LIBCPP_HIDE_FROM_ABI constexpr explicit __code_point_view(const wchar_t* __first, const wchar_t* __last)
139 : __first_(__first), __last_(__last) {}
140
141 _LIBCPP_HIDE_FROM_ABI constexpr const wchar_t* __position() const noexcept { return __first_; }
142 _LIBCPP_HIDE_FROM_ABI constexpr bool __at_end() const noexcept { return __first_ == __last_; }
143
144 _LIBCPP_HIDE_FROM_ABI constexpr char32_t __consume() noexcept {
145 _LIBCPP_ASSERT(__first_ != __last_, "can't move beyond the end of input");
146
147 if constexpr (sizeof(wchar_t) == 2) {
148 char32_t __result = *__first_++;
149 // Is the code unit part of a surrogate pair? See
150 // https://en.wikipedia.org/wiki/UTF-16#U+D800_to_U+DFFF
151 if (__result >= 0xd800 && __result <= 0xDfff) {
152 // Malformed Unicode.
153 if (__first_ == __last_) [[unlikely]]
154 return __replacement_character;
155
156 __result -= 0xd800;
157 __result <<= 10;
158 __result += *__first_++ - 0xdc00;
159 __result += 0x10000;
160 }
161 return __result;
162
163 } else if constexpr (sizeof(wchar_t) == 4) {
164 char32_t __result = *__first_++;
165 if (__result > 0x10FFFF) [[unlikely]]
166 return __replacement_character;
167 return __result;
168 } else {
169 // TODO FMT P2593R0 Use static_assert(false, "sizeof(wchar_t) has a not implemented value");
170 _LIBCPP_ASSERT(sizeof(wchar_t) == 0, "sizeof(wchar_t) has a not implemented value");
171 __libcpp_unreachable();
172 }
173 }
174
175private:
176 const wchar_t* __first_;
177 const wchar_t* __last_;
178};
179# endif
180
181_LIBCPP_HIDE_FROM_ABI constexpr bool __at_extended_grapheme_cluster_break(
182 bool& __ri_break_allowed,
183 bool __has_extened_pictographic,
184 __extended_grapheme_custer_property_boundary::__property __prev,
185 __extended_grapheme_custer_property_boundary::__property __next) {
186 using __extended_grapheme_custer_property_boundary::__property;
187
188 __has_extened_pictographic |= __prev == __property::__Extended_Pictographic;
189
190 // https://www.unicode.org/reports/tr29/tr29-39.html#Grapheme_Cluster_Boundary_Rules
191
192 // *** Break at the start and end of text, unless the text is empty. ***
193
194 _LIBCPP_ASSERT(__prev != __property::__sot, "should be handled in the constructor"); // GB1
195 _LIBCPP_ASSERT(__prev != __property::__eot, "should be handled by our caller"); // GB2
196
197 // *** Do not break between a CR and LF. Otherwise, break before and after controls. ***
198 if (__prev == __property::__CR && __next == __property::__LF) // GB3
199 return false;
200
201 if (__prev == __property::__Control || __prev == __property::__CR || __prev == __property::__LF) // GB4
202 return true;
203
204 if (__next == __property::__Control || __next == __property::__CR || __next == __property::__LF) // GB5
205 return true;
206
207 // *** Do not break Hangul syllable sequences. ***
208 if (__prev == __property::__L &&
209 (__next == __property::__L || __next == __property::__V || __next == __property::__LV ||
210 __next == __property::__LVT)) // GB6
211 return false;
212
213 if ((__prev == __property::__LV || __prev == __property::__V) &&
214 (__next == __property::__V || __next == __property::__T)) // GB7
215 return false;
216
217 if ((__prev == __property::__LVT || __prev == __property::__T) && __next == __property::__T) // GB8
218 return false;
219
220 // *** Do not break before extending characters or ZWJ. ***
221 if (__next == __property::__Extend || __next == __property::__ZWJ)
222 return false; // GB9
223
224 // *** Do not break before SpacingMarks, or after Prepend characters. ***
225 if (__next == __property::__SpacingMark) // GB9a
226 return false;
227
228 if (__prev == __property::__Prepend) // GB9b
229 return false;
230
231 // *** Do not break within emoji modifier sequences or emoji zwj sequences. ***
232
233 // GB11 \p{Extended_Pictographic} Extend* ZWJ x \p{Extended_Pictographic}
234 //
235 // Note that several parts of this rule are matched by GB9: Any x (Extend | ZWJ)
236 // - \p{Extended_Pictographic} x Extend
237 // - Extend x Extend
238 // - \p{Extended_Pictographic} x ZWJ
239 // - Extend x ZWJ
240 //
241 // So the only case left to test is
242 // - \p{Extended_Pictographic}' x ZWJ x \p{Extended_Pictographic}
243 // where \p{Extended_Pictographic}' is stored in __has_extened_pictographic
244 if (__has_extened_pictographic && __prev == __property::__ZWJ && __next == __property::__Extended_Pictographic)
245 return false;
246
247 // *** Do not break within emoji flag sequences ***
248
249 // That is, do not break between regional indicator (RI) symbols if there
250 // is an odd number of RI characters before the break point.
251
252 if (__prev == __property::__Regional_Indicator && __next == __property::__Regional_Indicator) { // GB12 + GB13
253 __ri_break_allowed = !__ri_break_allowed;
254 if (__ri_break_allowed)
255 return true;
256
257 return false;
258 }
259
260 // *** Otherwise, break everywhere. ***
261 return true; // GB999
262}
263
264/// Helper class to extract an extended grapheme cluster from a Unicode character range.
265///
266/// This function is used to determine the column width of an extended grapheme
267/// cluster. In order to do that only the first code point is evaluated.
268/// Therefore only this code point is extracted.
269template <class _CharT>
270class __extended_grapheme_cluster_view {
271public:
272 _LIBCPP_HIDE_FROM_ABI constexpr explicit __extended_grapheme_cluster_view(const _CharT* __first, const _CharT* __last)
273 : __code_point_view_(__first, __last),
274 __next_code_point_(__code_point_view_.__consume()),
275 __next_prop_(__extended_grapheme_custer_property_boundary::__get_property(__next_code_point_)) {}
276
277 struct __cluster {
278 /// The first code point of the extended grapheme cluster.
279 ///
280 /// The first code point is used to estimate the width of the extended
281 /// grapheme cluster.
282 char32_t __code_point_;
283
284 /// Points one beyond the last code unit in the extended grapheme cluster.
285 ///
286 /// It's expected the caller has the start position and thus can determine
287 /// the code unit range of the extended grapheme cluster.
288 const _CharT* __last_;
289 };
290
291 _LIBCPP_HIDE_FROM_ABI constexpr __cluster __consume() {
292 _LIBCPP_ASSERT(
293 __next_prop_ != __extended_grapheme_custer_property_boundary::__property::__eot,
294 "can't move beyond the end of input");
295 char32_t __code_point = __next_code_point_;
296 if (!__code_point_view_.__at_end())
297 return {__code_point, __get_break()};
298
299 __next_prop_ = __extended_grapheme_custer_property_boundary::__property::__eot;
300 return {__code_point, __code_point_view_.__position()};
301 }
302
303private:
304 __code_point_view<_CharT> __code_point_view_;
305
306 char32_t __next_code_point_;
307 __extended_grapheme_custer_property_boundary::__property __next_prop_;
308
309 _LIBCPP_HIDE_FROM_ABI constexpr const _CharT* __get_break() {
310 bool __ri_break_allowed = true;
311 bool __has_extened_pictographic = false;
312 while (true) {
313 const _CharT* __result = __code_point_view_.__position();
314 __extended_grapheme_custer_property_boundary::__property __prev = __next_prop_;
315 if (__code_point_view_.__at_end()) {
316 __next_prop_ = __extended_grapheme_custer_property_boundary::__property::__eot;
317 return __result;
318 }
319 __next_code_point_ = __code_point_view_.__consume();
320 __next_prop_ = __extended_grapheme_custer_property_boundary::__get_property(__next_code_point_);
321
322 __has_extened_pictographic |=
323 __prev == __extended_grapheme_custer_property_boundary::__property::__Extended_Pictographic;
324
325 if (__at_extended_grapheme_cluster_break(__ri_break_allowed, __has_extened_pictographic, __prev, __next_prop_))
326 return __result;
327 }
328 }
329};
330
331} // namespace __unicode
332
333# endif // _LIBCPP_HAS_NO_UNICODE
334
335#endif //_LIBCPP_STD_VER > 17
336
337_LIBCPP_END_NAMESPACE_STD
338
339#endif // _LIBCPP___FORMAT_UNICODE_H
lib/libcxx/include/__functional/binary_function.h+25-2
...@@ -13,19 +13,42 @@...@@ -13,19 +13,42 @@
13#include <__config>13#include <__config>
1414
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16#pragma GCC system_header16# pragma GCC system_header
17#endif17#endif
1818
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION)
22
21template <class _Arg1, class _Arg2, class _Result>23template <class _Arg1, class _Arg2, class _Result>
22struct _LIBCPP_TEMPLATE_VIS binary_function24struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 binary_function
23{25{
24 typedef _Arg1 first_argument_type;26 typedef _Arg1 first_argument_type;
25 typedef _Arg2 second_argument_type;27 typedef _Arg2 second_argument_type;
26 typedef _Result result_type;28 typedef _Result result_type;
27};29};
2830
31#endif // _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION)
32
33template <class _Arg1, class _Arg2, class _Result> struct __binary_function_keep_layout_base {
34#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
35 using first_argument_type _LIBCPP_DEPRECATED_IN_CXX17 = _Arg1;
36 using second_argument_type _LIBCPP_DEPRECATED_IN_CXX17 = _Arg2;
37 using result_type _LIBCPP_DEPRECATED_IN_CXX17 = _Result;
38#endif
39};
40
41#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION)
42_LIBCPP_DIAGNOSTIC_PUSH
43_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated-declarations")
44template <class _Arg1, class _Arg2, class _Result>
45using __binary_function = binary_function<_Arg1, _Arg2, _Result>;
46_LIBCPP_DIAGNOSTIC_POP
47#else
48template <class _Arg1, class _Arg2, class _Result>
49using __binary_function = __binary_function_keep_layout_base<_Arg1, _Arg2, _Result>;
50#endif
51
29_LIBCPP_END_NAMESPACE_STD52_LIBCPP_END_NAMESPACE_STD
3053
31#endif // _LIBCPP___FUNCTIONAL_BINARY_FUNCTION_H54#endif // _LIBCPP___FUNCTIONAL_BINARY_FUNCTION_H
lib/libcxx/include/__functional/binary_negate.h+4-4
...@@ -14,7 +14,7 @@...@@ -14,7 +14,7 @@
14#include <__functional/binary_function.h>14#include <__functional/binary_function.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
18#endif18#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -23,9 +23,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -23,9 +23,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2323
24template <class _Predicate>24template <class _Predicate>
25class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 binary_negate25class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 binary_negate
26 : public binary_function<typename _Predicate::first_argument_type,26 : public __binary_function<typename _Predicate::first_argument_type,
27 typename _Predicate::second_argument_type,27 typename _Predicate::second_argument_type,
28 bool>28 bool>
29{29{
30 _Predicate __pred_;30 _Predicate __pred_;
31public:31public:
lib/libcxx/include/__functional/bind.h+6-9
...@@ -18,16 +18,16 @@...@@ -18,16 +18,16 @@
18#include <type_traits>18#include <type_traits>
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
22#endif22#endif
2323
24_LIBCPP_BEGIN_NAMESPACE_STD24_LIBCPP_BEGIN_NAMESPACE_STD
2525
26template<class _Tp>26template<class _Tp>
27struct is_bind_expression : _If<27struct is_bind_expression : _If<
28 _IsSame<_Tp, typename __uncvref<_Tp>::type>::value,28 _IsSame<_Tp, __uncvref_t<_Tp> >::value,
29 false_type,29 false_type,
30 is_bind_expression<typename __uncvref<_Tp>::type>30 is_bind_expression<__uncvref_t<_Tp> >
31> {};31> {};
3232
33#if _LIBCPP_STD_VER > 1433#if _LIBCPP_STD_VER > 14
...@@ -37,9 +37,9 @@ inline constexpr size_t is_bind_expression_v = is_bind_expression<_Tp>::value;...@@ -37,9 +37,9 @@ inline constexpr size_t is_bind_expression_v = is_bind_expression<_Tp>::value;
3737
38template<class _Tp>38template<class _Tp>
39struct is_placeholder : _If<39struct is_placeholder : _If<
40 _IsSame<_Tp, typename __uncvref<_Tp>::type>::value,40 _IsSame<_Tp, __uncvref_t<_Tp> >::value,
41 integral_constant<int, 0>,41 integral_constant<int, 0>,
42 is_placeholder<typename __uncvref<_Tp>::type>42 is_placeholder<__uncvref_t<_Tp> >
43> {};43> {};
4444
45#if _LIBCPP_STD_VER > 1445#if _LIBCPP_STD_VER > 14
...@@ -264,10 +264,7 @@ __apply_functor(_Fp& __f, _BoundArgs& __bound_args, __tuple_indices<_Indx...>,...@@ -264,10 +264,7 @@ __apply_functor(_Fp& __f, _BoundArgs& __bound_args, __tuple_indices<_Indx...>,
264}264}
265265
266template<class _Fp, class ..._BoundArgs>266template<class _Fp, class ..._BoundArgs>
267class __bind267class __bind : public __weak_result_type<typename decay<_Fp>::type>
268#if _LIBCPP_STD_VER <= 17 || !defined(_LIBCPP_ABI_NO_BINDER_BASES)
269 : public __weak_result_type<typename decay<_Fp>::type>
270#endif
271{268{
272protected:269protected:
273 typedef typename decay<_Fp>::type _Fd;270 typedef typename decay<_Fp>::type _Fd;
lib/libcxx/include/__functional/bind_back.h+6-7
...@@ -19,7 +19,7 @@...@@ -19,7 +19,7 @@
19#include <type_traits>19#include <type_traits>
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
23#endif23#endif
2424
25_LIBCPP_BEGIN_NAMESPACE_STD25_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -31,12 +31,11 @@ struct __bind_back_op;...@@ -31,12 +31,11 @@ struct __bind_back_op;
3131
32template <size_t _NBound, size_t ..._Ip>32template <size_t _NBound, size_t ..._Ip>
33struct __bind_back_op<_NBound, index_sequence<_Ip...>> {33struct __bind_back_op<_NBound, index_sequence<_Ip...>> {
34 template <class _Fn, class _Bound, class ..._Args>34 template <class _Fn, class _BoundArgs, class... _Args>
35 _LIBCPP_HIDE_FROM_ABI35 _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Fn&& __f, _BoundArgs&& __bound_args, _Args&&... __args) const
36 constexpr auto operator()(_Fn&& __f, _Bound&& __bound, _Args&& ...__args) const36 noexcept(noexcept(_VSTD::invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)..., _VSTD::get<_Ip>(_VSTD::forward<_BoundArgs>(__bound_args))...)))
37 noexcept(noexcept(_VSTD::invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)..., _VSTD::get<_Ip>(_VSTD::forward<_Bound>(__bound))...)))37 -> decltype( _VSTD::invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)..., _VSTD::get<_Ip>(_VSTD::forward<_BoundArgs>(__bound_args))...))
38 -> decltype( _VSTD::invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)..., _VSTD::get<_Ip>(_VSTD::forward<_Bound>(__bound))...))38 { return _VSTD::invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)..., _VSTD::get<_Ip>(_VSTD::forward<_BoundArgs>(__bound_args))...); }
39 { return _VSTD::invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)..., _VSTD::get<_Ip>(_VSTD::forward<_Bound>(__bound))...); }
40};39};
4140
42template <class _Fn, class _BoundArgs>41template <class _Fn, class _BoundArgs>
lib/libcxx/include/__functional/bind_front.h+2-2
...@@ -13,11 +13,11 @@...@@ -13,11 +13,11 @@
13#include <__config>13#include <__config>
14#include <__functional/invoke.h>14#include <__functional/invoke.h>
15#include <__functional/perfect_forward.h>15#include <__functional/perfect_forward.h>
16#include <__utility/forward.h>
16#include <type_traits>17#include <type_traits>
17#include <utility>
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
21#endif21#endif
2222
23_LIBCPP_BEGIN_NAMESPACE_STD23_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__functional/binder1st.h+2-3
...@@ -14,7 +14,7 @@...@@ -14,7 +14,7 @@
14#include <__functional/unary_function.h>14#include <__functional/unary_function.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
18#endif18#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -23,8 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -23,8 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2323
24template <class __Operation>24template <class __Operation>
25class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 binder1st25class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 binder1st
26 : public unary_function<typename __Operation::second_argument_type,26 : public __unary_function<typename __Operation::second_argument_type, typename __Operation::result_type>
27 typename __Operation::result_type>
28{27{
29protected:28protected:
30 __Operation op;29 __Operation op;
lib/libcxx/include/__functional/binder2nd.h+2-3
...@@ -14,7 +14,7 @@...@@ -14,7 +14,7 @@
14#include <__functional/unary_function.h>14#include <__functional/unary_function.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
18#endif18#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -23,8 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -23,8 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2323
24template <class __Operation>24template <class __Operation>
25class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 binder2nd25class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 binder2nd
26 : public unary_function<typename __Operation::first_argument_type,26 : public __unary_function<typename __Operation::first_argument_type, typename __Operation::result_type>
27 typename __Operation::result_type>
28{27{
29protected:28protected:
30 __Operation op;29 __Operation op;
lib/libcxx/include/__functional/boyer_moore_searcher.h created+313
...@@ -0,0 +1,313 @@
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___FUNCTIONAL_BOYER_MOORE_SEARCHER_H
10#define _LIBCPP___FUNCTIONAL_BOYER_MOORE_SEARCHER_H
11
12#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
13# pragma GCC system_header
14#endif
15
16#include <__algorithm/fill_n.h>
17#include <__config>
18#include <__functional/hash.h>
19#include <__functional/operations.h>
20#include <__iterator/distance.h>
21#include <__iterator/iterator_traits.h>
22#include <__memory/shared_ptr.h>
23#include <__utility/pair.h>
24#include <array>
25#include <unordered_map>
26#include <vector>
27
28#if _LIBCPP_STD_VER > 14
29
30_LIBCPP_PUSH_MACROS
31#include <__undef_macros>
32
33_LIBCPP_BEGIN_NAMESPACE_STD
34
35template <class _Key,
36 class _Value,
37 class _Hash,
38 class _BinaryPredicate,
39 bool /*useArray*/>
40class _BMSkipTable;
41
42// General case for BM data searching; use a map
43template <class _Key,
44 class _Value,
45 class _Hash,
46 class _BinaryPredicate>
47class _BMSkipTable<_Key, _Value, _Hash, _BinaryPredicate, false> {
48private:
49 using value_type = _Value;
50 using key_type = _Key;
51
52 const value_type __default_value_;
53 unordered_map<_Key, _Value, _Hash, _BinaryPredicate> __table_;
54
55public:
56 _LIBCPP_HIDE_FROM_ABI
57 explicit _BMSkipTable(size_t __sz, value_type __default_value, _Hash __hash, _BinaryPredicate __pred)
58 : __default_value_(__default_value),
59 __table_(__sz, __hash, __pred) {}
60
61 _LIBCPP_HIDE_FROM_ABI void insert(const key_type& __key, value_type __val) {
62 __table_[__key] = __val;
63 }
64
65 _LIBCPP_HIDE_FROM_ABI value_type operator[](const key_type& __key) const {
66 auto __it = __table_.find(__key);
67 return __it == __table_.end() ? __default_value_ : __it->second;
68 }
69};
70
71// Special case small numeric values; use an array
72template <class _Key,
73 class _Value,
74 class _Hash,
75 class _BinaryPredicate>
76class _BMSkipTable<_Key, _Value, _Hash, _BinaryPredicate, true> {
77private:
78 using value_type = _Value;
79 using key_type = _Key;
80
81 using unsigned_key_type = make_unsigned_t<key_type>;
82 std::array<value_type, 256> __table_;
83 static_assert(numeric_limits<unsigned_key_type>::max() < 256);
84
85public:
86 _LIBCPP_HIDE_FROM_ABI explicit _BMSkipTable(size_t, value_type __default_value, _Hash, _BinaryPredicate) {
87 std::fill_n(__table_.data(), __table_.size(), __default_value);
88 }
89
90 _LIBCPP_HIDE_FROM_ABI void insert(key_type __key, value_type __val) {
91 __table_[static_cast<unsigned_key_type>(__key)] = __val;
92 }
93
94 _LIBCPP_HIDE_FROM_ABI value_type operator[](key_type __key) const {
95 return __table_[static_cast<unsigned_key_type>(__key)];
96 }
97};
98
99template <class _RandomAccessIterator1,
100 class _Hash = hash<typename iterator_traits<_RandomAccessIterator1>::value_type>,
101 class _BinaryPredicate = equal_to<>>
102class _LIBCPP_TEMPLATE_VIS boyer_moore_searcher {
103private:
104 using difference_type = typename std::iterator_traits<_RandomAccessIterator1>::difference_type;
105 using value_type = typename std::iterator_traits<_RandomAccessIterator1>::value_type;
106 using __skip_table_type = _BMSkipTable<value_type,
107 difference_type,
108 _Hash,
109 _BinaryPredicate,
110 is_integral_v<value_type>
111 && sizeof(value_type) == 1
112 && is_same_v<_Hash, hash<value_type>>
113 && is_same_v<_BinaryPredicate, equal_to<>>>;
114
115public:
116 boyer_moore_searcher(_RandomAccessIterator1 __first,
117 _RandomAccessIterator1 __last,
118 _Hash __hash = _Hash(),
119 _BinaryPredicate __pred = _BinaryPredicate())
120 : __first_(__first),
121 __last_(__last),
122 __pred_(__pred),
123 __pattern_length_(__last - __first),
124 __skip_table_(std::make_shared<__skip_table_type>(__pattern_length_, -1, __hash, __pred_)),
125 __suffix_(std::__allocate_shared_unbounded_array<difference_type[]>(
126 allocator<difference_type>(), __pattern_length_ + 1)) {
127 difference_type __i = 0;
128 while (__first != __last) {
129 __skip_table_->insert(*__first, __i);
130 ++__first;
131 ++__i;
132 }
133 __build_suffix_table(__first_, __last_, __pred_);
134 }
135
136 template <class _RandomAccessIterator2>
137 pair<_RandomAccessIterator2, _RandomAccessIterator2>
138 operator()(_RandomAccessIterator2 __first, _RandomAccessIterator2 __last) const {
139 static_assert(__is_same_uncvref<typename iterator_traits<_RandomAccessIterator1>::value_type,
140 typename iterator_traits<_RandomAccessIterator2>::value_type>::value,
141 "Corpus and Pattern iterators must point to the same type");
142 if (__first == __last)
143 return std::make_pair(__last, __last);
144 if (__first_ == __last_)
145 return std::make_pair(__first, __first);
146
147 if (__pattern_length_ > (__last - __first))
148 return std::make_pair(__last, __last);
149 return __search(__first, __last);
150 }
151
152private:
153 _RandomAccessIterator1 __first_;
154 _RandomAccessIterator1 __last_;
155 _BinaryPredicate __pred_;
156 difference_type __pattern_length_;
157 shared_ptr<__skip_table_type> __skip_table_;
158 shared_ptr<difference_type[]> __suffix_;
159
160 template <class _RandomAccessIterator2>
161 pair<_RandomAccessIterator2, _RandomAccessIterator2>
162 __search(_RandomAccessIterator2 __f, _RandomAccessIterator2 __l) const {
163 _RandomAccessIterator2 __current = __f;
164 const _RandomAccessIterator2 __last = __l - __pattern_length_;
165 const __skip_table_type& __skip_table = *__skip_table_;
166
167 while (__current <= __last) {
168 difference_type __j = __pattern_length_;
169 while (__pred_(__first_[__j - 1], __current[__j - 1])) {
170 --__j;
171 if (__j == 0)
172 return std::make_pair(__current, __current + __pattern_length_);
173 }
174
175 difference_type __k = __skip_table[__current[__j - 1]];
176 difference_type __m = __j - __k - 1;
177 if (__k < __j && __m > __suffix_[__j])
178 __current += __m;
179 else
180 __current += __suffix_[__j];
181 }
182 return std::make_pair(__l, __l);
183 }
184
185 template <class _Iterator, class _Container>
186 void __compute_bm_prefix(_Iterator __first, _Iterator __last, _BinaryPredicate __pred, _Container& __prefix) {
187 const size_t __count = __last - __first;
188
189 __prefix[0] = 0;
190 size_t __k = 0;
191
192 for (size_t __i = 1; __i != __count; ++__i) {
193 while (__k > 0 && !__pred(__first[__k], __first[__i]))
194 __k = __prefix[__k - 1];
195
196 if (__pred(__first[__k], __first[__i]))
197 ++__k;
198 __prefix[__i] = __k;
199 }
200 }
201
202 void __build_suffix_table(_RandomAccessIterator1 __first, _RandomAccessIterator1 __last, _BinaryPredicate __pred) {
203 const size_t __count = __last - __first;
204
205 if (__count == 0)
206 return;
207
208 vector<difference_type> __scratch(__count);
209
210 __compute_bm_prefix(__first, __last, __pred, __scratch);
211 for (size_t __i = 0; __i <= __count; ++__i)
212 __suffix_[__i] = __count - __scratch[__count - 1];
213
214 using _ReverseIter = reverse_iterator<_RandomAccessIterator1>;
215 __compute_bm_prefix(_ReverseIter(__last), _ReverseIter(__first), __pred, __scratch);
216
217 for (size_t __i = 0; __i != __count; ++__i) {
218 const size_t __j = __count - __scratch[__i];
219 const difference_type __k = __i - __scratch[__i] + 1;
220
221 if (__suffix_[__j] > __k)
222 __suffix_[__j] = __k;
223 }
224 }
225};
226
227template <class _RandomAccessIterator1,
228 class _Hash = hash<typename iterator_traits<_RandomAccessIterator1>::value_type>,
229 class _BinaryPredicate = equal_to<>>
230class _LIBCPP_TEMPLATE_VIS boyer_moore_horspool_searcher {
231private:
232 using difference_type = typename iterator_traits<_RandomAccessIterator1>::difference_type;
233 using value_type = typename iterator_traits<_RandomAccessIterator1>::value_type;
234 using __skip_table_type = _BMSkipTable<value_type,
235 difference_type,
236 _Hash,
237 _BinaryPredicate,
238 is_integral_v<value_type>
239 && sizeof(value_type) == 1
240 && is_same_v<_Hash, hash<value_type>>
241 && is_same_v<_BinaryPredicate, equal_to<>>>;
242public:
243 boyer_moore_horspool_searcher(_RandomAccessIterator1 __first,
244 _RandomAccessIterator1 __last,
245 _Hash __hash = _Hash(),
246 _BinaryPredicate __pred = _BinaryPredicate())
247 : __first_(__first),
248 __last_(__last),
249 __pred_(__pred),
250 __pattern_length_(__last - __first),
251 __skip_table_(std::make_shared<__skip_table_type>(__pattern_length_, __pattern_length_, __hash, __pred_)) {
252 if (__first == __last)
253 return;
254 --__last;
255 difference_type __i = 0;
256 while (__first != __last) {
257 __skip_table_->insert(*__first, __pattern_length_ - 1 - __i);
258 ++__first;
259 ++__i;
260 }
261 }
262
263 template <class _RandomAccessIterator2>
264 pair<_RandomAccessIterator2, _RandomAccessIterator2>
265 operator()(_RandomAccessIterator2 __first, _RandomAccessIterator2 __last) const {
266 static_assert(__is_same_uncvref<typename std::iterator_traits<_RandomAccessIterator1>::value_type,
267 typename std::iterator_traits<_RandomAccessIterator2>::value_type>::value,
268 "Corpus and Pattern iterators must point to the same type");
269 if (__first == __last)
270 return std::make_pair(__last, __last);
271 if (__first_ == __last_)
272 return std::make_pair(__first, __first);
273
274 if (__pattern_length_ > __last - __first)
275 return std::make_pair(__last, __last);
276
277 return __search(__first, __last);
278 }
279
280private:
281 _RandomAccessIterator1 __first_;
282 _RandomAccessIterator1 __last_;
283 _BinaryPredicate __pred_;
284 difference_type __pattern_length_;
285 shared_ptr<__skip_table_type> __skip_table_;
286
287 template <class _RandomAccessIterator2>
288 pair<_RandomAccessIterator2, _RandomAccessIterator2>
289 __search(_RandomAccessIterator2 __f, _RandomAccessIterator2 __l) const {
290 _RandomAccessIterator2 __current = __f;
291 const _RandomAccessIterator2 __last = __l - __pattern_length_;
292 const __skip_table_type& __skip_table = *__skip_table_;
293
294 while (__current <= __last) {
295 difference_type __j = __pattern_length_;
296 while (__pred_(__first_[__j - 1], __current[__j - 1])) {
297 --__j;
298 if (__j == 0)
299 return std::make_pair(__current, __current + __pattern_length_);
300 }
301 __current += __skip_table[__current[__pattern_length_ - 1]];
302 }
303 return std::make_pair(__l, __l);
304 }
305};
306
307_LIBCPP_END_NAMESPACE_STD
308
309_LIBCPP_POP_MACROS
310
311#endif // _LIBCPP_STD_VER > 14
312
313#endif // _LIBCPP___FUNCTIONAL_BOYER_MOORE_SEARCHER_H
lib/libcxx/include/__functional/compose.h+1-1
...@@ -17,7 +17,7 @@...@@ -17,7 +17,7 @@
17#include <type_traits>17#include <type_traits>
1818
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20#pragma GCC system_header20# pragma GCC system_header
21#endif21#endif
2222
23_LIBCPP_BEGIN_NAMESPACE_STD23_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__functional/default_searcher.h+6-6
...@@ -12,12 +12,13 @@...@@ -12,12 +12,13 @@
1212
13#include <__algorithm/search.h>13#include <__algorithm/search.h>
14#include <__config>14#include <__config>
15#include <__functional/identity.h>
15#include <__functional/operations.h>16#include <__functional/operations.h>
16#include <__iterator/iterator_traits.h>17#include <__iterator/iterator_traits.h>
17#include <utility>18#include <__utility/pair.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
21#endif22#endif
2223
23_LIBCPP_BEGIN_NAMESPACE_STD24_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -38,16 +39,15 @@ public:...@@ -38,16 +39,15 @@ public:
38 pair<_ForwardIterator2, _ForwardIterator2>39 pair<_ForwardIterator2, _ForwardIterator2>
39 operator () (_ForwardIterator2 __f, _ForwardIterator2 __l) const40 operator () (_ForwardIterator2 __f, _ForwardIterator2 __l) const
40 {41 {
41 return _VSTD::__search(__f, __l, __first_, __last_, __pred_,42 auto __proj = __identity();
42 typename iterator_traits<_ForwardIterator>::iterator_category(),43 return std::__search_impl(__f, __l, __first_, __last_, __pred_, __proj, __proj);
43 typename iterator_traits<_ForwardIterator2>::iterator_category());
44 }44 }
4545
46private:46private:
47 _ForwardIterator __first_;47 _ForwardIterator __first_;
48 _ForwardIterator __last_;48 _ForwardIterator __last_;
49 _BinaryPredicate __pred_;49 _BinaryPredicate __pred_;
50 };50};
5151
52#endif // _LIBCPP_STD_VER > 1452#endif // _LIBCPP_STD_VER > 14
5353
lib/libcxx/include/__functional/function.h+14-11
...@@ -10,8 +10,8 @@...@@ -10,8 +10,8 @@
10#ifndef _LIBCPP___FUNCTIONAL_FUNCTION_H10#ifndef _LIBCPP___FUNCTIONAL_FUNCTION_H
11#define _LIBCPP___FUNCTIONAL_FUNCTION_H11#define _LIBCPP___FUNCTIONAL_FUNCTION_H
1212
13#include <__assert>
13#include <__config>14#include <__config>
14#include <__debug>
15#include <__functional/binary_function.h>15#include <__functional/binary_function.h>
16#include <__functional/invoke.h>16#include <__functional/invoke.h>
17#include <__functional/unary_function.h>17#include <__functional/unary_function.h>
...@@ -20,19 +20,23 @@...@@ -20,19 +20,23 @@
20#include <__memory/allocator_traits.h>20#include <__memory/allocator_traits.h>
21#include <__memory/compressed_pair.h>21#include <__memory/compressed_pair.h>
22#include <__memory/shared_ptr.h>22#include <__memory/shared_ptr.h>
23#include <__utility/forward.h>
24#include <__utility/move.h>
25#include <__utility/swap.h>
23#include <exception>26#include <exception>
24#include <memory> // TODO: replace with <__memory/__builtin_new_allocator.h>27#include <memory> // TODO: replace with <__memory/__builtin_new_allocator.h>
25#include <type_traits>28#include <type_traits>
26#include <utility>
2729
28#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)30#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
29#pragma GCC system_header31# pragma GCC system_header
30#endif32#endif
3133
32_LIBCPP_BEGIN_NAMESPACE_STD34_LIBCPP_BEGIN_NAMESPACE_STD
3335
34// bad_function_call36// bad_function_call
3537
38_LIBCPP_DIAGNOSTIC_PUSH
39_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wweak-vtables")
36class _LIBCPP_EXCEPTION_ABI bad_function_call40class _LIBCPP_EXCEPTION_ABI bad_function_call
37 : public exception41 : public exception
38{42{
...@@ -50,6 +54,7 @@ public:...@@ -50,6 +54,7 @@ public:
50 virtual const char* what() const _NOEXCEPT;54 virtual const char* what() const _NOEXCEPT;
51#endif55#endif
52};56};
57_LIBCPP_DIAGNOSTIC_POP
5358
54_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY59_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
55void __throw_bad_function_call()60void __throw_bad_function_call()
...@@ -80,7 +85,7 @@ struct __maybe_derive_from_unary_function...@@ -80,7 +85,7 @@ struct __maybe_derive_from_unary_function
8085
81template<class _Rp, class _A1>86template<class _Rp, class _A1>
82struct __maybe_derive_from_unary_function<_Rp(_A1)>87struct __maybe_derive_from_unary_function<_Rp(_A1)>
83 : public unary_function<_A1, _Rp>88 : public __unary_function<_A1, _Rp>
84{89{
85};90};
8691
...@@ -91,7 +96,7 @@ struct __maybe_derive_from_binary_function...@@ -91,7 +96,7 @@ struct __maybe_derive_from_binary_function
9196
92template<class _Rp, class _A1, class _A2>97template<class _Rp, class _A1, class _A2>
93struct __maybe_derive_from_binary_function<_Rp(_A1, _A2)>98struct __maybe_derive_from_binary_function<_Rp(_A1, _A2)>
94 : public binary_function<_A1, _A2, _Rp>99 : public __binary_function<_A1, _A2, _Rp>
95{100{
96};101};
97102
...@@ -385,9 +390,9 @@ template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)>...@@ -385,9 +390,9 @@ template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)>
385 typedef __base<_Rp(_ArgTypes...)> __func;390 typedef __base<_Rp(_ArgTypes...)> __func;
386 __func* __f_;391 __func* __f_;
387392
388 _LIBCPP_NO_CFI static __func* __as_base(void* p)393 _LIBCPP_NO_CFI static __func* __as_base(void* __p)
389 {394 {
390 return reinterpret_cast<__func*>(p);395 return reinterpret_cast<__func*>(__p);
391 }396 }
392397
393 public:398 public:
...@@ -951,10 +956,8 @@ public:...@@ -951,10 +956,8 @@ public:
951956
952template<class _Rp, class ..._ArgTypes>957template<class _Rp, class ..._ArgTypes>
953class _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)>958class _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)>
954#if _LIBCPP_STD_VER <= 17 || !defined(_LIBCPP_ABI_NO_BINDER_BASES)
955 : public __function::__maybe_derive_from_unary_function<_Rp(_ArgTypes...)>,959 : public __function::__maybe_derive_from_unary_function<_Rp(_ArgTypes...)>,
956 public __function::__maybe_derive_from_binary_function<_Rp(_ArgTypes...)>960 public __function::__maybe_derive_from_binary_function<_Rp(_ArgTypes...)>
957#endif
958{961{
959#ifndef _LIBCPP_ABI_OPTIMIZED_FUNCTION962#ifndef _LIBCPP_ABI_OPTIMIZED_FUNCTION
960 typedef __function::__value_func<_Rp(_ArgTypes...)> __func;963 typedef __function::__value_func<_Rp(_ArgTypes...)> __func;
...@@ -1237,7 +1240,7 @@ void...@@ -1237,7 +1240,7 @@ void
1237swap(function<_Rp(_ArgTypes...)>& __x, function<_Rp(_ArgTypes...)>& __y) _NOEXCEPT1240swap(function<_Rp(_ArgTypes...)>& __x, function<_Rp(_ArgTypes...)>& __y) _NOEXCEPT
1238{return __x.swap(__y);}1241{return __x.swap(__y);}
12391242
1240#else // _LIBCPP_CXX03_LANG1243#elif defined(_LIBCPP_ENABLE_CXX03_FUNCTION)
12411244
1242namespace __function {1245namespace __function {
12431246
...@@ -2803,7 +2806,7 @@ void...@@ -2803,7 +2806,7 @@ void
2803swap(function<_Fp>& __x, function<_Fp>& __y)2806swap(function<_Fp>& __x, function<_Fp>& __y)
2804{return __x.swap(__y);}2807{return __x.swap(__y);}
28052808
2806#endif2809#endif // _LIBCPP_CXX03_LANG
28072810
2808_LIBCPP_END_NAMESPACE_STD2811_LIBCPP_END_NAMESPACE_STD
28092812
lib/libcxx/include/__functional/hash.h+24-207
...@@ -23,7 +23,7 @@...@@ -23,7 +23,7 @@
23#include <type_traits>23#include <type_traits>
2424
25#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)25#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
26#pragma GCC system_header26# pragma GCC system_header
27#endif27#endif
2828
29_LIBCPP_BEGIN_NAMESPACE_STD29_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -265,18 +265,10 @@ __murmur2_or_cityhash<_Size, 64>::operator()(const void* __key, _Size __len)...@@ -265,18 +265,10 @@ __murmur2_or_cityhash<_Size, 64>::operator()(const void* __key, _Size __len)
265template <class _Tp, size_t = sizeof(_Tp) / sizeof(size_t)>265template <class _Tp, size_t = sizeof(_Tp) / sizeof(size_t)>
266struct __scalar_hash;266struct __scalar_hash;
267267
268_LIBCPP_SUPPRESS_DEPRECATED_PUSH
269template <class _Tp>268template <class _Tp>
270struct __scalar_hash<_Tp, 0>269struct __scalar_hash<_Tp, 0>
271#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)270 : public __unary_function<_Tp, size_t>
272 : public unary_function<_Tp, size_t>
273#endif
274{271{
275_LIBCPP_SUPPRESS_DEPRECATED_POP
276#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
277 _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
278 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type;
279#endif
280 _LIBCPP_INLINE_VISIBILITY272 _LIBCPP_INLINE_VISIBILITY
281 size_t operator()(_Tp __v) const _NOEXCEPT273 size_t operator()(_Tp __v) const _NOEXCEPT
282 {274 {
...@@ -291,18 +283,10 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP...@@ -291,18 +283,10 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP
291 }283 }
292};284};
293285
294_LIBCPP_SUPPRESS_DEPRECATED_PUSH
295template <class _Tp>286template <class _Tp>
296struct __scalar_hash<_Tp, 1>287struct __scalar_hash<_Tp, 1>
297#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)288 : public __unary_function<_Tp, size_t>
298 : public unary_function<_Tp, size_t>
299#endif
300{289{
301_LIBCPP_SUPPRESS_DEPRECATED_POP
302#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
303 _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
304 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type;
305#endif
306 _LIBCPP_INLINE_VISIBILITY290 _LIBCPP_INLINE_VISIBILITY
307 size_t operator()(_Tp __v) const _NOEXCEPT291 size_t operator()(_Tp __v) const _NOEXCEPT
308 {292 {
...@@ -316,18 +300,10 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP...@@ -316,18 +300,10 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP
316 }300 }
317};301};
318302
319_LIBCPP_SUPPRESS_DEPRECATED_PUSH
320template <class _Tp>303template <class _Tp>
321struct __scalar_hash<_Tp, 2>304struct __scalar_hash<_Tp, 2>
322#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)305 : public __unary_function<_Tp, size_t>
323 : public unary_function<_Tp, size_t>
324#endif
325{306{
326_LIBCPP_SUPPRESS_DEPRECATED_POP
327#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
328 _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
329 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type;
330#endif
331 _LIBCPP_INLINE_VISIBILITY307 _LIBCPP_INLINE_VISIBILITY
332 size_t operator()(_Tp __v) const _NOEXCEPT308 size_t operator()(_Tp __v) const _NOEXCEPT
333 {309 {
...@@ -345,18 +321,10 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP...@@ -345,18 +321,10 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP
345 }321 }
346};322};
347323
348_LIBCPP_SUPPRESS_DEPRECATED_PUSH
349template <class _Tp>324template <class _Tp>
350struct __scalar_hash<_Tp, 3>325struct __scalar_hash<_Tp, 3>
351#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)326 : public __unary_function<_Tp, size_t>
352 : public unary_function<_Tp, size_t>
353#endif
354{327{
355_LIBCPP_SUPPRESS_DEPRECATED_POP
356#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
357 _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
358 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type;
359#endif
360 _LIBCPP_INLINE_VISIBILITY328 _LIBCPP_INLINE_VISIBILITY
361 size_t operator()(_Tp __v) const _NOEXCEPT329 size_t operator()(_Tp __v) const _NOEXCEPT
362 {330 {
...@@ -375,18 +343,10 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP...@@ -375,18 +343,10 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP
375 }343 }
376};344};
377345
378_LIBCPP_SUPPRESS_DEPRECATED_PUSH
379template <class _Tp>346template <class _Tp>
380struct __scalar_hash<_Tp, 4>347struct __scalar_hash<_Tp, 4>
381#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)348 : public __unary_function<_Tp, size_t>
382 : public unary_function<_Tp, size_t>
383#endif
384{349{
385_LIBCPP_SUPPRESS_DEPRECATED_POP
386#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
387 _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
388 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type;
389#endif
390 _LIBCPP_INLINE_VISIBILITY350 _LIBCPP_INLINE_VISIBILITY
391 size_t operator()(_Tp __v) const _NOEXCEPT351 size_t operator()(_Tp __v) const _NOEXCEPT
392 {352 {
...@@ -418,18 +378,10 @@ inline size_t __hash_combine(size_t __lhs, size_t __rhs) _NOEXCEPT {...@@ -418,18 +378,10 @@ inline size_t __hash_combine(size_t __lhs, size_t __rhs) _NOEXCEPT {
418 return _HashT()(__p);378 return _HashT()(__p);
419}379}
420380
421_LIBCPP_SUPPRESS_DEPRECATED_PUSH
422template<class _Tp>381template<class _Tp>
423struct _LIBCPP_TEMPLATE_VIS hash<_Tp*>382struct _LIBCPP_TEMPLATE_VIS hash<_Tp*>
424#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)383 : public __unary_function<_Tp*, size_t>
425 : public unary_function<_Tp*, size_t>
426#endif
427{384{
428_LIBCPP_SUPPRESS_DEPRECATED_POP
429#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
430 _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
431 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp* argument_type;
432#endif
433 _LIBCPP_INLINE_VISIBILITY385 _LIBCPP_INLINE_VISIBILITY
434 size_t operator()(_Tp* __v) const _NOEXCEPT386 size_t operator()(_Tp* __v) const _NOEXCEPT
435 {387 {
...@@ -443,234 +395,118 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP...@@ -443,234 +395,118 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP
443 }395 }
444};396};
445397
446_LIBCPP_SUPPRESS_DEPRECATED_PUSH
447template <>398template <>
448struct _LIBCPP_TEMPLATE_VIS hash<bool>399struct _LIBCPP_TEMPLATE_VIS hash<bool>
449#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)400 : public __unary_function<bool, size_t>
450 : public unary_function<bool, size_t>
451#endif
452{401{
453_LIBCPP_SUPPRESS_DEPRECATED_POP
454#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
455 _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
456 _LIBCPP_DEPRECATED_IN_CXX17 typedef bool argument_type;
457#endif
458 _LIBCPP_INLINE_VISIBILITY402 _LIBCPP_INLINE_VISIBILITY
459 size_t operator()(bool __v) const _NOEXCEPT {return static_cast<size_t>(__v);}403 size_t operator()(bool __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
460};404};
461405
462_LIBCPP_SUPPRESS_DEPRECATED_PUSH
463template <>406template <>
464struct _LIBCPP_TEMPLATE_VIS hash<char>407struct _LIBCPP_TEMPLATE_VIS hash<char>
465#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)408 : public __unary_function<char, size_t>
466 : public unary_function<char, size_t>
467#endif
468{409{
469_LIBCPP_SUPPRESS_DEPRECATED_POP
470#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
471 _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
472 _LIBCPP_DEPRECATED_IN_CXX17 typedef char argument_type;
473#endif
474 _LIBCPP_INLINE_VISIBILITY410 _LIBCPP_INLINE_VISIBILITY
475 size_t operator()(char __v) const _NOEXCEPT {return static_cast<size_t>(__v);}411 size_t operator()(char __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
476};412};
477413
478_LIBCPP_SUPPRESS_DEPRECATED_PUSH
479template <>414template <>
480struct _LIBCPP_TEMPLATE_VIS hash<signed char>415struct _LIBCPP_TEMPLATE_VIS hash<signed char>
481#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)416 : public __unary_function<signed char, size_t>
482 : public unary_function<signed char, size_t>
483#endif
484{417{
485_LIBCPP_SUPPRESS_DEPRECATED_POP
486#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
487 _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
488 _LIBCPP_DEPRECATED_IN_CXX17 typedef signed char argument_type;
489#endif
490 _LIBCPP_INLINE_VISIBILITY418 _LIBCPP_INLINE_VISIBILITY
491 size_t operator()(signed char __v) const _NOEXCEPT {return static_cast<size_t>(__v);}419 size_t operator()(signed char __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
492};420};
493421
494_LIBCPP_SUPPRESS_DEPRECATED_PUSH
495template <>422template <>
496struct _LIBCPP_TEMPLATE_VIS hash<unsigned char>423struct _LIBCPP_TEMPLATE_VIS hash<unsigned char>
497#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)424 : public __unary_function<unsigned char, size_t>
498 : public unary_function<unsigned char, size_t>
499#endif
500{425{
501_LIBCPP_SUPPRESS_DEPRECATED_POP
502#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
503 _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
504 _LIBCPP_DEPRECATED_IN_CXX17 typedef unsigned char argument_type;
505#endif
506 _LIBCPP_INLINE_VISIBILITY426 _LIBCPP_INLINE_VISIBILITY
507 size_t operator()(unsigned char __v) const _NOEXCEPT {return static_cast<size_t>(__v);}427 size_t operator()(unsigned char __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
508};428};
509429
510#ifndef _LIBCPP_HAS_NO_CHAR8_T430#ifndef _LIBCPP_HAS_NO_CHAR8_T
511_LIBCPP_SUPPRESS_DEPRECATED_PUSH
512template <>431template <>
513struct _LIBCPP_TEMPLATE_VIS hash<char8_t>432struct _LIBCPP_TEMPLATE_VIS hash<char8_t>
514#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)433 : public __unary_function<char8_t, size_t>
515 : public unary_function<char8_t, size_t>
516#endif
517{434{
518_LIBCPP_SUPPRESS_DEPRECATED_POP
519#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
520 _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
521 _LIBCPP_DEPRECATED_IN_CXX17 typedef char8_t argument_type;
522#endif
523 _LIBCPP_INLINE_VISIBILITY435 _LIBCPP_INLINE_VISIBILITY
524 size_t operator()(char8_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);}436 size_t operator()(char8_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
525};437};
526#endif // !_LIBCPP_HAS_NO_CHAR8_T438#endif // !_LIBCPP_HAS_NO_CHAR8_T
527439
528#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
529
530_LIBCPP_SUPPRESS_DEPRECATED_PUSH
531template <>440template <>
532struct _LIBCPP_TEMPLATE_VIS hash<char16_t>441struct _LIBCPP_TEMPLATE_VIS hash<char16_t>
533#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)442 : public __unary_function<char16_t, size_t>
534 : public unary_function<char16_t, size_t>
535#endif
536{443{
537_LIBCPP_SUPPRESS_DEPRECATED_POP
538#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
539 _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
540 _LIBCPP_DEPRECATED_IN_CXX17 typedef char16_t argument_type;
541#endif
542 _LIBCPP_INLINE_VISIBILITY444 _LIBCPP_INLINE_VISIBILITY
543 size_t operator()(char16_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);}445 size_t operator()(char16_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
544};446};
545447
546_LIBCPP_SUPPRESS_DEPRECATED_PUSH
547template <>448template <>
548struct _LIBCPP_TEMPLATE_VIS hash<char32_t>449struct _LIBCPP_TEMPLATE_VIS hash<char32_t>
549#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)450 : public __unary_function<char32_t, size_t>
550 : public unary_function<char32_t, size_t>
551#endif
552{451{
553_LIBCPP_SUPPRESS_DEPRECATED_POP
554#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
555 _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
556 _LIBCPP_DEPRECATED_IN_CXX17 typedef char32_t argument_type;
557#endif
558 _LIBCPP_INLINE_VISIBILITY452 _LIBCPP_INLINE_VISIBILITY
559 size_t operator()(char32_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);}453 size_t operator()(char32_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
560};454};
561455
562#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
563
564#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS456#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
565_LIBCPP_SUPPRESS_DEPRECATED_PUSH
566template <>457template <>
567struct _LIBCPP_TEMPLATE_VIS hash<wchar_t>458struct _LIBCPP_TEMPLATE_VIS hash<wchar_t>
568#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)459 : public __unary_function<wchar_t, size_t>
569 : public unary_function<wchar_t, size_t>
570#endif
571{460{
572_LIBCPP_SUPPRESS_DEPRECATED_POP
573#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
574 _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
575 _LIBCPP_DEPRECATED_IN_CXX17 typedef wchar_t argument_type;
576#endif
577 _LIBCPP_INLINE_VISIBILITY461 _LIBCPP_INLINE_VISIBILITY
578 size_t operator()(wchar_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);}462 size_t operator()(wchar_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
579};463};
580#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS464#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
581465
582_LIBCPP_SUPPRESS_DEPRECATED_PUSH
583template <>466template <>
584struct _LIBCPP_TEMPLATE_VIS hash<short>467struct _LIBCPP_TEMPLATE_VIS hash<short>
585#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)468 : public __unary_function<short, size_t>
586 : public unary_function<short, size_t>
587#endif
588{469{
589_LIBCPP_SUPPRESS_DEPRECATED_POP
590#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
591 _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
592 _LIBCPP_DEPRECATED_IN_CXX17 typedef short argument_type;
593#endif
594 _LIBCPP_INLINE_VISIBILITY470 _LIBCPP_INLINE_VISIBILITY
595 size_t operator()(short __v) const _NOEXCEPT {return static_cast<size_t>(__v);}471 size_t operator()(short __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
596};472};
597473
598_LIBCPP_SUPPRESS_DEPRECATED_PUSH
599template <>474template <>
600struct _LIBCPP_TEMPLATE_VIS hash<unsigned short>475struct _LIBCPP_TEMPLATE_VIS hash<unsigned short>
601#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)476 : public __unary_function<unsigned short, size_t>
602 : public unary_function<unsigned short, size_t>
603#endif
604{477{
605_LIBCPP_SUPPRESS_DEPRECATED_POP
606#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
607 _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
608 _LIBCPP_DEPRECATED_IN_CXX17 typedef unsigned short argument_type;
609#endif
610 _LIBCPP_INLINE_VISIBILITY478 _LIBCPP_INLINE_VISIBILITY
611 size_t operator()(unsigned short __v) const _NOEXCEPT {return static_cast<size_t>(__v);}479 size_t operator()(unsigned short __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
612};480};
613481
614_LIBCPP_SUPPRESS_DEPRECATED_PUSH
615template <>482template <>
616struct _LIBCPP_TEMPLATE_VIS hash<int>483struct _LIBCPP_TEMPLATE_VIS hash<int>
617#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)484 : public __unary_function<int, size_t>
618 : public unary_function<int, size_t>
619#endif
620{485{
621_LIBCPP_SUPPRESS_DEPRECATED_POP
622#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
623 _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
624 _LIBCPP_DEPRECATED_IN_CXX17 typedef int argument_type;
625#endif
626 _LIBCPP_INLINE_VISIBILITY486 _LIBCPP_INLINE_VISIBILITY
627 size_t operator()(int __v) const _NOEXCEPT {return static_cast<size_t>(__v);}487 size_t operator()(int __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
628};488};
629489
630_LIBCPP_SUPPRESS_DEPRECATED_PUSH
631template <>490template <>
632struct _LIBCPP_TEMPLATE_VIS hash<unsigned int>491struct _LIBCPP_TEMPLATE_VIS hash<unsigned int>
633#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)492 : public __unary_function<unsigned int, size_t>
634 : public unary_function<unsigned int, size_t>
635#endif
636{493{
637_LIBCPP_SUPPRESS_DEPRECATED_POP
638#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
639 _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
640 _LIBCPP_DEPRECATED_IN_CXX17 typedef unsigned int argument_type;
641#endif
642 _LIBCPP_INLINE_VISIBILITY494 _LIBCPP_INLINE_VISIBILITY
643 size_t operator()(unsigned int __v) const _NOEXCEPT {return static_cast<size_t>(__v);}495 size_t operator()(unsigned int __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
644};496};
645497
646_LIBCPP_SUPPRESS_DEPRECATED_PUSH
647template <>498template <>
648struct _LIBCPP_TEMPLATE_VIS hash<long>499struct _LIBCPP_TEMPLATE_VIS hash<long>
649#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)500 : public __unary_function<long, size_t>
650 : public unary_function<long, size_t>
651#endif
652{501{
653_LIBCPP_SUPPRESS_DEPRECATED_POP
654#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
655 _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
656 _LIBCPP_DEPRECATED_IN_CXX17 typedef long argument_type;
657#endif
658 _LIBCPP_INLINE_VISIBILITY502 _LIBCPP_INLINE_VISIBILITY
659 size_t operator()(long __v) const _NOEXCEPT {return static_cast<size_t>(__v);}503 size_t operator()(long __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
660};504};
661505
662_LIBCPP_SUPPRESS_DEPRECATED_PUSH
663template <>506template <>
664struct _LIBCPP_TEMPLATE_VIS hash<unsigned long>507struct _LIBCPP_TEMPLATE_VIS hash<unsigned long>
665#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)508 : public __unary_function<unsigned long, size_t>
666 : public unary_function<unsigned long, size_t>
667#endif
668{509{
669_LIBCPP_SUPPRESS_DEPRECATED_POP
670#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
671 _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
672 _LIBCPP_DEPRECATED_IN_CXX17 typedef unsigned long argument_type;
673#endif
674 _LIBCPP_INLINE_VISIBILITY510 _LIBCPP_INLINE_VISIBILITY
675 size_t operator()(unsigned long __v) const _NOEXCEPT {return static_cast<size_t>(__v);}511 size_t operator()(unsigned long __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
676};512};
...@@ -781,25 +617,15 @@ struct _LIBCPP_TEMPLATE_VIS hash<long double>...@@ -781,25 +617,15 @@ struct _LIBCPP_TEMPLATE_VIS hash<long double>
781 }617 }
782};618};
783619
784#if _LIBCPP_STD_VER > 11
785
786_LIBCPP_SUPPRESS_DEPRECATED_PUSH
787template <class _Tp, bool = is_enum<_Tp>::value>620template <class _Tp, bool = is_enum<_Tp>::value>
788struct _LIBCPP_TEMPLATE_VIS __enum_hash621struct _LIBCPP_TEMPLATE_VIS __enum_hash
789#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)622 : public __unary_function<_Tp, size_t>
790 : public unary_function<_Tp, size_t>
791#endif
792{623{
793_LIBCPP_SUPPRESS_DEPRECATED_POP
794#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
795 _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
796 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type;
797#endif
798 _LIBCPP_INLINE_VISIBILITY624 _LIBCPP_INLINE_VISIBILITY
799 size_t operator()(_Tp __v) const _NOEXCEPT625 size_t operator()(_Tp __v) const _NOEXCEPT
800 {626 {
801 typedef typename underlying_type<_Tp>::type type;627 typedef typename underlying_type<_Tp>::type type;
802 return hash<type>{}(static_cast<type>(__v));628 return hash<type>()(static_cast<type>(__v));
803 }629 }
804};630};
805template <class _Tp>631template <class _Tp>
...@@ -813,22 +639,13 @@ template <class _Tp>...@@ -813,22 +639,13 @@ template <class _Tp>
813struct _LIBCPP_TEMPLATE_VIS hash : public __enum_hash<_Tp>639struct _LIBCPP_TEMPLATE_VIS hash : public __enum_hash<_Tp>
814{640{
815};641};
816#endif
817642
818#if _LIBCPP_STD_VER > 14643#if _LIBCPP_STD_VER > 14
819644
820_LIBCPP_SUPPRESS_DEPRECATED_PUSH
821template <>645template <>
822struct _LIBCPP_TEMPLATE_VIS hash<nullptr_t>646struct _LIBCPP_TEMPLATE_VIS hash<nullptr_t>
823#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)647 : public __unary_function<nullptr_t, size_t>
824 : public unary_function<nullptr_t, size_t>
825#endif
826{648{
827_LIBCPP_SUPPRESS_DEPRECATED_POP
828#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
829 _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
830 _LIBCPP_DEPRECATED_IN_CXX17 typedef nullptr_t argument_type;
831#endif
832 _LIBCPP_INLINE_VISIBILITY649 _LIBCPP_INLINE_VISIBILITY
833 size_t operator()(nullptr_t) const _NOEXCEPT {650 size_t operator()(nullptr_t) const _NOEXCEPT {
834 return 662607004ull;651 return 662607004ull;
lib/libcxx/include/__functional/identity.h+11-2
...@@ -11,14 +11,23 @@...@@ -11,14 +11,23 @@
11#define _LIBCPP___FUNCTIONAL_IDENTITY_H11#define _LIBCPP___FUNCTIONAL_IDENTITY_H
1212
13#include <__config>13#include <__config>
14#include <utility>14#include <__utility/forward.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
18#endif18#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
2121
22struct __identity {
23 template <class _Tp>
24 _LIBCPP_NODISCARD _LIBCPP_CONSTEXPR _Tp&& operator()(_Tp&& __t) const _NOEXCEPT {
25 return std::forward<_Tp>(__t);
26 }
27
28 using is_transparent = void;
29};
30
22#if _LIBCPP_STD_VER > 1731#if _LIBCPP_STD_VER > 17
2332
24struct identity {33struct identity {
lib/libcxx/include/__functional/invoke.h+485-47
...@@ -11,79 +11,517 @@...@@ -11,79 +11,517 @@
11#define _LIBCPP___FUNCTIONAL_INVOKE_H11#define _LIBCPP___FUNCTIONAL_INVOKE_H
1212
13#include <__config>13#include <__config>
14#include <__functional/weak_result_type.h>14#include <__type_traits/add_lvalue_reference.h>
15#include <__type_traits/apply_cv.h>
16#include <__type_traits/conditional.h>
17#include <__type_traits/decay.h>
18#include <__type_traits/enable_if.h>
19#include <__type_traits/integral_constant.h>
20#include <__type_traits/is_base_of.h>
21#include <__type_traits/is_core_convertible.h>
22#include <__type_traits/is_member_function_pointer.h>
23#include <__type_traits/is_member_object_pointer.h>
24#include <__type_traits/is_reference_wrapper.h>
25#include <__type_traits/is_same.h>
26#include <__type_traits/is_void.h>
27#include <__type_traits/nat.h>
28#include <__type_traits/remove_cv.h>
29#include <__utility/declval.h>
15#include <__utility/forward.h>30#include <__utility/forward.h>
16#include <type_traits>
1731
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)32#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19#pragma GCC system_header33# pragma GCC system_header
20#endif34#endif
2135
36// TODO: Disentangle the type traits and std::invoke properly
37
22_LIBCPP_BEGIN_NAMESPACE_STD38_LIBCPP_BEGIN_NAMESPACE_STD
2339
40struct __any
41{
42 __any(...);
43};
44
45template <class _MP, bool _IsMemberFunctionPtr, bool _IsMemberObjectPtr>
46struct __member_pointer_traits_imp
47{
48};
49
50template <class _Rp, class _Class, class ..._Param>
51struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...), true, false>
52{
53 typedef _Class _ClassType;
54 typedef _Rp _ReturnType;
55 typedef _Rp (_FnType) (_Param...);
56};
57
58template <class _Rp, class _Class, class ..._Param>
59struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...), true, false>
60{
61 typedef _Class _ClassType;
62 typedef _Rp _ReturnType;
63 typedef _Rp (_FnType) (_Param..., ...);
64};
65
66template <class _Rp, class _Class, class ..._Param>
67struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const, true, false>
68{
69 typedef _Class const _ClassType;
70 typedef _Rp _ReturnType;
71 typedef _Rp (_FnType) (_Param...);
72};
73
74template <class _Rp, class _Class, class ..._Param>
75struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const, true, false>
76{
77 typedef _Class const _ClassType;
78 typedef _Rp _ReturnType;
79 typedef _Rp (_FnType) (_Param..., ...);
80};
81
82template <class _Rp, class _Class, class ..._Param>
83struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile, true, false>
84{
85 typedef _Class volatile _ClassType;
86 typedef _Rp _ReturnType;
87 typedef _Rp (_FnType) (_Param...);
88};
89
90template <class _Rp, class _Class, class ..._Param>
91struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile, true, false>
92{
93 typedef _Class volatile _ClassType;
94 typedef _Rp _ReturnType;
95 typedef _Rp (_FnType) (_Param..., ...);
96};
97
98template <class _Rp, class _Class, class ..._Param>
99struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile, true, false>
100{
101 typedef _Class const volatile _ClassType;
102 typedef _Rp _ReturnType;
103 typedef _Rp (_FnType) (_Param...);
104};
105
106template <class _Rp, class _Class, class ..._Param>
107struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile, true, false>
108{
109 typedef _Class const volatile _ClassType;
110 typedef _Rp _ReturnType;
111 typedef _Rp (_FnType) (_Param..., ...);
112};
113
114template <class _Rp, class _Class, class ..._Param>
115struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &, true, false>
116{
117 typedef _Class& _ClassType;
118 typedef _Rp _ReturnType;
119 typedef _Rp (_FnType) (_Param...);
120};
121
122template <class _Rp, class _Class, class ..._Param>
123struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &, true, false>
124{
125 typedef _Class& _ClassType;
126 typedef _Rp _ReturnType;
127 typedef _Rp (_FnType) (_Param..., ...);
128};
129
130template <class _Rp, class _Class, class ..._Param>
131struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&, true, false>
132{
133 typedef _Class const& _ClassType;
134 typedef _Rp _ReturnType;
135 typedef _Rp (_FnType) (_Param...);
136};
137
138template <class _Rp, class _Class, class ..._Param>
139struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&, true, false>
140{
141 typedef _Class const& _ClassType;
142 typedef _Rp _ReturnType;
143 typedef _Rp (_FnType) (_Param..., ...);
144};
145
146template <class _Rp, class _Class, class ..._Param>
147struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&, true, false>
148{
149 typedef _Class volatile& _ClassType;
150 typedef _Rp _ReturnType;
151 typedef _Rp (_FnType) (_Param...);
152};
153
154template <class _Rp, class _Class, class ..._Param>
155struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&, true, false>
156{
157 typedef _Class volatile& _ClassType;
158 typedef _Rp _ReturnType;
159 typedef _Rp (_FnType) (_Param..., ...);
160};
161
162template <class _Rp, class _Class, class ..._Param>
163struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&, true, false>
164{
165 typedef _Class const volatile& _ClassType;
166 typedef _Rp _ReturnType;
167 typedef _Rp (_FnType) (_Param...);
168};
169
170template <class _Rp, class _Class, class ..._Param>
171struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&, true, false>
172{
173 typedef _Class const volatile& _ClassType;
174 typedef _Rp _ReturnType;
175 typedef _Rp (_FnType) (_Param..., ...);
176};
177
178template <class _Rp, class _Class, class ..._Param>
179struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &&, true, false>
180{
181 typedef _Class&& _ClassType;
182 typedef _Rp _ReturnType;
183 typedef _Rp (_FnType) (_Param...);
184};
185
186template <class _Rp, class _Class, class ..._Param>
187struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &&, true, false>
188{
189 typedef _Class&& _ClassType;
190 typedef _Rp _ReturnType;
191 typedef _Rp (_FnType) (_Param..., ...);
192};
193
194template <class _Rp, class _Class, class ..._Param>
195struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&&, true, false>
196{
197 typedef _Class const&& _ClassType;
198 typedef _Rp _ReturnType;
199 typedef _Rp (_FnType) (_Param...);
200};
201
202template <class _Rp, class _Class, class ..._Param>
203struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&&, true, false>
204{
205 typedef _Class const&& _ClassType;
206 typedef _Rp _ReturnType;
207 typedef _Rp (_FnType) (_Param..., ...);
208};
209
210template <class _Rp, class _Class, class ..._Param>
211struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&&, true, false>
212{
213 typedef _Class volatile&& _ClassType;
214 typedef _Rp _ReturnType;
215 typedef _Rp (_FnType) (_Param...);
216};
217
218template <class _Rp, class _Class, class ..._Param>
219struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&&, true, false>
220{
221 typedef _Class volatile&& _ClassType;
222 typedef _Rp _ReturnType;
223 typedef _Rp (_FnType) (_Param..., ...);
224};
225
226template <class _Rp, class _Class, class ..._Param>
227struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&&, true, false>
228{
229 typedef _Class const volatile&& _ClassType;
230 typedef _Rp _ReturnType;
231 typedef _Rp (_FnType) (_Param...);
232};
233
234template <class _Rp, class _Class, class ..._Param>
235struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&&, true, false>
236{
237 typedef _Class const volatile&& _ClassType;
238 typedef _Rp _ReturnType;
239 typedef _Rp (_FnType) (_Param..., ...);
240};
241
242template <class _Rp, class _Class>
243struct __member_pointer_traits_imp<_Rp _Class::*, false, true>
244{
245 typedef _Class _ClassType;
246 typedef _Rp _ReturnType;
247};
248
249template <class _MP>
250struct __member_pointer_traits
251 : public __member_pointer_traits_imp<typename remove_cv<_MP>::type,
252 is_member_function_pointer<_MP>::value,
253 is_member_object_pointer<_MP>::value>
254{
255// typedef ... _ClassType;
256// typedef ... _ReturnType;
257// typedef ... _FnType;
258};
259
260template <class _DecayedFp>
261struct __member_pointer_class_type {};
262
263template <class _Ret, class _ClassType>
264struct __member_pointer_class_type<_Ret _ClassType::*> {
265 typedef _ClassType type;
266};
267
268template <class _Fp, class _A0,
269 class _DecayFp = typename decay<_Fp>::type,
270 class _DecayA0 = typename decay<_A0>::type,
271 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
272using __enable_if_bullet1 = typename enable_if
273 <
274 is_member_function_pointer<_DecayFp>::value
275 && is_base_of<_ClassT, _DecayA0>::value
276 >::type;
277
278template <class _Fp, class _A0,
279 class _DecayFp = typename decay<_Fp>::type,
280 class _DecayA0 = typename decay<_A0>::type>
281using __enable_if_bullet2 = typename enable_if
282 <
283 is_member_function_pointer<_DecayFp>::value
284 && __is_reference_wrapper<_DecayA0>::value
285 >::type;
286
287template <class _Fp, class _A0,
288 class _DecayFp = typename decay<_Fp>::type,
289 class _DecayA0 = typename decay<_A0>::type,
290 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
291using __enable_if_bullet3 = typename enable_if
292 <
293 is_member_function_pointer<_DecayFp>::value
294 && !is_base_of<_ClassT, _DecayA0>::value
295 && !__is_reference_wrapper<_DecayA0>::value
296 >::type;
297
298template <class _Fp, class _A0,
299 class _DecayFp = typename decay<_Fp>::type,
300 class _DecayA0 = typename decay<_A0>::type,
301 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
302using __enable_if_bullet4 = typename enable_if
303 <
304 is_member_object_pointer<_DecayFp>::value
305 && is_base_of<_ClassT, _DecayA0>::value
306 >::type;
307
308template <class _Fp, class _A0,
309 class _DecayFp = typename decay<_Fp>::type,
310 class _DecayA0 = typename decay<_A0>::type>
311using __enable_if_bullet5 = typename enable_if
312 <
313 is_member_object_pointer<_DecayFp>::value
314 && __is_reference_wrapper<_DecayA0>::value
315 >::type;
316
317template <class _Fp, class _A0,
318 class _DecayFp = typename decay<_Fp>::type,
319 class _DecayA0 = typename decay<_A0>::type,
320 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
321using __enable_if_bullet6 = typename enable_if
322 <
323 is_member_object_pointer<_DecayFp>::value
324 && !is_base_of<_ClassT, _DecayA0>::value
325 && !__is_reference_wrapper<_DecayA0>::value
326 >::type;
327
328// __invoke forward declarations
329
330// fall back - none of the bullets
331
332template <class ..._Args>
333__nat __invoke(__any, _Args&& ...__args);
334
335// bullets 1, 2 and 3
336
337template <class _Fp, class _A0, class ..._Args,
338 class = __enable_if_bullet1<_Fp, _A0> >
339inline _LIBCPP_INLINE_VISIBILITY
340_LIBCPP_CONSTEXPR decltype((std::declval<_A0>().*std::declval<_Fp>())(std::declval<_Args>()...))
341__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
342 _NOEXCEPT_(noexcept((static_cast<_A0&&>(__a0).*__f)(static_cast<_Args&&>(__args)...)))
343 { return (static_cast<_A0&&>(__a0).*__f)(static_cast<_Args&&>(__args)...); }
344
345template <class _Fp, class _A0, class ..._Args,
346 class = __enable_if_bullet2<_Fp, _A0> >
347inline _LIBCPP_INLINE_VISIBILITY
348_LIBCPP_CONSTEXPR decltype((std::declval<_A0>().get().*std::declval<_Fp>())(std::declval<_Args>()...))
349__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
350 _NOEXCEPT_(noexcept((__a0.get().*__f)(static_cast<_Args&&>(__args)...)))
351 { return (__a0.get().*__f)(static_cast<_Args&&>(__args)...); }
352
353template <class _Fp, class _A0, class ..._Args,
354 class = __enable_if_bullet3<_Fp, _A0> >
355inline _LIBCPP_INLINE_VISIBILITY
356_LIBCPP_CONSTEXPR decltype(((*std::declval<_A0>()).*std::declval<_Fp>())(std::declval<_Args>()...))
357__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
358 _NOEXCEPT_(noexcept(((*static_cast<_A0&&>(__a0)).*__f)(static_cast<_Args&&>(__args)...)))
359 { return ((*static_cast<_A0&&>(__a0)).*__f)(static_cast<_Args&&>(__args)...); }
360
361// bullets 4, 5 and 6
362
363template <class _Fp, class _A0,
364 class = __enable_if_bullet4<_Fp, _A0> >
365inline _LIBCPP_INLINE_VISIBILITY
366_LIBCPP_CONSTEXPR decltype(std::declval<_A0>().*std::declval<_Fp>())
367__invoke(_Fp&& __f, _A0&& __a0)
368 _NOEXCEPT_(noexcept(static_cast<_A0&&>(__a0).*__f))
369 { return static_cast<_A0&&>(__a0).*__f; }
370
371template <class _Fp, class _A0,
372 class = __enable_if_bullet5<_Fp, _A0> >
373inline _LIBCPP_INLINE_VISIBILITY
374_LIBCPP_CONSTEXPR decltype(std::declval<_A0>().get().*std::declval<_Fp>())
375__invoke(_Fp&& __f, _A0&& __a0)
376 _NOEXCEPT_(noexcept(__a0.get().*__f))
377 { return __a0.get().*__f; }
378
379template <class _Fp, class _A0,
380 class = __enable_if_bullet6<_Fp, _A0> >
381inline _LIBCPP_INLINE_VISIBILITY
382_LIBCPP_CONSTEXPR decltype((*std::declval<_A0>()).*std::declval<_Fp>())
383__invoke(_Fp&& __f, _A0&& __a0)
384 _NOEXCEPT_(noexcept((*static_cast<_A0&&>(__a0)).*__f))
385 { return (*static_cast<_A0&&>(__a0)).*__f; }
386
387// bullet 7
388
389template <class _Fp, class ..._Args>
390inline _LIBCPP_INLINE_VISIBILITY
391_LIBCPP_CONSTEXPR decltype(std::declval<_Fp>()(std::declval<_Args>()...))
392__invoke(_Fp&& __f, _Args&& ...__args)
393 _NOEXCEPT_(noexcept(static_cast<_Fp&&>(__f)(static_cast<_Args&&>(__args)...)))
394 { return static_cast<_Fp&&>(__f)(static_cast<_Args&&>(__args)...); }
395
396// __invokable
397template <class _Ret, class _Fp, class ..._Args>
398struct __invokable_r
399{
400 template <class _XFp, class ..._XArgs>
401 static decltype(std::__invoke(declval<_XFp>(), declval<_XArgs>()...)) __try_call(int);
402 template <class _XFp, class ..._XArgs>
403 static __nat __try_call(...);
404
405 // FIXME: Check that _Ret, _Fp, and _Args... are all complete types, cv void,
406 // or incomplete array types as required by the standard.
407 using _Result = decltype(__try_call<_Fp, _Args...>(0));
408
409 using type = typename conditional<
410 _IsNotSame<_Result, __nat>::value,
411 typename conditional< is_void<_Ret>::value, true_type, __is_core_convertible<_Result, _Ret> >::type,
412 false_type >::type;
413 static const bool value = type::value;
414};
415template <class _Fp, class ..._Args>
416using __invokable = __invokable_r<void, _Fp, _Args...>;
417
418template <bool _IsInvokable, bool _IsCVVoid, class _Ret, class _Fp, class ..._Args>
419struct __nothrow_invokable_r_imp {
420 static const bool value = false;
421};
422
423template <class _Ret, class _Fp, class ..._Args>
424struct __nothrow_invokable_r_imp<true, false, _Ret, _Fp, _Args...>
425{
426 typedef __nothrow_invokable_r_imp _ThisT;
427
428 template <class _Tp>
429 static void __test_noexcept(_Tp) _NOEXCEPT;
430
431 static const bool value = noexcept(_ThisT::__test_noexcept<_Ret>(
432 _VSTD::__invoke(declval<_Fp>(), declval<_Args>()...)));
433};
434
435template <class _Ret, class _Fp, class ..._Args>
436struct __nothrow_invokable_r_imp<true, true, _Ret, _Fp, _Args...>
437{
438 static const bool value = noexcept(
439 _VSTD::__invoke(declval<_Fp>(), declval<_Args>()...));
440};
441
442template <class _Ret, class _Fp, class ..._Args>
443using __nothrow_invokable_r =
444 __nothrow_invokable_r_imp<
445 __invokable_r<_Ret, _Fp, _Args...>::value,
446 is_void<_Ret>::value,
447 _Ret, _Fp, _Args...
448 >;
449
450template <class _Fp, class ..._Args>
451using __nothrow_invokable =
452 __nothrow_invokable_r_imp<
453 __invokable<_Fp, _Args...>::value,
454 true, void, _Fp, _Args...
455 >;
456
457template <class _Fp, class ..._Args>
458struct __invoke_of
459 : public enable_if<
460 __invokable<_Fp, _Args...>::value,
461 typename __invokable_r<void, _Fp, _Args...>::_Result>
462{
463};
464
24template <class _Ret, bool = is_void<_Ret>::value>465template <class _Ret, bool = is_void<_Ret>::value>
25struct __invoke_void_return_wrapper466struct __invoke_void_return_wrapper
26{467{
27#ifndef _LIBCPP_CXX03_LANG
28 template <class ..._Args>468 template <class ..._Args>
29 static _Ret __call(_Args&&... __args) {469 static _Ret __call(_Args&&... __args) {
30 return _VSTD::__invoke(_VSTD::forward<_Args>(__args)...);470 return std::__invoke(std::forward<_Args>(__args)...);
31 }
32#else
33 template <class _Fn>
34 static _Ret __call(_Fn __f) {
35 return _VSTD::__invoke(__f);
36 }471 }
37
38 template <class _Fn, class _A0>
39 static _Ret __call(_Fn __f, _A0& __a0) {
40 return _VSTD::__invoke(__f, __a0);
41 }
42
43 template <class _Fn, class _A0, class _A1>
44 static _Ret __call(_Fn __f, _A0& __a0, _A1& __a1) {
45 return _VSTD::__invoke(__f, __a0, __a1);
46 }
47
48 template <class _Fn, class _A0, class _A1, class _A2>
49 static _Ret __call(_Fn __f, _A0& __a0, _A1& __a1, _A2& __a2){
50 return _VSTD::__invoke(__f, __a0, __a1, __a2);
51 }
52#endif
53};472};
54473
55template <class _Ret>474template <class _Ret>
56struct __invoke_void_return_wrapper<_Ret, true>475struct __invoke_void_return_wrapper<_Ret, true>
57{476{
58#ifndef _LIBCPP_CXX03_LANG
59 template <class ..._Args>477 template <class ..._Args>
60 static void __call(_Args&&... __args) {478 static void __call(_Args&&... __args) {
61 _VSTD::__invoke(_VSTD::forward<_Args>(__args)...);479 std::__invoke(std::forward<_Args>(__args)...);
62 }
63#else
64 template <class _Fn>
65 static void __call(_Fn __f) {
66 _VSTD::__invoke(__f);
67 }480 }
481};
68482
69 template <class _Fn, class _A0>483#if _LIBCPP_STD_VER > 14
70 static void __call(_Fn __f, _A0& __a0) {
71 _VSTD::__invoke(__f, __a0);
72 }
73484
74 template <class _Fn, class _A0, class _A1>485// is_invocable
75 static void __call(_Fn __f, _A0& __a0, _A1& __a1) {
76 _VSTD::__invoke(__f, __a0, __a1);
77 }
78486
79 template <class _Fn, class _A0, class _A1, class _A2>487template <class _Fn, class ..._Args>
80 static void __call(_Fn __f, _A0& __a0, _A1& __a1, _A2& __a2) {488struct _LIBCPP_TEMPLATE_VIS is_invocable
81 _VSTD::__invoke(__f, __a0, __a1, __a2);489 : integral_constant<bool, __invokable<_Fn, _Args...>::value> {};
82 }490
83#endif491template <class _Ret, class _Fn, class ..._Args>
492struct _LIBCPP_TEMPLATE_VIS is_invocable_r
493 : integral_constant<bool, __invokable_r<_Ret, _Fn, _Args...>::value> {};
494
495template <class _Fn, class ..._Args>
496inline constexpr bool is_invocable_v = is_invocable<_Fn, _Args...>::value;
497
498template <class _Ret, class _Fn, class ..._Args>
499inline constexpr bool is_invocable_r_v = is_invocable_r<_Ret, _Fn, _Args...>::value;
500
501// is_nothrow_invocable
502
503template <class _Fn, class ..._Args>
504struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable
505 : integral_constant<bool, __nothrow_invokable<_Fn, _Args...>::value> {};
506
507template <class _Ret, class _Fn, class ..._Args>
508struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable_r
509 : integral_constant<bool, __nothrow_invokable_r<_Ret, _Fn, _Args...>::value> {};
510
511template <class _Fn, class ..._Args>
512inline constexpr bool is_nothrow_invocable_v = is_nothrow_invocable<_Fn, _Args...>::value;
513
514template <class _Ret, class _Fn, class ..._Args>
515inline constexpr bool is_nothrow_invocable_r_v = is_nothrow_invocable_r<_Ret, _Fn, _Args...>::value;
516
517template <class _Fn, class... _Args>
518struct _LIBCPP_TEMPLATE_VIS invoke_result
519 : __invoke_of<_Fn, _Args...>
520{
84};521};
85522
86#if _LIBCPP_STD_VER > 14523template <class _Fn, class... _Args>
524using invoke_result_t = typename invoke_result<_Fn, _Args...>::type;
87525
88template <class _Fn, class ..._Args>526template <class _Fn, class ..._Args>
89_LIBCPP_CONSTEXPR_AFTER_CXX17 invoke_result_t<_Fn, _Args...>527_LIBCPP_CONSTEXPR_AFTER_CXX17 invoke_result_t<_Fn, _Args...>
lib/libcxx/include/__functional/is_transparent.h+1-1
...@@ -14,7 +14,7 @@...@@ -14,7 +14,7 @@
14#include <type_traits>14#include <type_traits>
1515
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17#pragma GCC system_header17# pragma GCC system_header
18#endif18#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__functional/mem_fn.h+6-108
...@@ -14,19 +14,17 @@...@@ -14,19 +14,17 @@
14#include <__functional/binary_function.h>14#include <__functional/binary_function.h>
15#include <__functional/invoke.h>15#include <__functional/invoke.h>
16#include <__functional/weak_result_type.h>16#include <__functional/weak_result_type.h>
17#include <utility>17#include <__utility/forward.h>
18#include <type_traits>
1819
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20#pragma GCC system_header21# pragma GCC system_header
21#endif22#endif
2223
23_LIBCPP_BEGIN_NAMESPACE_STD24_LIBCPP_BEGIN_NAMESPACE_STD
2425
25template <class _Tp>26template <class _Tp>
26class __mem_fn27class __mem_fn : public __weak_result_type<_Tp>
27#if _LIBCPP_STD_VER <= 17 || !defined(_LIBCPP_ABI_NO_BINDER_BASES)
28 : public __weak_result_type<_Tp>
29#endif
30{28{
31public:29public:
32 // types30 // types
...@@ -38,114 +36,14 @@ public:...@@ -38,114 +36,14 @@ public:
38 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1736 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
39 __mem_fn(type __f) _NOEXCEPT : __f_(__f) {}37 __mem_fn(type __f) _NOEXCEPT : __f_(__f) {}
4038
41#ifndef _LIBCPP_CXX03_LANG
42 // invoke39 // invoke
43 template <class... _ArgTypes>40 template <class... _ArgTypes>
44 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1741 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
42
45 typename __invoke_return<type, _ArgTypes...>::type43 typename __invoke_return<type, _ArgTypes...>::type
46 operator() (_ArgTypes&&... __args) const {44 operator() (_ArgTypes&&... __args) const {
47 return _VSTD::__invoke(__f_, _VSTD::forward<_ArgTypes>(__args)...);45 return std::__invoke(__f_, std::forward<_ArgTypes>(__args)...);
48 }
49#else
50
51 template <class _A0>
52 _LIBCPP_INLINE_VISIBILITY
53 typename __invoke_return0<type, _A0>::type
54 operator() (_A0& __a0) const {
55 return _VSTD::__invoke(__f_, __a0);
56 }
57
58 template <class _A0>
59 _LIBCPP_INLINE_VISIBILITY
60 typename __invoke_return0<type, _A0 const>::type
61 operator() (_A0 const& __a0) const {
62 return _VSTD::__invoke(__f_, __a0);
63 }
64
65 template <class _A0, class _A1>
66 _LIBCPP_INLINE_VISIBILITY
67 typename __invoke_return1<type, _A0, _A1>::type
68 operator() (_A0& __a0, _A1& __a1) const {
69 return _VSTD::__invoke(__f_, __a0, __a1);
70 }
71
72 template <class _A0, class _A1>
73 _LIBCPP_INLINE_VISIBILITY
74 typename __invoke_return1<type, _A0 const, _A1>::type
75 operator() (_A0 const& __a0, _A1& __a1) const {
76 return _VSTD::__invoke(__f_, __a0, __a1);
77 }
78
79 template <class _A0, class _A1>
80 _LIBCPP_INLINE_VISIBILITY
81 typename __invoke_return1<type, _A0, _A1 const>::type
82 operator() (_A0& __a0, _A1 const& __a1) const {
83 return _VSTD::__invoke(__f_, __a0, __a1);
84 }
85
86 template <class _A0, class _A1>
87 _LIBCPP_INLINE_VISIBILITY
88 typename __invoke_return1<type, _A0 const, _A1 const>::type
89 operator() (_A0 const& __a0, _A1 const& __a1) const {
90 return _VSTD::__invoke(__f_, __a0, __a1);
91 }
92
93 template <class _A0, class _A1, class _A2>
94 _LIBCPP_INLINE_VISIBILITY
95 typename __invoke_return2<type, _A0, _A1, _A2>::type
96 operator() (_A0& __a0, _A1& __a1, _A2& __a2) const {
97 return _VSTD::__invoke(__f_, __a0, __a1, __a2);
98 }46 }
99
100 template <class _A0, class _A1, class _A2>
101 _LIBCPP_INLINE_VISIBILITY
102 typename __invoke_return2<type, _A0 const, _A1, _A2>::type
103 operator() (_A0 const& __a0, _A1& __a1, _A2& __a2) const {
104 return _VSTD::__invoke(__f_, __a0, __a1, __a2);
105 }
106
107 template <class _A0, class _A1, class _A2>
108 _LIBCPP_INLINE_VISIBILITY
109 typename __invoke_return2<type, _A0, _A1 const, _A2>::type
110 operator() (_A0& __a0, _A1 const& __a1, _A2& __a2) const {
111 return _VSTD::__invoke(__f_, __a0, __a1, __a2);
112 }
113
114 template <class _A0, class _A1, class _A2>
115 _LIBCPP_INLINE_VISIBILITY
116 typename __invoke_return2<type, _A0, _A1, _A2 const>::type
117 operator() (_A0& __a0, _A1& __a1, _A2 const& __a2) const {
118 return _VSTD::__invoke(__f_, __a0, __a1, __a2);
119 }
120
121 template <class _A0, class _A1, class _A2>
122 _LIBCPP_INLINE_VISIBILITY
123 typename __invoke_return2<type, _A0 const, _A1 const, _A2>::type
124 operator() (_A0 const& __a0, _A1 const& __a1, _A2& __a2) const {
125 return _VSTD::__invoke(__f_, __a0, __a1, __a2);
126 }
127
128 template <class _A0, class _A1, class _A2>
129 _LIBCPP_INLINE_VISIBILITY
130 typename __invoke_return2<type, _A0 const, _A1, _A2 const>::type
131 operator() (_A0 const& __a0, _A1& __a1, _A2 const& __a2) const {
132 return _VSTD::__invoke(__f_, __a0, __a1, __a2);
133 }
134
135 template <class _A0, class _A1, class _A2>
136 _LIBCPP_INLINE_VISIBILITY
137 typename __invoke_return2<type, _A0, _A1 const, _A2 const>::type
138 operator() (_A0& __a0, _A1 const& __a1, _A2 const& __a2) const {
139 return _VSTD::__invoke(__f_, __a0, __a1, __a2);
140 }
141
142 template <class _A0, class _A1, class _A2>
143 _LIBCPP_INLINE_VISIBILITY
144 typename __invoke_return2<type, _A0 const, _A1 const, _A2 const>::type
145 operator() (_A0 const& __a0, _A1 const& __a1, _A2 const& __a2) const {
146 return _VSTD::__invoke(__f_, __a0, __a1, __a2);
147 }
148#endif
149};47};
15048
151template<class _Rp, class _Tp>49template<class _Rp, class _Tp>
lib/libcxx/include/__functional/mem_fun_ref.h+9-9
...@@ -15,7 +15,7 @@...@@ -15,7 +15,7 @@
15#include <__functional/unary_function.h>15#include <__functional/unary_function.h>
1616
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header18# pragma GCC system_header
19#endif19#endif
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -24,7 +24,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -24,7 +24,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2424
25template<class _Sp, class _Tp>25template<class _Sp, class _Tp>
26class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun_t26class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun_t
27 : public unary_function<_Tp*, _Sp>27 : public __unary_function<_Tp*, _Sp>
28{28{
29 _Sp (_Tp::*__p_)();29 _Sp (_Tp::*__p_)();
30public:30public:
...@@ -36,7 +36,7 @@ public:...@@ -36,7 +36,7 @@ public:
3636
37template<class _Sp, class _Tp, class _Ap>37template<class _Sp, class _Tp, class _Ap>
38class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun1_t38class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun1_t
39 : public binary_function<_Tp*, _Ap, _Sp>39 : public __binary_function<_Tp*, _Ap, _Sp>
40{40{
41 _Sp (_Tp::*__p_)(_Ap);41 _Sp (_Tp::*__p_)(_Ap);
42public:42public:
...@@ -60,7 +60,7 @@ mem_fun(_Sp (_Tp::*__f)(_Ap))...@@ -60,7 +60,7 @@ mem_fun(_Sp (_Tp::*__f)(_Ap))
6060
61template<class _Sp, class _Tp>61template<class _Sp, class _Tp>
62class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun_ref_t62class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun_ref_t
63 : public unary_function<_Tp, _Sp>63 : public __unary_function<_Tp, _Sp>
64{64{
65 _Sp (_Tp::*__p_)();65 _Sp (_Tp::*__p_)();
66public:66public:
...@@ -72,7 +72,7 @@ public:...@@ -72,7 +72,7 @@ public:
7272
73template<class _Sp, class _Tp, class _Ap>73template<class _Sp, class _Tp, class _Ap>
74class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun1_ref_t74class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun1_ref_t
75 : public binary_function<_Tp, _Ap, _Sp>75 : public __binary_function<_Tp, _Ap, _Sp>
76{76{
77 _Sp (_Tp::*__p_)(_Ap);77 _Sp (_Tp::*__p_)(_Ap);
78public:78public:
...@@ -96,7 +96,7 @@ mem_fun_ref(_Sp (_Tp::*__f)(_Ap))...@@ -96,7 +96,7 @@ mem_fun_ref(_Sp (_Tp::*__f)(_Ap))
9696
97template <class _Sp, class _Tp>97template <class _Sp, class _Tp>
98class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun_t98class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun_t
99 : public unary_function<const _Tp*, _Sp>99 : public __unary_function<const _Tp*, _Sp>
100{100{
101 _Sp (_Tp::*__p_)() const;101 _Sp (_Tp::*__p_)() const;
102public:102public:
...@@ -108,7 +108,7 @@ public:...@@ -108,7 +108,7 @@ public:
108108
109template <class _Sp, class _Tp, class _Ap>109template <class _Sp, class _Tp, class _Ap>
110class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun1_t110class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun1_t
111 : public binary_function<const _Tp*, _Ap, _Sp>111 : public __binary_function<const _Tp*, _Ap, _Sp>
112{112{
113 _Sp (_Tp::*__p_)(_Ap) const;113 _Sp (_Tp::*__p_)(_Ap) const;
114public:114public:
...@@ -132,7 +132,7 @@ mem_fun(_Sp (_Tp::*__f)(_Ap) const)...@@ -132,7 +132,7 @@ mem_fun(_Sp (_Tp::*__f)(_Ap) const)
132132
133template <class _Sp, class _Tp>133template <class _Sp, class _Tp>
134class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun_ref_t134class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun_ref_t
135 : public unary_function<_Tp, _Sp>135 : public __unary_function<_Tp, _Sp>
136{136{
137 _Sp (_Tp::*__p_)() const;137 _Sp (_Tp::*__p_)() const;
138public:138public:
...@@ -144,7 +144,7 @@ public:...@@ -144,7 +144,7 @@ public:
144144
145template <class _Sp, class _Tp, class _Ap>145template <class _Sp, class _Tp, class _Ap>
146class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun1_ref_t146class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun1_ref_t
147 : public binary_function<_Tp, _Ap, _Sp>147 : public __binary_function<_Tp, _Ap, _Sp>
148{148{
149 _Sp (_Tp::*__p_)(_Ap) const;149 _Sp (_Tp::*__p_)(_Ap) const;
150public:150public:
lib/libcxx/include/__functional/not_fn.h+3-2
...@@ -13,10 +13,11 @@...@@ -13,10 +13,11 @@
13#include <__config>13#include <__config>
14#include <__functional/invoke.h>14#include <__functional/invoke.h>
15#include <__functional/perfect_forward.h>15#include <__functional/perfect_forward.h>
16#include <utility>16#include <__utility/forward.h>
17#include <type_traits>
1718
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19#pragma GCC system_header20# pragma GCC system_header
20#endif21#endif
2122
22_LIBCPP_BEGIN_NAMESPACE_STD23_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__functional/operations.h+20-188
...@@ -16,31 +16,22 @@...@@ -16,31 +16,22 @@
16#include <__utility/forward.h>16#include <__utility/forward.h>
1717
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19#pragma GCC system_header19# pragma GCC system_header
20#endif20#endif
2121
22_LIBCPP_BEGIN_NAMESPACE_STD22_LIBCPP_BEGIN_NAMESPACE_STD
2323
24// Arithmetic operations24// Arithmetic operations
2525
26_LIBCPP_SUPPRESS_DEPRECATED_PUSH
27#if _LIBCPP_STD_VER > 1126#if _LIBCPP_STD_VER > 11
28template <class _Tp = void>27template <class _Tp = void>
29#else28#else
30template <class _Tp>29template <class _Tp>
31#endif30#endif
32struct _LIBCPP_TEMPLATE_VIS plus31struct _LIBCPP_TEMPLATE_VIS plus
33#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)32 : __binary_function<_Tp, _Tp, _Tp>
34 : binary_function<_Tp, _Tp, _Tp>
35#endif
36{33{
37_LIBCPP_SUPPRESS_DEPRECATED_POP
38 typedef _Tp __result_type; // used by valarray34 typedef _Tp __result_type; // used by valarray
39#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
40 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
41 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
42 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
43#endif
44 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY35 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
45 _Tp operator()(const _Tp& __x, const _Tp& __y) const36 _Tp operator()(const _Tp& __x, const _Tp& __y) const
46 {return __x + __y;}37 {return __x + __y;}
...@@ -60,24 +51,15 @@ struct _LIBCPP_TEMPLATE_VIS plus<void>...@@ -60,24 +51,15 @@ struct _LIBCPP_TEMPLATE_VIS plus<void>
60};51};
61#endif52#endif
6253
63_LIBCPP_SUPPRESS_DEPRECATED_PUSH
64#if _LIBCPP_STD_VER > 1154#if _LIBCPP_STD_VER > 11
65template <class _Tp = void>55template <class _Tp = void>
66#else56#else
67template <class _Tp>57template <class _Tp>
68#endif58#endif
69struct _LIBCPP_TEMPLATE_VIS minus59struct _LIBCPP_TEMPLATE_VIS minus
70#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)60 : __binary_function<_Tp, _Tp, _Tp>
71 : binary_function<_Tp, _Tp, _Tp>
72#endif
73{61{
74_LIBCPP_SUPPRESS_DEPRECATED_POP
75 typedef _Tp __result_type; // used by valarray62 typedef _Tp __result_type; // used by valarray
76#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
77 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
78 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
79 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
80#endif
81 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY63 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
82 _Tp operator()(const _Tp& __x, const _Tp& __y) const64 _Tp operator()(const _Tp& __x, const _Tp& __y) const
83 {return __x - __y;}65 {return __x - __y;}
...@@ -97,24 +79,15 @@ struct _LIBCPP_TEMPLATE_VIS minus<void>...@@ -97,24 +79,15 @@ struct _LIBCPP_TEMPLATE_VIS minus<void>
97};79};
98#endif80#endif
9981
100_LIBCPP_SUPPRESS_DEPRECATED_PUSH
101#if _LIBCPP_STD_VER > 1182#if _LIBCPP_STD_VER > 11
102template <class _Tp = void>83template <class _Tp = void>
103#else84#else
104template <class _Tp>85template <class _Tp>
105#endif86#endif
106struct _LIBCPP_TEMPLATE_VIS multiplies87struct _LIBCPP_TEMPLATE_VIS multiplies
107#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)88 : __binary_function<_Tp, _Tp, _Tp>
108 : binary_function<_Tp, _Tp, _Tp>
109#endif
110{89{
111_LIBCPP_SUPPRESS_DEPRECATED_POP
112 typedef _Tp __result_type; // used by valarray90 typedef _Tp __result_type; // used by valarray
113#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
114 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
115 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
116 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
117#endif
118 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY91 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
119 _Tp operator()(const _Tp& __x, const _Tp& __y) const92 _Tp operator()(const _Tp& __x, const _Tp& __y) const
120 {return __x * __y;}93 {return __x * __y;}
...@@ -134,24 +107,15 @@ struct _LIBCPP_TEMPLATE_VIS multiplies<void>...@@ -134,24 +107,15 @@ struct _LIBCPP_TEMPLATE_VIS multiplies<void>
134};107};
135#endif108#endif
136109
137_LIBCPP_SUPPRESS_DEPRECATED_PUSH
138#if _LIBCPP_STD_VER > 11110#if _LIBCPP_STD_VER > 11
139template <class _Tp = void>111template <class _Tp = void>
140#else112#else
141template <class _Tp>113template <class _Tp>
142#endif114#endif
143struct _LIBCPP_TEMPLATE_VIS divides115struct _LIBCPP_TEMPLATE_VIS divides
144#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)116 : __binary_function<_Tp, _Tp, _Tp>
145 : binary_function<_Tp, _Tp, _Tp>
146#endif
147{117{
148_LIBCPP_SUPPRESS_DEPRECATED_POP
149 typedef _Tp __result_type; // used by valarray118 typedef _Tp __result_type; // used by valarray
150#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
151 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
152 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
153 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
154#endif
155 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY119 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
156 _Tp operator()(const _Tp& __x, const _Tp& __y) const120 _Tp operator()(const _Tp& __x, const _Tp& __y) const
157 {return __x / __y;}121 {return __x / __y;}
...@@ -171,24 +135,15 @@ struct _LIBCPP_TEMPLATE_VIS divides<void>...@@ -171,24 +135,15 @@ struct _LIBCPP_TEMPLATE_VIS divides<void>
171};135};
172#endif136#endif
173137
174_LIBCPP_SUPPRESS_DEPRECATED_PUSH
175#if _LIBCPP_STD_VER > 11138#if _LIBCPP_STD_VER > 11
176template <class _Tp = void>139template <class _Tp = void>
177#else140#else
178template <class _Tp>141template <class _Tp>
179#endif142#endif
180struct _LIBCPP_TEMPLATE_VIS modulus143struct _LIBCPP_TEMPLATE_VIS modulus
181#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)144 : __binary_function<_Tp, _Tp, _Tp>
182 : binary_function<_Tp, _Tp, _Tp>
183#endif
184{145{
185_LIBCPP_SUPPRESS_DEPRECATED_POP
186 typedef _Tp __result_type; // used by valarray146 typedef _Tp __result_type; // used by valarray
187#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
188 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
189 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
190 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
191#endif
192 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY147 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
193 _Tp operator()(const _Tp& __x, const _Tp& __y) const148 _Tp operator()(const _Tp& __x, const _Tp& __y) const
194 {return __x % __y;}149 {return __x % __y;}
...@@ -208,23 +163,15 @@ struct _LIBCPP_TEMPLATE_VIS modulus<void>...@@ -208,23 +163,15 @@ struct _LIBCPP_TEMPLATE_VIS modulus<void>
208};163};
209#endif164#endif
210165
211_LIBCPP_SUPPRESS_DEPRECATED_PUSH
212#if _LIBCPP_STD_VER > 11166#if _LIBCPP_STD_VER > 11
213template <class _Tp = void>167template <class _Tp = void>
214#else168#else
215template <class _Tp>169template <class _Tp>
216#endif170#endif
217struct _LIBCPP_TEMPLATE_VIS negate171struct _LIBCPP_TEMPLATE_VIS negate
218#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)172 : __unary_function<_Tp, _Tp>
219 : unary_function<_Tp, _Tp>
220#endif
221{173{
222_LIBCPP_SUPPRESS_DEPRECATED_POP
223 typedef _Tp __result_type; // used by valarray174 typedef _Tp __result_type; // used by valarray
224#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
225 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
226 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type;
227#endif
228 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY175 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
229 _Tp operator()(const _Tp& __x) const176 _Tp operator()(const _Tp& __x) const
230 {return -__x;}177 {return -__x;}
...@@ -246,24 +193,15 @@ struct _LIBCPP_TEMPLATE_VIS negate<void>...@@ -246,24 +193,15 @@ struct _LIBCPP_TEMPLATE_VIS negate<void>
246193
247// Bitwise operations194// Bitwise operations
248195
249_LIBCPP_SUPPRESS_DEPRECATED_PUSH
250#if _LIBCPP_STD_VER > 11196#if _LIBCPP_STD_VER > 11
251template <class _Tp = void>197template <class _Tp = void>
252#else198#else
253template <class _Tp>199template <class _Tp>
254#endif200#endif
255struct _LIBCPP_TEMPLATE_VIS bit_and201struct _LIBCPP_TEMPLATE_VIS bit_and
256#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)202 : __binary_function<_Tp, _Tp, _Tp>
257 : binary_function<_Tp, _Tp, _Tp>
258#endif
259{203{
260_LIBCPP_SUPPRESS_DEPRECATED_POP
261 typedef _Tp __result_type; // used by valarray204 typedef _Tp __result_type; // used by valarray
262#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
263 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
264 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
265 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
266#endif
267 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY205 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
268 _Tp operator()(const _Tp& __x, const _Tp& __y) const206 _Tp operator()(const _Tp& __x, const _Tp& __y) const
269 {return __x & __y;}207 {return __x & __y;}
...@@ -284,18 +222,10 @@ struct _LIBCPP_TEMPLATE_VIS bit_and<void>...@@ -284,18 +222,10 @@ struct _LIBCPP_TEMPLATE_VIS bit_and<void>
284#endif222#endif
285223
286#if _LIBCPP_STD_VER > 11224#if _LIBCPP_STD_VER > 11
287_LIBCPP_SUPPRESS_DEPRECATED_PUSH
288template <class _Tp = void>225template <class _Tp = void>
289struct _LIBCPP_TEMPLATE_VIS bit_not226struct _LIBCPP_TEMPLATE_VIS bit_not
290#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)227 : __unary_function<_Tp, _Tp>
291 : unary_function<_Tp, _Tp>
292#endif
293{228{
294_LIBCPP_SUPPRESS_DEPRECATED_POP
295#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
296 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
297 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type;
298#endif
299 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY229 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
300 _Tp operator()(const _Tp& __x) const230 _Tp operator()(const _Tp& __x) const
301 {return ~__x;}231 {return ~__x;}
...@@ -314,24 +244,15 @@ struct _LIBCPP_TEMPLATE_VIS bit_not<void>...@@ -314,24 +244,15 @@ struct _LIBCPP_TEMPLATE_VIS bit_not<void>
314};244};
315#endif245#endif
316246
317_LIBCPP_SUPPRESS_DEPRECATED_PUSH
318#if _LIBCPP_STD_VER > 11247#if _LIBCPP_STD_VER > 11
319template <class _Tp = void>248template <class _Tp = void>
320#else249#else
321template <class _Tp>250template <class _Tp>
322#endif251#endif
323struct _LIBCPP_TEMPLATE_VIS bit_or252struct _LIBCPP_TEMPLATE_VIS bit_or
324#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)253 : __binary_function<_Tp, _Tp, _Tp>
325 : binary_function<_Tp, _Tp, _Tp>
326#endif
327{254{
328_LIBCPP_SUPPRESS_DEPRECATED_POP
329 typedef _Tp __result_type; // used by valarray255 typedef _Tp __result_type; // used by valarray
330#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
331 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
332 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
333 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
334#endif
335 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY256 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
336 _Tp operator()(const _Tp& __x, const _Tp& __y) const257 _Tp operator()(const _Tp& __x, const _Tp& __y) const
337 {return __x | __y;}258 {return __x | __y;}
...@@ -351,24 +272,15 @@ struct _LIBCPP_TEMPLATE_VIS bit_or<void>...@@ -351,24 +272,15 @@ struct _LIBCPP_TEMPLATE_VIS bit_or<void>
351};272};
352#endif273#endif
353274
354_LIBCPP_SUPPRESS_DEPRECATED_PUSH
355#if _LIBCPP_STD_VER > 11275#if _LIBCPP_STD_VER > 11
356template <class _Tp = void>276template <class _Tp = void>
357#else277#else
358template <class _Tp>278template <class _Tp>
359#endif279#endif
360struct _LIBCPP_TEMPLATE_VIS bit_xor280struct _LIBCPP_TEMPLATE_VIS bit_xor
361#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)281 : __binary_function<_Tp, _Tp, _Tp>
362 : binary_function<_Tp, _Tp, _Tp>
363#endif
364{282{
365_LIBCPP_SUPPRESS_DEPRECATED_POP
366 typedef _Tp __result_type; // used by valarray283 typedef _Tp __result_type; // used by valarray
367#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
368 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
369 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
370 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
371#endif
372 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY284 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
373 _Tp operator()(const _Tp& __x, const _Tp& __y) const285 _Tp operator()(const _Tp& __x, const _Tp& __y) const
374 {return __x ^ __y;}286 {return __x ^ __y;}
...@@ -390,24 +302,15 @@ struct _LIBCPP_TEMPLATE_VIS bit_xor<void>...@@ -390,24 +302,15 @@ struct _LIBCPP_TEMPLATE_VIS bit_xor<void>
390302
391// Comparison operations303// Comparison operations
392304
393_LIBCPP_SUPPRESS_DEPRECATED_PUSH
394#if _LIBCPP_STD_VER > 11305#if _LIBCPP_STD_VER > 11
395template <class _Tp = void>306template <class _Tp = void>
396#else307#else
397template <class _Tp>308template <class _Tp>
398#endif309#endif
399struct _LIBCPP_TEMPLATE_VIS equal_to310struct _LIBCPP_TEMPLATE_VIS equal_to
400#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)311 : __binary_function<_Tp, _Tp, bool>
401 : binary_function<_Tp, _Tp, bool>
402#endif
403{312{
404_LIBCPP_SUPPRESS_DEPRECATED_POP
405 typedef bool __result_type; // used by valarray313 typedef bool __result_type; // used by valarray
406#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
407 _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
408 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
409 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
410#endif
411 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY314 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
412 bool operator()(const _Tp& __x, const _Tp& __y) const315 bool operator()(const _Tp& __x, const _Tp& __y) const
413 {return __x == __y;}316 {return __x == __y;}
...@@ -427,24 +330,15 @@ struct _LIBCPP_TEMPLATE_VIS equal_to<void>...@@ -427,24 +330,15 @@ struct _LIBCPP_TEMPLATE_VIS equal_to<void>
427};330};
428#endif331#endif
429332
430_LIBCPP_SUPPRESS_DEPRECATED_PUSH
431#if _LIBCPP_STD_VER > 11333#if _LIBCPP_STD_VER > 11
432template <class _Tp = void>334template <class _Tp = void>
433#else335#else
434template <class _Tp>336template <class _Tp>
435#endif337#endif
436struct _LIBCPP_TEMPLATE_VIS not_equal_to338struct _LIBCPP_TEMPLATE_VIS not_equal_to
437#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)339 : __binary_function<_Tp, _Tp, bool>
438 : binary_function<_Tp, _Tp, bool>
439#endif
440{340{
441_LIBCPP_SUPPRESS_DEPRECATED_POP
442 typedef bool __result_type; // used by valarray341 typedef bool __result_type; // used by valarray
443#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
444 _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
445 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
446 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
447#endif
448 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY342 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
449 bool operator()(const _Tp& __x, const _Tp& __y) const343 bool operator()(const _Tp& __x, const _Tp& __y) const
450 {return __x != __y;}344 {return __x != __y;}
...@@ -464,24 +358,15 @@ struct _LIBCPP_TEMPLATE_VIS not_equal_to<void>...@@ -464,24 +358,15 @@ struct _LIBCPP_TEMPLATE_VIS not_equal_to<void>
464};358};
465#endif359#endif
466360
467_LIBCPP_SUPPRESS_DEPRECATED_PUSH
468#if _LIBCPP_STD_VER > 11361#if _LIBCPP_STD_VER > 11
469template <class _Tp = void>362template <class _Tp = void>
470#else363#else
471template <class _Tp>364template <class _Tp>
472#endif365#endif
473struct _LIBCPP_TEMPLATE_VIS less366struct _LIBCPP_TEMPLATE_VIS less
474#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)367 : __binary_function<_Tp, _Tp, bool>
475 : binary_function<_Tp, _Tp, bool>
476#endif
477{368{
478_LIBCPP_SUPPRESS_DEPRECATED_POP
479 typedef bool __result_type; // used by valarray369 typedef bool __result_type; // used by valarray
480#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
481 _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
482 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
483 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
484#endif
485 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY370 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
486 bool operator()(const _Tp& __x, const _Tp& __y) const371 bool operator()(const _Tp& __x, const _Tp& __y) const
487 {return __x < __y;}372 {return __x < __y;}
...@@ -501,24 +386,15 @@ struct _LIBCPP_TEMPLATE_VIS less<void>...@@ -501,24 +386,15 @@ struct _LIBCPP_TEMPLATE_VIS less<void>
501};386};
502#endif387#endif
503388
504_LIBCPP_SUPPRESS_DEPRECATED_PUSH
505#if _LIBCPP_STD_VER > 11389#if _LIBCPP_STD_VER > 11
506template <class _Tp = void>390template <class _Tp = void>
507#else391#else
508template <class _Tp>392template <class _Tp>
509#endif393#endif
510struct _LIBCPP_TEMPLATE_VIS less_equal394struct _LIBCPP_TEMPLATE_VIS less_equal
511#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)395 : __binary_function<_Tp, _Tp, bool>
512 : binary_function<_Tp, _Tp, bool>
513#endif
514{396{
515_LIBCPP_SUPPRESS_DEPRECATED_POP
516 typedef bool __result_type; // used by valarray397 typedef bool __result_type; // used by valarray
517#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
518 _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
519 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
520 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
521#endif
522 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY398 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
523 bool operator()(const _Tp& __x, const _Tp& __y) const399 bool operator()(const _Tp& __x, const _Tp& __y) const
524 {return __x <= __y;}400 {return __x <= __y;}
...@@ -538,24 +414,15 @@ struct _LIBCPP_TEMPLATE_VIS less_equal<void>...@@ -538,24 +414,15 @@ struct _LIBCPP_TEMPLATE_VIS less_equal<void>
538};414};
539#endif415#endif
540416
541_LIBCPP_SUPPRESS_DEPRECATED_PUSH
542#if _LIBCPP_STD_VER > 11417#if _LIBCPP_STD_VER > 11
543template <class _Tp = void>418template <class _Tp = void>
544#else419#else
545template <class _Tp>420template <class _Tp>
546#endif421#endif
547struct _LIBCPP_TEMPLATE_VIS greater_equal422struct _LIBCPP_TEMPLATE_VIS greater_equal
548#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)423 : __binary_function<_Tp, _Tp, bool>
549 : binary_function<_Tp, _Tp, bool>
550#endif
551{424{
552_LIBCPP_SUPPRESS_DEPRECATED_POP
553 typedef bool __result_type; // used by valarray425 typedef bool __result_type; // used by valarray
554#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
555 _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
556 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
557 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
558#endif
559 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY426 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
560 bool operator()(const _Tp& __x, const _Tp& __y) const427 bool operator()(const _Tp& __x, const _Tp& __y) const
561 {return __x >= __y;}428 {return __x >= __y;}
...@@ -575,24 +442,15 @@ struct _LIBCPP_TEMPLATE_VIS greater_equal<void>...@@ -575,24 +442,15 @@ struct _LIBCPP_TEMPLATE_VIS greater_equal<void>
575};442};
576#endif443#endif
577444
578_LIBCPP_SUPPRESS_DEPRECATED_PUSH
579#if _LIBCPP_STD_VER > 11445#if _LIBCPP_STD_VER > 11
580template <class _Tp = void>446template <class _Tp = void>
581#else447#else
582template <class _Tp>448template <class _Tp>
583#endif449#endif
584struct _LIBCPP_TEMPLATE_VIS greater450struct _LIBCPP_TEMPLATE_VIS greater
585#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)451 : __binary_function<_Tp, _Tp, bool>
586 : binary_function<_Tp, _Tp, bool>
587#endif
588{452{
589_LIBCPP_SUPPRESS_DEPRECATED_POP
590 typedef bool __result_type; // used by valarray453 typedef bool __result_type; // used by valarray
591#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
592 _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
593 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
594 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
595#endif
596 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY454 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
597 bool operator()(const _Tp& __x, const _Tp& __y) const455 bool operator()(const _Tp& __x, const _Tp& __y) const
598 {return __x > __y;}456 {return __x > __y;}
...@@ -614,24 +472,15 @@ struct _LIBCPP_TEMPLATE_VIS greater<void>...@@ -614,24 +472,15 @@ struct _LIBCPP_TEMPLATE_VIS greater<void>
614472
615// Logical operations473// Logical operations
616474
617_LIBCPP_SUPPRESS_DEPRECATED_PUSH
618#if _LIBCPP_STD_VER > 11475#if _LIBCPP_STD_VER > 11
619template <class _Tp = void>476template <class _Tp = void>
620#else477#else
621template <class _Tp>478template <class _Tp>
622#endif479#endif
623struct _LIBCPP_TEMPLATE_VIS logical_and480struct _LIBCPP_TEMPLATE_VIS logical_and
624#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)481 : __binary_function<_Tp, _Tp, bool>
625 : binary_function<_Tp, _Tp, bool>
626#endif
627{482{
628_LIBCPP_SUPPRESS_DEPRECATED_POP
629 typedef bool __result_type; // used by valarray483 typedef bool __result_type; // used by valarray
630#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
631 _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
632 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
633 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
634#endif
635 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY484 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
636 bool operator()(const _Tp& __x, const _Tp& __y) const485 bool operator()(const _Tp& __x, const _Tp& __y) const
637 {return __x && __y;}486 {return __x && __y;}
...@@ -651,23 +500,15 @@ struct _LIBCPP_TEMPLATE_VIS logical_and<void>...@@ -651,23 +500,15 @@ struct _LIBCPP_TEMPLATE_VIS logical_and<void>
651};500};
652#endif501#endif
653502
654_LIBCPP_SUPPRESS_DEPRECATED_PUSH
655#if _LIBCPP_STD_VER > 11503#if _LIBCPP_STD_VER > 11
656template <class _Tp = void>504template <class _Tp = void>
657#else505#else
658template <class _Tp>506template <class _Tp>
659#endif507#endif
660struct _LIBCPP_TEMPLATE_VIS logical_not508struct _LIBCPP_TEMPLATE_VIS logical_not
661#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)509 : __unary_function<_Tp, bool>
662 : unary_function<_Tp, bool>
663#endif
664{510{
665_LIBCPP_SUPPRESS_DEPRECATED_POP
666 typedef bool __result_type; // used by valarray511 typedef bool __result_type; // used by valarray
667#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
668 _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
669 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type;
670#endif
671 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY512 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
672 bool operator()(const _Tp& __x) const513 bool operator()(const _Tp& __x) const
673 {return !__x;}514 {return !__x;}
...@@ -687,24 +528,15 @@ struct _LIBCPP_TEMPLATE_VIS logical_not<void>...@@ -687,24 +528,15 @@ struct _LIBCPP_TEMPLATE_VIS logical_not<void>
687};528};
688#endif529#endif
689530
690_LIBCPP_SUPPRESS_DEPRECATED_PUSH
691#if _LIBCPP_STD_VER > 11531#if _LIBCPP_STD_VER > 11
692template <class _Tp = void>532template <class _Tp = void>
693#else533#else
694template <class _Tp>534template <class _Tp>
695#endif535#endif
696struct _LIBCPP_TEMPLATE_VIS logical_or536struct _LIBCPP_TEMPLATE_VIS logical_or
697#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)537 : __binary_function<_Tp, _Tp, bool>
698 : binary_function<_Tp, _Tp, bool>
699#endif
700{538{
701_LIBCPP_SUPPRESS_DEPRECATED_POP
702 typedef bool __result_type; // used by valarray539 typedef bool __result_type; // used by valarray
703#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
704 _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
705 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
706 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
707#endif
708 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY540 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
709 bool operator()(const _Tp& __x, const _Tp& __y) const541 bool operator()(const _Tp& __x, const _Tp& __y) const
710 {return __x || __y;}542 {return __x || __y;}
lib/libcxx/include/__functional/perfect_forward.h+52-53
...@@ -18,70 +18,69 @@...@@ -18,70 +18,69 @@
18#include <type_traits>18#include <type_traits>
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
22#endif22#endif
2323
24_LIBCPP_BEGIN_NAMESPACE_STD24_LIBCPP_BEGIN_NAMESPACE_STD
2525
26#if _LIBCPP_STD_VER > 1426#if _LIBCPP_STD_VER > 14
2727
28template <class _Op, class _Indices, class ..._Bound>28template <class _Op, class _Indices, class... _BoundArgs>
29struct __perfect_forward_impl;29struct __perfect_forward_impl;
3030
31template <class _Op, size_t ..._Idx, class ..._Bound>31template <class _Op, size_t... _Idx, class... _BoundArgs>
32struct __perfect_forward_impl<_Op, index_sequence<_Idx...>, _Bound...> {32struct __perfect_forward_impl<_Op, index_sequence<_Idx...>, _BoundArgs...> {
33private:33private:
34 tuple<_Bound...> __bound_;34 tuple<_BoundArgs...> __bound_args_;
3535
36public:36public:
37 template <class ..._BoundArgs, class = enable_if_t<37 template <class... _Args, class = enable_if_t<
38 is_constructible_v<tuple<_Bound...>, _BoundArgs&&...>38 is_constructible_v<tuple<_BoundArgs...>, _Args&&...>
39 >>39 >>
40 explicit constexpr __perfect_forward_impl(_BoundArgs&& ...__bound)40 explicit constexpr __perfect_forward_impl(_Args&&... __bound_args)
41 : __bound_(_VSTD::forward<_BoundArgs>(__bound)...)41 : __bound_args_(_VSTD::forward<_Args>(__bound_args)...) {}
42 { }42
4343 __perfect_forward_impl(__perfect_forward_impl const&) = default;
44 __perfect_forward_impl(__perfect_forward_impl const&) = default;44 __perfect_forward_impl(__perfect_forward_impl&&) = default;
45 __perfect_forward_impl(__perfect_forward_impl&&) = default;45
4646 __perfect_forward_impl& operator=(__perfect_forward_impl const&) = default;
47 __perfect_forward_impl& operator=(__perfect_forward_impl const&) = default;47 __perfect_forward_impl& operator=(__perfect_forward_impl&&) = default;
48 __perfect_forward_impl& operator=(__perfect_forward_impl&&) = default;48
4949 template <class... _Args, class = enable_if_t<is_invocable_v<_Op, _BoundArgs&..., _Args...>>>
50 template <class ..._Args, class = enable_if_t<is_invocable_v<_Op, _Bound&..., _Args...>>>50 _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) &
51 _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) &51 noexcept(noexcept(_Op()(_VSTD::get<_Idx>(__bound_args_)..., _VSTD::forward<_Args>(__args)...)))
52 noexcept(noexcept(_Op()(_VSTD::get<_Idx>(__bound_)..., _VSTD::forward<_Args>(__args)...)))52 -> decltype( _Op()(_VSTD::get<_Idx>(__bound_args_)..., _VSTD::forward<_Args>(__args)...))
53 -> decltype( _Op()(_VSTD::get<_Idx>(__bound_)..., _VSTD::forward<_Args>(__args)...))53 { return _Op()(_VSTD::get<_Idx>(__bound_args_)..., _VSTD::forward<_Args>(__args)...); }
54 { return _Op()(_VSTD::get<_Idx>(__bound_)..., _VSTD::forward<_Args>(__args)...); }54
5555 template <class... _Args, class = enable_if_t<!is_invocable_v<_Op, _BoundArgs&..., _Args...>>>
56 template <class ..._Args, class = enable_if_t<!is_invocable_v<_Op, _Bound&..., _Args...>>>56 auto operator()(_Args&&...) & = delete;
57 auto operator()(_Args&&...) & = delete;57
5858 template <class... _Args, class = enable_if_t<is_invocable_v<_Op, _BoundArgs const&..., _Args...>>>
59 template <class ..._Args, class = enable_if_t<is_invocable_v<_Op, _Bound const&..., _Args...>>>59 _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) const&
60 _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) const&60 noexcept(noexcept(_Op()(_VSTD::get<_Idx>(__bound_args_)..., _VSTD::forward<_Args>(__args)...)))
61 noexcept(noexcept(_Op()(_VSTD::get<_Idx>(__bound_)..., _VSTD::forward<_Args>(__args)...)))61 -> decltype( _Op()(_VSTD::get<_Idx>(__bound_args_)..., _VSTD::forward<_Args>(__args)...))
62 -> decltype( _Op()(_VSTD::get<_Idx>(__bound_)..., _VSTD::forward<_Args>(__args)...))62 { return _Op()(_VSTD::get<_Idx>(__bound_args_)..., _VSTD::forward<_Args>(__args)...); }
63 { return _Op()(_VSTD::get<_Idx>(__bound_)..., _VSTD::forward<_Args>(__args)...); }63
6464 template <class... _Args, class = enable_if_t<!is_invocable_v<_Op, _BoundArgs const&..., _Args...>>>
65 template <class ..._Args, class = enable_if_t<!is_invocable_v<_Op, _Bound const&..., _Args...>>>65 auto operator()(_Args&&...) const& = delete;
66 auto operator()(_Args&&...) const& = delete;66
6767 template <class... _Args, class = enable_if_t<is_invocable_v<_Op, _BoundArgs..., _Args...>>>
68 template <class ..._Args, class = enable_if_t<is_invocable_v<_Op, _Bound..., _Args...>>>68 _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) &&
69 _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) &&69 noexcept(noexcept(_Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_args_))..., _VSTD::forward<_Args>(__args)...)))
70 noexcept(noexcept(_Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_))..., _VSTD::forward<_Args>(__args)...)))70 -> decltype( _Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_args_))..., _VSTD::forward<_Args>(__args)...))
71 -> decltype( _Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_))..., _VSTD::forward<_Args>(__args)...))71 { return _Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_args_))..., _VSTD::forward<_Args>(__args)...); }
72 { return _Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_))..., _VSTD::forward<_Args>(__args)...); }72
7373 template <class... _Args, class = enable_if_t<!is_invocable_v<_Op, _BoundArgs..., _Args...>>>
74 template <class ..._Args, class = enable_if_t<!is_invocable_v<_Op, _Bound..., _Args...>>>74 auto operator()(_Args&&...) && = delete;
75 auto operator()(_Args&&...) && = delete;75
7676 template <class... _Args, class = enable_if_t<is_invocable_v<_Op, _BoundArgs const..., _Args...>>>
77 template <class ..._Args, class = enable_if_t<is_invocable_v<_Op, _Bound const..., _Args...>>>77 _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) const&&
78 _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) const&&78 noexcept(noexcept(_Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_args_))..., _VSTD::forward<_Args>(__args)...)))
79 noexcept(noexcept(_Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_))..., _VSTD::forward<_Args>(__args)...)))79 -> decltype( _Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_args_))..., _VSTD::forward<_Args>(__args)...))
80 -> decltype( _Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_))..., _VSTD::forward<_Args>(__args)...))80 { return _Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_args_))..., _VSTD::forward<_Args>(__args)...); }
81 { return _Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_))..., _VSTD::forward<_Args>(__args)...); }81
8282 template <class... _Args, class = enable_if_t<!is_invocable_v<_Op, _BoundArgs const..., _Args...>>>
83 template <class ..._Args, class = enable_if_t<!is_invocable_v<_Op, _Bound const..., _Args...>>>83 auto operator()(_Args&&...) const&& = delete;
84 auto operator()(_Args&&...) const&& = delete;
85};84};
8685
87// __perfect_forward implements a perfect-forwarding call wrapper as explained in [func.require].86// __perfect_forward implements a perfect-forwarding call wrapper as explained in [func.require].
lib/libcxx/include/__functional/pointer_to_binary_function.h+2-2
...@@ -14,7 +14,7 @@...@@ -14,7 +14,7 @@
14#include <__functional/binary_function.h>14#include <__functional/binary_function.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
18#endif18#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2323
24template <class _Arg1, class _Arg2, class _Result>24template <class _Arg1, class _Arg2, class _Result>
25class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 pointer_to_binary_function25class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 pointer_to_binary_function
26 : public binary_function<_Arg1, _Arg2, _Result>26 : public __binary_function<_Arg1, _Arg2, _Result>
27{27{
28 _Result (*__f_)(_Arg1, _Arg2);28 _Result (*__f_)(_Arg1, _Arg2);
29public:29public:
lib/libcxx/include/__functional/pointer_to_unary_function.h+2-2
...@@ -14,7 +14,7 @@...@@ -14,7 +14,7 @@
14#include <__functional/unary_function.h>14#include <__functional/unary_function.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
18#endif18#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2323
24template <class _Arg, class _Result>24template <class _Arg, class _Result>
25class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 pointer_to_unary_function25class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 pointer_to_unary_function
26 : public unary_function<_Arg, _Result>26 : public __unary_function<_Arg, _Result>
27{27{
28 _Result (*__f_)(_Arg);28 _Result (*__f_)(_Arg);
29public:29public:
lib/libcxx/include/__functional/ranges_operations.h+5-4
...@@ -11,16 +11,16 @@...@@ -11,16 +11,16 @@
11#define _LIBCPP___FUNCTIONAL_RANGES_OPERATIONS_H11#define _LIBCPP___FUNCTIONAL_RANGES_OPERATIONS_H
1212
13#include <__config>13#include <__config>
14#include <__utility/forward.h>
14#include <concepts>15#include <concepts>
15#include <utility>
1616
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header18# pragma GCC system_header
19#endif19#endif
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
23#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)23#if _LIBCPP_STD_VER > 17
2424
25namespace ranges {25namespace ranges {
2626
...@@ -91,7 +91,8 @@ struct greater_equal {...@@ -91,7 +91,8 @@ struct greater_equal {
91};91};
9292
93} // namespace ranges93} // namespace ranges
94#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)94
95#endif // _LIBCPP_STD_VER > 17
9596
96_LIBCPP_END_NAMESPACE_STD97_LIBCPP_END_NAMESPACE_STD
9798
lib/libcxx/include/__functional/reference_wrapper.h+3-113
...@@ -17,16 +17,13 @@...@@ -17,16 +17,13 @@
17#include <type_traits>17#include <type_traits>
1818
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20#pragma GCC system_header20# pragma GCC system_header
21#endif21#endif
2222
23_LIBCPP_BEGIN_NAMESPACE_STD23_LIBCPP_BEGIN_NAMESPACE_STD
2424
25template <class _Tp>25template <class _Tp>
26class _LIBCPP_TEMPLATE_VIS reference_wrapper26class _LIBCPP_TEMPLATE_VIS reference_wrapper : public __weak_result_type<_Tp>
27#if _LIBCPP_STD_VER <= 17 || !defined(_LIBCPP_ABI_NO_BINDER_BASES)
28 : public __weak_result_type<_Tp>
29#endif
30{27{
31public:28public:
32 // types29 // types
...@@ -51,120 +48,13 @@ public:...@@ -51,120 +48,13 @@ public:
51 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1748 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
52 type& get() const _NOEXCEPT {return *__f_;}49 type& get() const _NOEXCEPT {return *__f_;}
5350
54#ifndef _LIBCPP_CXX03_LANG
55 // invoke51 // invoke
56 template <class... _ArgTypes>52 template <class... _ArgTypes>
57 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1753 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
58 typename __invoke_of<type&, _ArgTypes...>::type54 typename __invoke_of<type&, _ArgTypes...>::type
59 operator() (_ArgTypes&&... __args) const {55 operator() (_ArgTypes&&... __args) const {
60 return _VSTD::__invoke(get(), _VSTD::forward<_ArgTypes>(__args)...);56 return std::__invoke(get(), std::forward<_ArgTypes>(__args)...);
61 }
62#else
63
64 _LIBCPP_INLINE_VISIBILITY
65 typename __invoke_return<type>::type
66 operator() () const {
67 return _VSTD::__invoke(get());
68 }
69
70 template <class _A0>
71 _LIBCPP_INLINE_VISIBILITY
72 typename __invoke_return0<type, _A0>::type
73 operator() (_A0& __a0) const {
74 return _VSTD::__invoke(get(), __a0);
75 }
76
77 template <class _A0>
78 _LIBCPP_INLINE_VISIBILITY
79 typename __invoke_return0<type, _A0 const>::type
80 operator() (_A0 const& __a0) const {
81 return _VSTD::__invoke(get(), __a0);
82 }
83
84 template <class _A0, class _A1>
85 _LIBCPP_INLINE_VISIBILITY
86 typename __invoke_return1<type, _A0, _A1>::type
87 operator() (_A0& __a0, _A1& __a1) const {
88 return _VSTD::__invoke(get(), __a0, __a1);
89 }
90
91 template <class _A0, class _A1>
92 _LIBCPP_INLINE_VISIBILITY
93 typename __invoke_return1<type, _A0 const, _A1>::type
94 operator() (_A0 const& __a0, _A1& __a1) const {
95 return _VSTD::__invoke(get(), __a0, __a1);
96 }
97
98 template <class _A0, class _A1>
99 _LIBCPP_INLINE_VISIBILITY
100 typename __invoke_return1<type, _A0, _A1 const>::type
101 operator() (_A0& __a0, _A1 const& __a1) const {
102 return _VSTD::__invoke(get(), __a0, __a1);
103 }
104
105 template <class _A0, class _A1>
106 _LIBCPP_INLINE_VISIBILITY
107 typename __invoke_return1<type, _A0 const, _A1 const>::type
108 operator() (_A0 const& __a0, _A1 const& __a1) const {
109 return _VSTD::__invoke(get(), __a0, __a1);
110 }
111
112 template <class _A0, class _A1, class _A2>
113 _LIBCPP_INLINE_VISIBILITY
114 typename __invoke_return2<type, _A0, _A1, _A2>::type
115 operator() (_A0& __a0, _A1& __a1, _A2& __a2) const {
116 return _VSTD::__invoke(get(), __a0, __a1, __a2);
117 }
118
119 template <class _A0, class _A1, class _A2>
120 _LIBCPP_INLINE_VISIBILITY
121 typename __invoke_return2<type, _A0 const, _A1, _A2>::type
122 operator() (_A0 const& __a0, _A1& __a1, _A2& __a2) const {
123 return _VSTD::__invoke(get(), __a0, __a1, __a2);
124 }
125
126 template <class _A0, class _A1, class _A2>
127 _LIBCPP_INLINE_VISIBILITY
128 typename __invoke_return2<type, _A0, _A1 const, _A2>::type
129 operator() (_A0& __a0, _A1 const& __a1, _A2& __a2) const {
130 return _VSTD::__invoke(get(), __a0, __a1, __a2);
131 }
132
133 template <class _A0, class _A1, class _A2>
134 _LIBCPP_INLINE_VISIBILITY
135 typename __invoke_return2<type, _A0, _A1, _A2 const>::type
136 operator() (_A0& __a0, _A1& __a1, _A2 const& __a2) const {
137 return _VSTD::__invoke(get(), __a0, __a1, __a2);
138 }
139
140 template <class _A0, class _A1, class _A2>
141 _LIBCPP_INLINE_VISIBILITY
142 typename __invoke_return2<type, _A0 const, _A1 const, _A2>::type
143 operator() (_A0 const& __a0, _A1 const& __a1, _A2& __a2) const {
144 return _VSTD::__invoke(get(), __a0, __a1, __a2);
145 }
146
147 template <class _A0, class _A1, class _A2>
148 _LIBCPP_INLINE_VISIBILITY
149 typename __invoke_return2<type, _A0 const, _A1, _A2 const>::type
150 operator() (_A0 const& __a0, _A1& __a1, _A2 const& __a2) const {
151 return _VSTD::__invoke(get(), __a0, __a1, __a2);
152 }
153
154 template <class _A0, class _A1, class _A2>
155 _LIBCPP_INLINE_VISIBILITY
156 typename __invoke_return2<type, _A0, _A1 const, _A2 const>::type
157 operator() (_A0& __a0, _A1 const& __a1, _A2 const& __a2) const {
158 return _VSTD::__invoke(get(), __a0, __a1, __a2);
159 }
160
161 template <class _A0, class _A1, class _A2>
162 _LIBCPP_INLINE_VISIBILITY
163 typename __invoke_return2<type, _A0 const, _A1 const, _A2 const>::type
164 operator() (_A0 const& __a0, _A1 const& __a1, _A2 const& __a2) const {
165 return _VSTD::__invoke(get(), __a0, __a1, __a2);
166 }57 }
167#endif // _LIBCPP_CXX03_LANG
168};58};
16959
170#if _LIBCPP_STD_VER > 1460#if _LIBCPP_STD_VER > 14
lib/libcxx/include/__functional/unary_function.h+24-2
...@@ -12,18 +12,40 @@...@@ -12,18 +12,40 @@
12#include <__config>12#include <__config>
1313
14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
15#pragma GCC system_header15# pragma GCC system_header
16#endif16#endif
1717
18_LIBCPP_BEGIN_NAMESPACE_STD18_LIBCPP_BEGIN_NAMESPACE_STD
1919
20#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION)
21
20template <class _Arg, class _Result>22template <class _Arg, class _Result>
21struct _LIBCPP_TEMPLATE_VIS unary_function23struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 unary_function
22{24{
23 typedef _Arg argument_type;25 typedef _Arg argument_type;
24 typedef _Result result_type;26 typedef _Result result_type;
25};27};
2628
29#endif // _LIBCPP_STD_VER <= 14
30
31template <class _Arg, class _Result> struct __unary_function_keep_layout_base {
32#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
33 using argument_type _LIBCPP_DEPRECATED_IN_CXX17 = _Arg;
34 using result_type _LIBCPP_DEPRECATED_IN_CXX17 = _Result;
35#endif
36};
37
38#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION)
39_LIBCPP_DIAGNOSTIC_PUSH
40_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated-declarations")
41template <class _Arg, class _Result>
42using __unary_function = unary_function<_Arg, _Result>;
43_LIBCPP_DIAGNOSTIC_POP
44#else
45template <class _Arg, class _Result>
46using __unary_function = __unary_function_keep_layout_base<_Arg, _Result>;
47#endif
48
27_LIBCPP_END_NAMESPACE_STD49_LIBCPP_END_NAMESPACE_STD
2850
29#endif // _LIBCPP___FUNCTIONAL_UNARY_FUNCTION_H51#endif // _LIBCPP___FUNCTIONAL_UNARY_FUNCTION_H
lib/libcxx/include/__functional/unary_negate.h+2-2
...@@ -14,7 +14,7 @@...@@ -14,7 +14,7 @@
14#include <__functional/unary_function.h>14#include <__functional/unary_function.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
18#endif18#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2323
24template <class _Predicate>24template <class _Predicate>
25class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 unary_negate25class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 unary_negate
26 : public unary_function<typename _Predicate::argument_type, bool>26 : public __unary_function<typename _Predicate::argument_type, bool>
27{27{
28 _Predicate __pred_;28 _Predicate __pred_;
29public:29public:
lib/libcxx/include/__functional/unwrap_ref.h+1-1
...@@ -12,7 +12,7 @@...@@ -12,7 +12,7 @@
12#include <__config>12#include <__config>
1313
14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
15#pragma GCC system_header15# pragma GCC system_header
16#endif16#endif
1717
18_LIBCPP_BEGIN_NAMESPACE_STD18_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__functional/weak_result_type.h+57-247
...@@ -16,7 +16,7 @@...@@ -16,7 +16,7 @@
16#include <type_traits>16#include <type_traits>
1717
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19#pragma GCC system_header19# pragma GCC system_header
20#endif20#endif
2121
22_LIBCPP_BEGIN_NAMESPACE_STD22_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -25,11 +25,10 @@ template <class _Tp>...@@ -25,11 +25,10 @@ template <class _Tp>
25struct __has_result_type25struct __has_result_type
26{26{
27private:27private:
28 struct __two {char __lx; char __lxx;};28 template <class _Up> static false_type __test(...);
29 template <class _Up> static __two __test(...);29 template <class _Up> static true_type __test(typename _Up::result_type* = 0);
30 template <class _Up> static char __test(typename _Up::result_type* = 0);
31public:30public:
32 static const bool value = sizeof(__test<_Tp>(0)) == 1;31 static const bool value = decltype(__test<_Tp>(0))::value;
33};32};
3433
35// __weak_result_type34// __weak_result_type
...@@ -41,8 +40,9 @@ private:...@@ -41,8 +40,9 @@ private:
41 struct __two {char __lx; char __lxx;};40 struct __two {char __lx; char __lxx;};
42 static __two __test(...);41 static __two __test(...);
43 template <class _Ap, class _Rp>42 template <class _Ap, class _Rp>
44 static unary_function<_Ap, _Rp>43 static __unary_function<_Ap, _Rp>
45 __test(const volatile unary_function<_Ap, _Rp>*);44 __test(const volatile __unary_function<_Ap, _Rp>*);
45
46public:46public:
47 static const bool value = !is_same<decltype(__test((_Tp*)0)), __two>::value;47 static const bool value = !is_same<decltype(__test((_Tp*)0)), __two>::value;
48 typedef decltype(__test((_Tp*)0)) type;48 typedef decltype(__test((_Tp*)0)) type;
...@@ -55,8 +55,9 @@ private:...@@ -55,8 +55,9 @@ private:
55 struct __two {char __lx; char __lxx;};55 struct __two {char __lx; char __lxx;};
56 static __two __test(...);56 static __two __test(...);
57 template <class _A1, class _A2, class _Rp>57 template <class _A1, class _A2, class _Rp>
58 static binary_function<_A1, _A2, _Rp>58 static __binary_function<_A1, _A2, _Rp>
59 __test(const volatile binary_function<_A1, _A2, _Rp>*);59 __test(const volatile __binary_function<_A1, _A2, _Rp>*);
60
60public:61public:
61 static const bool value = !is_same<decltype(__test((_Tp*)0)), __two>::value;62 static const bool value = !is_same<decltype(__test((_Tp*)0)), __two>::value;
62 typedef decltype(__test((_Tp*)0)) type;63 typedef decltype(__test((_Tp*)0)) type;
...@@ -89,7 +90,9 @@ struct __weak_result_type_imp // bool is true...@@ -89,7 +90,9 @@ struct __weak_result_type_imp // bool is true
89 : public __maybe_derive_from_unary_function<_Tp>,90 : public __maybe_derive_from_unary_function<_Tp>,
90 public __maybe_derive_from_binary_function<_Tp>91 public __maybe_derive_from_binary_function<_Tp>
91{92{
92 typedef _LIBCPP_NODEBUG typename _Tp::result_type result_type;93#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
94 using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = typename _Tp::result_type;
95#endif
93};96};
9497
95template <class _Tp>98template <class _Tp>
...@@ -110,62 +113,68 @@ struct __weak_result_type...@@ -110,62 +113,68 @@ struct __weak_result_type
110template <class _Rp>113template <class _Rp>
111struct __weak_result_type<_Rp ()>114struct __weak_result_type<_Rp ()>
112{115{
113 typedef _LIBCPP_NODEBUG _Rp result_type;116#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
117 using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp;
118#endif
114};119};
115120
116template <class _Rp>121template <class _Rp>
117struct __weak_result_type<_Rp (&)()>122struct __weak_result_type<_Rp (&)()>
118{123{
119 typedef _LIBCPP_NODEBUG _Rp result_type;124#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
125 using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp;
126#endif
120};127};
121128
122template <class _Rp>129template <class _Rp>
123struct __weak_result_type<_Rp (*)()>130struct __weak_result_type<_Rp (*)()>
124{131{
125 typedef _LIBCPP_NODEBUG _Rp result_type;132#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
133 using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp;
134#endif
126};135};
127136
128// 1 argument case137// 1 argument case
129138
130template <class _Rp, class _A1>139template <class _Rp, class _A1>
131struct __weak_result_type<_Rp (_A1)>140struct __weak_result_type<_Rp (_A1)>
132 : public unary_function<_A1, _Rp>141 : public __unary_function<_A1, _Rp>
133{142{
134};143};
135144
136template <class _Rp, class _A1>145template <class _Rp, class _A1>
137struct __weak_result_type<_Rp (&)(_A1)>146struct __weak_result_type<_Rp (&)(_A1)>
138 : public unary_function<_A1, _Rp>147 : public __unary_function<_A1, _Rp>
139{148{
140};149};
141150
142template <class _Rp, class _A1>151template <class _Rp, class _A1>
143struct __weak_result_type<_Rp (*)(_A1)>152struct __weak_result_type<_Rp (*)(_A1)>
144 : public unary_function<_A1, _Rp>153 : public __unary_function<_A1, _Rp>
145{154{
146};155};
147156
148template <class _Rp, class _Cp>157template <class _Rp, class _Cp>
149struct __weak_result_type<_Rp (_Cp::*)()>158struct __weak_result_type<_Rp (_Cp::*)()>
150 : public unary_function<_Cp*, _Rp>159 : public __unary_function<_Cp*, _Rp>
151{160{
152};161};
153162
154template <class _Rp, class _Cp>163template <class _Rp, class _Cp>
155struct __weak_result_type<_Rp (_Cp::*)() const>164struct __weak_result_type<_Rp (_Cp::*)() const>
156 : public unary_function<const _Cp*, _Rp>165 : public __unary_function<const _Cp*, _Rp>
157{166{
158};167};
159168
160template <class _Rp, class _Cp>169template <class _Rp, class _Cp>
161struct __weak_result_type<_Rp (_Cp::*)() volatile>170struct __weak_result_type<_Rp (_Cp::*)() volatile>
162 : public unary_function<volatile _Cp*, _Rp>171 : public __unary_function<volatile _Cp*, _Rp>
163{172{
164};173};
165174
166template <class _Rp, class _Cp>175template <class _Rp, class _Cp>
167struct __weak_result_type<_Rp (_Cp::*)() const volatile>176struct __weak_result_type<_Rp (_Cp::*)() const volatile>
168 : public unary_function<const volatile _Cp*, _Rp>177 : public __unary_function<const volatile _Cp*, _Rp>
169{178{
170};179};
171180
...@@ -173,90 +182,102 @@ struct __weak_result_type<_Rp (_Cp::*)() const volatile>...@@ -173,90 +182,102 @@ struct __weak_result_type<_Rp (_Cp::*)() const volatile>
173182
174template <class _Rp, class _A1, class _A2>183template <class _Rp, class _A1, class _A2>
175struct __weak_result_type<_Rp (_A1, _A2)>184struct __weak_result_type<_Rp (_A1, _A2)>
176 : public binary_function<_A1, _A2, _Rp>185 : public __binary_function<_A1, _A2, _Rp>
177{186{
178};187};
179188
180template <class _Rp, class _A1, class _A2>189template <class _Rp, class _A1, class _A2>
181struct __weak_result_type<_Rp (*)(_A1, _A2)>190struct __weak_result_type<_Rp (*)(_A1, _A2)>
182 : public binary_function<_A1, _A2, _Rp>191 : public __binary_function<_A1, _A2, _Rp>
183{192{
184};193};
185194
186template <class _Rp, class _A1, class _A2>195template <class _Rp, class _A1, class _A2>
187struct __weak_result_type<_Rp (&)(_A1, _A2)>196struct __weak_result_type<_Rp (&)(_A1, _A2)>
188 : public binary_function<_A1, _A2, _Rp>197 : public __binary_function<_A1, _A2, _Rp>
189{198{
190};199};
191200
192template <class _Rp, class _Cp, class _A1>201template <class _Rp, class _Cp, class _A1>
193struct __weak_result_type<_Rp (_Cp::*)(_A1)>202struct __weak_result_type<_Rp (_Cp::*)(_A1)>
194 : public binary_function<_Cp*, _A1, _Rp>203 : public __binary_function<_Cp*, _A1, _Rp>
195{204{
196};205};
197206
198template <class _Rp, class _Cp, class _A1>207template <class _Rp, class _Cp, class _A1>
199struct __weak_result_type<_Rp (_Cp::*)(_A1) const>208struct __weak_result_type<_Rp (_Cp::*)(_A1) const>
200 : public binary_function<const _Cp*, _A1, _Rp>209 : public __binary_function<const _Cp*, _A1, _Rp>
201{210{
202};211};
203212
204template <class _Rp, class _Cp, class _A1>213template <class _Rp, class _Cp, class _A1>
205struct __weak_result_type<_Rp (_Cp::*)(_A1) volatile>214struct __weak_result_type<_Rp (_Cp::*)(_A1) volatile>
206 : public binary_function<volatile _Cp*, _A1, _Rp>215 : public __binary_function<volatile _Cp*, _A1, _Rp>
207{216{
208};217};
209218
210template <class _Rp, class _Cp, class _A1>219template <class _Rp, class _Cp, class _A1>
211struct __weak_result_type<_Rp (_Cp::*)(_A1) const volatile>220struct __weak_result_type<_Rp (_Cp::*)(_A1) const volatile>
212 : public binary_function<const volatile _Cp*, _A1, _Rp>221 : public __binary_function<const volatile _Cp*, _A1, _Rp>
213{222{
214};223};
215224
216
217#ifndef _LIBCPP_CXX03_LANG
218// 3 or more arguments225// 3 or more arguments
219226
220template <class _Rp, class _A1, class _A2, class _A3, class ..._A4>227template <class _Rp, class _A1, class _A2, class _A3, class ..._A4>
221struct __weak_result_type<_Rp (_A1, _A2, _A3, _A4...)>228struct __weak_result_type<_Rp (_A1, _A2, _A3, _A4...)>
222{229{
223 typedef _Rp result_type;230#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
231 using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp;
232#endif
224};233};
225234
226template <class _Rp, class _A1, class _A2, class _A3, class ..._A4>235template <class _Rp, class _A1, class _A2, class _A3, class ..._A4>
227struct __weak_result_type<_Rp (&)(_A1, _A2, _A3, _A4...)>236struct __weak_result_type<_Rp (&)(_A1, _A2, _A3, _A4...)>
228{237{
229 typedef _Rp result_type;238#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
239 using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp;
240#endif
230};241};
231242
232template <class _Rp, class _A1, class _A2, class _A3, class ..._A4>243template <class _Rp, class _A1, class _A2, class _A3, class ..._A4>
233struct __weak_result_type<_Rp (*)(_A1, _A2, _A3, _A4...)>244struct __weak_result_type<_Rp (*)(_A1, _A2, _A3, _A4...)>
234{245{
235 typedef _Rp result_type;246#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
247 using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp;
248#endif
236};249};
237250
238template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3>251template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3>
239struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...)>252struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...)>
240{253{
241 typedef _Rp result_type;254#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
255 using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp;
256#endif
242};257};
243258
244template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3>259template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3>
245struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const>260struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const>
246{261{
247 typedef _Rp result_type;262#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
263 using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp;
264#endif
248};265};
249266
250template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3>267template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3>
251struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) volatile>268struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) volatile>
252{269{
253 typedef _Rp result_type;270#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
271 using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp;
272#endif
254};273};
255274
256template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3>275template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3>
257struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const volatile>276struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const volatile>
258{277{
259 typedef _Rp result_type;278#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
279 using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp;
280#endif
260};281};
261282
262template <class _Tp, class ..._Args>283template <class _Tp, class ..._Args>
...@@ -265,217 +286,6 @@ struct __invoke_return...@@ -265,217 +286,6 @@ struct __invoke_return
265 typedef decltype(_VSTD::__invoke(declval<_Tp>(), declval<_Args>()...)) type;286 typedef decltype(_VSTD::__invoke(declval<_Tp>(), declval<_Args>()...)) type;
266};287};
267288
268#else // defined(_LIBCPP_CXX03_LANG)
269
270template <class _Ret, class _T1, bool _IsFunc, bool _IsBase>
271struct __enable_invoke_imp;
272
273template <class _Ret, class _T1>
274struct __enable_invoke_imp<_Ret, _T1, true, true> {
275 typedef _Ret _Bullet1;
276 typedef _Bullet1 type;
277};
278
279template <class _Ret, class _T1>
280struct __enable_invoke_imp<_Ret, _T1, true, false> {
281 typedef _Ret _Bullet2;
282 typedef _Bullet2 type;
283};
284
285template <class _Ret, class _T1>
286struct __enable_invoke_imp<_Ret, _T1, false, true> {
287 typedef typename add_lvalue_reference<
288 typename __apply_cv<_T1, _Ret>::type
289 >::type _Bullet3;
290 typedef _Bullet3 type;
291};
292
293template <class _Ret, class _T1>
294struct __enable_invoke_imp<_Ret, _T1, false, false> {
295 typedef typename add_lvalue_reference<
296 typename __apply_cv<decltype(*declval<_T1>()), _Ret>::type
297 >::type _Bullet4;
298 typedef _Bullet4 type;
299};
300
301template <class _Ret, class _T1>
302struct __enable_invoke_imp<_Ret, _T1*, false, false> {
303 typedef typename add_lvalue_reference<
304 typename __apply_cv<_T1, _Ret>::type
305 >::type _Bullet4;
306 typedef _Bullet4 type;
307};
308
309template <class _Fn, class _T1,
310 class _Traits = __member_pointer_traits<_Fn>,
311 class _Ret = typename _Traits::_ReturnType,
312 class _Class = typename _Traits::_ClassType>
313struct __enable_invoke : __enable_invoke_imp<
314 _Ret, _T1,
315 is_member_function_pointer<_Fn>::value,
316 is_base_of<_Class, typename remove_reference<_T1>::type>::value>
317{
318};
319
320__nat __invoke(__any, ...);
321
322// first bullet
323
324template <class _Fn, class _T1>
325inline _LIBCPP_INLINE_VISIBILITY
326typename __enable_invoke<_Fn, _T1>::_Bullet1
327__invoke(_Fn __f, _T1& __t1) {
328 return (__t1.*__f)();
329}
330
331template <class _Fn, class _T1, class _A0>
332inline _LIBCPP_INLINE_VISIBILITY
333typename __enable_invoke<_Fn, _T1>::_Bullet1
334__invoke(_Fn __f, _T1& __t1, _A0& __a0) {
335 return (__t1.*__f)(__a0);
336}
337
338template <class _Fn, class _T1, class _A0, class _A1>
339inline _LIBCPP_INLINE_VISIBILITY
340typename __enable_invoke<_Fn, _T1>::_Bullet1
341__invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1) {
342 return (__t1.*__f)(__a0, __a1);
343}
344
345template <class _Fn, class _T1, class _A0, class _A1, class _A2>
346inline _LIBCPP_INLINE_VISIBILITY
347typename __enable_invoke<_Fn, _T1>::_Bullet1
348__invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1, _A2& __a2) {
349 return (__t1.*__f)(__a0, __a1, __a2);
350}
351
352template <class _Fn, class _T1>
353inline _LIBCPP_INLINE_VISIBILITY
354typename __enable_invoke<_Fn, _T1>::_Bullet2
355__invoke(_Fn __f, _T1& __t1) {
356 return ((*__t1).*__f)();
357}
358
359template <class _Fn, class _T1, class _A0>
360inline _LIBCPP_INLINE_VISIBILITY
361typename __enable_invoke<_Fn, _T1>::_Bullet2
362__invoke(_Fn __f, _T1& __t1, _A0& __a0) {
363 return ((*__t1).*__f)(__a0);
364}
365
366template <class _Fn, class _T1, class _A0, class _A1>
367inline _LIBCPP_INLINE_VISIBILITY
368typename __enable_invoke<_Fn, _T1>::_Bullet2
369__invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1) {
370 return ((*__t1).*__f)(__a0, __a1);
371}
372
373template <class _Fn, class _T1, class _A0, class _A1, class _A2>
374inline _LIBCPP_INLINE_VISIBILITY
375typename __enable_invoke<_Fn, _T1>::_Bullet2
376__invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1, _A2& __a2) {
377 return ((*__t1).*__f)(__a0, __a1, __a2);
378}
379
380template <class _Fn, class _T1>
381inline _LIBCPP_INLINE_VISIBILITY
382typename __enable_invoke<_Fn, _T1>::_Bullet3
383__invoke(_Fn __f, _T1& __t1) {
384 return __t1.*__f;
385}
386
387template <class _Fn, class _T1>
388inline _LIBCPP_INLINE_VISIBILITY
389typename __enable_invoke<_Fn, _T1>::_Bullet4
390__invoke(_Fn __f, _T1& __t1) {
391 return (*__t1).*__f;
392}
393
394// fifth bullet
395
396template <class _Fp>
397inline _LIBCPP_INLINE_VISIBILITY
398decltype(declval<_Fp&>()())
399__invoke(_Fp& __f)
400{
401 return __f();
402}
403
404template <class _Fp, class _A0>
405inline _LIBCPP_INLINE_VISIBILITY
406decltype(declval<_Fp&>()(declval<_A0&>()))
407__invoke(_Fp& __f, _A0& __a0)
408{
409 return __f(__a0);
410}
411
412template <class _Fp, class _A0, class _A1>
413inline _LIBCPP_INLINE_VISIBILITY
414decltype(declval<_Fp&>()(declval<_A0&>(), declval<_A1&>()))
415__invoke(_Fp& __f, _A0& __a0, _A1& __a1)
416{
417 return __f(__a0, __a1);
418}
419
420template <class _Fp, class _A0, class _A1, class _A2>
421inline _LIBCPP_INLINE_VISIBILITY
422decltype(declval<_Fp&>()(declval<_A0&>(), declval<_A1&>(), declval<_A2&>()))
423__invoke(_Fp& __f, _A0& __a0, _A1& __a1, _A2& __a2)
424{
425 return __f(__a0, __a1, __a2);
426}
427
428template <class _Fp, bool = __has_result_type<__weak_result_type<_Fp> >::value>
429struct __invoke_return
430{
431 typedef typename __weak_result_type<_Fp>::result_type type;
432};
433
434template <class _Fp>
435struct __invoke_return<_Fp, false>
436{
437 typedef decltype(_VSTD::__invoke(declval<_Fp&>())) type;
438};
439
440template <class _Tp, class _A0>
441struct __invoke_return0
442{
443 typedef decltype(_VSTD::__invoke(declval<_Tp&>(), declval<_A0&>())) type;
444};
445
446template <class _Rp, class _Tp, class _A0>
447struct __invoke_return0<_Rp _Tp::*, _A0>
448{
449 typedef typename __enable_invoke<_Rp _Tp::*, _A0>::type type;
450};
451
452template <class _Tp, class _A0, class _A1>
453struct __invoke_return1
454{
455 typedef decltype(_VSTD::__invoke(declval<_Tp&>(), declval<_A0&>(),
456 declval<_A1&>())) type;
457};
458
459template <class _Rp, class _Class, class _A0, class _A1>
460struct __invoke_return1<_Rp _Class::*, _A0, _A1> {
461 typedef typename __enable_invoke<_Rp _Class::*, _A0>::type type;
462};
463
464template <class _Tp, class _A0, class _A1, class _A2>
465struct __invoke_return2
466{
467 typedef decltype(_VSTD::__invoke(declval<_Tp&>(), declval<_A0&>(),
468 declval<_A1&>(),
469 declval<_A2&>())) type;
470};
471
472template <class _Ret, class _Class, class _A0, class _A1, class _A2>
473struct __invoke_return2<_Ret _Class::*, _A0, _A1, _A2> {
474 typedef typename __enable_invoke<_Ret _Class::*, _A0>::type type;
475};
476
477#endif // !defined(_LIBCPP_CXX03_LANG)
478
479_LIBCPP_END_NAMESPACE_STD289_LIBCPP_END_NAMESPACE_STD
480290
481#endif // _LIBCPP___FUNCTIONAL_WEAK_RESULT_TYPE_H291#endif // _LIBCPP___FUNCTIONAL_WEAK_RESULT_TYPE_H
lib/libcxx/include/__functional_base deleted-32
...@@ -1,32 +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_FUNCTIONAL_BASE
11#define _LIBCPP_FUNCTIONAL_BASE
12
13#include <__config>
14#include <__functional/binary_function.h>
15#include <__functional/invoke.h>
16#include <__functional/operations.h>
17#include <__functional/reference_wrapper.h>
18#include <__functional/unary_function.h>
19#include <__functional/weak_result_type.h>
20#include <__memory/allocator_arg_t.h>
21#include <__memory/uses_allocator.h>
22#include <exception>
23#include <new>
24#include <type_traits>
25#include <typeinfo>
26#include <utility>
27
28#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
29#pragma GCC system_header
30#endif
31
32#endif // _LIBCPP_FUNCTIONAL_BASE
lib/libcxx/include/__fwd/span.h created+37
...@@ -0,0 +1,37 @@
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_FWD_SPAN_H
11#define _LIBCPP_FWD_SPAN_H
12
13#include <__config>
14#include <cstddef>
15#include <limits>
16
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header
19#endif
20
21_LIBCPP_PUSH_MACROS
22#include <__undef_macros>
23
24_LIBCPP_BEGIN_NAMESPACE_STD
25
26#if _LIBCPP_STD_VER > 17
27
28inline constexpr size_t dynamic_extent = numeric_limits<size_t>::max();
29template <typename _Tp, size_t _Extent = dynamic_extent> class span;
30
31#endif
32
33_LIBCPP_END_NAMESPACE_STD
34
35_LIBCPP_POP_MACROS
36
37#endif // _LIBCPP_FWD_SPAN_H
lib/libcxx/include/__fwd/string_view.h created+37
...@@ -0,0 +1,37 @@
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_FWD_STRING_VIEW_H
11#define _LIBCPP_FWD_STRING_VIEW_H
12
13#include <__config>
14#include <iosfwd> // char_traits
15
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header
18#endif
19
20_LIBCPP_BEGIN_NAMESPACE_STD
21
22template<class _CharT, class _Traits = char_traits<_CharT> >
23class _LIBCPP_TEMPLATE_VIS basic_string_view;
24
25typedef basic_string_view<char> string_view;
26#ifndef _LIBCPP_HAS_NO_CHAR8_T
27typedef basic_string_view<char8_t> u8string_view;
28#endif
29typedef basic_string_view<char16_t> u16string_view;
30typedef basic_string_view<char32_t> u32string_view;
31#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
32typedef basic_string_view<wchar_t> wstring_view;
33#endif
34
35_LIBCPP_END_NAMESPACE_STD
36
37#endif // _LIBCPP_FWD_STRING_VIEW_H
lib/libcxx/include/__hash_table+87-176
...@@ -7,22 +7,26 @@...@@ -7,22 +7,26 @@
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
99
10#ifndef _LIBCPP__HASH_TABLE10#ifndef _LIBCPP___HASH_TABLE
11#define _LIBCPP__HASH_TABLE11#define _LIBCPP___HASH_TABLE
1212
13#include <__algorithm/max.h>
14#include <__algorithm/min.h>
15#include <__assert>
13#include <__bits> // __libcpp_clz16#include <__bits> // __libcpp_clz
14#include <__config>17#include <__config>
15#include <__debug>18#include <__debug>
16#include <algorithm>19#include <__functional/hash.h>
20#include <__iterator/iterator_traits.h>
21#include <__memory/swap_allocator.h>
22#include <__utility/swap.h>
17#include <cmath>23#include <cmath>
18#include <initializer_list>24#include <initializer_list>
19#include <iterator>
20#include <memory>25#include <memory>
21#include <type_traits>26#include <type_traits>
22#include <utility>
2327
24#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)28#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
25#pragma GCC system_header29# pragma GCC system_header
26#endif30#endif
2731
28_LIBCPP_PUSH_MACROS32_LIBCPP_PUSH_MACROS
...@@ -44,7 +48,7 @@ template <class ..._Args>...@@ -44,7 +48,7 @@ template <class ..._Args>
44struct __is_hash_value_type : false_type {};48struct __is_hash_value_type : false_type {};
4549
46template <class _One>50template <class _One>
47struct __is_hash_value_type<_One> : __is_hash_value_type_imp<typename __uncvref<_One>::type> {};51struct __is_hash_value_type<_One> : __is_hash_value_type_imp<__uncvref_t<_One> > {};
4852
49_LIBCPP_FUNC_VIS53_LIBCPP_FUNC_VIS
50size_t __next_prime(size_t __n);54size_t __next_prime(size_t __n);
...@@ -175,16 +179,14 @@ struct __hash_key_value_types<__hash_value_type<_Key, _Tp> > {...@@ -175,16 +179,14 @@ struct __hash_key_value_types<__hash_value_type<_Key, _Tp> > {
175179
176 template <class _Up>180 template <class _Up>
177 _LIBCPP_INLINE_VISIBILITY181 _LIBCPP_INLINE_VISIBILITY
178 static typename enable_if<__is_same_uncvref<_Up, __node_value_type>::value,182 static __enable_if_t<__is_same_uncvref<_Up, __node_value_type>::value, __container_value_type const&>
179 __container_value_type const&>::type
180 __get_value(_Up& __t) {183 __get_value(_Up& __t) {
181 return __t.__get_value();184 return __t.__get_value();
182 }185 }
183186
184 template <class _Up>187 template <class _Up>
185 _LIBCPP_INLINE_VISIBILITY188 _LIBCPP_INLINE_VISIBILITY
186 static typename enable_if<__is_same_uncvref<_Up, __container_value_type>::value,189 static __enable_if_t<__is_same_uncvref<_Up, __container_value_type>::value, __container_value_type const&>
187 __container_value_type const&>::type
188 __get_value(_Up& __t) {190 __get_value(_Up& __t) {
189 return __t;191 return __t;
190 }192 }
...@@ -291,7 +293,7 @@ public:...@@ -291,7 +293,7 @@ public:
291 _VSTD::__debug_db_insert_i(this);293 _VSTD::__debug_db_insert_i(this);
292 }294 }
293295
294#if _LIBCPP_DEBUG_LEVEL == 2296#ifdef _LIBCPP_ENABLE_DEBUG_MODE
295 _LIBCPP_INLINE_VISIBILITY297 _LIBCPP_INLINE_VISIBILITY
296 __hash_iterator(const __hash_iterator& __i)298 __hash_iterator(const __hash_iterator& __i)
297 : __node_(__i.__node_)299 : __node_(__i.__node_)
...@@ -315,7 +317,7 @@ public:...@@ -315,7 +317,7 @@ public:
315 }317 }
316 return *this;318 return *this;
317 }319 }
318#endif // _LIBCPP_DEBUG_LEVEL == 2320#endif // _LIBCPP_ENABLE_DEBUG_MODE
319321
320 _LIBCPP_INLINE_VISIBILITY322 _LIBCPP_INLINE_VISIBILITY
321 reference operator*() const {323 reference operator*() const {
...@@ -357,19 +359,15 @@ public:...@@ -357,19 +359,15 @@ public:
357 {return !(__x == __y);}359 {return !(__x == __y);}
358360
359private:361private:
360#if _LIBCPP_DEBUG_LEVEL == 2
361 _LIBCPP_INLINE_VISIBILITY362 _LIBCPP_INLINE_VISIBILITY
362 __hash_iterator(__next_pointer __node, const void* __c) _NOEXCEPT363 explicit __hash_iterator(__next_pointer __node, const void* __c) _NOEXCEPT
363 : __node_(__node)364 : __node_(__node)
364 {365 {
366 (void)__c;
367#ifdef _LIBCPP_ENABLE_DEBUG_MODE
365 __get_db()->__insert_ic(this, __c);368 __get_db()->__insert_ic(this, __c);
366 }
367#else
368 _LIBCPP_INLINE_VISIBILITY
369 __hash_iterator(__next_pointer __node) _NOEXCEPT
370 : __node_(__node)
371 {}
372#endif369#endif
370 }
373 template <class, class, class, class> friend class __hash_table;371 template <class, class, class, class> friend class __hash_table;
374 template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_const_iterator;372 template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_const_iterator;
375 template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_map_iterator;373 template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_map_iterator;
...@@ -405,12 +403,12 @@ public:...@@ -405,12 +403,12 @@ public:
405 __hash_const_iterator(const __non_const_iterator& __x) _NOEXCEPT403 __hash_const_iterator(const __non_const_iterator& __x) _NOEXCEPT
406 : __node_(__x.__node_)404 : __node_(__x.__node_)
407 {405 {
408#if _LIBCPP_DEBUG_LEVEL == 2406#ifdef _LIBCPP_ENABLE_DEBUG_MODE
409 __get_db()->__iterator_copy(this, _VSTD::addressof(__x));407 __get_db()->__iterator_copy(this, _VSTD::addressof(__x));
410#endif408#endif
411 }409 }
412410
413#if _LIBCPP_DEBUG_LEVEL == 2411#ifdef _LIBCPP_ENABLE_DEBUG_MODE
414 _LIBCPP_INLINE_VISIBILITY412 _LIBCPP_INLINE_VISIBILITY
415 __hash_const_iterator(const __hash_const_iterator& __i)413 __hash_const_iterator(const __hash_const_iterator& __i)
416 : __node_(__i.__node_)414 : __node_(__i.__node_)
...@@ -434,7 +432,7 @@ public:...@@ -434,7 +432,7 @@ public:
434 }432 }
435 return *this;433 return *this;
436 }434 }
437#endif // _LIBCPP_DEBUG_LEVEL == 2435#endif // _LIBCPP_ENABLE_DEBUG_MODE
438436
439 _LIBCPP_INLINE_VISIBILITY437 _LIBCPP_INLINE_VISIBILITY
440 reference operator*() const {438 reference operator*() const {
...@@ -475,19 +473,15 @@ public:...@@ -475,19 +473,15 @@ public:
475 {return !(__x == __y);}473 {return !(__x == __y);}
476474
477private:475private:
478#if _LIBCPP_DEBUG_LEVEL == 2
479 _LIBCPP_INLINE_VISIBILITY476 _LIBCPP_INLINE_VISIBILITY
480 __hash_const_iterator(__next_pointer __node, const void* __c) _NOEXCEPT477 explicit __hash_const_iterator(__next_pointer __node, const void* __c) _NOEXCEPT
481 : __node_(__node)478 : __node_(__node)
482 {479 {
480 (void)__c;
481#ifdef _LIBCPP_ENABLE_DEBUG_MODE
483 __get_db()->__insert_ic(this, __c);482 __get_db()->__insert_ic(this, __c);
484 }
485#else
486 _LIBCPP_INLINE_VISIBILITY
487 __hash_const_iterator(__next_pointer __node) _NOEXCEPT
488 : __node_(__node)
489 {}
490#endif483#endif
484 }
491 template <class, class, class, class> friend class __hash_table;485 template <class, class, class, class> friend class __hash_table;
492 template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator;486 template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator;
493 template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS unordered_map;487 template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS unordered_map;
...@@ -516,7 +510,7 @@ public:...@@ -516,7 +510,7 @@ public:
516 _VSTD::__debug_db_insert_i(this);510 _VSTD::__debug_db_insert_i(this);
517 }511 }
518512
519#if _LIBCPP_DEBUG_LEVEL == 2513#ifdef _LIBCPP_ENABLE_DEBUG_MODE
520 _LIBCPP_INLINE_VISIBILITY514 _LIBCPP_INLINE_VISIBILITY
521 __hash_local_iterator(const __hash_local_iterator& __i)515 __hash_local_iterator(const __hash_local_iterator& __i)
522 : __node_(__i.__node_),516 : __node_(__i.__node_),
...@@ -544,7 +538,7 @@ public:...@@ -544,7 +538,7 @@ public:
544 }538 }
545 return *this;539 return *this;
546 }540 }
547#endif // _LIBCPP_DEBUG_LEVEL == 2541#endif // _LIBCPP_ENABLE_DEBUG_MODE
548542
549 _LIBCPP_INLINE_VISIBILITY543 _LIBCPP_INLINE_VISIBILITY
550 reference operator*() const {544 reference operator*() const {
...@@ -588,30 +582,20 @@ public:...@@ -588,30 +582,20 @@ public:
588 {return !(__x == __y);}582 {return !(__x == __y);}
589583
590private:584private:
591#if _LIBCPP_DEBUG_LEVEL == 2
592 _LIBCPP_INLINE_VISIBILITY585 _LIBCPP_INLINE_VISIBILITY
593 __hash_local_iterator(__next_pointer __node, size_t __bucket,586 explicit __hash_local_iterator(__next_pointer __node, size_t __bucket,
594 size_t __bucket_count, const void* __c) _NOEXCEPT587 size_t __bucket_count, const void* __c) _NOEXCEPT
595 : __node_(__node),588 : __node_(__node),
596 __bucket_(__bucket),589 __bucket_(__bucket),
597 __bucket_count_(__bucket_count)590 __bucket_count_(__bucket_count)
598 {591 {
592 (void)__c;
593#ifdef _LIBCPP_ENABLE_DEBUG_MODE
599 __get_db()->__insert_ic(this, __c);594 __get_db()->__insert_ic(this, __c);
595#endif
600 if (__node_ != nullptr)596 if (__node_ != nullptr)
601 __node_ = __node_->__next_;597 __node_ = __node_->__next_;
602 }598 }
603#else
604 _LIBCPP_INLINE_VISIBILITY
605 __hash_local_iterator(__next_pointer __node, size_t __bucket,
606 size_t __bucket_count) _NOEXCEPT
607 : __node_(__node),
608 __bucket_(__bucket),
609 __bucket_count_(__bucket_count)
610 {
611 if (__node_ != nullptr)
612 __node_ = __node_->__next_;
613 }
614#endif
615 template <class, class, class, class> friend class __hash_table;599 template <class, class, class, class> friend class __hash_table;
616 template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator;600 template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator;
617 template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_map_iterator;601 template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_map_iterator;
...@@ -654,12 +638,12 @@ public:...@@ -654,12 +638,12 @@ public:
654 __bucket_(__x.__bucket_),638 __bucket_(__x.__bucket_),
655 __bucket_count_(__x.__bucket_count_)639 __bucket_count_(__x.__bucket_count_)
656 {640 {
657#if _LIBCPP_DEBUG_LEVEL == 2641#ifdef _LIBCPP_ENABLE_DEBUG_MODE
658 __get_db()->__iterator_copy(this, _VSTD::addressof(__x));642 __get_db()->__iterator_copy(this, _VSTD::addressof(__x));
659#endif643#endif
660 }644 }
661645
662#if _LIBCPP_DEBUG_LEVEL == 2646#ifdef _LIBCPP_ENABLE_DEBUG_MODE
663 _LIBCPP_INLINE_VISIBILITY647 _LIBCPP_INLINE_VISIBILITY
664 __hash_const_local_iterator(const __hash_const_local_iterator& __i)648 __hash_const_local_iterator(const __hash_const_local_iterator& __i)
665 : __node_(__i.__node_),649 : __node_(__i.__node_),
...@@ -687,7 +671,7 @@ public:...@@ -687,7 +671,7 @@ public:
687 }671 }
688 return *this;672 return *this;
689 }673 }
690#endif // _LIBCPP_DEBUG_LEVEL == 2674#endif // _LIBCPP_ENABLE_DEBUG_MODE
691675
692 _LIBCPP_INLINE_VISIBILITY676 _LIBCPP_INLINE_VISIBILITY
693 reference operator*() const {677 reference operator*() const {
...@@ -731,30 +715,20 @@ public:...@@ -731,30 +715,20 @@ public:
731 {return !(__x == __y);}715 {return !(__x == __y);}
732716
733private:717private:
734#if _LIBCPP_DEBUG_LEVEL == 2
735 _LIBCPP_INLINE_VISIBILITY718 _LIBCPP_INLINE_VISIBILITY
736 __hash_const_local_iterator(__next_pointer __node_ptr, size_t __bucket,719 explicit __hash_const_local_iterator(__next_pointer __node_ptr, size_t __bucket,
737 size_t __bucket_count, const void* __c) _NOEXCEPT720 size_t __bucket_count, const void* __c) _NOEXCEPT
738 : __node_(__node_ptr),721 : __node_(__node_ptr),
739 __bucket_(__bucket),722 __bucket_(__bucket),
740 __bucket_count_(__bucket_count)723 __bucket_count_(__bucket_count)
741 {724 {
725 (void)__c;
726#ifdef _LIBCPP_ENABLE_DEBUG_MODE
742 __get_db()->__insert_ic(this, __c);727 __get_db()->__insert_ic(this, __c);
728#endif
743 if (__node_ != nullptr)729 if (__node_ != nullptr)
744 __node_ = __node_->__next_;730 __node_ = __node_->__next_;
745 }731 }
746#else
747 _LIBCPP_INLINE_VISIBILITY
748 __hash_const_local_iterator(__next_pointer __node_ptr, size_t __bucket,
749 size_t __bucket_count) _NOEXCEPT
750 : __node_(__node_ptr),
751 __bucket_(__bucket),
752 __bucket_count_(__bucket_count)
753 {
754 if (__node_ != nullptr)
755 __node_ = __node_->__next_;
756 }
757#endif
758 template <class, class, class, class> friend class __hash_table;732 template <class, class, class, class> friend class __hash_table;
759 template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator;733 template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator;
760};734};
...@@ -1074,10 +1048,8 @@ public:...@@ -1074,10 +1048,8 @@ public:
10741048
1075 template <class _First, class _Second>1049 template <class _First, class _Second>
1076 _LIBCPP_INLINE_VISIBILITY1050 _LIBCPP_INLINE_VISIBILITY
1077 typename enable_if<1051 __enable_if_t<__can_extract_map_key<_First, key_type, __container_value_type>::value, pair<iterator, bool> >
1078 __can_extract_map_key<_First, key_type, __container_value_type>::value,1052 __emplace_unique(_First&& __f, _Second&& __s) {
1079 pair<iterator, bool>
1080 >::type __emplace_unique(_First&& __f, _Second&& __s) {
1081 return __emplace_unique_key_args(__f, _VSTD::forward<_First>(__f),1053 return __emplace_unique_key_args(__f, _VSTD::forward<_First>(__f),
1082 _VSTD::forward<_Second>(__s));1054 _VSTD::forward<_Second>(__s));
1083 }1055 }
...@@ -1121,9 +1093,7 @@ public:...@@ -1121,9 +1093,7 @@ public:
1121 return __emplace_unique_key_args(_NodeTypes::__get_key(__x), _VSTD::move(__x));1093 return __emplace_unique_key_args(_NodeTypes::__get_key(__x), _VSTD::move(__x));
1122 }1094 }
11231095
1124 template <class _Pp, class = typename enable_if<1096 template <class _Pp, class = __enable_if_t<!__is_same_uncvref<_Pp, __container_value_type>::value> >
1125 !__is_same_uncvref<_Pp, __container_value_type>::value
1126 >::type>
1127 _LIBCPP_INLINE_VISIBILITY1097 _LIBCPP_INLINE_VISIBILITY
1128 pair<iterator, bool> __insert_unique(_Pp&& __x) {1098 pair<iterator, bool> __insert_unique(_Pp&& __x) {
1129 return __emplace_unique(_VSTD::forward<_Pp>(__x));1099 return __emplace_unique(_VSTD::forward<_Pp>(__x));
...@@ -1177,9 +1147,16 @@ public:...@@ -1177,9 +1147,16 @@ public:
1177#endif1147#endif
11781148
1179 void clear() _NOEXCEPT;1149 void clear() _NOEXCEPT;
1180 void rehash(size_type __n);1150 _LIBCPP_INLINE_VISIBILITY void __rehash_unique(size_type __n) { __rehash<true>(__n); }
1181 _LIBCPP_INLINE_VISIBILITY void reserve(size_type __n)1151 _LIBCPP_INLINE_VISIBILITY void __rehash_multi(size_type __n) { __rehash<false>(__n); }
1182 {rehash(static_cast<size_type>(ceil(__n / max_load_factor())));}1152 _LIBCPP_INLINE_VISIBILITY void __reserve_unique(size_type __n)
1153 {
1154 __rehash_unique(static_cast<size_type>(ceil(__n / max_load_factor())));
1155 }
1156 _LIBCPP_INLINE_VISIBILITY void __reserve_multi(size_type __n)
1157 {
1158 __rehash_multi(static_cast<size_type>(ceil(__n / max_load_factor())));
1159 }
11831160
1184 _LIBCPP_INLINE_VISIBILITY1161 _LIBCPP_INLINE_VISIBILITY
1185 size_type bucket_count() const _NOEXCEPT1162 size_type bucket_count() const _NOEXCEPT
...@@ -1276,11 +1253,7 @@ public:...@@ -1276,11 +1253,7 @@ public:
1276 {1253 {
1277 _LIBCPP_ASSERT(__n < bucket_count(),1254 _LIBCPP_ASSERT(__n < bucket_count(),
1278 "unordered container::begin(n) called with n >= bucket_count()");1255 "unordered container::begin(n) called with n >= bucket_count()");
1279#if _LIBCPP_DEBUG_LEVEL == 2
1280 return local_iterator(__bucket_list_[__n], __n, bucket_count(), this);1256 return local_iterator(__bucket_list_[__n], __n, bucket_count(), this);
1281#else
1282 return local_iterator(__bucket_list_[__n], __n, bucket_count());
1283#endif
1284 }1257 }
12851258
1286 _LIBCPP_INLINE_VISIBILITY1259 _LIBCPP_INLINE_VISIBILITY
...@@ -1289,11 +1262,7 @@ public:...@@ -1289,11 +1262,7 @@ public:
1289 {1262 {
1290 _LIBCPP_ASSERT(__n < bucket_count(),1263 _LIBCPP_ASSERT(__n < bucket_count(),
1291 "unordered container::end(n) called with n >= bucket_count()");1264 "unordered container::end(n) called with n >= bucket_count()");
1292#if _LIBCPP_DEBUG_LEVEL == 2
1293 return local_iterator(nullptr, __n, bucket_count(), this);1265 return local_iterator(nullptr, __n, bucket_count(), this);
1294#else
1295 return local_iterator(nullptr, __n, bucket_count());
1296#endif
1297 }1266 }
12981267
1299 _LIBCPP_INLINE_VISIBILITY1268 _LIBCPP_INLINE_VISIBILITY
...@@ -1302,11 +1271,7 @@ public:...@@ -1302,11 +1271,7 @@ public:
1302 {1271 {
1303 _LIBCPP_ASSERT(__n < bucket_count(),1272 _LIBCPP_ASSERT(__n < bucket_count(),
1304 "unordered container::cbegin(n) called with n >= bucket_count()");1273 "unordered container::cbegin(n) called with n >= bucket_count()");
1305#if _LIBCPP_DEBUG_LEVEL == 2
1306 return const_local_iterator(__bucket_list_[__n], __n, bucket_count(), this);1274 return const_local_iterator(__bucket_list_[__n], __n, bucket_count(), this);
1307#else
1308 return const_local_iterator(__bucket_list_[__n], __n, bucket_count());
1309#endif
1310 }1275 }
13111276
1312 _LIBCPP_INLINE_VISIBILITY1277 _LIBCPP_INLINE_VISIBILITY
...@@ -1315,24 +1280,21 @@ public:...@@ -1315,24 +1280,21 @@ public:
1315 {1280 {
1316 _LIBCPP_ASSERT(__n < bucket_count(),1281 _LIBCPP_ASSERT(__n < bucket_count(),
1317 "unordered container::cend(n) called with n >= bucket_count()");1282 "unordered container::cend(n) called with n >= bucket_count()");
1318#if _LIBCPP_DEBUG_LEVEL == 2
1319 return const_local_iterator(nullptr, __n, bucket_count(), this);1283 return const_local_iterator(nullptr, __n, bucket_count(), this);
1320#else
1321 return const_local_iterator(nullptr, __n, bucket_count());
1322#endif
1323 }1284 }
13241285
1325#if _LIBCPP_DEBUG_LEVEL == 21286#ifdef _LIBCPP_ENABLE_DEBUG_MODE
13261287
1327 bool __dereferenceable(const const_iterator* __i) const;1288 bool __dereferenceable(const const_iterator* __i) const;
1328 bool __decrementable(const const_iterator* __i) const;1289 bool __decrementable(const const_iterator* __i) const;
1329 bool __addable(const const_iterator* __i, ptrdiff_t __n) const;1290 bool __addable(const const_iterator* __i, ptrdiff_t __n) const;
1330 bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const;1291 bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const;
13311292
1332#endif // _LIBCPP_DEBUG_LEVEL == 21293#endif // _LIBCPP_ENABLE_DEBUG_MODE
13331294
1334private:1295private:
1335 void __rehash(size_type __n);1296 template <bool _UniqueKeys> void __rehash(size_type __n);
1297 template <bool _UniqueKeys> void __do_rehash(size_type __n);
13361298
1337 template <class ..._Args>1299 template <class ..._Args>
1338 __node_holder __construct_node(_Args&& ...__args);1300 __node_holder __construct_node(_Args&& ...__args);
...@@ -1509,9 +1471,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::~__hash_table()...@@ -1509,9 +1471,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::~__hash_table()
1509#endif1471#endif
15101472
1511 __deallocate_node(__p1_.first().__next_);1473 __deallocate_node(__p1_.first().__next_);
1512#if _LIBCPP_DEBUG_LEVEL == 21474 std::__debug_db_erase_c(this);
1513 __get_db()->__erase_c(this);
1514#endif
1515}1475}
15161476
1517template <class _Tp, class _Hash, class _Equal, class _Alloc>1477template <class _Tp, class _Hash, class _Equal, class _Alloc>
...@@ -1553,7 +1513,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__deallocate_node(__next_pointer __np)...@@ -1553,7 +1513,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__deallocate_node(__next_pointer __np)
1553 while (__np != nullptr)1513 while (__np != nullptr)
1554 {1514 {
1555 __next_pointer __next = __np->__next_;1515 __next_pointer __next = __np->__next_;
1556#if _LIBCPP_DEBUG_LEVEL == 21516#ifdef _LIBCPP_ENABLE_DEBUG_MODE
1557 __c_node* __c = __get_db()->__find_c_and_lock(this);1517 __c_node* __c = __get_db()->__find_c_and_lock(this);
1558 for (__i_node** __p = __c->end_; __p != __c->beg_; )1518 for (__i_node** __p = __c->end_; __p != __c->beg_; )
1559 {1519 {
...@@ -1614,9 +1574,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign(...@@ -1614,9 +1574,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign(
1614 __u.__p1_.first().__next_ = nullptr;1574 __u.__p1_.first().__next_ = nullptr;
1615 __u.size() = 0;1575 __u.size() = 0;
1616 }1576 }
1617#if _LIBCPP_DEBUG_LEVEL == 21577 std::__debug_db_swap(this, std::addressof(__u));
1618 __get_db()->swap(this, _VSTD::addressof(__u));
1619#endif
1620}1578}
16211579
1622template <class _Tp, class _Hash, class _Equal, class _Alloc>1580template <class _Tp, class _Hash, class _Equal, class _Alloc>
...@@ -1766,11 +1724,7 @@ inline...@@ -1766,11 +1724,7 @@ inline
1766typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator1724typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
1767__hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() _NOEXCEPT1725__hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() _NOEXCEPT
1768{1726{
1769#if _LIBCPP_DEBUG_LEVEL == 2
1770 return iterator(__p1_.first().__next_, this);1727 return iterator(__p1_.first().__next_, this);
1771#else
1772 return iterator(__p1_.first().__next_);
1773#endif
1774}1728}
17751729
1776template <class _Tp, class _Hash, class _Equal, class _Alloc>1730template <class _Tp, class _Hash, class _Equal, class _Alloc>
...@@ -1778,11 +1732,7 @@ inline...@@ -1778,11 +1732,7 @@ inline
1778typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator1732typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
1779__hash_table<_Tp, _Hash, _Equal, _Alloc>::end() _NOEXCEPT1733__hash_table<_Tp, _Hash, _Equal, _Alloc>::end() _NOEXCEPT
1780{1734{
1781#if _LIBCPP_DEBUG_LEVEL == 2
1782 return iterator(nullptr, this);1735 return iterator(nullptr, this);
1783#else
1784 return iterator(nullptr);
1785#endif
1786}1736}
17871737
1788template <class _Tp, class _Hash, class _Equal, class _Alloc>1738template <class _Tp, class _Hash, class _Equal, class _Alloc>
...@@ -1790,11 +1740,7 @@ inline...@@ -1790,11 +1740,7 @@ inline
1790typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator1740typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator
1791__hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() const _NOEXCEPT1741__hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() const _NOEXCEPT
1792{1742{
1793#if _LIBCPP_DEBUG_LEVEL == 2
1794 return const_iterator(__p1_.first().__next_, this);1743 return const_iterator(__p1_.first().__next_, this);
1795#else
1796 return const_iterator(__p1_.first().__next_);
1797#endif
1798}1744}
17991745
1800template <class _Tp, class _Hash, class _Equal, class _Alloc>1746template <class _Tp, class _Hash, class _Equal, class _Alloc>
...@@ -1802,11 +1748,7 @@ inline...@@ -1802,11 +1748,7 @@ inline
1802typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator1748typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator
1803__hash_table<_Tp, _Hash, _Equal, _Alloc>::end() const _NOEXCEPT1749__hash_table<_Tp, _Hash, _Equal, _Alloc>::end() const _NOEXCEPT
1804{1750{
1805#if _LIBCPP_DEBUG_LEVEL == 2
1806 return const_iterator(nullptr, this);1751 return const_iterator(nullptr, this);
1807#else
1808 return const_iterator(nullptr);
1809#endif
1810}1752}
18111753
1812template <class _Tp, class _Hash, class _Equal, class _Alloc>1754template <class _Tp, class _Hash, class _Equal, class _Alloc>
...@@ -1857,7 +1799,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique_prepare(...@@ -1857,7 +1799,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique_prepare(
1857 }1799 }
1858 if (size()+1 > __bc * max_load_factor() || __bc == 0)1800 if (size()+1 > __bc * max_load_factor() || __bc == 0)
1859 {1801 {
1860 rehash(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc),1802 __rehash_unique(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc),
1861 size_type(ceil(float(size() + 1) / max_load_factor()))));1803 size_type(ceil(float(size() + 1) / max_load_factor()))));
1862 }1804 }
1863 return nullptr;1805 return nullptr;
...@@ -1911,11 +1853,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique(__node_pointer __...@@ -1911,11 +1853,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique(__node_pointer __
1911 __existing_node = __nd->__ptr();1853 __existing_node = __nd->__ptr();
1912 __inserted = true;1854 __inserted = true;
1913 }1855 }
1914#if _LIBCPP_DEBUG_LEVEL == 2
1915 return pair<iterator, bool>(iterator(__existing_node, this), __inserted);1856 return pair<iterator, bool>(iterator(__existing_node, this), __inserted);
1916#else
1917 return pair<iterator, bool>(iterator(__existing_node), __inserted);
1918#endif
1919}1857}
19201858
1921// Prepare the container for an insertion of the value __cp_val with the hash1859// Prepare the container for an insertion of the value __cp_val with the hash
...@@ -1933,7 +1871,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi_prepare(...@@ -1933,7 +1871,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi_prepare(
1933 size_type __bc = bucket_count();1871 size_type __bc = bucket_count();
1934 if (size()+1 > __bc * max_load_factor() || __bc == 0)1872 if (size()+1 > __bc * max_load_factor() || __bc == 0)
1935 {1873 {
1936 rehash(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc),1874 __rehash_multi(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc),
1937 size_type(ceil(float(size() + 1) / max_load_factor()))));1875 size_type(ceil(float(size() + 1) / max_load_factor()))));
1938 __bc = bucket_count();1876 __bc = bucket_count();
1939 }1877 }
...@@ -2009,11 +1947,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(__node_pointer __c...@@ -2009,11 +1947,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(__node_pointer __c
2009 __next_pointer __pn = __node_insert_multi_prepare(__cp->__hash(), __cp->__value_);1947 __next_pointer __pn = __node_insert_multi_prepare(__cp->__hash(), __cp->__value_);
2010 __node_insert_multi_perform(__cp, __pn);1948 __node_insert_multi_perform(__cp, __pn);
20111949
2012#if _LIBCPP_DEBUG_LEVEL == 2
2013 return iterator(__cp->__ptr(), this);1950 return iterator(__cp->__ptr(), this);
2014#else
2015 return iterator(__cp->__ptr());
2016#endif
2017}1951}
20181952
2019template <class _Tp, class _Hash, class _Equal, class _Alloc>1953template <class _Tp, class _Hash, class _Equal, class _Alloc>
...@@ -2031,7 +1965,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(...@@ -2031,7 +1965,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(
2031 size_type __bc = bucket_count();1965 size_type __bc = bucket_count();
2032 if (size()+1 > __bc * max_load_factor() || __bc == 0)1966 if (size()+1 > __bc * max_load_factor() || __bc == 0)
2033 {1967 {
2034 rehash(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc),1968 __rehash_multi(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc),
2035 size_type(ceil(float(size() + 1) / max_load_factor()))));1969 size_type(ceil(float(size() + 1) / max_load_factor()))));
2036 __bc = bucket_count();1970 __bc = bucket_count();
2037 }1971 }
...@@ -2042,11 +1976,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(...@@ -2042,11 +1976,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(
2042 __cp->__next_ = __np;1976 __cp->__next_ = __np;
2043 __pp->__next_ = static_cast<__next_pointer>(__cp);1977 __pp->__next_ = static_cast<__next_pointer>(__cp);
2044 ++size();1978 ++size();
2045#if _LIBCPP_DEBUG_LEVEL == 2
2046 return iterator(static_cast<__next_pointer>(__cp), this);1979 return iterator(static_cast<__next_pointer>(__cp), this);
2047#else
2048 return iterator(static_cast<__next_pointer>(__cp));
2049#endif
2050 }1980 }
2051 return __node_insert_multi(__cp);1981 return __node_insert_multi(__cp);
2052}1982}
...@@ -2083,7 +2013,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const&...@@ -2083,7 +2013,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const&
2083 __node_holder __h = __construct_node_hash(__hash, _VSTD::forward<_Args>(__args)...);2013 __node_holder __h = __construct_node_hash(__hash, _VSTD::forward<_Args>(__args)...);
2084 if (size()+1 > __bc * max_load_factor() || __bc == 0)2014 if (size()+1 > __bc * max_load_factor() || __bc == 0)
2085 {2015 {
2086 rehash(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc),2016 __rehash_unique(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc),
2087 size_type(ceil(float(size() + 1) / max_load_factor()))));2017 size_type(ceil(float(size() + 1) / max_load_factor()))));
2088 __bc = bucket_count();2018 __bc = bucket_count();
2089 __chash = __constrain_hash(__hash, __bc);2019 __chash = __constrain_hash(__hash, __bc);
...@@ -2112,11 +2042,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const&...@@ -2112,11 +2042,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const&
2112 __inserted = true;2042 __inserted = true;
2113 }2043 }
2114__done:2044__done:
2115#if _LIBCPP_DEBUG_LEVEL == 2
2116 return pair<iterator, bool>(iterator(__nd, this), __inserted);2045 return pair<iterator, bool>(iterator(__nd, this), __inserted);
2117#else
2118 return pair<iterator, bool>(iterator(__nd), __inserted);
2119#endif
2120}2046}
21212047
2122template <class _Tp, class _Hash, class _Equal, class _Alloc>2048template <class _Tp, class _Hash, class _Equal, class _Alloc>
...@@ -2290,8 +2216,9 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_merge_multi(...@@ -2290,8 +2216,9 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_merge_multi(
2290#endif // _LIBCPP_STD_VER > 142216#endif // _LIBCPP_STD_VER > 14
22912217
2292template <class _Tp, class _Hash, class _Equal, class _Alloc>2218template <class _Tp, class _Hash, class _Equal, class _Alloc>
2219template <bool _UniqueKeys>
2293void2220void
2294__hash_table<_Tp, _Hash, _Equal, _Alloc>::rehash(size_type __n)2221__hash_table<_Tp, _Hash, _Equal, _Alloc>::__rehash(size_type __n)
2295_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK2222_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
2296{2223{
2297 if (__n == 1)2224 if (__n == 1)
...@@ -2300,7 +2227,7 @@ _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK...@@ -2300,7 +2227,7 @@ _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
2300 __n = __next_prime(__n);2227 __n = __next_prime(__n);
2301 size_type __bc = bucket_count();2228 size_type __bc = bucket_count();
2302 if (__n > __bc)2229 if (__n > __bc)
2303 __rehash(__n);2230 __do_rehash<_UniqueKeys>(__n);
2304 else if (__n < __bc)2231 else if (__n < __bc)
2305 {2232 {
2306 __n = _VSTD::max<size_type>2233 __n = _VSTD::max<size_type>
...@@ -2310,17 +2237,16 @@ _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK...@@ -2310,17 +2237,16 @@ _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
2310 __next_prime(size_t(ceil(float(size()) / max_load_factor())))2237 __next_prime(size_t(ceil(float(size()) / max_load_factor())))
2311 );2238 );
2312 if (__n < __bc)2239 if (__n < __bc)
2313 __rehash(__n);2240 __do_rehash<_UniqueKeys>(__n);
2314 }2241 }
2315}2242}
23162243
2317template <class _Tp, class _Hash, class _Equal, class _Alloc>2244template <class _Tp, class _Hash, class _Equal, class _Alloc>
2245template <bool _UniqueKeys>
2318void2246void
2319__hash_table<_Tp, _Hash, _Equal, _Alloc>::__rehash(size_type __nbc)2247__hash_table<_Tp, _Hash, _Equal, _Alloc>::__do_rehash(size_type __nbc)
2320{2248{
2321#if _LIBCPP_DEBUG_LEVEL == 22249 std::__debug_db_invalidate_all(this);
2322 __get_db()->__invalidate_all(this);
2323#endif
2324 __pointer_allocator& __npa = __bucket_list_.get_deleter().__alloc();2250 __pointer_allocator& __npa = __bucket_list_.get_deleter().__alloc();
2325 __bucket_list_.reset(__nbc > 0 ?2251 __bucket_list_.reset(__nbc > 0 ?
2326 __pointer_alloc_traits::allocate(__npa, __nbc) : nullptr);2252 __pointer_alloc_traits::allocate(__npa, __nbc) : nullptr);
...@@ -2353,11 +2279,14 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__rehash(size_type __nbc)...@@ -2353,11 +2279,14 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__rehash(size_type __nbc)
2353 else2279 else
2354 {2280 {
2355 __next_pointer __np = __cp;2281 __next_pointer __np = __cp;
2356 for (; __np->__next_ != nullptr &&2282 if _LIBCPP_CONSTEXPR_AFTER_CXX14 (!_UniqueKeys)
2357 key_eq()(__cp->__upcast()->__value_,2283 {
2358 __np->__next_->__upcast()->__value_);2284 for (; __np->__next_ != nullptr &&
2359 __np = __np->__next_)2285 key_eq()(__cp->__upcast()->__value_,
2360 ;2286 __np->__next_->__upcast()->__value_);
2287 __np = __np->__next_)
2288 ;
2289 }
2361 __pp->__next_ = __np->__next_;2290 __pp->__next_ = __np->__next_;
2362 __np->__next_ = __bucket_list_[__chash]->__next_;2291 __np->__next_ = __bucket_list_[__chash]->__next_;
2363 __bucket_list_[__chash]->__next_ = __cp;2292 __bucket_list_[__chash]->__next_ = __cp;
...@@ -2389,11 +2318,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k)...@@ -2389,11 +2318,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k)
2389 {2318 {
2390 if ((__nd->__hash() == __hash)2319 if ((__nd->__hash() == __hash)
2391 && key_eq()(__nd->__upcast()->__value_, __k))2320 && key_eq()(__nd->__upcast()->__value_, __k))
2392#if _LIBCPP_DEBUG_LEVEL == 2
2393 return iterator(__nd, this);2321 return iterator(__nd, this);
2394#else
2395 return iterator(__nd);
2396#endif
2397 }2322 }
2398 }2323 }
2399 }2324 }
...@@ -2420,11 +2345,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k) const...@@ -2420,11 +2345,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k) const
2420 {2345 {
2421 if ((__nd->__hash() == __hash)2346 if ((__nd->__hash() == __hash)
2422 && key_eq()(__nd->__upcast()->__value_, __k))2347 && key_eq()(__nd->__upcast()->__value_, __k))
2423#if _LIBCPP_DEBUG_LEVEL == 2
2424 return const_iterator(__nd, this);2348 return const_iterator(__nd, this);
2425#else
2426 return const_iterator(__nd);
2427#endif
2428 }2349 }
2429 }2350 }
24302351
...@@ -2475,13 +2396,9 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::erase(const_iterator __p)...@@ -2475,13 +2396,9 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::erase(const_iterator __p)
2475 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this,2396 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this,
2476 "unordered container erase(iterator) called with an iterator not"2397 "unordered container erase(iterator) called with an iterator not"
2477 " referring to this container");2398 " referring to this container");
2478 _LIBCPP_DEBUG_ASSERT(__p != end(),2399 _LIBCPP_ASSERT(__p != end(),
2479 "unordered container erase(iterator) called with a non-dereferenceable iterator");2400 "unordered container erase(iterator) called with a non-dereferenceable iterator");
2480#if _LIBCPP_DEBUG_LEVEL == 2
2481 iterator __r(__np, this);2401 iterator __r(__np, this);
2482#else
2483 iterator __r(__np);
2484#endif
2485 ++__r;2402 ++__r;
2486 remove(__p);2403 remove(__p);
2487 return __r;2404 return __r;
...@@ -2504,11 +2421,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::erase(const_iterator __first,...@@ -2504,11 +2421,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::erase(const_iterator __first,
2504 erase(__p);2421 erase(__p);
2505 }2422 }
2506 __next_pointer __np = __last.__node_;2423 __next_pointer __np = __last.__node_;
2507#if _LIBCPP_DEBUG_LEVEL == 2
2508 return iterator (__np, this);2424 return iterator (__np, this);
2509#else
2510 return iterator (__np);
2511#endif
2512}2425}
25132426
2514template <class _Tp, class _Hash, class _Equal, class _Alloc>2427template <class _Tp, class _Hash, class _Equal, class _Alloc>
...@@ -2575,7 +2488,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::remove(const_iterator __p) _NOEXCEPT...@@ -2575,7 +2488,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::remove(const_iterator __p) _NOEXCEPT
2575 __pn->__next_ = __cn->__next_;2488 __pn->__next_ = __cn->__next_;
2576 __cn->__next_ = nullptr;2489 __cn->__next_ = nullptr;
2577 --size();2490 --size();
2578#if _LIBCPP_DEBUG_LEVEL == 22491#ifdef _LIBCPP_ENABLE_DEBUG_MODE
2579 __c_node* __c = __get_db()->__find_c_and_lock(this);2492 __c_node* __c = __get_db()->__find_c_and_lock(this);
2580 for (__i_node** __dp = __c->end_; __dp != __c->beg_; )2493 for (__i_node** __dp = __c->end_; __dp != __c->beg_; )
2581 {2494 {
...@@ -2726,9 +2639,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::swap(__hash_table& __u)...@@ -2726,9 +2639,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::swap(__hash_table& __u)
2726 if (__u.size() > 0)2639 if (__u.size() > 0)
2727 __u.__bucket_list_[__constrain_hash(__u.__p1_.first().__next_->__hash(), __u.bucket_count())] =2640 __u.__bucket_list_[__constrain_hash(__u.__p1_.first().__next_->__hash(), __u.bucket_count())] =
2728 __u.__p1_.first().__ptr();2641 __u.__p1_.first().__ptr();
2729#if _LIBCPP_DEBUG_LEVEL == 22642 std::__debug_db_swap(this, std::addressof(__u));
2730 __get_db()->swap(this, _VSTD::addressof(__u));
2731#endif
2732}2643}
27332644
2734template <class _Tp, class _Hash, class _Equal, class _Alloc>2645template <class _Tp, class _Hash, class _Equal, class _Alloc>
...@@ -2760,7 +2671,7 @@ swap(__hash_table<_Tp, _Hash, _Equal, _Alloc>& __x,...@@ -2760,7 +2671,7 @@ swap(__hash_table<_Tp, _Hash, _Equal, _Alloc>& __x,
2760 __x.swap(__y);2671 __x.swap(__y);
2761}2672}
27622673
2763#if _LIBCPP_DEBUG_LEVEL == 22674#ifdef _LIBCPP_ENABLE_DEBUG_MODE
27642675
2765template <class _Tp, class _Hash, class _Equal, class _Alloc>2676template <class _Tp, class _Hash, class _Equal, class _Alloc>
2766bool2677bool
...@@ -2790,10 +2701,10 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__subscriptable(const const_iterator*,...@@ -2790,10 +2701,10 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__subscriptable(const const_iterator*,
2790 return false;2701 return false;
2791}2702}
27922703
2793#endif // _LIBCPP_DEBUG_LEVEL == 22704#endif // _LIBCPP_ENABLE_DEBUG_MODE
27942705
2795_LIBCPP_END_NAMESPACE_STD2706_LIBCPP_END_NAMESPACE_STD
27962707
2797_LIBCPP_POP_MACROS2708_LIBCPP_POP_MACROS
27982709
2799#endif // _LIBCPP__HASH_TABLE2710#endif // _LIBCPP___HASH_TABLE
lib/libcxx/include/__ios/fpos.h created+79
...@@ -0,0 +1,79 @@
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___IOS_FPOS_H
11#define _LIBCPP___IOS_FPOS_H
12
13#include <__config>
14#include <iosfwd>
15
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header
18#endif
19
20_LIBCPP_BEGIN_NAMESPACE_STD
21
22template <class _StateT>
23class _LIBCPP_TEMPLATE_VIS fpos {
24private:
25 _StateT __st_;
26 streamoff __off_;
27
28public:
29 _LIBCPP_HIDE_FROM_ABI fpos(streamoff __off = streamoff()) : __st_(), __off_(__off) {}
30
31 _LIBCPP_HIDE_FROM_ABI operator streamoff() const { return __off_; }
32
33 _LIBCPP_HIDE_FROM_ABI _StateT state() const { return __st_; }
34 _LIBCPP_HIDE_FROM_ABI void state(_StateT __st) { __st_ = __st; }
35
36 _LIBCPP_HIDE_FROM_ABI fpos& operator+=(streamoff __off) {
37 __off_ += __off;
38 return *this;
39 }
40
41 _LIBCPP_HIDE_FROM_ABI fpos operator+(streamoff __off) const {
42 fpos __t(*this);
43 __t += __off;
44 return __t;
45 }
46
47 _LIBCPP_HIDE_FROM_ABI fpos& operator-=(streamoff __off) {
48 __off_ -= __off;
49 return *this;
50 }
51
52 _LIBCPP_HIDE_FROM_ABI fpos operator-(streamoff __off) const {
53 fpos __t(*this);
54 __t -= __off;
55 return __t;
56 }
57};
58
59template <class _StateT>
60inline _LIBCPP_HIDE_FROM_ABI
61streamoff operator-(const fpos<_StateT>& __x, const fpos<_StateT>& __y) {
62 return streamoff(__x) - streamoff(__y);
63}
64
65template <class _StateT>
66inline _LIBCPP_HIDE_FROM_ABI
67bool operator==(const fpos<_StateT>& __x, const fpos<_StateT>& __y) {
68 return streamoff(__x) == streamoff(__y);
69}
70
71template <class _StateT>
72inline _LIBCPP_HIDE_FROM_ABI
73bool operator!=(const fpos<_StateT>& __x, const fpos<_StateT>& __y) {
74 return streamoff(__x) != streamoff(__y);
75}
76
77_LIBCPP_END_NAMESPACE_STD
78
79#endif // _LIBCPP___IOS_FPOS_H
lib/libcxx/include/__iterator/access.h+1-1
...@@ -14,7 +14,7 @@...@@ -14,7 +14,7 @@
14#include <cstddef>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
18#endif18#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__iterator/advance.h+27-27
...@@ -10,19 +10,20 @@...@@ -10,19 +10,20 @@
10#ifndef _LIBCPP___ITERATOR_ADVANCE_H10#ifndef _LIBCPP___ITERATOR_ADVANCE_H
11#define _LIBCPP___ITERATOR_ADVANCE_H11#define _LIBCPP___ITERATOR_ADVANCE_H
1212
13#include <__assert>
13#include <__config>14#include <__config>
14#include <__debug>
15#include <__iterator/concepts.h>15#include <__iterator/concepts.h>
16#include <__iterator/incrementable_traits.h>16#include <__iterator/incrementable_traits.h>
17#include <__iterator/iterator_traits.h>17#include <__iterator/iterator_traits.h>
18#include <__utility/move.h>18#include <__utility/move.h>
19#include <__utility/unreachable.h>
19#include <concepts>20#include <concepts>
20#include <cstdlib>21#include <cstdlib>
21#include <limits>22#include <limits>
22#include <type_traits>23#include <type_traits>
2324
24#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)25#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
25#pragma GCC system_header26# pragma GCC system_header
26#endif27#endif
2728
28_LIBCPP_BEGIN_NAMESPACE_STD29_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -64,7 +65,7 @@ void advance(_InputIter& __i, _Distance __orig_n) {...@@ -64,7 +65,7 @@ void advance(_InputIter& __i, _Distance __orig_n) {
64 _VSTD::__advance(__i, __n, typename iterator_traits<_InputIter>::iterator_category());65 _VSTD::__advance(__i, __n, typename iterator_traits<_InputIter>::iterator_category());
65}66}
6667
67#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)68#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
6869
69// [range.iter.op.advance]70// [range.iter.op.advance]
7071
...@@ -116,47 +117,46 @@ public:...@@ -116,47 +117,46 @@ public:
116 }117 }
117 }118 }
118119
119 // Preconditions: Either `assignable_from<I&, S> || sized_sentinel_for<S, I>` is modeled, or [i, bound) denotes a range.120 // Preconditions: Either `assignable_from<I&, S> || sized_sentinel_for<S, I>` is modeled, or [i, bound_sentinel) denotes a range.
120 template <input_or_output_iterator _Ip, sentinel_for<_Ip> _Sp>121 template <input_or_output_iterator _Ip, sentinel_for<_Ip> _Sp>
121 _LIBCPP_HIDE_FROM_ABI122 _LIBCPP_HIDE_FROM_ABI constexpr void operator()(_Ip& __i, _Sp __bound_sentinel) const {
122 constexpr void operator()(_Ip& __i, _Sp __bound) const {123 // If `I` and `S` model `assignable_from<I&, S>`, equivalent to `i = std::move(bound_sentinel)`.
123 // If `I` and `S` model `assignable_from<I&, S>`, equivalent to `i = std::move(bound)`.
124 if constexpr (assignable_from<_Ip&, _Sp>) {124 if constexpr (assignable_from<_Ip&, _Sp>) {
125 __i = _VSTD::move(__bound);125 __i = _VSTD::move(__bound_sentinel);
126 }126 }
127 // Otherwise, if `S` and `I` model `sized_sentinel_for<S, I>`, equivalent to `ranges::advance(i, bound - i)`.127 // Otherwise, if `S` and `I` model `sized_sentinel_for<S, I>`, equivalent to `ranges::advance(i, bound_sentinel - i)`.
128 else if constexpr (sized_sentinel_for<_Sp, _Ip>) {128 else if constexpr (sized_sentinel_for<_Sp, _Ip>) {
129 (*this)(__i, __bound - __i);129 (*this)(__i, __bound_sentinel - __i);
130 }130 }
131 // Otherwise, while `bool(i != bound)` is true, increments `i`.131 // Otherwise, while `bool(i != bound_sentinel)` is true, increments `i`.
132 else {132 else {
133 while (__i != __bound) {133 while (__i != __bound_sentinel) {
134 ++__i;134 ++__i;
135 }135 }
136 }136 }
137 }137 }
138138
139 // Preconditions:139 // Preconditions:
140 // * If `n > 0`, [i, bound) denotes a range.140 // * If `n > 0`, [i, bound_sentinel) denotes a range.
141 // * If `n == 0`, [i, bound) or [bound, i) denotes a range.141 // * If `n == 0`, [i, bound_sentinel) or [bound_sentinel, i) denotes a range.
142 // * If `n < 0`, [bound, i) denotes a range, `I` models `bidirectional_iterator`, and `I` and `S` model `same_as<I, S>`.142 // * If `n < 0`, [bound_sentinel, i) denotes a range, `I` models `bidirectional_iterator`, and `I` and `S` model `same_as<I, S>`.
143 // Returns: `n - M`, where `M` is the difference between the the ending and starting position.143 // Returns: `n - M`, where `M` is the difference between the ending and starting position.
144 template <input_or_output_iterator _Ip, sentinel_for<_Ip> _Sp>144 template <input_or_output_iterator _Ip, sentinel_for<_Ip> _Sp>
145 _LIBCPP_HIDE_FROM_ABI145 _LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Ip> operator()(_Ip& __i, iter_difference_t<_Ip> __n,
146 constexpr iter_difference_t<_Ip> operator()(_Ip& __i, iter_difference_t<_Ip> __n, _Sp __bound) const {146 _Sp __bound_sentinel) const {
147 _LIBCPP_ASSERT((__n >= 0) || (bidirectional_iterator<_Ip> && same_as<_Ip, _Sp>),147 _LIBCPP_ASSERT((__n >= 0) || (bidirectional_iterator<_Ip> && same_as<_Ip, _Sp>),
148 "If `n < 0`, then `bidirectional_iterator<I> && same_as<I, S>` must be true.");148 "If `n < 0`, then `bidirectional_iterator<I> && same_as<I, S>` must be true.");
149 // If `S` and `I` model `sized_sentinel_for<S, I>`:149 // If `S` and `I` model `sized_sentinel_for<S, I>`:
150 if constexpr (sized_sentinel_for<_Sp, _Ip>) {150 if constexpr (sized_sentinel_for<_Sp, _Ip>) {
151 // If |n| >= |bound - i|, equivalent to `ranges::advance(i, bound)`.151 // If |n| >= |bound_sentinel - i|, equivalent to `ranges::advance(i, bound_sentinel)`.
152 // __magnitude_geq(a, b) returns |a| >= |b|, assuming they have the same sign.152 // __magnitude_geq(a, b) returns |a| >= |b|, assuming they have the same sign.
153 auto __magnitude_geq = [](auto __a, auto __b) {153 auto __magnitude_geq = [](auto __a, auto __b) {
154 return __a == 0 ? __b == 0 :154 return __a == 0 ? __b == 0 :
155 __a > 0 ? __a >= __b :155 __a > 0 ? __a >= __b :
156 __a <= __b;156 __a <= __b;
157 };157 };
158 if (const auto __M = __bound - __i; __magnitude_geq(__n, __M)) {158 if (const auto __M = __bound_sentinel - __i; __magnitude_geq(__n, __M)) {
159 (*this)(__i, __bound);159 (*this)(__i, __bound_sentinel);
160 return __n - __M;160 return __n - __M;
161 }161 }
162162
...@@ -164,16 +164,16 @@ public:...@@ -164,16 +164,16 @@ public:
164 (*this)(__i, __n);164 (*this)(__i, __n);
165 return 0;165 return 0;
166 } else {166 } else {
167 // Otherwise, if `n` is non-negative, while `bool(i != bound)` is true, increments `i` but at167 // Otherwise, if `n` is non-negative, while `bool(i != bound_sentinel)` is true, increments `i` but at
168 // most `n` times.168 // most `n` times.
169 while (__i != __bound && __n > 0) {169 while (__i != __bound_sentinel && __n > 0) {
170 ++__i;170 ++__i;
171 --__n;171 --__n;
172 }172 }
173173
174 // Otherwise, while `bool(i != bound)` is true, decrements `i` but at most `-n` times.174 // Otherwise, while `bool(i != bound_sentinel)` is true, decrements `i` but at most `-n` times.
175 if constexpr (bidirectional_iterator<_Ip> && same_as<_Ip, _Sp>) {175 if constexpr (bidirectional_iterator<_Ip> && same_as<_Ip, _Sp>) {
176 while (__i != __bound && __n < 0) {176 while (__i != __bound_sentinel && __n < 0) {
177 --__i;177 --__i;
178 ++__n;178 ++__n;
179 }179 }
...@@ -181,7 +181,7 @@ public:...@@ -181,7 +181,7 @@ public:
181 return __n;181 return __n;
182 }182 }
183183
184 _LIBCPP_UNREACHABLE();184 __libcpp_unreachable();
185 }185 }
186};186};
187187
...@@ -192,7 +192,7 @@ inline namespace __cpo {...@@ -192,7 +192,7 @@ inline namespace __cpo {
192} // namespace __cpo192} // namespace __cpo
193} // namespace ranges193} // namespace ranges
194194
195#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)195#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
196196
197_LIBCPP_END_NAMESPACE_STD197_LIBCPP_END_NAMESPACE_STD
198198
lib/libcxx/include/__iterator/back_insert_iterator.h+7-5
...@@ -18,7 +18,7 @@...@@ -18,7 +18,7 @@
18#include <cstddef>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
22#endif22#endif
2323
24_LIBCPP_BEGIN_NAMESPACE_STD24_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -46,15 +46,17 @@ public:...@@ -46,15 +46,17 @@ public:
46 typedef _Container container_type;46 typedef _Container container_type;
4747
48 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit back_insert_iterator(_Container& __x) : container(_VSTD::addressof(__x)) {}48 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit back_insert_iterator(_Container& __x) : container(_VSTD::addressof(__x)) {}
49 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator=(const typename _Container::value_type& __value_)49 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator=(const typename _Container::value_type& __value)
50 {container->push_back(__value_); return *this;}50 {container->push_back(__value); return *this;}
51#ifndef _LIBCPP_CXX03_LANG51#ifndef _LIBCPP_CXX03_LANG
52 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator=(typename _Container::value_type&& __value_)52 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator=(typename _Container::value_type&& __value)
53 {container->push_back(_VSTD::move(__value_)); return *this;}53 {container->push_back(_VSTD::move(__value)); return *this;}
54#endif // _LIBCPP_CXX03_LANG54#endif // _LIBCPP_CXX03_LANG
55 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator*() {return *this;}55 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator*() {return *this;}
56 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator++() {return *this;}56 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator++() {return *this;}
57 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator operator++(int) {return *this;}57 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator operator++(int) {return *this;}
58
59 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _Container* __get_container() const { return container; }
58};60};
5961
60template <class _Container>62template <class _Container>
lib/libcxx/include/__iterator/bounded_iter.h created+229
...@@ -0,0 +1,229 @@
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_BOUNDED_ITER_H
11#define _LIBCPP___ITERATOR_BOUNDED_ITER_H
12
13#include <__assert>
14#include <__config>
15#include <__iterator/iterator_traits.h>
16#include <__memory/pointer_traits.h>
17#include <__utility/move.h>
18#include <type_traits>
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// Iterator wrapper that carries the valid range it is allowed to access.
27//
28// This is a simple iterator wrapper for contiguous iterators that points
29// within a [begin, end) range and carries these bounds with it. The iterator
30// ensures that it is pointing within that [begin, end) range when it is
31// dereferenced.
32//
33// Arithmetic operations are allowed and the bounds of the resulting iterator
34// are not checked. Hence, it is possible to create an iterator pointing outside
35// its range, but it is not possible to dereference it.
36template <class _Iterator, class = __enable_if_t< __is_cpp17_contiguous_iterator<_Iterator>::value > >
37struct __bounded_iter {
38 using value_type = typename iterator_traits<_Iterator>::value_type;
39 using difference_type = typename iterator_traits<_Iterator>::difference_type;
40 using pointer = typename iterator_traits<_Iterator>::pointer;
41 using reference = typename iterator_traits<_Iterator>::reference;
42 using iterator_category = typename iterator_traits<_Iterator>::iterator_category;
43#if _LIBCPP_STD_VER > 17
44 using iterator_concept = contiguous_iterator_tag;
45#endif
46
47 // Create a singular iterator.
48 //
49 // Such an iterator does not point to any object and is conceptually out of bounds, so it is
50 // not dereferenceable. Observing operations like comparison and assignment are valid.
51 _LIBCPP_HIDE_FROM_ABI __bounded_iter() = default;
52
53 _LIBCPP_HIDE_FROM_ABI __bounded_iter(__bounded_iter const&) = default;
54 _LIBCPP_HIDE_FROM_ABI __bounded_iter(__bounded_iter&&) = default;
55
56 template <class _OtherIterator, class = __enable_if_t< is_convertible<_OtherIterator, _Iterator>::value > >
57 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __bounded_iter(__bounded_iter<_OtherIterator> const& __other) _NOEXCEPT
58 : __current_(__other.__current_),
59 __begin_(__other.__begin_),
60 __end_(__other.__end_) {}
61
62 // Assign a bounded iterator to another one, rebinding the bounds of the iterator as well.
63 _LIBCPP_HIDE_FROM_ABI __bounded_iter& operator=(__bounded_iter const&) = default;
64 _LIBCPP_HIDE_FROM_ABI __bounded_iter& operator=(__bounded_iter&&) = default;
65
66private:
67 // Create an iterator wrapping the given iterator, and whose bounds are described
68 // by the provided [begin, end) range.
69 //
70 // This constructor does not check whether the resulting iterator is within its bounds.
71 // However, it does check that the provided [begin, end) range is a valid range (that
72 // is, begin <= end).
73 //
74 // Since it is non-standard for iterators to have this constructor, __bounded_iter must
75 // be created via `std::__make_bounded_iter`.
76 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit __bounded_iter(
77 _Iterator __current, _Iterator __begin, _Iterator __end)
78 : __current_(__current), __begin_(__begin), __end_(__end) {
79 _LIBCPP_ASSERT(__begin <= __end, "__bounded_iter(current, begin, end): [begin, end) is not a valid range");
80 }
81
82 template <class _It>
83 friend _LIBCPP_CONSTEXPR __bounded_iter<_It> __make_bounded_iter(_It, _It, _It);
84
85public:
86 // Dereference and indexing operations.
87 //
88 // These operations check that the iterator is dereferenceable, that is within [begin, end).
89 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 reference operator*() const _NOEXCEPT {
90 _LIBCPP_ASSERT(
91 __in_bounds(__current_), "__bounded_iter::operator*: Attempt to dereference an out-of-range iterator");
92 return *__current_;
93 }
94
95 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 pointer operator->() const _NOEXCEPT {
96 _LIBCPP_ASSERT(
97 __in_bounds(__current_), "__bounded_iter::operator->: Attempt to dereference an out-of-range iterator");
98 return std::__to_address(__current_);
99 }
100
101 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 reference operator[](difference_type __n) const _NOEXCEPT {
102 _LIBCPP_ASSERT(
103 __in_bounds(__current_ + __n), "__bounded_iter::operator[]: Attempt to index an iterator out-of-range");
104 return __current_[__n];
105 }
106
107 // Arithmetic operations.
108 //
109 // These operations do not check that the resulting iterator is within the bounds, since that
110 // would make it impossible to create a past-the-end iterator.
111 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __bounded_iter& operator++() _NOEXCEPT {
112 ++__current_;
113 return *this;
114 }
115 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __bounded_iter operator++(int) _NOEXCEPT {
116 __bounded_iter __tmp(*this);
117 ++*this;
118 return __tmp;
119 }
120
121 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __bounded_iter& operator--() _NOEXCEPT {
122 --__current_;
123 return *this;
124 }
125 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __bounded_iter operator--(int) _NOEXCEPT {
126 __bounded_iter __tmp(*this);
127 --*this;
128 return __tmp;
129 }
130
131 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __bounded_iter& operator+=(difference_type __n) _NOEXCEPT {
132 __current_ += __n;
133 return *this;
134 }
135 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 friend __bounded_iter
136 operator+(__bounded_iter const& __self, difference_type __n) _NOEXCEPT {
137 __bounded_iter __tmp(__self);
138 __tmp += __n;
139 return __tmp;
140 }
141 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 friend __bounded_iter
142 operator+(difference_type __n, __bounded_iter const& __self) _NOEXCEPT {
143 __bounded_iter __tmp(__self);
144 __tmp += __n;
145 return __tmp;
146 }
147
148 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __bounded_iter& operator-=(difference_type __n) _NOEXCEPT {
149 __current_ -= __n;
150 return *this;
151 }
152 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 friend __bounded_iter
153 operator-(__bounded_iter const& __self, difference_type __n) _NOEXCEPT {
154 __bounded_iter __tmp(__self);
155 __tmp -= __n;
156 return __tmp;
157 }
158 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 friend difference_type
159 operator-(__bounded_iter const& __x, __bounded_iter const& __y) _NOEXCEPT {
160 return __x.__current_ - __y.__current_;
161 }
162
163 // Comparison operations.
164 //
165 // These operations do not check whether the iterators are within their bounds.
166 // The valid range for each iterator is also not considered as part of the comparison,
167 // i.e. two iterators pointing to the same location will be considered equal even
168 // if they have different validity ranges.
169 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR friend bool
170 operator==(__bounded_iter const& __x, __bounded_iter const& __y) _NOEXCEPT {
171 return __x.__current_ == __y.__current_;
172 }
173 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR friend bool
174 operator!=(__bounded_iter const& __x, __bounded_iter const& __y) _NOEXCEPT {
175 return __x.__current_ != __y.__current_;
176 }
177 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR friend bool
178 operator<(__bounded_iter const& __x, __bounded_iter const& __y) _NOEXCEPT {
179 return __x.__current_ < __y.__current_;
180 }
181 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR friend bool
182 operator>(__bounded_iter const& __x, __bounded_iter const& __y) _NOEXCEPT {
183 return __x.__current_ > __y.__current_;
184 }
185 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR friend bool
186 operator<=(__bounded_iter const& __x, __bounded_iter const& __y) _NOEXCEPT {
187 return __x.__current_ <= __y.__current_;
188 }
189 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR friend bool
190 operator>=(__bounded_iter const& __x, __bounded_iter const& __y) _NOEXCEPT {
191 return __x.__current_ >= __y.__current_;
192 }
193
194private:
195 // Return whether the given iterator is in the bounds of this __bounded_iter.
196 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __in_bounds(_Iterator const& __iter) const {
197 return __iter >= __begin_ && __iter < __end_;
198 }
199
200 template <class>
201 friend struct pointer_traits;
202 _Iterator __current_; // current iterator
203 _Iterator __begin_, __end_; // valid range represented as [begin, end)
204};
205
206template <class _It>
207_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __bounded_iter<_It> __make_bounded_iter(_It __it, _It __begin, _It __end) {
208 return __bounded_iter<_It>(std::move(__it), std::move(__begin), std::move(__end));
209}
210
211#if _LIBCPP_STD_VER <= 17
212template <class _Iterator>
213struct __is_cpp17_contiguous_iterator<__bounded_iter<_Iterator> > : true_type {};
214#endif
215
216template <class _Iterator>
217struct pointer_traits<__bounded_iter<_Iterator> > {
218 using pointer = __bounded_iter<_Iterator>;
219 using element_type = typename pointer_traits<_Iterator>::element_type;
220 using difference_type = typename pointer_traits<_Iterator>::difference_type;
221
222 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR static element_type* to_address(pointer __it) _NOEXCEPT {
223 return std::__to_address(__it.__current_);
224 }
225};
226
227_LIBCPP_END_NAMESPACE_STD
228
229#endif // _LIBCPP___ITERATOR_BOUNDED_ITER_H
lib/libcxx/include/__iterator/common_iterator.h+13-26
...@@ -10,8 +10,8 @@...@@ -10,8 +10,8 @@
10#ifndef _LIBCPP___ITERATOR_COMMON_ITERATOR_H10#ifndef _LIBCPP___ITERATOR_COMMON_ITERATOR_H
11#define _LIBCPP___ITERATOR_COMMON_ITERATOR_H11#define _LIBCPP___ITERATOR_COMMON_ITERATOR_H
1212
13#include <__assert>
13#include <__config>14#include <__config>
14#include <__debug>
15#include <__iterator/concepts.h>15#include <__iterator/concepts.h>
16#include <__iterator/incrementable_traits.h>16#include <__iterator/incrementable_traits.h>
17#include <__iterator/iter_move.h>17#include <__iterator/iter_move.h>
...@@ -22,12 +22,12 @@...@@ -22,12 +22,12 @@
22#include <variant>22#include <variant>
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
26#endif26#endif
2727
28_LIBCPP_BEGIN_NAMESPACE_STD28_LIBCPP_BEGIN_NAMESPACE_STD
2929
30#if !defined(_LIBCPP_HAS_NO_CONCEPTS)30#if _LIBCPP_STD_VER > 17
3131
32template<class _Iter>32template<class _Iter>
33concept __can_use_postfix_proxy =33concept __can_use_postfix_proxy =
...@@ -37,31 +37,18 @@ concept __can_use_postfix_proxy =...@@ -37,31 +37,18 @@ concept __can_use_postfix_proxy =
37template<input_or_output_iterator _Iter, sentinel_for<_Iter> _Sent>37template<input_or_output_iterator _Iter, sentinel_for<_Iter> _Sent>
38 requires (!same_as<_Iter, _Sent> && copyable<_Iter>)38 requires (!same_as<_Iter, _Sent> && copyable<_Iter>)
39class common_iterator {39class common_iterator {
40 class __proxy {40 struct __proxy {
41 friend common_iterator;
42
43 iter_value_t<_Iter> __value;
44 // We can move __x because the only caller verifies that __x is not a reference.
45 constexpr __proxy(iter_reference_t<_Iter>&& __x)
46 : __value(_VSTD::move(__x)) {}
47
48 public:
49 constexpr const iter_value_t<_Iter>* operator->() const noexcept {41 constexpr const iter_value_t<_Iter>* operator->() const noexcept {
50 return _VSTD::addressof(__value);42 return _VSTD::addressof(__value_);
51 }43 }
44 iter_value_t<_Iter> __value_;
52 };45 };
5346
54 class __postfix_proxy {47 struct __postfix_proxy {
55 friend common_iterator;
56
57 iter_value_t<_Iter> __value;
58 constexpr __postfix_proxy(iter_reference_t<_Iter>&& __x)
59 : __value(_VSTD::forward<iter_reference_t<_Iter>>(__x)) {}
60
61 public:
62 constexpr const iter_value_t<_Iter>& operator*() const noexcept {48 constexpr const iter_value_t<_Iter>& operator*() const noexcept {
63 return __value;49 return __value_;
64 }50 }
51 iter_value_t<_Iter> __value_;
65 };52 };
6653
67public:54public:
...@@ -133,7 +120,7 @@ public:...@@ -133,7 +120,7 @@ public:
133 auto&& __tmp = *_VSTD::__unchecked_get<_Iter>(__hold_);120 auto&& __tmp = *_VSTD::__unchecked_get<_Iter>(__hold_);
134 return _VSTD::addressof(__tmp);121 return _VSTD::addressof(__tmp);
135 } else {122 } else {
136 return __proxy(*_VSTD::__unchecked_get<_Iter>(__hold_));123 return __proxy{*_VSTD::__unchecked_get<_Iter>(__hold_)};
137 }124 }
138 }125 }
139126
...@@ -148,11 +135,11 @@ public:...@@ -148,11 +135,11 @@ public:
148 auto __tmp = *this;135 auto __tmp = *this;
149 ++*this;136 ++*this;
150 return __tmp;137 return __tmp;
151 } else if constexpr (requires (_Iter& __i) { { *__i++ } -> __referenceable; } ||138 } else if constexpr (requires (_Iter& __i) { { *__i++ } -> __can_reference; } ||
152 !__can_use_postfix_proxy<_Iter>) {139 !__can_use_postfix_proxy<_Iter>) {
153 return _VSTD::__unchecked_get<_Iter>(__hold_)++;140 return _VSTD::__unchecked_get<_Iter>(__hold_)++;
154 } else {141 } else {
155 __postfix_proxy __p(**this);142 auto __p = __postfix_proxy{**this};
156 ++*this;143 ++*this;
157 return __p;144 return __p;
158 }145 }
...@@ -276,7 +263,7 @@ struct iterator_traits<common_iterator<_Iter, _Sent>> {...@@ -276,7 +263,7 @@ struct iterator_traits<common_iterator<_Iter, _Sent>> {
276 using reference = iter_reference_t<_Iter>;263 using reference = iter_reference_t<_Iter>;
277};264};
278265
279#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)266#endif // _LIBCPP_STD_VER > 17
280267
281_LIBCPP_END_NAMESPACE_STD268_LIBCPP_END_NAMESPACE_STD
282269
lib/libcxx/include/__iterator/concepts.h+20-4
...@@ -21,12 +21,12 @@...@@ -21,12 +21,12 @@
21#include <type_traits>21#include <type_traits>
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
25#endif25#endif
2626
27_LIBCPP_BEGIN_NAMESPACE_STD27_LIBCPP_BEGIN_NAMESPACE_STD
2828
29#if !defined(_LIBCPP_HAS_NO_CONCEPTS)29#if _LIBCPP_STD_VER > 17
3030
31// [iterator.concept.readable]31// [iterator.concept.readable]
32template<class _In>32template<class _In>
...@@ -90,7 +90,7 @@ concept incrementable =...@@ -90,7 +90,7 @@ concept incrementable =
90template<class _Ip>90template<class _Ip>
91concept input_or_output_iterator =91concept input_or_output_iterator =
92 requires(_Ip __i) {92 requires(_Ip __i) {
93 { *__i } -> __referenceable;93 { *__i } -> __can_reference;
94 } &&94 } &&
95 weakly_incrementable<_Ip>;95 weakly_incrementable<_Ip>;
9696
...@@ -254,10 +254,26 @@ concept indirectly_movable_storable =...@@ -254,10 +254,26 @@ concept indirectly_movable_storable =
254 constructible_from<iter_value_t<_In>, iter_rvalue_reference_t<_In>> &&254 constructible_from<iter_value_t<_In>, iter_rvalue_reference_t<_In>> &&
255 assignable_from<iter_value_t<_In>&, iter_rvalue_reference_t<_In>>;255 assignable_from<iter_value_t<_In>&, iter_rvalue_reference_t<_In>>;
256256
257template<class _In, class _Out>
258concept indirectly_copyable =
259 indirectly_readable<_In> &&
260 indirectly_writable<_Out, iter_reference_t<_In>>;
261
262template<class _In, class _Out>
263concept indirectly_copyable_storable =
264 indirectly_copyable<_In, _Out> &&
265 indirectly_writable<_Out, iter_value_t<_In>&> &&
266 indirectly_writable<_Out, const iter_value_t<_In>&> &&
267 indirectly_writable<_Out, iter_value_t<_In>&&> &&
268 indirectly_writable<_Out, const iter_value_t<_In>&&> &&
269 copyable<iter_value_t<_In>> &&
270 constructible_from<iter_value_t<_In>, iter_reference_t<_In>> &&
271 assignable_from<iter_value_t<_In>&, iter_reference_t<_In>>;
272
257// Note: indirectly_swappable is located in iter_swap.h to prevent a dependency cycle273// Note: indirectly_swappable is located in iter_swap.h to prevent a dependency cycle
258// (both iter_swap and indirectly_swappable require indirectly_readable).274// (both iter_swap and indirectly_swappable require indirectly_readable).
259275
260#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)276#endif // _LIBCPP_STD_VER > 17
261277
262_LIBCPP_END_NAMESPACE_STD278_LIBCPP_END_NAMESPACE_STD
263279
lib/libcxx/include/__iterator/counted_iterator.h+5-5
...@@ -9,8 +9,8 @@...@@ -9,8 +9,8 @@
9#ifndef _LIBCPP___ITERATOR_COUNTED_ITERATOR_H9#ifndef _LIBCPP___ITERATOR_COUNTED_ITERATOR_H
10#define _LIBCPP___ITERATOR_COUNTED_ITERATOR_H10#define _LIBCPP___ITERATOR_COUNTED_ITERATOR_H
1111
12#include <__assert>
12#include <__config>13#include <__config>
13#include <__debug>
14#include <__iterator/concepts.h>14#include <__iterator/concepts.h>
15#include <__iterator/default_sentinel.h>15#include <__iterator/default_sentinel.h>
16#include <__iterator/incrementable_traits.h>16#include <__iterator/incrementable_traits.h>
...@@ -25,12 +25,12 @@...@@ -25,12 +25,12 @@
25#include <type_traits>25#include <type_traits>
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
29#endif29#endif
3030
31_LIBCPP_BEGIN_NAMESPACE_STD31_LIBCPP_BEGIN_NAMESPACE_STD
3232
33#if !defined(_LIBCPP_HAS_NO_CONCEPTS)33#if _LIBCPP_STD_VER > 17
3434
35template<class>35template<class>
36struct __counted_iterator_concept {};36struct __counted_iterator_concept {};
...@@ -65,7 +65,7 @@ class counted_iterator...@@ -65,7 +65,7 @@ class counted_iterator
65 , public __counted_iterator_value_type<_Iter>65 , public __counted_iterator_value_type<_Iter>
66{66{
67public:67public:
68 [[no_unique_address]] _Iter __current_ = _Iter();68 _LIBCPP_NO_UNIQUE_ADDRESS _Iter __current_ = _Iter();
69 iter_difference_t<_Iter> __count_ = 0;69 iter_difference_t<_Iter> __count_ = 0;
7070
71 using iterator_type = _Iter;71 using iterator_type = _Iter;
...@@ -296,7 +296,7 @@ struct iterator_traits<counted_iterator<_Iter>> : iterator_traits<_Iter> {...@@ -296,7 +296,7 @@ struct iterator_traits<counted_iterator<_Iter>> : iterator_traits<_Iter> {
296 add_pointer_t<iter_reference_t<_Iter>>, void>;296 add_pointer_t<iter_reference_t<_Iter>>, void>;
297};297};
298298
299#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)299#endif // _LIBCPP_STD_VER > 17
300300
301_LIBCPP_END_NAMESPACE_STD301_LIBCPP_END_NAMESPACE_STD
302302
lib/libcxx/include/__iterator/data.h+1-1
...@@ -15,7 +15,7 @@...@@ -15,7 +15,7 @@
15#include <initializer_list>15#include <initializer_list>
1616
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header18# pragma GCC system_header
19#endif19#endif
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__iterator/default_sentinel.h+3-3
...@@ -13,17 +13,17 @@...@@ -13,17 +13,17 @@
13#include <__config>13#include <__config>
1414
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16#pragma GCC system_header16# pragma GCC system_header
17#endif17#endif
1818
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21#if !defined(_LIBCPP_HAS_NO_CONCEPTS)21#if _LIBCPP_STD_VER > 17
2222
23struct default_sentinel_t { };23struct default_sentinel_t { };
24inline constexpr default_sentinel_t default_sentinel{};24inline constexpr default_sentinel_t default_sentinel{};
2525
26#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)26#endif // _LIBCPP_STD_VER > 17
2727
28_LIBCPP_END_NAMESPACE_STD28_LIBCPP_END_NAMESPACE_STD
2929
lib/libcxx/include/__iterator/distance.h+3-3
...@@ -20,7 +20,7 @@...@@ -20,7 +20,7 @@
20#include <type_traits>20#include <type_traits>
2121
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23#pragma GCC system_header23# pragma GCC system_header
24#endif24#endif
2525
26_LIBCPP_BEGIN_NAMESPACE_STD26_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -52,7 +52,7 @@ distance(_InputIter __first, _InputIter __last)...@@ -52,7 +52,7 @@ distance(_InputIter __first, _InputIter __last)
52 return _VSTD::__distance(__first, __last, typename iterator_traits<_InputIter>::iterator_category());52 return _VSTD::__distance(__first, __last, typename iterator_traits<_InputIter>::iterator_category());
53}53}
5454
55#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)55#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
5656
57// [range.iter.op.distance]57// [range.iter.op.distance]
5858
...@@ -100,7 +100,7 @@ inline namespace __cpo {...@@ -100,7 +100,7 @@ inline namespace __cpo {
100} // namespace __cpo100} // namespace __cpo
101} // namespace ranges101} // namespace ranges
102102
103#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)103#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
104104
105_LIBCPP_END_NAMESPACE_STD105_LIBCPP_END_NAMESPACE_STD
106106
lib/libcxx/include/__iterator/empty.h+1-1
...@@ -15,7 +15,7 @@...@@ -15,7 +15,7 @@
15#include <initializer_list>15#include <initializer_list>
1616
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header18# pragma GCC system_header
19#endif19#endif
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__iterator/erase_if_container.h+1-1
...@@ -13,7 +13,7 @@...@@ -13,7 +13,7 @@
13#include <__config>13#include <__config>
1414
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16#pragma GCC system_header16# pragma GCC system_header
17#endif17#endif
1818
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__iterator/front_insert_iterator.h+5-5
...@@ -18,7 +18,7 @@...@@ -18,7 +18,7 @@
18#include <cstddef>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
22#endif22#endif
2323
24_LIBCPP_BEGIN_NAMESPACE_STD24_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -46,11 +46,11 @@ public:...@@ -46,11 +46,11 @@ public:
46 typedef _Container container_type;46 typedef _Container container_type;
4747
48 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit front_insert_iterator(_Container& __x) : container(_VSTD::addressof(__x)) {}48 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit front_insert_iterator(_Container& __x) : container(_VSTD::addressof(__x)) {}
49 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator& operator=(const typename _Container::value_type& __value_)49 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator& operator=(const typename _Container::value_type& __value)
50 {container->push_front(__value_); return *this;}50 {container->push_front(__value); return *this;}
51#ifndef _LIBCPP_CXX03_LANG51#ifndef _LIBCPP_CXX03_LANG
52 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator& operator=(typename _Container::value_type&& __value_)52 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator& operator=(typename _Container::value_type&& __value)
53 {container->push_front(_VSTD::move(__value_)); return *this;}53 {container->push_front(_VSTD::move(__value)); return *this;}
54#endif // _LIBCPP_CXX03_LANG54#endif // _LIBCPP_CXX03_LANG
55 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator& operator*() {return *this;}55 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator& operator*() {return *this;}
56 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator& operator++() {return *this;}56 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator& operator++() {return *this;}
lib/libcxx/include/__iterator/incrementable_traits.h+4-3
...@@ -11,16 +11,17 @@...@@ -11,16 +11,17 @@
11#define _LIBCPP___ITERATOR_INCREMENTABLE_TRAITS_H11#define _LIBCPP___ITERATOR_INCREMENTABLE_TRAITS_H
1212
13#include <__config>13#include <__config>
14#include <__type_traits/is_primary_template.h>
14#include <concepts>15#include <concepts>
15#include <type_traits>16#include <type_traits>
1617
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header19# pragma GCC system_header
19#endif20#endif
2021
21_LIBCPP_BEGIN_NAMESPACE_STD22_LIBCPP_BEGIN_NAMESPACE_STD
2223
23#if !defined(_LIBCPP_HAS_NO_CONCEPTS)24#if _LIBCPP_STD_VER > 17
2425
25// [incrementable.traits]26// [incrementable.traits]
26template<class> struct incrementable_traits {};27template<class> struct incrementable_traits {};
...@@ -65,7 +66,7 @@ using iter_difference_t = typename conditional_t<__is_primary_template<iterator_...@@ -65,7 +66,7 @@ using iter_difference_t = typename conditional_t<__is_primary_template<iterator_
65 incrementable_traits<remove_cvref_t<_Ip> >,66 incrementable_traits<remove_cvref_t<_Ip> >,
66 iterator_traits<remove_cvref_t<_Ip> > >::difference_type;67 iterator_traits<remove_cvref_t<_Ip> > >::difference_type;
6768
68#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)69#endif // _LIBCPP_STD_VER > 17
6970
70_LIBCPP_END_NAMESPACE_STD71_LIBCPP_END_NAMESPACE_STD
7172
lib/libcxx/include/__iterator/indirectly_comparable.h+6-2
...@@ -15,15 +15,19 @@...@@ -15,15 +15,19 @@
15#include <__iterator/concepts.h>15#include <__iterator/concepts.h>
16#include <__iterator/projected.h>16#include <__iterator/projected.h>
1717
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header
20#endif
21
18_LIBCPP_BEGIN_NAMESPACE_STD22_LIBCPP_BEGIN_NAMESPACE_STD
1923
20#if !defined(_LIBCPP_HAS_NO_CONCEPTS)24#if _LIBCPP_STD_VER > 17
2125
22template <class _I1, class _I2, class _Rp, class _P1 = identity, class _P2 = identity>26template <class _I1, class _I2, class _Rp, class _P1 = identity, class _P2 = identity>
23concept indirectly_comparable =27concept indirectly_comparable =
24 indirect_binary_predicate<_Rp, projected<_I1, _P1>, projected<_I2, _P2>>;28 indirect_binary_predicate<_Rp, projected<_I1, _P1>, projected<_I2, _P2>>;
2529
26#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)30#endif // _LIBCPP_STD_VER > 17
2731
28_LIBCPP_END_NAMESPACE_STD32_LIBCPP_END_NAMESPACE_STD
2933
lib/libcxx/include/__iterator/insert_iterator.h+6-6
...@@ -19,12 +19,12 @@...@@ -19,12 +19,12 @@
19#include <cstddef>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
23#endif23#endif
2424
25_LIBCPP_BEGIN_NAMESPACE_STD25_LIBCPP_BEGIN_NAMESPACE_STD
2626
27#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
28template <class _Container>28template <class _Container>
29using __insert_iterator_iter_t = ranges::iterator_t<_Container>;29using __insert_iterator_iter_t = ranges::iterator_t<_Container>;
30#else30#else
...@@ -57,11 +57,11 @@ public:...@@ -57,11 +57,11 @@ public:
5757
58 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator(_Container& __x, __insert_iterator_iter_t<_Container> __i)58 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator(_Container& __x, __insert_iterator_iter_t<_Container> __i)
59 : container(_VSTD::addressof(__x)), iter(__i) {}59 : container(_VSTD::addressof(__x)), iter(__i) {}
60 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator=(const typename _Container::value_type& __value_)60 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator=(const typename _Container::value_type& __value)
61 {iter = container->insert(iter, __value_); ++iter; return *this;}61 {iter = container->insert(iter, __value); ++iter; return *this;}
62#ifndef _LIBCPP_CXX03_LANG62#ifndef _LIBCPP_CXX03_LANG
63 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator=(typename _Container::value_type&& __value_)63 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator=(typename _Container::value_type&& __value)
64 {iter = container->insert(iter, _VSTD::move(__value_)); ++iter; return *this;}64 {iter = container->insert(iter, _VSTD::move(__value)); ++iter; return *this;}
65#endif // _LIBCPP_CXX03_LANG65#endif // _LIBCPP_CXX03_LANG
66 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator*() {return *this;}66 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator*() {return *this;}
67 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator++() {return *this;}67 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator++() {return *this;}
lib/libcxx/include/__iterator/istream_iterator.h+14-1
...@@ -11,13 +11,15 @@...@@ -11,13 +11,15 @@
11#define _LIBCPP___ITERATOR_ISTREAM_ITERATOR_H11#define _LIBCPP___ITERATOR_ISTREAM_ITERATOR_H
1212
13#include <__config>13#include <__config>
14#include <__iterator/default_sentinel.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>
18#include <cstddef>
17#include <iosfwd> // for forward declarations of char_traits and basic_istream19#include <iosfwd> // for forward declarations of char_traits and basic_istream
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
21#endif23#endif
2224
23_LIBCPP_BEGIN_NAMESPACE_STD25_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -45,6 +47,9 @@ private:...@@ -45,6 +47,9 @@ private:
45 _Tp __value_;47 _Tp __value_;
46public:48public:
47 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR istream_iterator() : __in_stream_(nullptr), __value_() {}49 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR istream_iterator() : __in_stream_(nullptr), __value_() {}
50#if _LIBCPP_STD_VER > 17
51 _LIBCPP_HIDE_FROM_ABI constexpr istream_iterator(default_sentinel_t) : istream_iterator() {}
52#endif // _LIBCPP_STD_VER > 17
48 _LIBCPP_INLINE_VISIBILITY istream_iterator(istream_type& __s) : __in_stream_(_VSTD::addressof(__s))53 _LIBCPP_INLINE_VISIBILITY istream_iterator(istream_type& __s) : __in_stream_(_VSTD::addressof(__s))
49 {54 {
50 if (!(*__in_stream_ >> __value_))55 if (!(*__in_stream_ >> __value_))
...@@ -67,6 +72,12 @@ public:...@@ -67,6 +72,12 @@ public:
67 bool72 bool
68 operator==(const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __x,73 operator==(const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __x,
69 const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __y);74 const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __y);
75
76#if _LIBCPP_STD_VER > 17
77 friend _LIBCPP_HIDE_FROM_ABI bool operator==(const istream_iterator& __i, default_sentinel_t) {
78 return __i.__in_stream_ == nullptr;
79 }
80#endif // _LIBCPP_STD_VER > 17
70};81};
7182
72template <class _Tp, class _CharT, class _Traits, class _Distance>83template <class _Tp, class _CharT, class _Traits, class _Distance>
...@@ -78,6 +89,7 @@ operator==(const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __x,...@@ -78,6 +89,7 @@ operator==(const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __x,
78 return __x.__in_stream_ == __y.__in_stream_;89 return __x.__in_stream_ == __y.__in_stream_;
79}90}
8091
92#if _LIBCPP_STD_VER <= 17
81template <class _Tp, class _CharT, class _Traits, class _Distance>93template <class _Tp, class _CharT, class _Traits, class _Distance>
82inline _LIBCPP_INLINE_VISIBILITY94inline _LIBCPP_INLINE_VISIBILITY
83bool95bool
...@@ -86,6 +98,7 @@ operator!=(const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __x,...@@ -86,6 +98,7 @@ operator!=(const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __x,
86{98{
87 return !(__x == __y);99 return !(__x == __y);
88}100}
101#endif // _LIBCPP_STD_VER <= 17
89102
90_LIBCPP_END_NAMESPACE_STD103_LIBCPP_END_NAMESPACE_STD
91104
lib/libcxx/include/__iterator/istreambuf_iterator.h+16-2
...@@ -11,12 +11,13 @@...@@ -11,12 +11,13 @@
11#define _LIBCPP___ITERATOR_ISTREAMBUF_ITERATOR_H11#define _LIBCPP___ITERATOR_ISTREAMBUF_ITERATOR_H
1212
13#include <__config>13#include <__config>
14#include <__iterator/default_sentinel.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 <iosfwd> // for forward declaration of basic_streambuf17#include <iosfwd> // for forward declaration of basic_streambuf
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
20#endif21#endif
2122
22_LIBCPP_BEGIN_NAMESPACE_STD23_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -49,7 +50,8 @@ private:...@@ -49,7 +50,8 @@ private:
49 {50 {
50 char_type __keep_;51 char_type __keep_;
51 streambuf_type* __sbuf_;52 streambuf_type* __sbuf_;
52 _LIBCPP_INLINE_VISIBILITY __proxy(char_type __c, streambuf_type* __s)53 _LIBCPP_INLINE_VISIBILITY
54 explicit __proxy(char_type __c, streambuf_type* __s)
53 : __keep_(__c), __sbuf_(__s) {}55 : __keep_(__c), __sbuf_(__s) {}
54 friend class istreambuf_iterator;56 friend class istreambuf_iterator;
55 public:57 public:
...@@ -65,6 +67,10 @@ private:...@@ -65,6 +67,10 @@ private:
65 }67 }
66public:68public:
67 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR istreambuf_iterator() _NOEXCEPT : __sbuf_(nullptr) {}69 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR istreambuf_iterator() _NOEXCEPT : __sbuf_(nullptr) {}
70#if _LIBCPP_STD_VER > 17
71 _LIBCPP_INLINE_VISIBILITY constexpr istreambuf_iterator(default_sentinel_t) noexcept
72 : istreambuf_iterator() {}
73#endif // _LIBCPP_STD_VER > 17
68 _LIBCPP_INLINE_VISIBILITY istreambuf_iterator(istream_type& __s) _NOEXCEPT74 _LIBCPP_INLINE_VISIBILITY istreambuf_iterator(istream_type& __s) _NOEXCEPT
69 : __sbuf_(__s.rdbuf()) {}75 : __sbuf_(__s.rdbuf()) {}
70 _LIBCPP_INLINE_VISIBILITY istreambuf_iterator(streambuf_type* __s) _NOEXCEPT76 _LIBCPP_INLINE_VISIBILITY istreambuf_iterator(streambuf_type* __s) _NOEXCEPT
...@@ -86,6 +92,12 @@ public:...@@ -86,6 +92,12 @@ public:
8692
87 _LIBCPP_INLINE_VISIBILITY bool equal(const istreambuf_iterator& __b) const93 _LIBCPP_INLINE_VISIBILITY bool equal(const istreambuf_iterator& __b) const
88 {return __test_for_eof() == __b.__test_for_eof();}94 {return __test_for_eof() == __b.__test_for_eof();}
95
96#if _LIBCPP_STD_VER > 17
97 friend _LIBCPP_HIDE_FROM_ABI bool operator==(const istreambuf_iterator& __i, default_sentinel_t) {
98 return __i.__test_for_eof();
99 }
100#endif // _LIBCPP_STD_VER > 17
89};101};
90102
91template <class _CharT, class _Traits>103template <class _CharT, class _Traits>
...@@ -94,11 +106,13 @@ bool operator==(const istreambuf_iterator<_CharT,_Traits>& __a,...@@ -94,11 +106,13 @@ bool operator==(const istreambuf_iterator<_CharT,_Traits>& __a,
94 const istreambuf_iterator<_CharT,_Traits>& __b)106 const istreambuf_iterator<_CharT,_Traits>& __b)
95 {return __a.equal(__b);}107 {return __a.equal(__b);}
96108
109#if _LIBCPP_STD_VER <= 17
97template <class _CharT, class _Traits>110template <class _CharT, class _Traits>
98inline _LIBCPP_INLINE_VISIBILITY111inline _LIBCPP_INLINE_VISIBILITY
99bool operator!=(const istreambuf_iterator<_CharT,_Traits>& __a,112bool operator!=(const istreambuf_iterator<_CharT,_Traits>& __a,
100 const istreambuf_iterator<_CharT,_Traits>& __b)113 const istreambuf_iterator<_CharT,_Traits>& __b)
101 {return !__a.equal(__b);}114 {return !__a.equal(__b);}
115#endif // _LIBCPP_STD_VER <= 17
102116
103_LIBCPP_END_NAMESPACE_STD117_LIBCPP_END_NAMESPACE_STD
104118
lib/libcxx/include/__iterator/iter_move.h+40-34
...@@ -10,20 +10,20 @@...@@ -10,20 +10,20 @@
10#ifndef _LIBCPP___ITERATOR_ITER_MOVE_H10#ifndef _LIBCPP___ITERATOR_ITER_MOVE_H
11#define _LIBCPP___ITERATOR_ITER_MOVE_H11#define _LIBCPP___ITERATOR_ITER_MOVE_H
1212
13#include <__concepts/class_or_enum.h>
13#include <__config>14#include <__config>
14#include <__iterator/iterator_traits.h>15#include <__iterator/iterator_traits.h>
15#include <__utility/forward.h>16#include <__utility/forward.h>
16#include <concepts> // __class_or_enum17#include <__utility/move.h>
17#include <type_traits>18#include <type_traits>
18#include <utility>
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
22#endif22#endif
2323
24_LIBCPP_BEGIN_NAMESPACE_STD24_LIBCPP_BEGIN_NAMESPACE_STD
2525
26#if !defined(_LIBCPP_HAS_NO_CONCEPTS)26#if _LIBCPP_STD_VER > 17
2727
28// [iterator.cust.move]28// [iterator.cust.move]
2929
...@@ -36,44 +36,50 @@ template <class _Tp>...@@ -36,44 +36,50 @@ template <class _Tp>
36concept __unqualified_iter_move =36concept __unqualified_iter_move =
37 __class_or_enum<remove_cvref_t<_Tp>> &&37 __class_or_enum<remove_cvref_t<_Tp>> &&
38 requires (_Tp&& __t) {38 requires (_Tp&& __t) {
39 iter_move(_VSTD::forward<_Tp>(__t));39 iter_move(std::forward<_Tp>(__t));
40 };40 };
4141
42// [iterator.cust.move]/142template<class _Tp>
43// The name ranges::iter_move denotes a customization point object.43concept __move_deref =
44// The expression ranges::iter_move(E) for a subexpression E is44 !__unqualified_iter_move<_Tp> &&
45// expression-equivalent to:45 requires (_Tp&& __t) {
46 *__t;
47 requires is_lvalue_reference_v<decltype(*__t)>;
48 };
49
50template<class _Tp>
51concept __just_deref =
52 !__unqualified_iter_move<_Tp> &&
53 !__move_deref<_Tp> &&
54 requires (_Tp&& __t) {
55 *__t;
56 requires (!is_lvalue_reference_v<decltype(*__t)>);
57 };
58
59// [iterator.cust.move]
60
46struct __fn {61struct __fn {
47 // [iterator.cust.move]/1.1
48 // iter_move(E), if E has class or enumeration type and iter_move(E) is a
49 // well-formed expression when treated as an unevaluated operand, [...]
50 template<class _Ip>62 template<class _Ip>
51 requires __class_or_enum<remove_cvref_t<_Ip>> && __unqualified_iter_move<_Ip>63 requires __unqualified_iter_move<_Ip>
52 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator()(_Ip&& __i) const64 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator()(_Ip&& __i) const
53 noexcept(noexcept(iter_move(_VSTD::forward<_Ip>(__i))))65 noexcept(noexcept(iter_move(std::forward<_Ip>(__i))))
54 {66 {
55 return iter_move(_VSTD::forward<_Ip>(__i));67 return iter_move(std::forward<_Ip>(__i));
56 }68 }
5769
58 // [iterator.cust.move]/1.2
59 // Otherwise, if the expression *E is well-formed:
60 // 1.2.1 if *E is an lvalue, std::move(*E);
61 // 1.2.2 otherwise, *E.
62 template<class _Ip>70 template<class _Ip>
63 requires (!(__class_or_enum<remove_cvref_t<_Ip>> && __unqualified_iter_move<_Ip>)) &&71 requires __move_deref<_Ip>
64 requires(_Ip&& __i) { *_VSTD::forward<_Ip>(__i); }72 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Ip&& __i) const
65 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator()(_Ip&& __i) const73 noexcept(noexcept(std::move(*std::forward<_Ip>(__i))))
66 noexcept(noexcept(*_VSTD::forward<_Ip>(__i)))74 -> decltype( std::move(*std::forward<_Ip>(__i)))
67 {75 { return std::move(*std::forward<_Ip>(__i)); }
68 if constexpr (is_lvalue_reference_v<decltype(*_VSTD::forward<_Ip>(__i))>) {
69 return _VSTD::move(*_VSTD::forward<_Ip>(__i));
70 } else {
71 return *_VSTD::forward<_Ip>(__i);
72 }
73 }
7476
75 // [iterator.cust.move]/1.377 template<class _Ip>
76 // Otherwise, ranges::iter_move(E) is ill-formed.78 requires __just_deref<_Ip>
79 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Ip&& __i) const
80 noexcept(noexcept(*std::forward<_Ip>(__i)))
81 -> decltype( *std::forward<_Ip>(__i))
82 { return *std::forward<_Ip>(__i); }
77};83};
78} // namespace __iter_move84} // namespace __iter_move
7985
...@@ -83,10 +89,10 @@ inline namespace __cpo {...@@ -83,10 +89,10 @@ inline namespace __cpo {
83} // namespace ranges89} // namespace ranges
8490
85template<__dereferenceable _Tp>91template<__dereferenceable _Tp>
86 requires requires(_Tp& __t) { { ranges::iter_move(__t) } -> __referenceable; }92 requires requires(_Tp& __t) { { ranges::iter_move(__t) } -> __can_reference; }
87using iter_rvalue_reference_t = decltype(ranges::iter_move(declval<_Tp&>()));93using iter_rvalue_reference_t = decltype(ranges::iter_move(declval<_Tp&>()));
8894
89#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)95#endif // _LIBCPP_STD_VER > 17
9096
91_LIBCPP_END_NAMESPACE_STD97_LIBCPP_END_NAMESPACE_STD
9298
lib/libcxx/include/__iterator/iter_swap.h+3-3
...@@ -20,12 +20,12 @@...@@ -20,12 +20,12 @@
20#include <type_traits>20#include <type_traits>
2121
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23#pragma GCC system_header23# pragma GCC system_header
24#endif24#endif
2525
26_LIBCPP_BEGIN_NAMESPACE_STD26_LIBCPP_BEGIN_NAMESPACE_STD
2727
28#if !defined(_LIBCPP_HAS_NO_CONCEPTS)28#if _LIBCPP_STD_VER > 17
2929
30// [iter.cust.swap]30// [iter.cust.swap]
3131
...@@ -99,7 +99,7 @@ concept indirectly_swappable =...@@ -99,7 +99,7 @@ concept indirectly_swappable =
99 ranges::iter_swap(__i2, __i1);99 ranges::iter_swap(__i2, __i1);
100 };100 };
101101
102#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)102#endif // _LIBCPP_STD_VER > 17
103103
104_LIBCPP_END_NAMESPACE_STD104_LIBCPP_END_NAMESPACE_STD
105105
lib/libcxx/include/__iterator/iterator.h+1-1
...@@ -14,7 +14,7 @@...@@ -14,7 +14,7 @@
14#include <cstddef>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
18#endif18#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__iterator/iterator_traits.h+51-34
...@@ -17,31 +17,31 @@...@@ -17,31 +17,31 @@
17#include <type_traits>17#include <type_traits>
1818
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20#pragma GCC system_header20# pragma GCC system_header
21#endif21#endif
2222
23_LIBCPP_BEGIN_NAMESPACE_STD23_LIBCPP_BEGIN_NAMESPACE_STD
2424
25#if !defined(_LIBCPP_HAS_NO_CONCEPTS)25#if _LIBCPP_STD_VER > 17
2626
27template <class _Tp>27template <class _Tp>
28using __with_reference = _Tp&;28using __with_reference = _Tp&;
2929
30template <class _Tp>30template <class _Tp>
31concept __referenceable = requires {31concept __can_reference = requires {
32 typename __with_reference<_Tp>;32 typename __with_reference<_Tp>;
33};33};
3434
35template <class _Tp>35template <class _Tp>
36concept __dereferenceable = requires(_Tp& __t) {36concept __dereferenceable = requires(_Tp& __t) {
37 { *__t } -> __referenceable; // not required to be equality-preserving37 { *__t } -> __can_reference; // not required to be equality-preserving
38};38};
3939
40// [iterator.traits]40// [iterator.traits]
41template<__dereferenceable _Tp>41template<__dereferenceable _Tp>
42using iter_reference_t = decltype(*declval<_Tp&>());42using iter_reference_t = decltype(*declval<_Tp&>());
4343
44#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)44#endif // _LIBCPP_STD_VER > 17
4545
46template <class _Iter>46template <class _Iter>
47struct _LIBCPP_TEMPLATE_VIS iterator_traits;47struct _LIBCPP_TEMPLATE_VIS iterator_traits;
...@@ -105,15 +105,14 @@ template <class _Tp>...@@ -105,15 +105,14 @@ template <class _Tp>
105struct __has_iterator_typedefs105struct __has_iterator_typedefs
106{106{
107private:107private:
108 struct __two {char __lx; char __lxx;};108 template <class _Up> static false_type __test(...);
109 template <class _Up> static __two __test(...);109 template <class _Up> static true_type __test(typename __void_t<typename _Up::iterator_category>::type* = 0,
110 template <class _Up> static char __test(typename __void_t<typename _Up::iterator_category>::type* = 0,110 typename __void_t<typename _Up::difference_type>::type* = 0,
111 typename __void_t<typename _Up::difference_type>::type* = 0,111 typename __void_t<typename _Up::value_type>::type* = 0,
112 typename __void_t<typename _Up::value_type>::type* = 0,112 typename __void_t<typename _Up::reference>::type* = 0,
113 typename __void_t<typename _Up::reference>::type* = 0,113 typename __void_t<typename _Up::pointer>::type* = 0);
114 typename __void_t<typename _Up::pointer>::type* = 0);
115public:114public:
116 static const bool value = sizeof(__test<_Tp>(0,0,0,0,0)) == 1;115 static const bool value = decltype(__test<_Tp>(0,0,0,0,0))::value;
117};116};
118117
119118
...@@ -121,35 +120,34 @@ template <class _Tp>...@@ -121,35 +120,34 @@ template <class _Tp>
121struct __has_iterator_category120struct __has_iterator_category
122{121{
123private:122private:
124 struct __two {char __lx; char __lxx;};123 template <class _Up> static false_type __test(...);
125 template <class _Up> static __two __test(...);124 template <class _Up> static true_type __test(typename _Up::iterator_category* = nullptr);
126 template <class _Up> static char __test(typename _Up::iterator_category* = nullptr);
127public:125public:
128 static const bool value = sizeof(__test<_Tp>(nullptr)) == 1;126 static const bool value = decltype(__test<_Tp>(nullptr))::value;
129};127};
130128
131template <class _Tp>129template <class _Tp>
132struct __has_iterator_concept130struct __has_iterator_concept
133{131{
134private:132private:
135 struct __two {char __lx; char __lxx;};133 template <class _Up> static false_type __test(...);
136 template <class _Up> static __two __test(...);134 template <class _Up> static true_type __test(typename _Up::iterator_concept* = nullptr);
137 template <class _Up> static char __test(typename _Up::iterator_concept* = nullptr);
138public:135public:
139 static const bool value = sizeof(__test<_Tp>(nullptr)) == 1;136 static const bool value = decltype(__test<_Tp>(nullptr))::value;
140};137};
141138
142#if !defined(_LIBCPP_HAS_NO_CONCEPTS)139#if _LIBCPP_STD_VER > 17
143140
144// The `cpp17-*-iterator` exposition-only concepts are easily confused with the Cpp17*Iterator tables,141// The `cpp17-*-iterator` exposition-only concepts have very similar names to the `Cpp17*Iterator` named requirements
145// so they've been banished to a namespace that makes it obvious they have a niche use-case.142// from `[iterator.cpp17]`. To avoid confusion between the two, the exposition-only concepts have been banished to
143// a "detail" namespace indicating they have a niche use-case.
146namespace __iterator_traits_detail {144namespace __iterator_traits_detail {
147template<class _Ip>145template<class _Ip>
148concept __cpp17_iterator =146concept __cpp17_iterator =
149 requires(_Ip __i) {147 requires(_Ip __i) {
150 { *__i } -> __referenceable;148 { *__i } -> __can_reference;
151 { ++__i } -> same_as<_Ip&>;149 { ++__i } -> same_as<_Ip&>;
152 { *__i++ } -> __referenceable;150 { *__i++ } -> __can_reference;
153 } &&151 } &&
154 copyable<_Ip>;152 copyable<_Ip>;
155153
...@@ -198,7 +196,7 @@ concept __cpp17_random_access_iterator =...@@ -198,7 +196,7 @@ concept __cpp17_random_access_iterator =
198 { __i + __n } -> same_as<_Ip>;196 { __i + __n } -> same_as<_Ip>;
199 { __n + __i } -> same_as<_Ip>;197 { __n + __i } -> same_as<_Ip>;
200 { __i - __n } -> same_as<_Ip>;198 { __i - __n } -> same_as<_Ip>;
201 { __i - __i } -> same_as<decltype(__n)>;199 { __i - __i } -> same_as<decltype(__n)>; // NOLINT(misc-redundant-expression) ; This is llvm.org/PR54114
202 { __i[__n] } -> convertible_to<iter_reference_t<_Ip>>;200 { __i[__n] } -> convertible_to<iter_reference_t<_Ip>>;
203 };201 };
204} // namespace __iterator_traits_detail202} // namespace __iterator_traits_detail
...@@ -362,7 +360,7 @@ struct iterator_traits : __iterator_traits<_Ip> {...@@ -362,7 +360,7 @@ struct iterator_traits : __iterator_traits<_Ip> {
362 using __primary_template = iterator_traits;360 using __primary_template = iterator_traits;
363};361};
364362
365#else // !defined(_LIBCPP_HAS_NO_CONCEPTS)363#else // _LIBCPP_STD_VER > 17
366364
367template <class _Iter, bool> struct __iterator_traits {};365template <class _Iter, bool> struct __iterator_traits {};
368366
...@@ -399,10 +397,10 @@ struct _LIBCPP_TEMPLATE_VIS iterator_traits...@@ -399,10 +397,10 @@ struct _LIBCPP_TEMPLATE_VIS iterator_traits
399397
400 using __primary_template = iterator_traits;398 using __primary_template = iterator_traits;
401};399};
402#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)400#endif // _LIBCPP_STD_VER > 17
403401
404template<class _Tp>402template<class _Tp>
405#if !defined(_LIBCPP_HAS_NO_CONCEPTS)403#if _LIBCPP_STD_VER > 17
406requires is_object_v<_Tp>404requires is_object_v<_Tp>
407#endif405#endif
408struct _LIBCPP_TEMPLATE_VIS iterator_traits<_Tp*>406struct _LIBCPP_TEMPLATE_VIS iterator_traits<_Tp*>
...@@ -468,27 +466,46 @@ template <class _Up>...@@ -468,27 +466,46 @@ template <class _Up>
468struct __is_cpp17_contiguous_iterator<_Up*> : true_type {};466struct __is_cpp17_contiguous_iterator<_Up*> : true_type {};
469467
470468
469template <class _Iter>
470class __wrap_iter;
471
471template <class _Tp>472template <class _Tp>
472struct __is_exactly_cpp17_input_iterator473struct __is_exactly_cpp17_input_iterator
473 : public integral_constant<bool,474 : public integral_constant<bool,
474 __has_iterator_category_convertible_to<_Tp, input_iterator_tag>::value &&475 __has_iterator_category_convertible_to<_Tp, input_iterator_tag>::value &&
475 !__has_iterator_category_convertible_to<_Tp, forward_iterator_tag>::value> {};476 !__has_iterator_category_convertible_to<_Tp, forward_iterator_tag>::value> {};
476477
477#if _LIBCPP_STD_VER >= 17478template <class _Tp>
479struct __is_exactly_cpp17_forward_iterator
480 : public integral_constant<bool,
481 __has_iterator_category_convertible_to<_Tp, forward_iterator_tag>::value &&
482 !__has_iterator_category_convertible_to<_Tp, bidirectional_iterator_tag>::value> {};
483
484template <class _Tp>
485struct __is_exactly_cpp17_bidirectional_iterator
486 : public integral_constant<bool,
487 __has_iterator_category_convertible_to<_Tp, bidirectional_iterator_tag>::value &&
488 !__has_iterator_category_convertible_to<_Tp, random_access_iterator_tag>::value> {};
489
478template<class _InputIterator>490template<class _InputIterator>
479using __iter_value_type = typename iterator_traits<_InputIterator>::value_type;491using __iter_value_type = typename iterator_traits<_InputIterator>::value_type;
480492
481template<class _InputIterator>493template<class _InputIterator>
482using __iter_key_type = remove_const_t<typename iterator_traits<_InputIterator>::value_type::first_type>;494using __iter_key_type = typename remove_const<typename iterator_traits<_InputIterator>::value_type::first_type>::type;
483495
484template<class _InputIterator>496template<class _InputIterator>
485using __iter_mapped_type = typename iterator_traits<_InputIterator>::value_type::second_type;497using __iter_mapped_type = typename iterator_traits<_InputIterator>::value_type::second_type;
486498
487template<class _InputIterator>499template<class _InputIterator>
488using __iter_to_alloc_type = pair<500using __iter_to_alloc_type = pair<
489 add_const_t<typename iterator_traits<_InputIterator>::value_type::first_type>,501 typename add_const<typename iterator_traits<_InputIterator>::value_type::first_type>::type,
490 typename iterator_traits<_InputIterator>::value_type::second_type>;502 typename iterator_traits<_InputIterator>::value_type::second_type>;
491#endif // _LIBCPP_STD_VER >= 17503
504template <class _Iter>
505using __iterator_category_type = typename iterator_traits<_Iter>::iterator_category;
506
507template <class _Iter>
508using __iterator_pointer_type = typename iterator_traits<_Iter>::pointer;
492509
493_LIBCPP_END_NAMESPACE_STD510_LIBCPP_END_NAMESPACE_STD
494511
lib/libcxx/include/__iterator/mergeable.h created+41
...@@ -0,0 +1,41 @@
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_MERGEABLE_H
11#define _LIBCPP___ITERATOR_MERGEABLE_H
12
13#include <__config>
14#include <__functional/identity.h>
15#include <__functional/ranges_operations.h>
16#include <__iterator/concepts.h>
17#include <__iterator/projected.h>
18
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20# pragma GCC system_header
21#endif
22
23_LIBCPP_BEGIN_NAMESPACE_STD
24
25#if _LIBCPP_STD_VER > 17
26
27template <class _Input1, class _Input2, class _Output,
28 class _Comp = ranges::less, class _Proj1 = identity, class _Proj2 = identity>
29concept mergeable =
30 input_iterator<_Input1> &&
31 input_iterator<_Input2> &&
32 weakly_incrementable<_Output> &&
33 indirectly_copyable<_Input1, _Output> &&
34 indirectly_copyable<_Input2, _Output> &&
35 indirect_strict_weak_order<_Comp, projected<_Input1, _Proj1>, projected<_Input2, _Proj2>>;
36
37#endif // _LIBCPP_STD_VER > 17
38
39_LIBCPP_END_NAMESPACE_STD
40
41#endif // _LIBCPP___ITERATOR_MERGEABLE_H
lib/libcxx/include/__iterator/move_iterator.h+158-17
...@@ -10,51 +10,131 @@...@@ -10,51 +10,131 @@
10#ifndef _LIBCPP___ITERATOR_MOVE_ITERATOR_H10#ifndef _LIBCPP___ITERATOR_MOVE_ITERATOR_H
11#define _LIBCPP___ITERATOR_MOVE_ITERATOR_H11#define _LIBCPP___ITERATOR_MOVE_ITERATOR_H
1212
13#include <__compare/compare_three_way_result.h>
14#include <__compare/three_way_comparable.h>
15#include <__concepts/assignable.h>
16#include <__concepts/convertible_to.h>
17#include <__concepts/derived_from.h>
18#include <__concepts/same_as.h>
13#include <__config>19#include <__config>
20#include <__iterator/concepts.h>
21#include <__iterator/incrementable_traits.h>
22#include <__iterator/iter_move.h>
23#include <__iterator/iter_swap.h>
14#include <__iterator/iterator_traits.h>24#include <__iterator/iterator_traits.h>
25#include <__iterator/move_sentinel.h>
26#include <__iterator/readable_traits.h>
15#include <__utility/move.h>27#include <__utility/move.h>
16#include <type_traits>28#include <type_traits>
1729
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)30#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19#pragma GCC system_header31# pragma GCC system_header
20#endif32#endif
2133
22_LIBCPP_BEGIN_NAMESPACE_STD34_LIBCPP_BEGIN_NAMESPACE_STD
2335
36#if _LIBCPP_STD_VER > 17
37template<class _Iter, class = void>
38struct __move_iter_category_base {};
39
40template<class _Iter>
41 requires requires { typename iterator_traits<_Iter>::iterator_category; }
42struct __move_iter_category_base<_Iter> {
43 using iterator_category = _If<
44 derived_from<typename iterator_traits<_Iter>::iterator_category, random_access_iterator_tag>,
45 random_access_iterator_tag,
46 typename iterator_traits<_Iter>::iterator_category
47 >;
48};
49
50template<class _Iter, class _Sent>
51concept __move_iter_comparable = requires {
52 { declval<const _Iter&>() == declval<_Sent>() } -> convertible_to<bool>;
53};
54#endif // _LIBCPP_STD_VER > 17
55
24template <class _Iter>56template <class _Iter>
25class _LIBCPP_TEMPLATE_VIS move_iterator57class _LIBCPP_TEMPLATE_VIS move_iterator
58#if _LIBCPP_STD_VER > 17
59 : public __move_iter_category_base<_Iter>
60#endif
26{61{
27public:62public:
28#if _LIBCPP_STD_VER > 1763#if _LIBCPP_STD_VER > 17
29 typedef input_iterator_tag iterator_concept;64 using iterator_type = _Iter;
30#endif65 using iterator_concept = input_iterator_tag;
3166 // iterator_category is inherited and not always present
67 using value_type = iter_value_t<_Iter>;
68 using difference_type = iter_difference_t<_Iter>;
69 using pointer = _Iter;
70 using reference = iter_rvalue_reference_t<_Iter>;
71#else
32 typedef _Iter iterator_type;72 typedef _Iter iterator_type;
33 typedef _If<73 typedef _If<
34 __is_cpp17_random_access_iterator<_Iter>::value,74 __is_cpp17_random_access_iterator<_Iter>::value,
35 random_access_iterator_tag,75 random_access_iterator_tag,
36 typename iterator_traits<_Iter>::iterator_category76 typename iterator_traits<_Iter>::iterator_category
37 > iterator_category;77 > iterator_category;
38 typedef typename iterator_traits<iterator_type>::value_type value_type;78 typedef typename iterator_traits<iterator_type>::value_type value_type;
39 typedef typename iterator_traits<iterator_type>::difference_type difference_type;79 typedef typename iterator_traits<iterator_type>::difference_type difference_type;
40 typedef iterator_type pointer;80 typedef iterator_type pointer;
4181
42#ifndef _LIBCPP_CXX03_LANG
43 typedef typename iterator_traits<iterator_type>::reference __reference;82 typedef typename iterator_traits<iterator_type>::reference __reference;
44 typedef typename conditional<83 typedef typename conditional<
45 is_reference<__reference>::value,84 is_reference<__reference>::value,
46 typename remove_reference<__reference>::type&&,85 typename remove_reference<__reference>::type&&,
47 __reference86 __reference
48 >::type reference;87 >::type reference;
49#else88#endif // _LIBCPP_STD_VER > 17
50 typedef typename iterator_traits<iterator_type>::reference reference;
51#endif
5289
53 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1490 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
54 move_iterator() : __current_() {}91 explicit move_iterator(_Iter __i) : __current_(std::move(__i)) {}
92
93 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
94 move_iterator& operator++() { ++__current_; return *this; }
95
96 _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
97 pointer operator->() const { return __current_; }
98
99#if _LIBCPP_STD_VER > 17
100 _LIBCPP_HIDE_FROM_ABI constexpr
101 move_iterator() requires is_constructible_v<_Iter> : __current_() {}
102
103 template <class _Up>
104 requires (!_IsSame<_Up, _Iter>::value) && convertible_to<const _Up&, _Iter>
105 _LIBCPP_HIDE_FROM_ABI constexpr
106 move_iterator(const move_iterator<_Up>& __u) : __current_(__u.base()) {}
107
108 template <class _Up>
109 requires (!_IsSame<_Up, _Iter>::value) &&
110 convertible_to<const _Up&, _Iter> &&
111 assignable_from<_Iter&, const _Up&>
112 _LIBCPP_HIDE_FROM_ABI constexpr
113 move_iterator& operator=(const move_iterator<_Up>& __u) {
114 __current_ = __u.base();
115 return *this;
116 }
117
118 _LIBCPP_HIDE_FROM_ABI constexpr const _Iter& base() const & noexcept { return __current_; }
119 _LIBCPP_HIDE_FROM_ABI constexpr _Iter base() && { return std::move(__current_); }
55120
121 _LIBCPP_HIDE_FROM_ABI constexpr
122 reference operator*() const { return ranges::iter_move(__current_); }
123 _LIBCPP_HIDE_FROM_ABI constexpr
124 reference operator[](difference_type __n) const { return ranges::iter_move(__current_ + __n); }
125
126 _LIBCPP_HIDE_FROM_ABI constexpr
127 auto operator++(int)
128 requires forward_iterator<_Iter>
129 {
130 move_iterator __tmp(*this); ++__current_; return __tmp;
131 }
132
133 _LIBCPP_HIDE_FROM_ABI constexpr
134 void operator++(int) { ++__current_; }
135#else
56 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14136 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
57 explicit move_iterator(_Iter __i) : __current_(_VSTD::move(__i)) {}137 move_iterator() : __current_() {}
58138
59 template <class _Up, class = __enable_if_t<139 template <class _Up, class = __enable_if_t<
60 !is_same<_Up, _Iter>::value && is_convertible<const _Up&, _Iter>::value140 !is_same<_Up, _Iter>::value && is_convertible<const _Up&, _Iter>::value
...@@ -79,14 +159,12 @@ public:...@@ -79,14 +159,12 @@ public:
79 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14159 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
80 reference operator*() const { return static_cast<reference>(*__current_); }160 reference operator*() const { return static_cast<reference>(*__current_); }
81 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14161 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
82 pointer operator->() const { return __current_; }
83 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
84 reference operator[](difference_type __n) const { return static_cast<reference>(__current_[__n]); }162 reference operator[](difference_type __n) const { return static_cast<reference>(__current_[__n]); }
85163
86 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
87 move_iterator& operator++() { ++__current_; return *this; }
88 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14164 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
89 move_iterator operator++(int) { move_iterator __tmp(*this); ++__current_; return __tmp; }165 move_iterator operator++(int) { move_iterator __tmp(*this); ++__current_; return __tmp; }
166#endif // _LIBCPP_STD_VER > 17
167
90 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14168 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
91 move_iterator& operator--() { --__current_; return *this; }169 move_iterator& operator--() { --__current_; return *this; }
92 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14170 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
...@@ -100,7 +178,48 @@ public:...@@ -100,7 +178,48 @@ public:
100 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14178 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
101 move_iterator& operator-=(difference_type __n) { __current_ -= __n; return *this; }179 move_iterator& operator-=(difference_type __n) { __current_ -= __n; return *this; }
102180
181#if _LIBCPP_STD_VER > 17
182 template<sentinel_for<_Iter> _Sent>
183 friend _LIBCPP_HIDE_FROM_ABI constexpr
184 bool operator==(const move_iterator& __x, const move_sentinel<_Sent>& __y)
185 requires __move_iter_comparable<_Iter, _Sent>
186 {
187 return __x.base() == __y.base();
188 }
189
190 template<sized_sentinel_for<_Iter> _Sent>
191 friend _LIBCPP_HIDE_FROM_ABI constexpr
192 iter_difference_t<_Iter> operator-(const move_sentinel<_Sent>& __x, const move_iterator& __y)
193 {
194 return __x.base() - __y.base();
195 }
196
197 template<sized_sentinel_for<_Iter> _Sent>
198 friend _LIBCPP_HIDE_FROM_ABI constexpr
199 iter_difference_t<_Iter> operator-(const move_iterator& __x, const move_sentinel<_Sent>& __y)
200 {
201 return __x.base() - __y.base();
202 }
203
204 friend _LIBCPP_HIDE_FROM_ABI constexpr
205 iter_rvalue_reference_t<_Iter> iter_move(const move_iterator& __i)
206 noexcept(noexcept(ranges::iter_move(__i.__current_)))
207 {
208 return ranges::iter_move(__i.__current_);
209 }
210
211 template<indirectly_swappable<_Iter> _It2>
212 friend _LIBCPP_HIDE_FROM_ABI constexpr
213 void iter_swap(const move_iterator& __x, const move_iterator<_It2>& __y)
214 noexcept(noexcept(ranges::iter_swap(__x.__current_, __y.__current_)))
215 {
216 return ranges::iter_swap(__x.__current_, __y.__current_);
217 }
218#endif // _LIBCPP_STD_VER > 17
219
103private:220private:
221 template<class _It2> friend class move_iterator;
222
104 _Iter __current_;223 _Iter __current_;
105};224};
106225
...@@ -111,12 +230,14 @@ bool operator==(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& _...@@ -111,12 +230,14 @@ bool operator==(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& _
111 return __x.base() == __y.base();230 return __x.base() == __y.base();
112}231}
113232
233#if _LIBCPP_STD_VER <= 17
114template <class _Iter1, class _Iter2>234template <class _Iter1, class _Iter2>
115inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14235inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
116bool operator!=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)236bool operator!=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
117{237{
118 return __x.base() != __y.base();238 return __x.base() != __y.base();
119}239}
240#endif // _LIBCPP_STD_VER <= 17
120241
121template <class _Iter1, class _Iter2>242template <class _Iter1, class _Iter2>
122inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14243inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
...@@ -146,6 +267,16 @@ bool operator>=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& _...@@ -146,6 +267,16 @@ bool operator>=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& _
146 return __x.base() >= __y.base();267 return __x.base() >= __y.base();
147}268}
148269
270#if _LIBCPP_STD_VER > 17
271template <class _Iter1, three_way_comparable_with<_Iter1> _Iter2>
272inline _LIBCPP_HIDE_FROM_ABI constexpr
273auto operator<=>(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
274 -> compare_three_way_result_t<_Iter1, _Iter2>
275{
276 return __x.base() <=> __y.base();
277}
278#endif // _LIBCPP_STD_VER > 17
279
149#ifndef _LIBCPP_CXX03_LANG280#ifndef _LIBCPP_CXX03_LANG
150template <class _Iter1, class _Iter2>281template <class _Iter1, class _Iter2>
151inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14282inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
...@@ -162,8 +293,17 @@ operator-(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)...@@ -162,8 +293,17 @@ operator-(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
162{293{
163 return __x.base() - __y.base();294 return __x.base() - __y.base();
164}295}
165#endif296#endif // !_LIBCPP_CXX03_LANG
166297
298#if _LIBCPP_STD_VER > 17
299template <class _Iter>
300inline _LIBCPP_HIDE_FROM_ABI constexpr
301move_iterator<_Iter> operator+(iter_difference_t<_Iter> __n, const move_iterator<_Iter>& __x)
302 requires requires { { __x.base() + __n } -> same_as<_Iter>; }
303{
304 return __x + __n;
305}
306#else
167template <class _Iter>307template <class _Iter>
168inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14308inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
169move_iterator<_Iter>309move_iterator<_Iter>
...@@ -171,13 +311,14 @@ operator+(typename move_iterator<_Iter>::difference_type __n, const move_iterato...@@ -171,13 +311,14 @@ operator+(typename move_iterator<_Iter>::difference_type __n, const move_iterato
171{311{
172 return move_iterator<_Iter>(__x.base() + __n);312 return move_iterator<_Iter>(__x.base() + __n);
173}313}
314#endif // _LIBCPP_STD_VER > 17
174315
175template <class _Iter>316template <class _Iter>
176inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14317inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
177move_iterator<_Iter>318move_iterator<_Iter>
178make_move_iterator(_Iter __i)319make_move_iterator(_Iter __i)
179{320{
180 return move_iterator<_Iter>(_VSTD::move(__i));321 return move_iterator<_Iter>(std::move(__i));
181}322}
182323
183_LIBCPP_END_NAMESPACE_STD324_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__iterator/move_sentinel.h created+57
...@@ -0,0 +1,57 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ITERATOR_MOVE_SENTINEL_H
10#define _LIBCPP___ITERATOR_MOVE_SENTINEL_H
11
12#include <__concepts/assignable.h>
13#include <__concepts/convertible_to.h>
14#include <__concepts/semiregular.h>
15#include <__config>
16#include <__utility/move.h>
17
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header
20#endif
21
22_LIBCPP_BEGIN_NAMESPACE_STD
23
24#if _LIBCPP_STD_VER > 17
25
26template <semiregular _Sent>
27class _LIBCPP_TEMPLATE_VIS move_sentinel
28{
29public:
30 _LIBCPP_HIDE_FROM_ABI
31 move_sentinel() = default;
32
33 _LIBCPP_HIDE_FROM_ABI constexpr
34 explicit move_sentinel(_Sent __s) : __last_(std::move(__s)) {}
35
36 template <class _S2>
37 requires convertible_to<const _S2&, _Sent>
38 _LIBCPP_HIDE_FROM_ABI constexpr
39 move_sentinel(const move_sentinel<_S2>& __s) : __last_(__s.base()) {}
40
41 template <class _S2>
42 requires assignable_from<_Sent&, const _S2&>
43 _LIBCPP_HIDE_FROM_ABI constexpr
44 move_sentinel& operator=(const move_sentinel<_S2>& __s)
45 { __last_ = __s.base(); return *this; }
46
47 constexpr _Sent base() const { return __last_; }
48
49private:
50 _Sent __last_ = _Sent();
51};
52
53#endif // _LIBCPP_STD_VER > 17
54
55_LIBCPP_END_NAMESPACE_STD
56
57#endif // _LIBCPP___ITERATOR_MOVE_SENTINEL_H
lib/libcxx/include/__iterator/next.h+8-10
...@@ -10,8 +10,8 @@...@@ -10,8 +10,8 @@
10#ifndef _LIBCPP___ITERATOR_NEXT_H10#ifndef _LIBCPP___ITERATOR_NEXT_H
11#define _LIBCPP___ITERATOR_NEXT_H11#define _LIBCPP___ITERATOR_NEXT_H
1212
13#include <__assert>
13#include <__config>14#include <__config>
14#include <__debug>
15#include <__iterator/advance.h>15#include <__iterator/advance.h>
16#include <__iterator/concepts.h>16#include <__iterator/concepts.h>
17#include <__iterator/incrementable_traits.h>17#include <__iterator/incrementable_traits.h>
...@@ -19,7 +19,7 @@...@@ -19,7 +19,7 @@
19#include <type_traits>19#include <type_traits>
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
23#endif23#endif
2424
25_LIBCPP_BEGIN_NAMESPACE_STD25_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -35,7 +35,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14...@@ -35,7 +35,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
35 return __x;35 return __x;
36}36}
3737
38#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)38#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
3939
40// [range.iter.op.next]40// [range.iter.op.next]
4141
...@@ -58,16 +58,14 @@ struct __fn {...@@ -58,16 +58,14 @@ struct __fn {
58 }58 }
5959
60 template <input_or_output_iterator _Ip, sentinel_for<_Ip> _Sp>60 template <input_or_output_iterator _Ip, sentinel_for<_Ip> _Sp>
61 _LIBCPP_HIDE_FROM_ABI61 _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x, _Sp __bound_sentinel) const {
62 constexpr _Ip operator()(_Ip __x, _Sp __bound) const {62 ranges::advance(__x, __bound_sentinel);
63 ranges::advance(__x, __bound);
64 return __x;63 return __x;
65 }64 }
6665
67 template <input_or_output_iterator _Ip, sentinel_for<_Ip> _Sp>66 template <input_or_output_iterator _Ip, sentinel_for<_Ip> _Sp>
68 _LIBCPP_HIDE_FROM_ABI67 _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n, _Sp __bound_sentinel) const {
69 constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n, _Sp __bound) const {68 ranges::advance(__x, __n, __bound_sentinel);
70 ranges::advance(__x, __n, __bound);
71 return __x;69 return __x;
72 }70 }
73};71};
...@@ -79,7 +77,7 @@ inline namespace __cpo {...@@ -79,7 +77,7 @@ inline namespace __cpo {
79} // namespace __cpo77} // namespace __cpo
80} // namespace ranges78} // namespace ranges
8179
82#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)80#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
8381
84_LIBCPP_END_NAMESPACE_STD82_LIBCPP_END_NAMESPACE_STD
8583
lib/libcxx/include/__iterator/ostream_iterator.h+4-3
...@@ -14,10 +14,11 @@...@@ -14,10 +14,11 @@
14#include <__iterator/iterator.h>14#include <__iterator/iterator.h>
15#include <__iterator/iterator_traits.h>15#include <__iterator/iterator_traits.h>
16#include <__memory/addressof.h>16#include <__memory/addressof.h>
17#include <cstddef>
17#include <iosfwd> // for forward declarations of char_traits and basic_ostream18#include <iosfwd> // for forward declarations of char_traits and basic_ostream
1819
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20#pragma GCC system_header21# pragma GCC system_header
21#endif22#endif
2223
23_LIBCPP_BEGIN_NAMESPACE_STD24_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -52,9 +53,9 @@ public:...@@ -52,9 +53,9 @@ public:
52 : __out_stream_(_VSTD::addressof(__s)), __delim_(nullptr) {}53 : __out_stream_(_VSTD::addressof(__s)), __delim_(nullptr) {}
53 _LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s, const _CharT* __delimiter) _NOEXCEPT54 _LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s, const _CharT* __delimiter) _NOEXCEPT
54 : __out_stream_(_VSTD::addressof(__s)), __delim_(__delimiter) {}55 : __out_stream_(_VSTD::addressof(__s)), __delim_(__delimiter) {}
55 _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator=(const _Tp& __value_)56 _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator=(const _Tp& __value)
56 {57 {
57 *__out_stream_ << __value_;58 *__out_stream_ << __value;
58 if (__delim_)59 if (__delim_)
59 *__out_stream_ << __delim_;60 *__out_stream_ << __delim_;
60 return *this;61 return *this;
lib/libcxx/include/__iterator/ostreambuf_iterator.h+2-1
...@@ -13,10 +13,11 @@...@@ -13,10 +13,11 @@
13#include <__config>13#include <__config>
14#include <__iterator/iterator.h>14#include <__iterator/iterator.h>
15#include <__iterator/iterator_traits.h>15#include <__iterator/iterator_traits.h>
16#include <cstddef>
16#include <iosfwd> // for forward declaration of basic_streambuf17#include <iosfwd> // for forward declaration of basic_streambuf
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
20#endif21#endif
2122
22_LIBCPP_BEGIN_NAMESPACE_STD23_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__iterator/permutable.h created+35
...@@ -0,0 +1,35 @@
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_PERMUTABLE_H
11#define _LIBCPP___ITERATOR_PERMUTABLE_H
12
13#include <__config>
14#include <__iterator/concepts.h>
15#include <__iterator/iter_swap.h>
16
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header
19#endif
20
21_LIBCPP_BEGIN_NAMESPACE_STD
22
23#if _LIBCPP_STD_VER > 17
24
25template <class _Iterator>
26concept permutable =
27 forward_iterator<_Iterator> &&
28 indirectly_movable_storable<_Iterator, _Iterator> &&
29 indirectly_swappable<_Iterator, _Iterator>;
30
31#endif // _LIBCPP_STD_VER > 17
32
33_LIBCPP_END_NAMESPACE_STD
34
35#endif // _LIBCPP___ITERATOR_PERMUTABLE_H
lib/libcxx/include/__iterator/prev.h+6-7
...@@ -10,8 +10,8 @@...@@ -10,8 +10,8 @@
10#ifndef _LIBCPP___ITERATOR_PREV_H10#ifndef _LIBCPP___ITERATOR_PREV_H
11#define _LIBCPP___ITERATOR_PREV_H11#define _LIBCPP___ITERATOR_PREV_H
1212
13#include <__assert>
13#include <__config>14#include <__config>
14#include <__debug>
15#include <__iterator/advance.h>15#include <__iterator/advance.h>
16#include <__iterator/concepts.h>16#include <__iterator/concepts.h>
17#include <__iterator/incrementable_traits.h>17#include <__iterator/incrementable_traits.h>
...@@ -19,7 +19,7 @@...@@ -19,7 +19,7 @@
19#include <type_traits>19#include <type_traits>
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
23#endif23#endif
2424
25_LIBCPP_BEGIN_NAMESPACE_STD25_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -34,7 +34,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14...@@ -34,7 +34,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
34 return __x;34 return __x;
35}35}
3636
37#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)37#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
3838
39// [range.iter.op.prev]39// [range.iter.op.prev]
4040
...@@ -57,9 +57,8 @@ struct __fn {...@@ -57,9 +57,8 @@ struct __fn {
57 }57 }
5858
59 template <bidirectional_iterator _Ip>59 template <bidirectional_iterator _Ip>
60 _LIBCPP_HIDE_FROM_ABI60 _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n, _Ip __bound_iter) const {
61 constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n, _Ip __bound) const {61 ranges::advance(__x, -__n, __bound_iter);
62 ranges::advance(__x, -__n, __bound);
63 return __x;62 return __x;
64 }63 }
65};64};
...@@ -71,7 +70,7 @@ inline namespace __cpo {...@@ -71,7 +70,7 @@ inline namespace __cpo {
71} // namespace __cpo70} // namespace __cpo
72} // namespace ranges71} // namespace ranges
7372
74#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)73#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
7574
76_LIBCPP_END_NAMESPACE_STD75_LIBCPP_END_NAMESPACE_STD
7776
lib/libcxx/include/__iterator/projected.h+3-3
...@@ -15,12 +15,12 @@...@@ -15,12 +15,12 @@
15#include <type_traits>15#include <type_traits>
1616
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header18# pragma GCC system_header
19#endif19#endif
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
23#if !defined(_LIBCPP_HAS_NO_CONCEPTS)23#if _LIBCPP_STD_VER > 17
2424
25template<indirectly_readable _It, indirectly_regular_unary_invocable<_It> _Proj>25template<indirectly_readable _It, indirectly_regular_unary_invocable<_It> _Proj>
26struct projected {26struct projected {
...@@ -33,7 +33,7 @@ struct incrementable_traits<projected<_It, _Proj>> {...@@ -33,7 +33,7 @@ struct incrementable_traits<projected<_It, _Proj>> {
33 using difference_type = iter_difference_t<_It>;33 using difference_type = iter_difference_t<_It>;
34};34};
3535
36#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)36#endif // _LIBCPP_STD_VER > 17
3737
38_LIBCPP_END_NAMESPACE_STD38_LIBCPP_END_NAMESPACE_STD
3939
lib/libcxx/include/__iterator/readable_traits.h+3-3
...@@ -15,12 +15,12 @@...@@ -15,12 +15,12 @@
15#include <type_traits>15#include <type_traits>
1616
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header18# pragma GCC system_header
19#endif19#endif
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
23#if !defined(_LIBCPP_HAS_NO_CONCEPTS)23#if _LIBCPP_STD_VER > 17
2424
25// [readable.traits]25// [readable.traits]
26template<class> struct __cond_value_type {};26template<class> struct __cond_value_type {};
...@@ -79,7 +79,7 @@ using iter_value_t = typename conditional_t<__is_primary_template<iterator_trait...@@ -79,7 +79,7 @@ using iter_value_t = typename conditional_t<__is_primary_template<iterator_trait
79 indirectly_readable_traits<remove_cvref_t<_Ip> >,79 indirectly_readable_traits<remove_cvref_t<_Ip> >,
80 iterator_traits<remove_cvref_t<_Ip> > >::value_type;80 iterator_traits<remove_cvref_t<_Ip> > >::value_type;
8181
82#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)82#endif // _LIBCPP_STD_VER > 17
8383
84_LIBCPP_END_NAMESPACE_STD84_LIBCPP_END_NAMESPACE_STD
8585
lib/libcxx/include/__iterator/reverse_access.h+2-6
...@@ -16,13 +16,11 @@...@@ -16,13 +16,11 @@
16#include <initializer_list>16#include <initializer_list>
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_LIBCPP_BEGIN_NAMESPACE_STD22_LIBCPP_BEGIN_NAMESPACE_STD
2323
24#if !defined(_LIBCPP_CXX03_LANG)
25
26#if _LIBCPP_STD_VER > 1124#if _LIBCPP_STD_VER > 11
2725
28template <class _Tp, size_t _Np>26template <class _Tp, size_t _Np>
...@@ -95,9 +93,7 @@ auto crend(const _Cp& __c) -> decltype(_VSTD::rend(__c))...@@ -95,9 +93,7 @@ auto crend(const _Cp& __c) -> decltype(_VSTD::rend(__c))
95 return _VSTD::rend(__c);93 return _VSTD::rend(__c);
96}94}
9795
98#endif96#endif // _LIBCPP_STD_VER > 11
99
100#endif // !defined(_LIBCPP_CXX03_LANG)
10197
102_LIBCPP_END_NAMESPACE_STD98_LIBCPP_END_NAMESPACE_STD
10399
lib/libcxx/include/__iterator/reverse_iterator.h+311-20
...@@ -10,16 +10,30 @@...@@ -10,16 +10,30 @@
10#ifndef _LIBCPP___ITERATOR_REVERSE_ITERATOR_H10#ifndef _LIBCPP___ITERATOR_REVERSE_ITERATOR_H
11#define _LIBCPP___ITERATOR_REVERSE_ITERATOR_H11#define _LIBCPP___ITERATOR_REVERSE_ITERATOR_H
1212
13#include <__algorithm/unwrap_iter.h>
13#include <__compare/compare_three_way_result.h>14#include <__compare/compare_three_way_result.h>
14#include <__compare/three_way_comparable.h>15#include <__compare/three_way_comparable.h>
16#include <__concepts/convertible_to.h>
15#include <__config>17#include <__config>
18#include <__iterator/advance.h>
19#include <__iterator/concepts.h>
20#include <__iterator/incrementable_traits.h>
21#include <__iterator/iter_move.h>
22#include <__iterator/iter_swap.h>
16#include <__iterator/iterator.h>23#include <__iterator/iterator.h>
17#include <__iterator/iterator_traits.h>24#include <__iterator/iterator_traits.h>
25#include <__iterator/next.h>
26#include <__iterator/prev.h>
27#include <__iterator/readable_traits.h>
18#include <__memory/addressof.h>28#include <__memory/addressof.h>
29#include <__ranges/access.h>
30#include <__ranges/concepts.h>
31#include <__ranges/subrange.h>
32#include <__utility/move.h>
19#include <type_traits>33#include <type_traits>
2034
21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)35#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
22#pragma GCC system_header36# pragma GCC system_header
23#endif37#endif
2438
25_LIBCPP_BEGIN_NAMESPACE_STD39_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -41,22 +55,29 @@ private:...@@ -41,22 +55,29 @@ private:
41 _Iter __t; // no longer used as of LWG #2360, not removed due to ABI break55 _Iter __t; // no longer used as of LWG #2360, not removed due to ABI break
42#endif56#endif
4357
58#if _LIBCPP_STD_VER > 17
59 static_assert(__is_cpp17_bidirectional_iterator<_Iter>::value || bidirectional_iterator<_Iter>,
60 "reverse_iterator<It> requires It to be a bidirectional iterator.");
61#endif // _LIBCPP_STD_VER > 17
62
44protected:63protected:
45 _Iter current;64 _Iter current;
46public:65public:
47 typedef _Iter iterator_type;66 using iterator_type = _Iter;
48 typedef typename iterator_traits<_Iter>::difference_type difference_type;
49 typedef typename iterator_traits<_Iter>::reference reference;
50 typedef typename iterator_traits<_Iter>::pointer pointer;
51 typedef _If<__is_cpp17_random_access_iterator<_Iter>::value,
52 random_access_iterator_tag,
53 typename iterator_traits<_Iter>::iterator_category> iterator_category;
54 typedef typename iterator_traits<_Iter>::value_type value_type;
5567
68 using iterator_category = _If<__is_cpp17_random_access_iterator<_Iter>::value,
69 random_access_iterator_tag,
70 typename iterator_traits<_Iter>::iterator_category>;
71 using pointer = typename iterator_traits<_Iter>::pointer;
56#if _LIBCPP_STD_VER > 1772#if _LIBCPP_STD_VER > 17
57 typedef _If<__is_cpp17_random_access_iterator<_Iter>::value,73 using iterator_concept = _If<random_access_iterator<_Iter>, random_access_iterator_tag, bidirectional_iterator_tag>;
58 random_access_iterator_tag,74 using value_type = iter_value_t<_Iter>;
59 bidirectional_iterator_tag> iterator_concept;75 using difference_type = iter_difference_t<_Iter>;
76 using reference = iter_reference_t<_Iter>;
77#else
78 using value_type = typename iterator_traits<_Iter>::value_type;
79 using difference_type = typename iterator_traits<_Iter>::difference_type;
80 using reference = typename iterator_traits<_Iter>::reference;
60#endif81#endif
6182
62#ifndef _LIBCPP_ABI_NO_ITERATOR_BASES83#ifndef _LIBCPP_ABI_NO_ITERATOR_BASES
...@@ -114,32 +135,81 @@ public:...@@ -114,32 +135,81 @@ public:
114 _Iter base() const {return current;}135 _Iter base() const {return current;}
115 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14136 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
116 reference operator*() const {_Iter __tmp = current; return *--__tmp;}137 reference operator*() const {_Iter __tmp = current; return *--__tmp;}
138
139#if _LIBCPP_STD_VER > 17
140 _LIBCPP_INLINE_VISIBILITY
141 constexpr pointer operator->() const
142 requires is_pointer_v<_Iter> || requires(const _Iter __i) { __i.operator->(); }
143 {
144 if constexpr (is_pointer_v<_Iter>) {
145 return std::prev(current);
146 } else {
147 return std::prev(current).operator->();
148 }
149 }
150#else
117 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14151 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
118 pointer operator->() const {return _VSTD::addressof(operator*());}152 pointer operator->() const {
153 return std::addressof(operator*());
154 }
155#endif // _LIBCPP_STD_VER > 17
156
119 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14157 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
120 reverse_iterator& operator++() {--current; return *this;}158 reverse_iterator& operator++() {--current; return *this;}
121 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14159 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
122 reverse_iterator operator++(int) {reverse_iterator __tmp(*this); --current; return __tmp;}160 reverse_iterator operator++(int) {reverse_iterator __tmp(*this); --current; return __tmp;}
123 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14161 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
124 reverse_iterator& operator--() {++current; return *this;}162 reverse_iterator& operator--() {++current; return *this;}
125 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14163 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
126 reverse_iterator operator--(int) {reverse_iterator __tmp(*this); ++current; return __tmp;}164 reverse_iterator operator--(int) {reverse_iterator __tmp(*this); ++current; return __tmp;}
127 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14165 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
128 reverse_iterator operator+ (difference_type __n) const {return reverse_iterator(current - __n);}166 reverse_iterator operator+(difference_type __n) const {return reverse_iterator(current - __n);}
129 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14167 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
130 reverse_iterator& operator+=(difference_type __n) {current -= __n; return *this;}168 reverse_iterator& operator+=(difference_type __n) {current -= __n; return *this;}
131 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14169 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
132 reverse_iterator operator- (difference_type __n) const {return reverse_iterator(current + __n);}170 reverse_iterator operator-(difference_type __n) const {return reverse_iterator(current + __n);}
133 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14171 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
134 reverse_iterator& operator-=(difference_type __n) {current += __n; return *this;}172 reverse_iterator& operator-=(difference_type __n) {current += __n; return *this;}
135 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14173 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
136 reference operator[](difference_type __n) const {return *(*this + __n);}174 reference operator[](difference_type __n) const {return *(*this + __n);}
175
176#if _LIBCPP_STD_VER > 17
177 _LIBCPP_HIDE_FROM_ABI friend constexpr
178 iter_rvalue_reference_t<_Iter> iter_move(const reverse_iterator& __i)
179 noexcept(is_nothrow_copy_constructible_v<_Iter> &&
180 noexcept(ranges::iter_move(--declval<_Iter&>()))) {
181 auto __tmp = __i.base();
182 return ranges::iter_move(--__tmp);
183 }
184
185 template <indirectly_swappable<_Iter> _Iter2>
186 _LIBCPP_HIDE_FROM_ABI friend constexpr
187 void iter_swap(const reverse_iterator& __x, const reverse_iterator<_Iter2>& __y)
188 noexcept(is_nothrow_copy_constructible_v<_Iter> &&
189 is_nothrow_copy_constructible_v<_Iter2> &&
190 noexcept(ranges::iter_swap(--declval<_Iter&>(), --declval<_Iter2&>()))) {
191 auto __xtmp = __x.base();
192 auto __ytmp = __y.base();
193 ranges::iter_swap(--__xtmp, --__ytmp);
194 }
195#endif // _LIBCPP_STD_VER > 17
137};196};
138197
198template <class _Iter>
199struct __is_reverse_iterator : false_type {};
200
201template <class _Iter>
202struct __is_reverse_iterator<reverse_iterator<_Iter> > : true_type {};
203
139template <class _Iter1, class _Iter2>204template <class _Iter1, class _Iter2>
140inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14205inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
141bool206bool
142operator==(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)207operator==(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
208#if _LIBCPP_STD_VER > 17
209 requires requires {
210 { __x.base() == __y.base() } -> convertible_to<bool>;
211 }
212#endif // _LIBCPP_STD_VER > 17
143{213{
144 return __x.base() == __y.base();214 return __x.base() == __y.base();
145}215}
...@@ -148,6 +218,11 @@ template <class _Iter1, class _Iter2>...@@ -148,6 +218,11 @@ template <class _Iter1, class _Iter2>
148inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14218inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
149bool219bool
150operator<(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)220operator<(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
221#if _LIBCPP_STD_VER > 17
222 requires requires {
223 { __x.base() > __y.base() } -> convertible_to<bool>;
224 }
225#endif // _LIBCPP_STD_VER > 17
151{226{
152 return __x.base() > __y.base();227 return __x.base() > __y.base();
153}228}
...@@ -156,6 +231,11 @@ template <class _Iter1, class _Iter2>...@@ -156,6 +231,11 @@ template <class _Iter1, class _Iter2>
156inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14231inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
157bool232bool
158operator!=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)233operator!=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
234#if _LIBCPP_STD_VER > 17
235 requires requires {
236 { __x.base() != __y.base() } -> convertible_to<bool>;
237 }
238#endif // _LIBCPP_STD_VER > 17
159{239{
160 return __x.base() != __y.base();240 return __x.base() != __y.base();
161}241}
...@@ -164,6 +244,11 @@ template <class _Iter1, class _Iter2>...@@ -164,6 +244,11 @@ template <class _Iter1, class _Iter2>
164inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14244inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
165bool245bool
166operator>(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)246operator>(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
247#if _LIBCPP_STD_VER > 17
248 requires requires {
249 { __x.base() < __y.base() } -> convertible_to<bool>;
250 }
251#endif // _LIBCPP_STD_VER > 17
167{252{
168 return __x.base() < __y.base();253 return __x.base() < __y.base();
169}254}
...@@ -172,6 +257,11 @@ template <class _Iter1, class _Iter2>...@@ -172,6 +257,11 @@ template <class _Iter1, class _Iter2>
172inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14257inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
173bool258bool
174operator>=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)259operator>=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
260#if _LIBCPP_STD_VER > 17
261 requires requires {
262 { __x.base() <= __y.base() } -> convertible_to<bool>;
263 }
264#endif // _LIBCPP_STD_VER > 17
175{265{
176 return __x.base() <= __y.base();266 return __x.base() <= __y.base();
177}267}
...@@ -180,11 +270,16 @@ template <class _Iter1, class _Iter2>...@@ -180,11 +270,16 @@ template <class _Iter1, class _Iter2>
180inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14270inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
181bool271bool
182operator<=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)272operator<=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
273#if _LIBCPP_STD_VER > 17
274 requires requires {
275 { __x.base() >= __y.base() } -> convertible_to<bool>;
276 }
277#endif // _LIBCPP_STD_VER > 17
183{278{
184 return __x.base() >= __y.base();279 return __x.base() >= __y.base();
185}280}
186281
187#if !defined(_LIBCPP_HAS_NO_CONCEPTS)282#if _LIBCPP_STD_VER > 17
188template <class _Iter1, three_way_comparable_with<_Iter1> _Iter2>283template <class _Iter1, three_way_comparable_with<_Iter1> _Iter2>
189_LIBCPP_HIDE_FROM_ABI constexpr284_LIBCPP_HIDE_FROM_ABI constexpr
190compare_three_way_result_t<_Iter1, _Iter2>285compare_three_way_result_t<_Iter1, _Iter2>
...@@ -192,7 +287,7 @@ operator<=>(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>&...@@ -192,7 +287,7 @@ operator<=>(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>&
192{287{
193 return __y.base() <=> __x.base();288 return __y.base() <=> __x.base();
194}289}
195#endif290#endif // _LIBCPP_STD_VER > 17
196291
197#ifndef _LIBCPP_CXX03_LANG292#ifndef _LIBCPP_CXX03_LANG
198template <class _Iter1, class _Iter2>293template <class _Iter1, class _Iter2>
...@@ -221,6 +316,12 @@ operator+(typename reverse_iterator<_Iter>::difference_type __n, const reverse_i...@@ -221,6 +316,12 @@ operator+(typename reverse_iterator<_Iter>::difference_type __n, const reverse_i
221 return reverse_iterator<_Iter>(__x.base() - __n);316 return reverse_iterator<_Iter>(__x.base() - __n);
222}317}
223318
319#if _LIBCPP_STD_VER > 17
320template <class _Iter1, class _Iter2>
321 requires (!sized_sentinel_for<_Iter1, _Iter2>)
322inline constexpr bool disable_sized_sentinel_for<reverse_iterator<_Iter1>, reverse_iterator<_Iter2>> = true;
323#endif // _LIBCPP_STD_VER > 17
324
224#if _LIBCPP_STD_VER > 11325#if _LIBCPP_STD_VER > 11
225template <class _Iter>326template <class _Iter>
226inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14327inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
...@@ -230,6 +331,196 @@ reverse_iterator<_Iter> make_reverse_iterator(_Iter __i)...@@ -230,6 +331,196 @@ reverse_iterator<_Iter> make_reverse_iterator(_Iter __i)
230}331}
231#endif332#endif
232333
334#if _LIBCPP_STD_VER <= 17
335template <class _Iter>
336using __unconstrained_reverse_iterator = reverse_iterator<_Iter>;
337#else
338
339// __unconstrained_reverse_iterator allows us to use reverse iterators in the implementation of algorithms by working
340// around a language issue in C++20.
341// In C++20, when a reverse iterator wraps certain C++20-hostile iterators, calling comparison operators on it will
342// result in a compilation error. However, calling comparison operators on the pristine hostile iterator is not
343// an error. Thus, we cannot use reverse_iterators in the implementation of an algorithm that accepts a
344// C++20-hostile iterator. This class is an internal workaround -- it is a copy of reverse_iterator with
345// tweaks to make it support hostile iterators.
346//
347// A C++20-hostile iterator is one that defines a comparison operator where one of the arguments is an exact match
348// and the other requires an implicit conversion, for example:
349// friend bool operator==(const BaseIter&, const DerivedIter&);
350//
351// C++20 rules for rewriting equality operators create another overload of this function with parameters reversed:
352// friend bool operator==(const DerivedIter&, const BaseIter&);
353//
354// This creates an ambiguity in overload resolution.
355//
356// Clang treats this ambiguity differently in different contexts. When operator== is actually called in the function
357// body, the code is accepted with a warning. When a concept requires operator== to be a valid expression, however,
358// it evaluates to false. Thus, the implementation of reverse_iterator::operator== can actually call operator== on its
359// base iterators, but the constraints on reverse_iterator::operator== prevent it from being considered during overload
360// resolution. This class simply removes the problematic constraints from comparison functions.
361template <class _Iter>
362class __unconstrained_reverse_iterator {
363 _Iter __iter_;
364
365public:
366 static_assert(__is_cpp17_bidirectional_iterator<_Iter>::value);
367
368 using iterator_type = _Iter;
369 using iterator_category =
370 _If<__is_cpp17_random_access_iterator<_Iter>::value, random_access_iterator_tag, __iterator_category_type<_Iter>>;
371 using pointer = __iterator_pointer_type<_Iter>;
372 using value_type = iter_value_t<_Iter>;
373 using difference_type = iter_difference_t<_Iter>;
374 using reference = iter_reference_t<_Iter>;
375
376 _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator() = default;
377 _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator(const __unconstrained_reverse_iterator&) = default;
378 _LIBCPP_HIDE_FROM_ABI constexpr explicit __unconstrained_reverse_iterator(_Iter __iter) : __iter_(__iter) {}
379
380 _LIBCPP_HIDE_FROM_ABI constexpr _Iter base() const { return __iter_; }
381 _LIBCPP_HIDE_FROM_ABI constexpr reference operator*() const {
382 auto __tmp = __iter_;
383 return *--__tmp;
384 }
385
386 _LIBCPP_HIDE_FROM_ABI constexpr pointer operator->() const {
387 if constexpr (is_pointer_v<_Iter>) {
388 return std::prev(__iter_);
389 } else {
390 return std::prev(__iter_).operator->();
391 }
392 }
393
394 _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator& operator++() {
395 --__iter_;
396 return *this;
397 }
398
399 _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator operator++(int) {
400 auto __tmp = *this;
401 --__iter_;
402 return __tmp;
403 }
404
405 _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator& operator--() {
406 ++__iter_;
407 return *this;
408 }
409
410 _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator operator--(int) {
411 auto __tmp = *this;
412 ++__iter_;
413 return __tmp;
414 }
415
416 _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator& operator+=(difference_type __n) {
417 __iter_ -= __n;
418 return *this;
419 }
420
421 _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator& operator-=(difference_type __n) {
422 __iter_ += __n;
423 return *this;
424 }
425
426 _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator operator+(difference_type __n) const {
427 return __unconstrained_reverse_iterator(__iter_ - __n);
428 }
429
430 _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator operator-(difference_type __n) const {
431 return __unconstrained_reverse_iterator(__iter_ + __n);
432 }
433
434 _LIBCPP_HIDE_FROM_ABI constexpr difference_type operator-(const __unconstrained_reverse_iterator& __other) const {
435 return __other.__iter_ - __iter_;
436 }
437
438 _LIBCPP_HIDE_FROM_ABI constexpr auto operator[](difference_type __n) const { return *(*this + __n); }
439
440 // Deliberately unconstrained unlike the comparison functions in `reverse_iterator` -- see the class comment for the
441 // rationale.
442 _LIBCPP_HIDE_FROM_ABI friend constexpr bool
443 operator==(const __unconstrained_reverse_iterator& __lhs, const __unconstrained_reverse_iterator& __rhs) {
444 return __lhs.base() == __rhs.base();
445 }
446
447 _LIBCPP_HIDE_FROM_ABI friend constexpr bool
448 operator!=(const __unconstrained_reverse_iterator& __lhs, const __unconstrained_reverse_iterator& __rhs) {
449 return __lhs.base() != __rhs.base();
450 }
451
452 _LIBCPP_HIDE_FROM_ABI friend constexpr bool
453 operator<(const __unconstrained_reverse_iterator& __lhs, const __unconstrained_reverse_iterator& __rhs) {
454 return __lhs.base() > __rhs.base();
455 }
456
457 _LIBCPP_HIDE_FROM_ABI friend constexpr bool
458 operator>(const __unconstrained_reverse_iterator& __lhs, const __unconstrained_reverse_iterator& __rhs) {
459 return __lhs.base() < __rhs.base();
460 }
461
462 _LIBCPP_HIDE_FROM_ABI friend constexpr bool
463 operator<=(const __unconstrained_reverse_iterator& __lhs, const __unconstrained_reverse_iterator& __rhs) {
464 return __lhs.base() >= __rhs.base();
465 }
466
467 _LIBCPP_HIDE_FROM_ABI friend constexpr bool
468 operator>=(const __unconstrained_reverse_iterator& __lhs, const __unconstrained_reverse_iterator& __rhs) {
469 return __lhs.base() <= __rhs.base();
470 }
471};
472
473template <class _Iter>
474struct __is_reverse_iterator<__unconstrained_reverse_iterator<_Iter>> : true_type {};
475
476#endif // _LIBCPP_STD_VER <= 17
477
478template <template <class> class _RevIter1, template <class> class _RevIter2, class _Iter>
479struct __unwrap_reverse_iter_impl {
480 using _UnwrappedIter = decltype(__unwrap_iter_impl<_Iter>::__unwrap(std::declval<_Iter>()));
481 using _ReverseWrapper = _RevIter1<_RevIter2<_Iter> >;
482
483 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ReverseWrapper
484 __rewrap(_ReverseWrapper __orig_iter, _UnwrappedIter __unwrapped_iter) {
485 return _ReverseWrapper(
486 _RevIter2<_Iter>(__unwrap_iter_impl<_Iter>::__rewrap(__orig_iter.base().base(), __unwrapped_iter)));
487 }
488
489 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _UnwrappedIter __unwrap(_ReverseWrapper __i) _NOEXCEPT {
490 return __unwrap_iter_impl<_Iter>::__unwrap(__i.base().base());
491 }
492};
493
494#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
495template <ranges::bidirectional_range _Range>
496_LIBCPP_HIDE_FROM_ABI constexpr ranges::
497 subrange<reverse_iterator<ranges::iterator_t<_Range>>, reverse_iterator<ranges::iterator_t<_Range>>>
498 __reverse_range(_Range&& __range) {
499 auto __first = ranges::begin(__range);
500 return {std::make_reverse_iterator(ranges::next(__first, ranges::end(__range))), std::make_reverse_iterator(__first)};
501}
502#endif
503
504template <class _Iter, bool __b>
505struct __unwrap_iter_impl<reverse_iterator<reverse_iterator<_Iter> >, __b>
506 : __unwrap_reverse_iter_impl<reverse_iterator, reverse_iterator, _Iter> {};
507
508#if _LIBCPP_STD_VER > 17
509
510template <class _Iter, bool __b>
511struct __unwrap_iter_impl<reverse_iterator<__unconstrained_reverse_iterator<_Iter>>, __b>
512 : __unwrap_reverse_iter_impl<reverse_iterator, __unconstrained_reverse_iterator, _Iter> {};
513
514template <class _Iter, bool __b>
515struct __unwrap_iter_impl<__unconstrained_reverse_iterator<reverse_iterator<_Iter>>, __b>
516 : __unwrap_reverse_iter_impl<__unconstrained_reverse_iterator, reverse_iterator, _Iter> {};
517
518template <class _Iter, bool __b>
519struct __unwrap_iter_impl<__unconstrained_reverse_iterator<__unconstrained_reverse_iterator<_Iter>>, __b>
520 : __unwrap_reverse_iter_impl<__unconstrained_reverse_iterator, __unconstrained_reverse_iterator, _Iter> {};
521
522#endif // _LIBCPP_STD_VER > 17
523
233_LIBCPP_END_NAMESPACE_STD524_LIBCPP_END_NAMESPACE_STD
234525
235#endif // _LIBCPP___ITERATOR_REVERSE_ITERATOR_H526#endif // _LIBCPP___ITERATOR_REVERSE_ITERATOR_H
lib/libcxx/include/__iterator/size.h+6-1
...@@ -15,7 +15,7 @@...@@ -15,7 +15,7 @@
15#include <type_traits>15#include <type_traits>
1616
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header18# pragma GCC system_header
19#endif19#endif
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -41,9 +41,14 @@ _NOEXCEPT_(noexcept(static_cast<common_type_t<ptrdiff_t, make_signed_t<decltype(...@@ -41,9 +41,14 @@ _NOEXCEPT_(noexcept(static_cast<common_type_t<ptrdiff_t, make_signed_t<decltype(
41-> common_type_t<ptrdiff_t, make_signed_t<decltype(__c.size())>>41-> common_type_t<ptrdiff_t, make_signed_t<decltype(__c.size())>>
42{ return static_cast<common_type_t<ptrdiff_t, make_signed_t<decltype(__c.size())>>>(__c.size()); }42{ return static_cast<common_type_t<ptrdiff_t, make_signed_t<decltype(__c.size())>>>(__c.size()); }
4343
44// GCC complains about the implicit conversion from ptrdiff_t to size_t in
45// the array bound.
46_LIBCPP_DIAGNOSTIC_PUSH
47_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wsign-conversion")
44template <class _Tp, ptrdiff_t _Sz>48template <class _Tp, ptrdiff_t _Sz>
45_LIBCPP_INLINE_VISIBILITY49_LIBCPP_INLINE_VISIBILITY
46constexpr ptrdiff_t ssize(const _Tp (&)[_Sz]) noexcept { return _Sz; }50constexpr ptrdiff_t ssize(const _Tp (&)[_Sz]) noexcept { return _Sz; }
51_LIBCPP_DIAGNOSTIC_POP
47#endif52#endif
4853
49#endif // _LIBCPP_STD_VER > 1454#endif // _LIBCPP_STD_VER > 14
lib/libcxx/include/__iterator/sortable.h created+37
...@@ -0,0 +1,37 @@
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_SORTABLE_H
11#define _LIBCPP___ITERATOR_SORTABLE_H
12
13#include <__config>
14#include <__functional/identity.h>
15#include <__functional/ranges_operations.h>
16#include <__iterator/concepts.h>
17#include <__iterator/permutable.h>
18#include <__iterator/projected.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#if _LIBCPP_STD_VER > 17
27
28template <class _Iter, class _Comp = ranges::less, class _Proj = identity>
29concept sortable =
30 permutable<_Iter> &&
31 indirect_strict_weak_order<_Comp, projected<_Iter, _Proj>>;
32
33#endif // _LIBCPP_STD_VER > 17
34
35_LIBCPP_END_NAMESPACE_STD
36
37#endif // _LIBCPP___ITERATOR_SORTABLE_H
lib/libcxx/include/__iterator/unreachable_sentinel.h+3-3
...@@ -14,12 +14,12 @@...@@ -14,12 +14,12 @@
14#include <__iterator/concepts.h>14#include <__iterator/concepts.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
18#endif18#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
2121
22#if !defined(_LIBCPP_HAS_NO_CONCEPTS)22#if _LIBCPP_STD_VER > 17
2323
24struct unreachable_sentinel_t {24struct unreachable_sentinel_t {
25 template<weakly_incrementable _Iter>25 template<weakly_incrementable _Iter>
...@@ -31,7 +31,7 @@ struct unreachable_sentinel_t {...@@ -31,7 +31,7 @@ struct unreachable_sentinel_t {
3131
32inline constexpr unreachable_sentinel_t unreachable_sentinel{};32inline constexpr unreachable_sentinel_t unreachable_sentinel{};
3333
34#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)34#endif // _LIBCPP_STD_VER > 17
3535
36_LIBCPP_END_NAMESPACE_STD36_LIBCPP_END_NAMESPACE_STD
3737
lib/libcxx/include/__iterator/wrap_iter.h+8-8
...@@ -18,7 +18,7 @@...@@ -18,7 +18,7 @@
18#include <type_traits>18#include <type_traits>
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
22#endif22#endif
2323
24_LIBCPP_BEGIN_NAMESPACE_STD24_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -50,12 +50,12 @@ public:...@@ -50,12 +50,12 @@ public:
50 typename enable_if<is_convertible<_Up, iterator_type>::value>::type* = nullptr) _NOEXCEPT50 typename enable_if<is_convertible<_Up, iterator_type>::value>::type* = nullptr) _NOEXCEPT
51 : __i(__u.base())51 : __i(__u.base())
52 {52 {
53#if _LIBCPP_DEBUG_LEVEL == 253#ifdef _LIBCPP_ENABLE_DEBUG_MODE
54 if (!__libcpp_is_constant_evaluated())54 if (!__libcpp_is_constant_evaluated())
55 __get_db()->__iterator_copy(this, _VSTD::addressof(__u));55 __get_db()->__iterator_copy(this, _VSTD::addressof(__u));
56#endif56#endif
57 }57 }
58#if _LIBCPP_DEBUG_LEVEL == 258#ifdef _LIBCPP_ENABLE_DEBUG_MODE
59 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1159 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
60 __wrap_iter(const __wrap_iter& __x)60 __wrap_iter(const __wrap_iter& __x)
61 : __i(__x.base())61 : __i(__x.base())
...@@ -135,15 +135,15 @@ public:...@@ -135,15 +135,15 @@ public:
135 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 iterator_type base() const _NOEXCEPT {return __i;}135 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 iterator_type base() const _NOEXCEPT {return __i;}
136136
137private:137private:
138#if _LIBCPP_DEBUG_LEVEL == 2138 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
139 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter(const void* __p, iterator_type __x) : __i(__x)139 explicit __wrap_iter(const void* __p, iterator_type __x) _NOEXCEPT : __i(__x)
140 {140 {
141 (void)__p;
142#ifdef _LIBCPP_ENABLE_DEBUG_MODE
141 if (!__libcpp_is_constant_evaluated())143 if (!__libcpp_is_constant_evaluated())
142 __get_db()->__insert_ic(this, __p);144 __get_db()->__insert_ic(this, __p);
143 }
144#else
145 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter(iterator_type __x) _NOEXCEPT : __i(__x) {}
146#endif145#endif
146 }
147147
148 template <class _Up> friend class __wrap_iter;148 template <class _Up> friend class __wrap_iter;
149 template <class _CharT, class _Traits, class _Alloc> friend class basic_string;149 template <class _CharT, class _Traits, class _Alloc> friend class basic_string;
lib/libcxx/include/__libcpp_version deleted-1
...@@ -1 +0,0 @@
114000
lib/libcxx/include/__locale+17-17
...@@ -18,24 +18,22 @@...@@ -18,24 +18,22 @@
18#include <memory>18#include <memory>
19#include <mutex>19#include <mutex>
20#include <string>20#include <string>
21#include <utility>
2221
23#if defined(_LIBCPP_MSVCRT_LIKE)22#if defined(_LIBCPP_MSVCRT_LIKE)
24# include <cstring>
25# include <__support/win32/locale_win32.h>23# include <__support/win32/locale_win32.h>
24# include <cstring>
26#elif defined(_AIX) || defined(__MVS__)25#elif defined(_AIX) || defined(__MVS__)
27# include <__support/ibm/xlocale.h>26# include <__support/ibm/xlocale.h>
28#elif defined(__ANDROID__)27#elif defined(__ANDROID__)
29# include <__support/android/locale_bionic.h>28# include <__support/android/locale_bionic.h>
30#elif defined(__sun__)29#elif defined(__sun__)
31# include <xlocale.h>
32# include <__support/solaris/xlocale.h>30# include <__support/solaris/xlocale.h>
31# include <xlocale.h>
33#elif defined(_NEWLIB_VERSION)32#elif defined(_NEWLIB_VERSION)
34# include <__support/newlib/xlocale.h>33# include <__support/newlib/xlocale.h>
35#elif defined(__OpenBSD__)34#elif defined(__OpenBSD__)
36# include <__support/openbsd/xlocale.h>35# include <__support/openbsd/xlocale.h>
37#elif (defined(__APPLE__) || defined(__FreeBSD__) \36#elif (defined(__APPLE__) || defined(__FreeBSD__))
38 || defined(__EMSCRIPTEN__) || defined(__IBMCPP__))
39# include <xlocale.h>37# include <xlocale.h>
40#elif defined(__Fuchsia__)38#elif defined(__Fuchsia__)
41# include <__support/fuchsia/xlocale.h>39# include <__support/fuchsia/xlocale.h>
...@@ -47,7 +45,7 @@...@@ -47,7 +45,7 @@
47#endif45#endif
4846
49#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)47#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
50#pragma GCC system_header48# pragma GCC system_header
51#endif49#endif
5250
53_LIBCPP_BEGIN_NAMESPACE_STD51_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -339,9 +337,9 @@ collate<_CharT>::do_hash(const char_type* __lo, const char_type* __hi) const...@@ -339,9 +337,9 @@ collate<_CharT>::do_hash(const char_type* __lo, const char_type* __hi) const
339 return static_cast<long>(__h);337 return static_cast<long>(__h);
340}338}
341339
342_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate<char>)340extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate<char>;
343#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS341#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
344_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate<wchar_t>)342extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate<wchar_t>;
345#endif343#endif
346344
347// template <class CharT> class collate_byname;345// template <class CharT> class collate_byname;
...@@ -454,6 +452,7 @@ public:...@@ -454,6 +452,7 @@ public:
454 static const mask blank = _BLANK;452 static const mask blank = _BLANK;
455 static const mask __regex_word = 0x4000; // 0x8000 and 0x0100 and 0x00ff are used453 static const mask __regex_word = 0x4000; // 0x8000 and 0x0100 and 0x00ff are used
456# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT454# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT
455# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA
457#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__)456#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__)
458# ifdef __APPLE__457# ifdef __APPLE__
459 typedef __uint32_t mask;458 typedef __uint32_t mask;
...@@ -493,7 +492,11 @@ public:...@@ -493,7 +492,11 @@ public:
493 static const mask punct = _ISPUNCT;492 static const mask punct = _ISPUNCT;
494 static const mask xdigit = _ISXDIGIT;493 static const mask xdigit = _ISXDIGIT;
495 static const mask blank = _ISBLANK;494 static const mask blank = _ISBLANK;
495# if defined(_AIX)
496 static const mask __regex_word = 0x8000;
497# else
496 static const mask __regex_word = 0x80;498 static const mask __regex_word = 0x80;
499# endif
497#elif defined(_NEWLIB_VERSION)500#elif defined(_NEWLIB_VERSION)
498 // Same type as Newlib's _ctype_ array in newlib/libc/include/ctype.h.501 // Same type as Newlib's _ctype_ array in newlib/libc/include/ctype.h.
499 typedef char mask;502 typedef char mask;
...@@ -546,11 +549,8 @@ public:...@@ -546,11 +549,8 @@ public:
546549
547 _LIBCPP_INLINE_VISIBILITY ctype_base() {}550 _LIBCPP_INLINE_VISIBILITY ctype_base() {}
548551
549// TODO: Remove the ifndef when the assert no longer fails on AIX.
550#ifndef _AIX
551 static_assert((__regex_word & ~(space | print | cntrl | upper | lower | alpha | digit | punct | xdigit | blank)) == __regex_word,552 static_assert((__regex_word & ~(space | print | cntrl | upper | lower | alpha | digit | punct | xdigit | blank)) == __regex_word,
552 "__regex_word can't overlap other bits");553 "__regex_word can't overlap other bits");
553#endif
554};554};
555555
556template <class _CharT> class _LIBCPP_TEMPLATE_VIS ctype;556template <class _CharT> class _LIBCPP_TEMPLATE_VIS ctype;
...@@ -1498,15 +1498,15 @@ codecvt_byname<_InternT, _ExternT, _StateT>::~codecvt_byname()...@@ -1498,15 +1498,15 @@ codecvt_byname<_InternT, _ExternT, _StateT>::~codecvt_byname()
1498}1498}
1499_LIBCPP_SUPPRESS_DEPRECATED_POP1499_LIBCPP_SUPPRESS_DEPRECATED_POP
15001500
1501_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char, char, mbstate_t>)1501extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char, char, mbstate_t>;
1502#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS1502#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
1503_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<wchar_t, char, mbstate_t>)1503extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<wchar_t, char, mbstate_t>;
1504#endif1504#endif
1505_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char16_t, char, mbstate_t>) // deprecated in C++201505extern template class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char16_t, char, mbstate_t>; // deprecated in C++20
1506_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char, mbstate_t>) // deprecated in C++201506extern template class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char, mbstate_t>; // deprecated in C++20
1507#ifndef _LIBCPP_HAS_NO_CHAR8_T1507#ifndef _LIBCPP_HAS_NO_CHAR8_T
1508_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char16_t, char8_t, mbstate_t>) // C++201508extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char16_t, char8_t, mbstate_t>; // C++20
1509_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char8_t, mbstate_t>) // C++201509extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char8_t, mbstate_t>; // C++20
1510#endif1510#endif
15111511
1512template <size_t _Np>1512template <size_t _Np>
lib/libcxx/include/__mbstate_t.h+1-1
...@@ -13,7 +13,7 @@...@@ -13,7 +13,7 @@
13#include <__config>13#include <__config>
1414
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16#pragma GCC system_header16# pragma GCC system_header
17#endif17#endif
1818
19// TODO(ldionne):19// TODO(ldionne):
lib/libcxx/include/__memory/addressof.h+1-1
...@@ -13,7 +13,7 @@...@@ -13,7 +13,7 @@
13#include <__config>13#include <__config>
1414
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16#pragma GCC system_header16# pragma GCC system_header
17#endif17#endif
1818
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__memory/allocate_at_least.h created+61
...@@ -0,0 +1,61 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___MEMORY_ALLOCATE_AT_LEAST_H
10#define _LIBCPP___MEMORY_ALLOCATE_AT_LEAST_H
11
12#include <__config>
13#include <__memory/allocator_traits.h>
14#include <cstddef>
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 _LIBCPP_STD_VER > 20
23template <class _Pointer>
24struct allocation_result {
25 _Pointer ptr;
26 size_t count;
27};
28
29template <class _Alloc>
30[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr
31allocation_result<typename allocator_traits<_Alloc>::pointer> allocate_at_least(_Alloc& __alloc, size_t __n) {
32 if constexpr (requires { __alloc.allocate_at_least(__n); }) {
33 return __alloc.allocate_at_least(__n);
34 } else {
35 return {__alloc.allocate(__n), __n};
36 }
37}
38
39template <class _Alloc>
40[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr
41auto __allocate_at_least(_Alloc& __alloc, size_t __n) {
42 return std::allocate_at_least(__alloc, __n);
43}
44#else
45template <class _Pointer>
46struct __allocation_result {
47 _Pointer ptr;
48 size_t count;
49};
50
51template <class _Alloc>
52_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
53__allocation_result<typename allocator_traits<_Alloc>::pointer> __allocate_at_least(_Alloc& __alloc, size_t __n) {
54 return {__alloc.allocate(__n), __n};
55}
56
57#endif // _LIBCPP_STD_VER > 20
58
59_LIBCPP_END_NAMESPACE_STD
60
61#endif // _LIBCPP___MEMORY_ALLOCATE_AT_LEAST_H
lib/libcxx/include/__memory/allocation_guard.h+2-2
...@@ -12,11 +12,11 @@...@@ -12,11 +12,11 @@
1212
13#include <__config>13#include <__config>
14#include <__memory/allocator_traits.h>14#include <__memory/allocator_traits.h>
15#include <__utility/move.h>
15#include <cstddef>16#include <cstddef>
16#include <utility>
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_LIBCPP_BEGIN_NAMESPACE_STD22_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__memory/allocator.h+23-2
...@@ -11,6 +11,7 @@...@@ -11,6 +11,7 @@
11#define _LIBCPP___MEMORY_ALLOCATOR_H11#define _LIBCPP___MEMORY_ALLOCATOR_H
1212
13#include <__config>13#include <__config>
14#include <__memory/allocate_at_least.h>
14#include <__memory/allocator_traits.h>15#include <__memory/allocator_traits.h>
15#include <__utility/forward.h>16#include <__utility/forward.h>
16#include <cstddef>17#include <cstddef>
...@@ -19,34 +20,40 @@...@@ -19,34 +20,40 @@
19#include <type_traits>20#include <type_traits>
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
25_LIBCPP_BEGIN_NAMESPACE_STD26_LIBCPP_BEGIN_NAMESPACE_STD
2627
27template <class _Tp> class allocator;28template <class _Tp> class allocator;
2829
29#if _LIBCPP_STD_VER <= 1730#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_VOID_SPECIALIZATION)
31// These specializations shouldn't be marked _LIBCPP_DEPRECATED_IN_CXX17.
32// Specializing allocator<void> is deprecated, but not using it.
30template <>33template <>
31class _LIBCPP_TEMPLATE_VIS allocator<void>34class _LIBCPP_TEMPLATE_VIS allocator<void>
32{35{
36#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS)
33public:37public:
34 _LIBCPP_DEPRECATED_IN_CXX17 typedef void* pointer;38 _LIBCPP_DEPRECATED_IN_CXX17 typedef void* pointer;
35 _LIBCPP_DEPRECATED_IN_CXX17 typedef const void* const_pointer;39 _LIBCPP_DEPRECATED_IN_CXX17 typedef const void* const_pointer;
36 _LIBCPP_DEPRECATED_IN_CXX17 typedef void value_type;40 _LIBCPP_DEPRECATED_IN_CXX17 typedef void value_type;
3741
38 template <class _Up> struct _LIBCPP_DEPRECATED_IN_CXX17 rebind {typedef allocator<_Up> other;};42 template <class _Up> struct _LIBCPP_DEPRECATED_IN_CXX17 rebind {typedef allocator<_Up> other;};
43#endif
39};44};
4045
41template <>46template <>
42class _LIBCPP_TEMPLATE_VIS allocator<const void>47class _LIBCPP_TEMPLATE_VIS allocator<const void>
43{48{
49#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS)
44public:50public:
45 _LIBCPP_DEPRECATED_IN_CXX17 typedef const void* pointer;51 _LIBCPP_DEPRECATED_IN_CXX17 typedef const void* pointer;
46 _LIBCPP_DEPRECATED_IN_CXX17 typedef const void* const_pointer;52 _LIBCPP_DEPRECATED_IN_CXX17 typedef const void* const_pointer;
47 _LIBCPP_DEPRECATED_IN_CXX17 typedef const void value_type;53 _LIBCPP_DEPRECATED_IN_CXX17 typedef const void value_type;
4854
49 template <class _Up> struct _LIBCPP_DEPRECATED_IN_CXX17 rebind {typedef allocator<_Up> other;};55 template <class _Up> struct _LIBCPP_DEPRECATED_IN_CXX17 rebind {typedef allocator<_Up> other;};
56#endif
50};57};
51#endif58#endif
5259
...@@ -106,6 +113,13 @@ public:...@@ -106,6 +113,13 @@ public:
106 }113 }
107 }114 }
108115
116#if _LIBCPP_STD_VER > 20
117 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr
118 allocation_result<_Tp*> allocate_at_least(size_t __n) {
119 return {allocate(__n), __n};
120 }
121#endif
122
109 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17123 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
110 void deallocate(_Tp* __p, size_t __n) _NOEXCEPT {124 void deallocate(_Tp* __p, size_t __n) _NOEXCEPT {
111 if (__libcpp_is_constant_evaluated()) {125 if (__libcpp_is_constant_evaluated()) {
...@@ -188,6 +202,13 @@ public:...@@ -188,6 +202,13 @@ public:
188 }202 }
189 }203 }
190204
205#if _LIBCPP_STD_VER > 20
206 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr
207 allocation_result<const _Tp*> allocate_at_least(size_t __n) {
208 return {allocate(__n), __n};
209 }
210#endif
211
191 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17212 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
192 void deallocate(const _Tp* __p, size_t __n) {213 void deallocate(const _Tp* __p, size_t __n) {
193 if (__libcpp_is_constant_evaluated()) {214 if (__libcpp_is_constant_evaluated()) {
lib/libcxx/include/__memory/allocator_arg_t.h+2-2
...@@ -16,7 +16,7 @@...@@ -16,7 +16,7 @@
16#include <type_traits>16#include <type_traits>
1717
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19#pragma GCC system_header19# pragma GCC system_header
20#endif20#endif
2121
22_LIBCPP_BEGIN_NAMESPACE_STD22_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -36,7 +36,7 @@ extern _LIBCPP_EXPORTED_FROM_ABI const allocator_arg_t allocator_arg;...@@ -36,7 +36,7 @@ extern _LIBCPP_EXPORTED_FROM_ABI const allocator_arg_t allocator_arg;
36template <class _Tp, class _Alloc, class ..._Args>36template <class _Tp, class _Alloc, class ..._Args>
37struct __uses_alloc_ctor_imp37struct __uses_alloc_ctor_imp
38{38{
39 typedef _LIBCPP_NODEBUG typename __uncvref<_Alloc>::type _RawAlloc;39 typedef _LIBCPP_NODEBUG __uncvref_t<_Alloc> _RawAlloc;
40 static const bool __ua = uses_allocator<_Tp, _RawAlloc>::value;40 static const bool __ua = uses_allocator<_Tp, _RawAlloc>::value;
41 static const bool __ic =41 static const bool __ic =
42 is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value;42 is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value;
lib/libcxx/include/__memory/allocator_traits.h+1-1
...@@ -18,7 +18,7 @@...@@ -18,7 +18,7 @@
18#include <type_traits>18#include <type_traits>
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
22#endif22#endif
2323
24_LIBCPP_PUSH_MACROS24_LIBCPP_PUSH_MACROS
lib/libcxx/include/__memory/assume_aligned.h created+46
...@@ -0,0 +1,46 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___MEMORY_ASSUME_ALIGNED_H
11#define _LIBCPP___MEMORY_ASSUME_ALIGNED_H
12
13#include <__assert>
14#include <__config>
15#include <cstddef>
16#include <cstdint>
17#include <type_traits> // for is_constant_evaluated()
18
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20# pragma GCC system_header
21#endif
22
23_LIBCPP_BEGIN_NAMESPACE_STD
24
25#if _LIBCPP_STD_VER > 17
26
27template <size_t _Np, class _Tp>
28[[nodiscard]]
29_LIBCPP_HIDE_FROM_ABI
30constexpr _Tp* assume_aligned(_Tp* __ptr) {
31 static_assert(_Np != 0 && (_Np & (_Np - 1)) == 0,
32 "std::assume_aligned<N>(p) requires N to be a power of two");
33
34 if (is_constant_evaluated()) {
35 return __ptr;
36 } else {
37 _LIBCPP_ASSERT(reinterpret_cast<uintptr_t>(__ptr) % _Np == 0, "Alignment assumption is violated");
38 return static_cast<_Tp*>(__builtin_assume_aligned(__ptr, _Np));
39 }
40}
41
42#endif // _LIBCPP_STD_VER > 17
43
44_LIBCPP_END_NAMESPACE_STD
45
46#endif // _LIBCPP___MEMORY_ASSUME_ALIGNED_H
lib/libcxx/include/__memory/auto_ptr.h+5-2
...@@ -11,12 +11,13 @@...@@ -11,12 +11,13 @@
11#define _LIBCPP___MEMORY_AUTO_PTR_H11#define _LIBCPP___MEMORY_AUTO_PTR_H
1212
13#include <__config>13#include <__config>
14#include <__nullptr>
1514
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17#pragma GCC system_header16# pragma GCC system_header
18#endif17#endif
1918
19#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
20
20_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2122
22template <class _Tp>23template <class _Tp>
...@@ -78,4 +79,6 @@ public:...@@ -78,4 +79,6 @@ public:
7879
79_LIBCPP_END_NAMESPACE_STD80_LIBCPP_END_NAMESPACE_STD
8081
82#endif // _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
83
81#endif // _LIBCPP___MEMORY_AUTO_PTR_H84#endif // _LIBCPP___MEMORY_AUTO_PTR_H
lib/libcxx/include/__memory/compressed_pair.h+69-88
...@@ -12,12 +12,12 @@...@@ -12,12 +12,12 @@
1212
13#include <__config>13#include <__config>
14#include <__utility/forward.h>14#include <__utility/forward.h>
15#include <__utility/move.h>
15#include <tuple> // needed in c++03 for some constructors16#include <tuple> // needed in c++03 for some constructors
16#include <type_traits>17#include <type_traits>
17#include <utility>
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
21#endif21#endif
2222
23_LIBCPP_BEGIN_NAMESPACE_STD23_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -26,40 +26,28 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -26,40 +26,28 @@ _LIBCPP_BEGIN_NAMESPACE_STD
26struct __default_init_tag {};26struct __default_init_tag {};
27struct __value_init_tag {};27struct __value_init_tag {};
2828
29template <class _Tp, int _Idx,29template <class _Tp, int _Idx, bool _CanBeEmptyBase = is_empty<_Tp>::value && !__libcpp_is_final<_Tp>::value>
30 bool _CanBeEmptyBase =
31 is_empty<_Tp>::value && !__libcpp_is_final<_Tp>::value>
32struct __compressed_pair_elem {30struct __compressed_pair_elem {
33 typedef _Tp _ParamT;31 using _ParamT = _Tp;
34 typedef _Tp& reference;32 using reference = _Tp&;
35 typedef const _Tp& const_reference;33 using const_reference = const _Tp&;
36
37 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
38 __compressed_pair_elem(__default_init_tag) {}
39 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
40 __compressed_pair_elem(__value_init_tag) : __value_() {}
41
42 template <class _Up, class = typename enable_if<
43 !is_same<__compressed_pair_elem, typename decay<_Up>::type>::value
44 >::type>
45 _LIBCPP_INLINE_VISIBILITY
46 _LIBCPP_CONSTEXPR explicit
47 __compressed_pair_elem(_Up&& __u)
48 : __value_(_VSTD::forward<_Up>(__u))
49 {
50 }
5134
35 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(__default_init_tag) {}
36 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(__value_init_tag) : __value_() {}
37
38 template <class _Up, class = __enable_if_t<!is_same<__compressed_pair_elem, typename decay<_Up>::type>::value> >
39 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
40 explicit __compressed_pair_elem(_Up&& __u) : __value_(std::forward<_Up>(__u)) {}
5241
53#ifndef _LIBCPP_CXX03_LANG42#ifndef _LIBCPP_CXX03_LANG
54 template <class... _Args, size_t... _Indexes>43 template <class... _Args, size_t... _Indices>
55 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1444 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
56 __compressed_pair_elem(piecewise_construct_t, tuple<_Args...> __args,45 explicit __compressed_pair_elem(piecewise_construct_t, tuple<_Args...> __args, __tuple_indices<_Indices...>)
57 __tuple_indices<_Indexes...>)46 : __value_(std::forward<_Args>(std::get<_Indices>(__args))...) {}
58 : __value_(_VSTD::forward<_Args>(_VSTD::get<_Indexes>(__args))...) {}
59#endif47#endif
6048
61 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 reference __get() _NOEXCEPT { return __value_; }49 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 reference __get() _NOEXCEPT { return __value_; }
62 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR const_reference __get() const _NOEXCEPT { return __value_; }50 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const_reference __get() const _NOEXCEPT { return __value_; }
6351
64private:52private:
65 _Tp __value_;53 _Tp __value_;
...@@ -67,36 +55,28 @@ private:...@@ -67,36 +55,28 @@ private:
6755
68template <class _Tp, int _Idx>56template <class _Tp, int _Idx>
69struct __compressed_pair_elem<_Tp, _Idx, true> : private _Tp {57struct __compressed_pair_elem<_Tp, _Idx, true> : private _Tp {
70 typedef _Tp _ParamT;58 using _ParamT = _Tp;
71 typedef _Tp& reference;59 using reference = _Tp&;
72 typedef const _Tp& const_reference;60 using const_reference = const _Tp&;
73 typedef _Tp __value_type;61 using __value_type = _Tp;
7462
75 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __compressed_pair_elem() = default;63 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem() = default;
76 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR64 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(__default_init_tag) {}
77 __compressed_pair_elem(__default_init_tag) {}65 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(__value_init_tag) : __value_type() {}
78 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR66
79 __compressed_pair_elem(__value_init_tag) : __value_type() {}67 template <class _Up, class = __enable_if_t<!is_same<__compressed_pair_elem, typename decay<_Up>::type>::value> >
8068 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
81 template <class _Up, class = typename enable_if<69 explicit __compressed_pair_elem(_Up&& __u) : __value_type(std::forward<_Up>(__u)) {}
82 !is_same<__compressed_pair_elem, typename decay<_Up>::type>::value
83 >::type>
84 _LIBCPP_INLINE_VISIBILITY
85 _LIBCPP_CONSTEXPR explicit
86 __compressed_pair_elem(_Up&& __u)
87 : __value_type(_VSTD::forward<_Up>(__u))
88 {}
8970
90#ifndef _LIBCPP_CXX03_LANG71#ifndef _LIBCPP_CXX03_LANG
91 template <class... _Args, size_t... _Indexes>72 template <class... _Args, size_t... _Indices>
92 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1473 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
93 __compressed_pair_elem(piecewise_construct_t, tuple<_Args...> __args,74 __compressed_pair_elem(piecewise_construct_t, tuple<_Args...> __args, __tuple_indices<_Indices...>)
94 __tuple_indices<_Indexes...>)75 : __value_type(std::forward<_Args>(std::get<_Indices>(__args))...) {}
95 : __value_type(_VSTD::forward<_Args>(_VSTD::get<_Indexes>(__args))...) {}
96#endif76#endif
9777
98 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 reference __get() _NOEXCEPT { return *this; }78 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 reference __get() _NOEXCEPT { return *this; }
99 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR const_reference __get() const _NOEXCEPT { return *this; }79 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const_reference __get() const _NOEXCEPT { return *this; }
100};80};
10181
102template <class _T1, class _T2>82template <class _T1, class _T2>
...@@ -109,72 +89,73 @@ public:...@@ -109,72 +89,73 @@ public:
109 // object and the allocator have the same type).89 // object and the allocator have the same type).
110 static_assert((!is_same<_T1, _T2>::value),90 static_assert((!is_same<_T1, _T2>::value),
111 "__compressed_pair cannot be instantiated when T1 and T2 are the same type; "91 "__compressed_pair cannot be instantiated when T1 and T2 are the same type; "
112 "The current implementation is NOT ABI-compatible with the previous "92 "The current implementation is NOT ABI-compatible with the previous implementation for this configuration");
113 "implementation for this configuration");
11493
115 typedef _LIBCPP_NODEBUG __compressed_pair_elem<_T1, 0> _Base1;94 using _Base1 _LIBCPP_NODEBUG = __compressed_pair_elem<_T1, 0>;
116 typedef _LIBCPP_NODEBUG __compressed_pair_elem<_T2, 1> _Base2;95 using _Base2 _LIBCPP_NODEBUG = __compressed_pair_elem<_T2, 1>;
11796
118 template <bool _Dummy = true,97 template <bool _Dummy = true,
119 class = typename enable_if<98 class = __enable_if_t<
120 __dependent_type<is_default_constructible<_T1>, _Dummy>::value &&99 __dependent_type<is_default_constructible<_T1>, _Dummy>::value &&
121 __dependent_type<is_default_constructible<_T2>, _Dummy>::value100 __dependent_type<is_default_constructible<_T2>, _Dummy>::value
122 >::type101 >
123 >102 >
124 _LIBCPP_INLINE_VISIBILITY103 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
125 _LIBCPP_CONSTEXPR __compressed_pair() : _Base1(__value_init_tag()), _Base2(__value_init_tag()) {}104 explicit __compressed_pair() : _Base1(__value_init_tag()), _Base2(__value_init_tag()) {}
126105
127 template <class _U1, class _U2>106 template <class _U1, class _U2>
128 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR107 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
129 __compressed_pair(_U1&& __t1, _U2&& __t2)108 explicit __compressed_pair(_U1&& __t1, _U2&& __t2) : _Base1(std::forward<_U1>(__t1)), _Base2(std::forward<_U2>(__t2)) {}
130 : _Base1(_VSTD::forward<_U1>(__t1)), _Base2(_VSTD::forward<_U2>(__t2)) {}
131109
132#ifndef _LIBCPP_CXX03_LANG110#ifndef _LIBCPP_CXX03_LANG
133 template <class... _Args1, class... _Args2>111 template <class... _Args1, class... _Args2>
134 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14112 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
135 __compressed_pair(piecewise_construct_t __pc, tuple<_Args1...> __first_args,113 explicit __compressed_pair(piecewise_construct_t __pc, tuple<_Args1...> __first_args,
136 tuple<_Args2...> __second_args)114 tuple<_Args2...> __second_args)
137 : _Base1(__pc, _VSTD::move(__first_args),115 : _Base1(__pc, std::move(__first_args), typename __make_tuple_indices<sizeof...(_Args1)>::type()),
138 typename __make_tuple_indices<sizeof...(_Args1)>::type()),116 _Base2(__pc, std::move(__second_args), typename __make_tuple_indices<sizeof...(_Args2)>::type()) {}
139 _Base2(__pc, _VSTD::move(__second_args),
140 typename __make_tuple_indices<sizeof...(_Args2)>::type()) {}
141#endif117#endif
142118
143 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 typename _Base1::reference first() _NOEXCEPT {119 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
120 typename _Base1::reference first() _NOEXCEPT {
144 return static_cast<_Base1&>(*this).__get();121 return static_cast<_Base1&>(*this).__get();
145 }122 }
146123
147 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename _Base1::const_reference first() const _NOEXCEPT {124 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
125 typename _Base1::const_reference first() const _NOEXCEPT {
148 return static_cast<_Base1 const&>(*this).__get();126 return static_cast<_Base1 const&>(*this).__get();
149 }127 }
150128
151 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 typename _Base2::reference second() _NOEXCEPT {129 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
130 typename _Base2::reference second() _NOEXCEPT {
152 return static_cast<_Base2&>(*this).__get();131 return static_cast<_Base2&>(*this).__get();
153 }132 }
154133
155 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename _Base2::const_reference second() const _NOEXCEPT {134 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
135 typename _Base2::const_reference second() const _NOEXCEPT {
156 return static_cast<_Base2 const&>(*this).__get();136 return static_cast<_Base2 const&>(*this).__get();
157 }137 }
158138
159 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR139 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR static
160 static _Base1* __get_first_base(__compressed_pair* __pair) _NOEXCEPT {140 _Base1* __get_first_base(__compressed_pair* __pair) _NOEXCEPT {
161 return static_cast<_Base1*>(__pair);141 return static_cast<_Base1*>(__pair);
162 }142 }
163 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR143 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR static
164 static _Base2* __get_second_base(__compressed_pair* __pair) _NOEXCEPT {144 _Base2* __get_second_base(__compressed_pair* __pair) _NOEXCEPT {
165 return static_cast<_Base2*>(__pair);145 return static_cast<_Base2*>(__pair);
166 }146 }
167147
168 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 void swap(__compressed_pair& __x)148 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
149 void swap(__compressed_pair& __x)
169 _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && __is_nothrow_swappable<_T2>::value) {150 _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && __is_nothrow_swappable<_T2>::value) {
170 using _VSTD::swap;151 using std::swap;
171 swap(first(), __x.first());152 swap(first(), __x.first());
172 swap(second(), __x.second());153 swap(second(), __x.second());
173 }154 }
174};155};
175156
176template <class _T1, class _T2>157template <class _T1, class _T2>
177inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11158inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
178void swap(__compressed_pair<_T1, _T2>& __x, __compressed_pair<_T1, _T2>& __y)159void swap(__compressed_pair<_T1, _T2>& __x, __compressed_pair<_T1, _T2>& __y)
179 _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && __is_nothrow_swappable<_T2>::value) {160 _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && __is_nothrow_swappable<_T2>::value) {
180 __x.swap(__y);161 __x.swap(__y);
lib/libcxx/include/__memory/concepts.h+3-3
...@@ -20,12 +20,12 @@...@@ -20,12 +20,12 @@
20#include <type_traits>20#include <type_traits>
2121
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23#pragma GCC system_header23# pragma GCC system_header
24#endif24#endif
2525
26_LIBCPP_BEGIN_NAMESPACE_STD26_LIBCPP_BEGIN_NAMESPACE_STD
2727
28#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)28#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
2929
30namespace ranges {30namespace ranges {
3131
...@@ -61,7 +61,7 @@ concept __nothrow_forward_range =...@@ -61,7 +61,7 @@ concept __nothrow_forward_range =
6161
62} // namespace ranges62} // namespace ranges
6363
64#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)64#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
6565
66_LIBCPP_END_NAMESPACE_STD66_LIBCPP_END_NAMESPACE_STD
6767
lib/libcxx/include/__memory/construct_at.h+19-12
...@@ -10,17 +10,17 @@...@@ -10,17 +10,17 @@
10#ifndef _LIBCPP___MEMORY_CONSTRUCT_AT_H10#ifndef _LIBCPP___MEMORY_CONSTRUCT_AT_H
11#define _LIBCPP___MEMORY_CONSTRUCT_AT_H11#define _LIBCPP___MEMORY_CONSTRUCT_AT_H
1212
13#include <__assert>
13#include <__config>14#include <__config>
14#include <__debug>
15#include <__iterator/access.h>15#include <__iterator/access.h>
16#include <__memory/addressof.h>16#include <__memory/addressof.h>
17#include <__memory/voidify.h>17#include <__memory/voidify.h>
18#include <__utility/forward.h>18#include <__utility/forward.h>
19#include <__utility/move.h>
19#include <type_traits>20#include <type_traits>
20#include <utility>
2121
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23#pragma GCC system_header23# pragma GCC system_header
24#endif24#endif
2525
26_LIBCPP_BEGIN_NAMESPACE_STD26_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -29,17 +29,24 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -29,17 +29,24 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2929
30#if _LIBCPP_STD_VER > 1730#if _LIBCPP_STD_VER > 17
3131
32template<class _Tp, class ..._Args, class = decltype(32template <class _Tp, class... _Args, class = decltype(::new(declval<void*>()) _Tp(declval<_Args>()...))>
33 ::new (declval<void*>()) _Tp(declval<_Args>()...)33_LIBCPP_HIDE_FROM_ABI constexpr _Tp* construct_at(_Tp* __location, _Args&&... __args) {
34)>34 _LIBCPP_ASSERT(__location != nullptr, "null pointer given to construct_at");
35_LIBCPP_HIDE_FROM_ABI35 return ::new (_VSTD::__voidify(*__location)) _Tp(_VSTD::forward<_Args>(__args)...);
36constexpr _Tp* construct_at(_Tp* __location, _Args&& ...__args) {
37 _LIBCPP_ASSERT(__location, "null pointer given to construct_at");
38 return ::new (_VSTD::__voidify(*__location)) _Tp(_VSTD::forward<_Args>(__args)...);
39}36}
4037
41#endif38#endif
4239
40template <class _Tp, class... _Args, class = decltype(::new(declval<void*>()) _Tp(declval<_Args>()...))>
41_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp* __construct_at(_Tp* __location, _Args&&... __args) {
42#if _LIBCPP_STD_VER > 17
43 return std::construct_at(__location, std::forward<_Args>(__args)...);
44#else
45 return _LIBCPP_ASSERT(__location != nullptr, "null pointer given to construct_at"),
46 ::new (std::__voidify(*__location)) _Tp(std::forward<_Args>(__args)...);
47#endif
48}
49
43// destroy_at50// destroy_at
4451
45// The internal functions are available regardless of the language version (with the exception of the `__destroy_at`52// The internal functions are available regardless of the language version (with the exception of the `__destroy_at`
...@@ -52,7 +59,7 @@ _ForwardIterator __destroy(_ForwardIterator, _ForwardIterator);...@@ -52,7 +59,7 @@ _ForwardIterator __destroy(_ForwardIterator, _ForwardIterator);
52template <class _Tp, typename enable_if<!is_array<_Tp>::value, int>::type = 0>59template <class _Tp, typename enable_if<!is_array<_Tp>::value, int>::type = 0>
53_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1760_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
54void __destroy_at(_Tp* __loc) {61void __destroy_at(_Tp* __loc) {
55 _LIBCPP_ASSERT(__loc, "null pointer given to destroy_at");62 _LIBCPP_ASSERT(__loc != nullptr, "null pointer given to destroy_at");
56 __loc->~_Tp();63 __loc->~_Tp();
57}64}
5865
...@@ -60,7 +67,7 @@ void __destroy_at(_Tp* __loc) {...@@ -60,7 +67,7 @@ void __destroy_at(_Tp* __loc) {
60template <class _Tp, typename enable_if<is_array<_Tp>::value, int>::type = 0>67template <class _Tp, typename enable_if<is_array<_Tp>::value, int>::type = 0>
61_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1768_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
62void __destroy_at(_Tp* __loc) {69void __destroy_at(_Tp* __loc) {
63 _LIBCPP_ASSERT(__loc, "null pointer given to destroy_at");70 _LIBCPP_ASSERT(__loc != nullptr, "null pointer given to destroy_at");
64 _VSTD::__destroy(_VSTD::begin(*__loc), _VSTD::end(*__loc));71 _VSTD::__destroy(_VSTD::begin(*__loc), _VSTD::end(*__loc));
65}72}
66#endif73#endif
lib/libcxx/include/__memory/pointer_traits.h+5-6
...@@ -15,7 +15,7 @@...@@ -15,7 +15,7 @@
15#include <type_traits>15#include <type_traits>
1616
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header18# pragma GCC system_header
19#endif19#endif
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -71,13 +71,12 @@ template <class _Tp, class _Up>...@@ -71,13 +71,12 @@ template <class _Tp, class _Up>
71struct __has_rebind71struct __has_rebind
72{72{
73private:73private:
74 struct __two {char __lx; char __lxx;};74 template <class _Xp> static false_type __test(...);
75 template <class _Xp> static __two __test(...);
76 _LIBCPP_SUPPRESS_DEPRECATED_PUSH75 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
77 template <class _Xp> static char __test(typename _Xp::template rebind<_Up>* = 0);76 template <class _Xp> static true_type __test(typename _Xp::template rebind<_Up>* = 0);
78 _LIBCPP_SUPPRESS_DEPRECATED_POP77 _LIBCPP_SUPPRESS_DEPRECATED_POP
79public:78public:
80 static const bool value = sizeof(__test<_Tp>(0)) == 1;79 static const bool value = decltype(__test<_Tp>(0))::value;
81};80};
8281
83template <class _Tp, class _Up, bool = __has_rebind<_Tp, _Up>::value>82template <class _Tp, class _Up, bool = __has_rebind<_Tp, _Up>::value>
...@@ -123,7 +122,7 @@ struct _LIBCPP_TEMPLATE_VIS pointer_traits...@@ -123,7 +122,7 @@ struct _LIBCPP_TEMPLATE_VIS pointer_traits
123private:122private:
124 struct __nat {};123 struct __nat {};
125public:124public:
126 _LIBCPP_INLINE_VISIBILITY125 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
127 static pointer pointer_to(typename conditional<is_void<element_type>::value,126 static pointer pointer_to(typename conditional<is_void<element_type>::value,
128 __nat, element_type>::type& __r)127 __nat, element_type>::type& __r)
129 {return pointer::pointer_to(__r);}128 {return pointer::pointer_to(__r);}
lib/libcxx/include/__memory/ranges_construct_at.h+3-3
...@@ -24,12 +24,12 @@...@@ -24,12 +24,12 @@
24#include <__utility/move.h>24#include <__utility/move.h>
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
28#endif28#endif
2929
30_LIBCPP_BEGIN_NAMESPACE_STD30_LIBCPP_BEGIN_NAMESPACE_STD
3131
32#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)32#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
33namespace ranges {33namespace ranges {
3434
35// construct_at35// construct_at
...@@ -117,7 +117,7 @@ inline namespace __cpo {...@@ -117,7 +117,7 @@ inline namespace __cpo {
117117
118} // namespace ranges118} // namespace ranges
119119
120#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)120#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
121121
122_LIBCPP_END_NAMESPACE_STD122_LIBCPP_END_NAMESPACE_STD
123123
lib/libcxx/include/__memory/ranges_uninitialized_algorithms.h+3-3
...@@ -27,12 +27,12 @@...@@ -27,12 +27,12 @@
27#include <type_traits>27#include <type_traits>
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
31#endif31#endif
3232
33_LIBCPP_BEGIN_NAMESPACE_STD33_LIBCPP_BEGIN_NAMESPACE_STD
3434
35#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)35#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
3636
37namespace ranges {37namespace ranges {
3838
...@@ -311,7 +311,7 @@ inline namespace __cpo {...@@ -311,7 +311,7 @@ inline namespace __cpo {
311311
312} // namespace ranges312} // namespace ranges
313313
314#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)314#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
315315
316_LIBCPP_END_NAMESPACE_STD316_LIBCPP_END_NAMESPACE_STD
317317
lib/libcxx/include/__memory/raw_storage_iterator.h+4-3
...@@ -11,13 +11,14 @@...@@ -11,13 +11,14 @@
11#define _LIBCPP___MEMORY_RAW_STORAGE_ITERATOR_H11#define _LIBCPP___MEMORY_RAW_STORAGE_ITERATOR_H
1212
13#include <__config>13#include <__config>
14#include <__iterator/iterator.h>
15#include <__iterator/iterator_traits.h>
14#include <__memory/addressof.h>16#include <__memory/addressof.h>
17#include <__utility/move.h>
15#include <cstddef>18#include <cstddef>
16#include <iterator>
17#include <utility>
1819
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20#pragma GCC system_header21# pragma GCC system_header
21#endif22#endif
2223
23_LIBCPP_BEGIN_NAMESPACE_STD24_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__memory/shared_ptr.h+236-41
...@@ -15,32 +15,33 @@...@@ -15,32 +15,33 @@
15#include <__functional/binary_function.h>15#include <__functional/binary_function.h>
16#include <__functional/operations.h>16#include <__functional/operations.h>
17#include <__functional/reference_wrapper.h>17#include <__functional/reference_wrapper.h>
18#include <__functional_base>18#include <__iterator/access.h>
19#include <__memory/addressof.h>19#include <__memory/addressof.h>
20#include <__memory/allocation_guard.h>20#include <__memory/allocation_guard.h>
21#include <__memory/allocator.h>21#include <__memory/allocator.h>
22#include <__memory/allocator_traits.h>22#include <__memory/allocator_traits.h>
23#include <__memory/auto_ptr.h>
23#include <__memory/compressed_pair.h>24#include <__memory/compressed_pair.h>
25#include <__memory/construct_at.h>
24#include <__memory/pointer_traits.h>26#include <__memory/pointer_traits.h>
27#include <__memory/uninitialized_algorithms.h>
25#include <__memory/unique_ptr.h>28#include <__memory/unique_ptr.h>
26#include <__utility/forward.h>29#include <__utility/forward.h>
30#include <__utility/move.h>
31#include <__utility/swap.h>
27#include <cstddef>32#include <cstddef>
28#include <cstdlib> // abort33#include <cstdlib> // abort
29#include <iosfwd>34#include <iosfwd>
30#include <stdexcept>35#include <stdexcept>
31#include <type_traits>36#include <type_traits>
32#include <typeinfo>37#include <typeinfo>
33#include <utility>
34#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)38#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
35# include <atomic>39# include <atomic>
36#endif40#endif
3741
38#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
39# include <__memory/auto_ptr.h>
40#endif
4142
42#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)43#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
43#pragma GCC system_header44# pragma GCC system_header
44#endif45#endif
4546
46_LIBCPP_BEGIN_NAMESPACE_STD47_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -159,10 +160,9 @@ public:...@@ -159,10 +160,9 @@ public:
159 explicit __shared_count(long __refs = 0) _NOEXCEPT160 explicit __shared_count(long __refs = 0) _NOEXCEPT
160 : __shared_owners_(__refs) {}161 : __shared_owners_(__refs) {}
161162
162#if defined(_LIBCPP_BUILDING_LIBRARY) && \163#if defined(_LIBCPP_SHARED_PTR_DEFINE_LEGACY_INLINE_FUNCTIONS)
163 defined(_LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS)164 void __add_shared() noexcept;
164 void __add_shared() _NOEXCEPT;165 bool __release_shared() noexcept;
165 bool __release_shared() _NOEXCEPT;
166#else166#else
167 _LIBCPP_INLINE_VISIBILITY167 _LIBCPP_INLINE_VISIBILITY
168 void __add_shared() _NOEXCEPT {168 void __add_shared() _NOEXCEPT {
...@@ -197,11 +197,10 @@ protected:...@@ -197,11 +197,10 @@ protected:
197 virtual ~__shared_weak_count();197 virtual ~__shared_weak_count();
198198
199public:199public:
200#if defined(_LIBCPP_BUILDING_LIBRARY) && \200#if defined(_LIBCPP_SHARED_PTR_DEFINE_LEGACY_INLINE_FUNCTIONS)
201 defined(_LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS)201 void __add_shared() noexcept;
202 void __add_shared() _NOEXCEPT;202 void __add_weak() noexcept;
203 void __add_weak() _NOEXCEPT;203 void __release_shared() noexcept;
204 void __release_shared() _NOEXCEPT;
205#else204#else
206 _LIBCPP_INLINE_VISIBILITY205 _LIBCPP_INLINE_VISIBILITY
207 void __add_shared() _NOEXCEPT {206 void __add_shared() _NOEXCEPT {
...@@ -457,7 +456,7 @@ public:...@@ -457,7 +456,7 @@ public:
457 explicit shared_ptr(_Yp* __p) : __ptr_(__p) {456 explicit shared_ptr(_Yp* __p) : __ptr_(__p) {
458 unique_ptr<_Yp> __hold(__p);457 unique_ptr<_Yp> __hold(__p);
459 typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT;458 typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT;
460 typedef __shared_ptr_pointer<_Yp*, __shared_ptr_default_delete<_Tp, _Yp>, _AllocT > _CntrlBlk;459 typedef __shared_ptr_pointer<_Yp*, __shared_ptr_default_delete<_Tp, _Yp>, _AllocT> _CntrlBlk;
461 __cntrl_ = new _CntrlBlk(__p, __shared_ptr_default_delete<_Tp, _Yp>(), _AllocT());460 __cntrl_ = new _CntrlBlk(__p, __shared_ptr_default_delete<_Tp, _Yp>(), _AllocT());
462 __hold.release();461 __hold.release();
463 __enable_weak_this(__p, __p);462 __enable_weak_this(__p, __p);
...@@ -473,7 +472,7 @@ public:...@@ -473,7 +472,7 @@ public:
473 {472 {
474#endif // _LIBCPP_NO_EXCEPTIONS473#endif // _LIBCPP_NO_EXCEPTIONS
475 typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT;474 typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT;
476 typedef __shared_ptr_pointer<_Yp*, _Dp, _AllocT > _CntrlBlk;475 typedef __shared_ptr_pointer<_Yp*, _Dp, _AllocT> _CntrlBlk;
477#ifndef _LIBCPP_CXX03_LANG476#ifndef _LIBCPP_CXX03_LANG
478 __cntrl_ = new _CntrlBlk(__p, _VSTD::move(__d), _AllocT());477 __cntrl_ = new _CntrlBlk(__p, _VSTD::move(__d), _AllocT());
479#else478#else
...@@ -532,7 +531,7 @@ public:...@@ -532,7 +531,7 @@ public:
532 {531 {
533#endif // _LIBCPP_NO_EXCEPTIONS532#endif // _LIBCPP_NO_EXCEPTIONS
534 typedef typename __shared_ptr_default_allocator<_Tp>::type _AllocT;533 typedef typename __shared_ptr_default_allocator<_Tp>::type _AllocT;
535 typedef __shared_ptr_pointer<nullptr_t, _Dp, _AllocT > _CntrlBlk;534 typedef __shared_ptr_pointer<nullptr_t, _Dp, _AllocT> _CntrlBlk;
536#ifndef _LIBCPP_CXX03_LANG535#ifndef _LIBCPP_CXX03_LANG
537 __cntrl_ = new _CntrlBlk(__p, _VSTD::move(__d), _AllocT());536 __cntrl_ = new _CntrlBlk(__p, _VSTD::move(__d), _AllocT());
538#else537#else
...@@ -665,8 +664,8 @@ public:...@@ -665,8 +664,8 @@ public:
665#endif664#endif
666 {665 {
667 typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT;666 typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT;
668 typedef __shared_ptr_pointer<typename unique_ptr<_Yp, _Dp>::pointer, _Dp, _AllocT > _CntrlBlk;667 typedef __shared_ptr_pointer<typename unique_ptr<_Yp, _Dp>::pointer, _Dp, _AllocT> _CntrlBlk;
669 __cntrl_ = new _CntrlBlk(__r.get(), __r.get_deleter(), _AllocT());668 __cntrl_ = new _CntrlBlk(__r.get(), std::move(__r.get_deleter()), _AllocT());
670 __enable_weak_this(__r.get(), __r.get());669 __enable_weak_this(__r.get(), __r.get());
671 }670 }
672 __r.release();671 __r.release();
...@@ -689,7 +688,7 @@ public:...@@ -689,7 +688,7 @@ public:
689 typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT;688 typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT;
690 typedef __shared_ptr_pointer<typename unique_ptr<_Yp, _Dp>::pointer,689 typedef __shared_ptr_pointer<typename unique_ptr<_Yp, _Dp>::pointer,
691 reference_wrapper<typename remove_reference<_Dp>::type>,690 reference_wrapper<typename remove_reference<_Dp>::type>,
692 _AllocT > _CntrlBlk;691 _AllocT> _CntrlBlk;
693 __cntrl_ = new _CntrlBlk(__r.get(), _VSTD::ref(__r.get_deleter()), _AllocT());692 __cntrl_ = new _CntrlBlk(__r.get(), _VSTD::ref(__r.get_deleter()), _AllocT());
694 __enable_weak_this(__r.get(), __r.get());693 __enable_weak_this(__r.get(), __r.get());
695 }694 }
...@@ -963,6 +962,220 @@ shared_ptr<_Tp> make_shared(_Args&& ...__args)...@@ -963,6 +962,220 @@ shared_ptr<_Tp> make_shared(_Args&& ...__args)
963 return _VSTD::allocate_shared<_Tp>(allocator<_Tp>(), _VSTD::forward<_Args>(__args)...);962 return _VSTD::allocate_shared<_Tp>(allocator<_Tp>(), _VSTD::forward<_Args>(__args)...);
964}963}
965964
965#if _LIBCPP_STD_VER > 14
966
967template <size_t _Alignment>
968struct __sp_aligned_storage {
969 alignas(_Alignment) char __storage[_Alignment];
970};
971
972template <class _Tp, class _Alloc>
973struct __unbounded_array_control_block;
974
975template <class _Tp, class _Alloc>
976struct __unbounded_array_control_block<_Tp[], _Alloc> : __shared_weak_count
977{
978 _LIBCPP_HIDE_FROM_ABI constexpr
979 _Tp* __get_data() noexcept { return __data_; }
980
981 _LIBCPP_HIDE_FROM_ABI
982 explicit __unbounded_array_control_block(_Alloc const& __alloc, size_t __count, _Tp const& __arg)
983 : __alloc_(__alloc), __count_(__count)
984 {
985 std::__uninitialized_allocator_fill_n(__alloc_, std::begin(__data_), __count_, __arg);
986 }
987
988 _LIBCPP_HIDE_FROM_ABI
989 explicit __unbounded_array_control_block(_Alloc const& __alloc, size_t __count)
990 : __alloc_(__alloc), __count_(__count)
991 {
992 std::__uninitialized_allocator_value_construct_n(__alloc_, std::begin(__data_), __count_);
993 }
994
995 // Returns the number of bytes required to store a control block followed by the given number
996 // of elements of _Tp, with the whole storage being aligned to a multiple of _Tp's alignment.
997 _LIBCPP_HIDE_FROM_ABI
998 static constexpr size_t __bytes_for(size_t __elements) {
999 // When there's 0 elements, the control block alone is enough since it holds one element.
1000 // Otherwise, we allocate one fewer element than requested because the control block already
1001 // holds one. Also, we use the bitwise formula below to ensure that we allocate enough bytes
1002 // for the whole allocation to be a multiple of _Tp's alignment. That formula is taken from [1].
1003 //
1004 // [1]: https://en.wikipedia.org/wiki/Data_structure_alignment#Computing_padding
1005 size_t __bytes = __elements == 0 ? sizeof(__unbounded_array_control_block)
1006 : (__elements - 1) * sizeof(_Tp) + sizeof(__unbounded_array_control_block);
1007 constexpr size_t __align = alignof(_Tp);
1008 return (__bytes + __align - 1) & ~(__align - 1);
1009 }
1010
1011 _LIBCPP_HIDE_FROM_ABI
1012 ~__unbounded_array_control_block() override { } // can't be `= default` because of the sometimes-non-trivial union member __data_
1013
1014private:
1015 void __on_zero_shared() _NOEXCEPT override {
1016 __allocator_traits_rebind_t<_Alloc, _Tp> __value_alloc(__alloc_);
1017 std::__allocator_destroy_multidimensional(__value_alloc, __data_, __data_ + __count_);
1018 }
1019
1020 void __on_zero_shared_weak() _NOEXCEPT override {
1021 using _AlignedStorage = __sp_aligned_storage<alignof(__unbounded_array_control_block)>;
1022 using _StorageAlloc = __allocator_traits_rebind_t<_Alloc, _AlignedStorage>;
1023 using _PointerTraits = pointer_traits<typename allocator_traits<_StorageAlloc>::pointer>;
1024
1025 _StorageAlloc __tmp(__alloc_);
1026 __alloc_.~_Alloc();
1027 size_t __size = __unbounded_array_control_block::__bytes_for(__count_);
1028 _AlignedStorage* __storage = reinterpret_cast<_AlignedStorage*>(this);
1029 allocator_traits<_StorageAlloc>::deallocate(__tmp, _PointerTraits::pointer_to(*__storage), __size);
1030 }
1031
1032 _LIBCPP_NO_UNIQUE_ADDRESS _Alloc __alloc_;
1033 size_t __count_;
1034 union {
1035 _Tp __data_[1];
1036 };
1037};
1038
1039template<class _Array, class _Alloc, class... _Arg>
1040_LIBCPP_HIDE_FROM_ABI
1041shared_ptr<_Array> __allocate_shared_unbounded_array(const _Alloc& __a, size_t __n, _Arg&& ...__arg)
1042{
1043 static_assert(__libcpp_is_unbounded_array<_Array>::value);
1044 // We compute the number of bytes necessary to hold the control block and the
1045 // array elements. Then, we allocate an array of properly-aligned dummy structs
1046 // large enough to hold the control block and array. This allows shifting the
1047 // burden of aligning memory properly from us to the allocator.
1048 using _ControlBlock = __unbounded_array_control_block<_Array, _Alloc>;
1049 using _AlignedStorage = __sp_aligned_storage<alignof(_ControlBlock)>;
1050 using _StorageAlloc = __allocator_traits_rebind_t<_Alloc, _AlignedStorage>;
1051 __allocation_guard<_StorageAlloc> __guard(__a, _ControlBlock::__bytes_for(__n) / sizeof(_AlignedStorage));
1052 _ControlBlock* __control_block = reinterpret_cast<_ControlBlock*>(std::addressof(*__guard.__get()));
1053 std::__construct_at(__control_block, __a, __n, std::forward<_Arg>(__arg)...);
1054 __guard.__release_ptr();
1055 return shared_ptr<_Array>::__create_with_control_block(__control_block->__get_data(), __control_block);
1056}
1057
1058template <class _Tp, class _Alloc>
1059struct __bounded_array_control_block;
1060
1061template <class _Tp, size_t _Count, class _Alloc>
1062struct __bounded_array_control_block<_Tp[_Count], _Alloc>
1063 : __shared_weak_count
1064{
1065 _LIBCPP_HIDE_FROM_ABI constexpr
1066 _Tp* __get_data() noexcept { return __data_; }
1067
1068 _LIBCPP_HIDE_FROM_ABI
1069 explicit __bounded_array_control_block(_Alloc const& __alloc, _Tp const& __arg) : __alloc_(__alloc) {
1070 std::__uninitialized_allocator_fill_n(__alloc_, std::addressof(__data_[0]), _Count, __arg);
1071 }
1072
1073 _LIBCPP_HIDE_FROM_ABI
1074 explicit __bounded_array_control_block(_Alloc const& __alloc) : __alloc_(__alloc) {
1075 std::__uninitialized_allocator_value_construct_n(__alloc_, std::addressof(__data_[0]), _Count);
1076 }
1077
1078 _LIBCPP_HIDE_FROM_ABI
1079 ~__bounded_array_control_block() override { } // can't be `= default` because of the sometimes-non-trivial union member __data_
1080
1081private:
1082 void __on_zero_shared() _NOEXCEPT override {
1083 __allocator_traits_rebind_t<_Alloc, _Tp> __value_alloc(__alloc_);
1084 std::__allocator_destroy_multidimensional(__value_alloc, __data_, __data_ + _Count);
1085 }
1086
1087 void __on_zero_shared_weak() _NOEXCEPT override {
1088 using _ControlBlockAlloc = __allocator_traits_rebind_t<_Alloc, __bounded_array_control_block>;
1089 using _PointerTraits = pointer_traits<typename allocator_traits<_ControlBlockAlloc>::pointer>;
1090
1091 _ControlBlockAlloc __tmp(__alloc_);
1092 __alloc_.~_Alloc();
1093 allocator_traits<_ControlBlockAlloc>::deallocate(__tmp, _PointerTraits::pointer_to(*this), sizeof(*this));
1094 }
1095
1096 _LIBCPP_NO_UNIQUE_ADDRESS _Alloc __alloc_;
1097 union {
1098 _Tp __data_[_Count];
1099 };
1100};
1101
1102template<class _Array, class _Alloc, class... _Arg>
1103_LIBCPP_HIDE_FROM_ABI
1104shared_ptr<_Array> __allocate_shared_bounded_array(const _Alloc& __a, _Arg&& ...__arg)
1105{
1106 static_assert(__libcpp_is_bounded_array<_Array>::value);
1107 using _ControlBlock = __bounded_array_control_block<_Array, _Alloc>;
1108 using _ControlBlockAlloc = __allocator_traits_rebind_t<_Alloc, _ControlBlock>;
1109
1110 __allocation_guard<_ControlBlockAlloc> __guard(__a, 1);
1111 _ControlBlock* __control_block = reinterpret_cast<_ControlBlock*>(std::addressof(*__guard.__get()));
1112 std::__construct_at(__control_block, __a, std::forward<_Arg>(__arg)...);
1113 __guard.__release_ptr();
1114 return shared_ptr<_Array>::__create_with_control_block(__control_block->__get_data(), __control_block);
1115}
1116
1117#endif // _LIBCPP_STD_VER > 14
1118
1119#if _LIBCPP_STD_VER > 17
1120
1121template<class _Tp, class _Alloc, class = __enable_if_t<is_bounded_array<_Tp>::value>>
1122_LIBCPP_HIDE_FROM_ABI
1123shared_ptr<_Tp> allocate_shared(const _Alloc& __a)
1124{
1125 return std::__allocate_shared_bounded_array<_Tp>(__a);
1126}
1127
1128template<class _Tp, class _Alloc, class = __enable_if_t<is_bounded_array<_Tp>::value>>
1129_LIBCPP_HIDE_FROM_ABI
1130shared_ptr<_Tp> allocate_shared(const _Alloc& __a, const remove_extent_t<_Tp>& __u)
1131{
1132 return std::__allocate_shared_bounded_array<_Tp>(__a, __u);
1133}
1134
1135template<class _Tp, class _Alloc, class = __enable_if_t<is_unbounded_array<_Tp>::value>>
1136_LIBCPP_HIDE_FROM_ABI
1137shared_ptr<_Tp> allocate_shared(const _Alloc& __a, size_t __n)
1138{
1139 return std::__allocate_shared_unbounded_array<_Tp>(__a, __n);
1140}
1141
1142template<class _Tp, class _Alloc, class = __enable_if_t<is_unbounded_array<_Tp>::value>>
1143_LIBCPP_HIDE_FROM_ABI
1144shared_ptr<_Tp> allocate_shared(const _Alloc& __a, size_t __n, const remove_extent_t<_Tp>& __u)
1145{
1146 return std::__allocate_shared_unbounded_array<_Tp>(__a, __n, __u);
1147}
1148
1149template<class _Tp, class = __enable_if_t<is_bounded_array<_Tp>::value>>
1150_LIBCPP_HIDE_FROM_ABI
1151shared_ptr<_Tp> make_shared()
1152{
1153 return std::__allocate_shared_bounded_array<_Tp>(allocator<_Tp>());
1154}
1155
1156template<class _Tp, class = __enable_if_t<is_bounded_array<_Tp>::value>>
1157_LIBCPP_HIDE_FROM_ABI
1158shared_ptr<_Tp> make_shared(const remove_extent_t<_Tp>& __u)
1159{
1160 return std::__allocate_shared_bounded_array<_Tp>(allocator<_Tp>(), __u);
1161}
1162
1163template<class _Tp, class = __enable_if_t<is_unbounded_array<_Tp>::value>>
1164_LIBCPP_HIDE_FROM_ABI
1165shared_ptr<_Tp> make_shared(size_t __n)
1166{
1167 return std::__allocate_shared_unbounded_array<_Tp>(allocator<_Tp>(), __n);
1168}
1169
1170template<class _Tp, class = __enable_if_t<is_unbounded_array<_Tp>::value>>
1171_LIBCPP_HIDE_FROM_ABI
1172shared_ptr<_Tp> make_shared(size_t __n, const remove_extent_t<_Tp>& __u)
1173{
1174 return std::__allocate_shared_unbounded_array<_Tp>(allocator<_Tp>(), __n, __u);
1175}
1176
1177#endif // _LIBCPP_STD_VER > 17
1178
966template<class _Tp, class _Up>1179template<class _Tp, class _Up>
967inline _LIBCPP_INLINE_VISIBILITY1180inline _LIBCPP_INLINE_VISIBILITY
968bool1181bool
...@@ -1442,19 +1655,10 @@ template <class _Tp> struct owner_less;...@@ -1442,19 +1655,10 @@ template <class _Tp> struct owner_less;
1442#endif1655#endif
14431656
14441657
1445_LIBCPP_SUPPRESS_DEPRECATED_PUSH
1446template <class _Tp>1658template <class _Tp>
1447struct _LIBCPP_TEMPLATE_VIS owner_less<shared_ptr<_Tp> >1659struct _LIBCPP_TEMPLATE_VIS owner_less<shared_ptr<_Tp> >
1448#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)1660 : __binary_function<shared_ptr<_Tp>, shared_ptr<_Tp>, bool>
1449 : binary_function<shared_ptr<_Tp>, shared_ptr<_Tp>, bool>
1450#endif
1451{1661{
1452_LIBCPP_SUPPRESS_DEPRECATED_POP
1453#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
1454 _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
1455 _LIBCPP_DEPRECATED_IN_CXX17 typedef shared_ptr<_Tp> first_argument_type;
1456 _LIBCPP_DEPRECATED_IN_CXX17 typedef shared_ptr<_Tp> second_argument_type;
1457#endif
1458 _LIBCPP_INLINE_VISIBILITY1662 _LIBCPP_INLINE_VISIBILITY
1459 bool operator()(shared_ptr<_Tp> const& __x, shared_ptr<_Tp> const& __y) const _NOEXCEPT1663 bool operator()(shared_ptr<_Tp> const& __x, shared_ptr<_Tp> const& __y) const _NOEXCEPT
1460 {return __x.owner_before(__y);}1664 {return __x.owner_before(__y);}
...@@ -1466,19 +1670,10 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP...@@ -1466,19 +1670,10 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP
1466 {return __x.owner_before(__y);}1670 {return __x.owner_before(__y);}
1467};1671};
14681672
1469_LIBCPP_SUPPRESS_DEPRECATED_PUSH
1470template <class _Tp>1673template <class _Tp>
1471struct _LIBCPP_TEMPLATE_VIS owner_less<weak_ptr<_Tp> >1674struct _LIBCPP_TEMPLATE_VIS owner_less<weak_ptr<_Tp> >
1472#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)1675 : __binary_function<weak_ptr<_Tp>, weak_ptr<_Tp>, bool>
1473 : binary_function<weak_ptr<_Tp>, weak_ptr<_Tp>, bool>
1474#endif
1475{1676{
1476_LIBCPP_SUPPRESS_DEPRECATED_POP
1477#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
1478 _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
1479 _LIBCPP_DEPRECATED_IN_CXX17 typedef weak_ptr<_Tp> first_argument_type;
1480 _LIBCPP_DEPRECATED_IN_CXX17 typedef weak_ptr<_Tp> second_argument_type;
1481#endif
1482 _LIBCPP_INLINE_VISIBILITY1677 _LIBCPP_INLINE_VISIBILITY
1483 bool operator()( weak_ptr<_Tp> const& __x, weak_ptr<_Tp> const& __y) const _NOEXCEPT1678 bool operator()( weak_ptr<_Tp> const& __x, weak_ptr<_Tp> const& __y) const _NOEXCEPT
1484 {return __x.owner_before(__y);}1679 {return __x.owner_before(__y);}
lib/libcxx/include/__memory/swap_allocator.h created+53
...@@ -0,0 +1,53 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___MEMORY_SWAP_ALLOCATOR_H
10#define _LIBCPP___MEMORY_SWAP_ALLOCATOR_H
11
12#include <__config>
13#include <__memory/allocator_traits.h>
14#include <__type_traits/integral_constant.h>
15#include <__utility/swap.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>
24_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 void __swap_allocator(_Alloc& __a1, _Alloc& __a2, true_type)
25#if _LIBCPP_STD_VER > 11
26 _NOEXCEPT
27#else
28 _NOEXCEPT_(__is_nothrow_swappable<_Alloc>::value)
29#endif
30{
31 using _VSTD::swap;
32 swap(__a1, __a2);
33}
34
35template <typename _Alloc>
36inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 void
37__swap_allocator(_Alloc&, _Alloc&, false_type) _NOEXCEPT {}
38
39template <typename _Alloc>
40inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 void __swap_allocator(_Alloc& __a1, _Alloc& __a2)
41#if _LIBCPP_STD_VER > 11
42 _NOEXCEPT
43#else
44 _NOEXCEPT_(__is_nothrow_swappable<_Alloc>::value)
45#endif
46{
47 _VSTD::__swap_allocator(
48 __a1, __a2, integral_constant<bool, allocator_traits<_Alloc>::propagate_on_container_swap::value>());
49}
50
51_LIBCPP_END_NAMESPACE_STD
52
53#endif // _LIBCPP___MEMORY_SWAP_ALLOCATOR_H
lib/libcxx/include/__memory/temporary_buffer.h+7-4
...@@ -11,18 +11,19 @@...@@ -11,18 +11,19 @@
11#define _LIBCPP___MEMORY_TEMPORARY_BUFFER_H11#define _LIBCPP___MEMORY_TEMPORARY_BUFFER_H
1212
13#include <__config>13#include <__config>
14#include <__type_traits/alignment_of.h>
15#include <__utility/pair.h>
14#include <cstddef>16#include <cstddef>
15#include <new>17#include <new>
16#include <utility> // pair
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
20#endif21#endif
2122
22_LIBCPP_BEGIN_NAMESPACE_STD23_LIBCPP_BEGIN_NAMESPACE_STD
2324
24template <class _Tp>25template <class _Tp>
25_LIBCPP_NODISCARD_EXT _LIBCPP_NO_CFI26_LIBCPP_NODISCARD_EXT _LIBCPP_NO_CFI _LIBCPP_DEPRECATED_IN_CXX17
26pair<_Tp*, ptrdiff_t>27pair<_Tp*, ptrdiff_t>
27get_temporary_buffer(ptrdiff_t __n) _NOEXCEPT28get_temporary_buffer(ptrdiff_t __n) _NOEXCEPT
28{29{
...@@ -67,7 +68,7 @@ get_temporary_buffer(ptrdiff_t __n) _NOEXCEPT...@@ -67,7 +68,7 @@ get_temporary_buffer(ptrdiff_t __n) _NOEXCEPT
67}68}
6869
69template <class _Tp>70template <class _Tp>
70inline _LIBCPP_INLINE_VISIBILITY71inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_DEPRECATED_IN_CXX17
71void return_temporary_buffer(_Tp* __p) _NOEXCEPT72void return_temporary_buffer(_Tp* __p) _NOEXCEPT
72{73{
73 _VSTD::__libcpp_deallocate_unsized((void*)__p, _LIBCPP_ALIGNOF(_Tp));74 _VSTD::__libcpp_deallocate_unsized((void*)__p, _LIBCPP_ALIGNOF(_Tp));
...@@ -75,8 +76,10 @@ void return_temporary_buffer(_Tp* __p) _NOEXCEPT...@@ -75,8 +76,10 @@ void return_temporary_buffer(_Tp* __p) _NOEXCEPT
7576
76struct __return_temporary_buffer77struct __return_temporary_buffer
77{78{
79_LIBCPP_SUPPRESS_DEPRECATED_PUSH
78 template <class _Tp>80 template <class _Tp>
79 _LIBCPP_INLINE_VISIBILITY void operator()(_Tp* __p) const {_VSTD::return_temporary_buffer(__p);}81 _LIBCPP_INLINE_VISIBILITY void operator()(_Tp* __p) const {_VSTD::return_temporary_buffer(__p);}
82_LIBCPP_SUPPRESS_DEPRECATED_POP
80};83};
8184
82_LIBCPP_END_NAMESPACE_STD85_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__memory/uninitialized_algorithms.h+295-3
...@@ -10,15 +10,24 @@...@@ -10,15 +10,24 @@
10#ifndef _LIBCPP___MEMORY_UNINITIALIZED_ALGORITHMS_H10#ifndef _LIBCPP___MEMORY_UNINITIALIZED_ALGORITHMS_H
11#define _LIBCPP___MEMORY_UNINITIALIZED_ALGORITHMS_H11#define _LIBCPP___MEMORY_UNINITIALIZED_ALGORITHMS_H
1212
13#include <__algorithm/copy.h>
14#include <__algorithm/move.h>
13#include <__config>15#include <__config>
16#include <__iterator/iterator_traits.h>
17#include <__iterator/reverse_iterator.h>
14#include <__memory/addressof.h>18#include <__memory/addressof.h>
19#include <__memory/allocator_traits.h>
15#include <__memory/construct_at.h>20#include <__memory/construct_at.h>
21#include <__memory/pointer_traits.h>
16#include <__memory/voidify.h>22#include <__memory/voidify.h>
17#include <iterator>23#include <__type_traits/is_constant_evaluated.h>
18#include <utility>24#include <__utility/move.h>
25#include <__utility/pair.h>
26#include <__utility/transaction.h>
27#include <type_traits>
1928
20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)29#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
21#pragma GCC system_header30# pragma GCC system_header
22#endif31#endif
2332
24_LIBCPP_BEGIN_NAMESPACE_STD33_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -343,8 +352,291 @@ uninitialized_move_n(_InputIterator __ifirst, _Size __n, _ForwardIterator __ofir...@@ -343,8 +352,291 @@ uninitialized_move_n(_InputIterator __ifirst, _Size __n, _ForwardIterator __ofir
343 __unreachable_sentinel(), __iter_move);352 __unreachable_sentinel(), __iter_move);
344}353}
345354
355// TODO: Rewrite this to iterate left to right and use reverse_iterators when calling
356// Destroys every element in the range [first, last) FROM RIGHT TO LEFT using allocator
357// destruction. If elements are themselves C-style arrays, they are recursively destroyed
358// in the same manner.
359//
360// This function assumes that destructors do not throw, and that the allocator is bound to
361// the correct type.
362template<class _Alloc, class _BidirIter, class = __enable_if_t<
363 __is_cpp17_bidirectional_iterator<_BidirIter>::value
364>>
365_LIBCPP_HIDE_FROM_ABI
366constexpr void __allocator_destroy_multidimensional(_Alloc& __alloc, _BidirIter __first, _BidirIter __last) noexcept {
367 using _ValueType = typename iterator_traits<_BidirIter>::value_type;
368 static_assert(is_same_v<typename allocator_traits<_Alloc>::value_type, _ValueType>,
369 "The allocator should already be rebound to the correct type");
370
371 if (__first == __last)
372 return;
373
374 if constexpr (is_array_v<_ValueType>) {
375 static_assert(!__libcpp_is_unbounded_array<_ValueType>::value,
376 "arrays of unbounded arrays don't exist, but if they did we would mess up here");
377
378 using _Element = remove_extent_t<_ValueType>;
379 __allocator_traits_rebind_t<_Alloc, _Element> __elem_alloc(__alloc);
380 do {
381 --__last;
382 decltype(auto) __array = *__last;
383 std::__allocator_destroy_multidimensional(__elem_alloc, __array, __array + extent_v<_ValueType>);
384 } while (__last != __first);
385 } else {
386 do {
387 --__last;
388 allocator_traits<_Alloc>::destroy(__alloc, std::addressof(*__last));
389 } while (__last != __first);
390 }
391}
392
393// Constructs the object at the given location using the allocator's construct method.
394//
395// If the object being constructed is an array, each element of the array is allocator-constructed,
396// recursively. If an exception is thrown during the construction of an array, the initialized
397// elements are destroyed in reverse order of initialization using allocator destruction.
398//
399// This function assumes that the allocator is bound to the correct type.
400template<class _Alloc, class _Tp>
401_LIBCPP_HIDE_FROM_ABI
402constexpr void __allocator_construct_at(_Alloc& __alloc, _Tp* __loc) {
403 static_assert(is_same_v<typename allocator_traits<_Alloc>::value_type, _Tp>,
404 "The allocator should already be rebound to the correct type");
405
406 if constexpr (is_array_v<_Tp>) {
407 using _Element = remove_extent_t<_Tp>;
408 __allocator_traits_rebind_t<_Alloc, _Element> __elem_alloc(__alloc);
409 size_t __i = 0;
410 _Tp& __array = *__loc;
411
412 // If an exception is thrown, destroy what we have constructed so far in reverse order.
413 __transaction __guard([&]() { std::__allocator_destroy_multidimensional(__elem_alloc, __array, __array + __i); });
414 for (; __i != extent_v<_Tp>; ++__i) {
415 std::__allocator_construct_at(__elem_alloc, std::addressof(__array[__i]));
416 }
417 __guard.__complete();
418 } else {
419 allocator_traits<_Alloc>::construct(__alloc, __loc);
420 }
421}
422
423// Constructs the object at the given location using the allocator's construct method, passing along
424// the provided argument.
425//
426// If the object being constructed is an array, the argument is also assumed to be an array. Each
427// each element of the array being constructed is allocator-constructed from the corresponding
428// element of the argument array. If an exception is thrown during the construction of an array,
429// the initialized elements are destroyed in reverse order of initialization using allocator
430// destruction.
431//
432// This function assumes that the allocator is bound to the correct type.
433template<class _Alloc, class _Tp, class _Arg>
434_LIBCPP_HIDE_FROM_ABI
435constexpr void __allocator_construct_at(_Alloc& __alloc, _Tp* __loc, _Arg const& __arg) {
436 static_assert(is_same_v<typename allocator_traits<_Alloc>::value_type, _Tp>,
437 "The allocator should already be rebound to the correct type");
438
439 if constexpr (is_array_v<_Tp>) {
440 static_assert(is_array_v<_Arg>,
441 "Provided non-array initialization argument to __allocator_construct_at when "
442 "trying to construct an array.");
443
444 using _Element = remove_extent_t<_Tp>;
445 __allocator_traits_rebind_t<_Alloc, _Element> __elem_alloc(__alloc);
446 size_t __i = 0;
447 _Tp& __array = *__loc;
448
449 // If an exception is thrown, destroy what we have constructed so far in reverse order.
450 __transaction __guard([&]() { std::__allocator_destroy_multidimensional(__elem_alloc, __array, __array + __i); });
451 for (; __i != extent_v<_Tp>; ++__i) {
452 std::__allocator_construct_at(__elem_alloc, std::addressof(__array[__i]), __arg[__i]);
453 }
454 __guard.__complete();
455 } else {
456 allocator_traits<_Alloc>::construct(__alloc, __loc, __arg);
457 }
458}
459
460// Given a range starting at it and containing n elements, initializes each element in the
461// range from left to right using the construct method of the allocator (rebound to the
462// correct type).
463//
464// If an exception is thrown, the initialized elements are destroyed in reverse order of
465// initialization using allocator_traits destruction. If the elements in the range are C-style
466// arrays, they are initialized element-wise using allocator construction, and recursively so.
467template<class _Alloc, class _BidirIter, class _Tp, class _Size = typename iterator_traits<_BidirIter>::difference_type>
468_LIBCPP_HIDE_FROM_ABI
469constexpr void __uninitialized_allocator_fill_n(_Alloc& __alloc, _BidirIter __it, _Size __n, _Tp const& __value) {
470 using _ValueType = typename iterator_traits<_BidirIter>::value_type;
471 __allocator_traits_rebind_t<_Alloc, _ValueType> __value_alloc(__alloc);
472 _BidirIter __begin = __it;
473
474 // If an exception is thrown, destroy what we have constructed so far in reverse order.
475 __transaction __guard([&]() { std::__allocator_destroy_multidimensional(__value_alloc, __begin, __it); });
476 for (; __n != 0; --__n, ++__it) {
477 std::__allocator_construct_at(__value_alloc, std::addressof(*__it), __value);
478 }
479 __guard.__complete();
480}
481
482// Same as __uninitialized_allocator_fill_n, but doesn't pass any initialization argument
483// to the allocator's construct method, which results in value initialization.
484template<class _Alloc, class _BidirIter, class _Size = typename iterator_traits<_BidirIter>::difference_type>
485_LIBCPP_HIDE_FROM_ABI
486constexpr void __uninitialized_allocator_value_construct_n(_Alloc& __alloc, _BidirIter __it, _Size __n) {
487 using _ValueType = typename iterator_traits<_BidirIter>::value_type;
488 __allocator_traits_rebind_t<_Alloc, _ValueType> __value_alloc(__alloc);
489 _BidirIter __begin = __it;
490
491 // If an exception is thrown, destroy what we have constructed so far in reverse order.
492 __transaction __guard([&]() { std::__allocator_destroy_multidimensional(__value_alloc, __begin, __it); });
493 for (; __n != 0; --__n, ++__it) {
494 std::__allocator_construct_at(__value_alloc, std::addressof(*__it));
495 }
496 __guard.__complete();
497}
498
346#endif // _LIBCPP_STD_VER > 14499#endif // _LIBCPP_STD_VER > 14
347500
501// Destroy all elements in [__first, __last) from left to right using allocator destruction.
502template <class _Alloc, class _Iter, class _Sent>
503_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void
504__allocator_destroy(_Alloc& __alloc, _Iter __first, _Sent __last) {
505 for (; __first != __last; ++__first)
506 allocator_traits<_Alloc>::destroy(__alloc, std::__to_address(__first));
507}
508
509template <class _Alloc, class _Iter>
510class _AllocatorDestroyRangeReverse {
511public:
512 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
513 _AllocatorDestroyRangeReverse(_Alloc& __alloc, _Iter& __first, _Iter& __last)
514 : __alloc_(__alloc), __first_(__first), __last_(__last) {}
515
516 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 void operator()() const {
517 std::__allocator_destroy(__alloc_, std::reverse_iterator<_Iter>(__last_), std::reverse_iterator<_Iter>(__first_));
518 }
519
520private:
521 _Alloc& __alloc_;
522 _Iter& __first_;
523 _Iter& __last_;
524};
525
526// Copy-construct [__first1, __last1) in [__first2, __first2 + N), where N is distance(__first1, __last1).
527//
528// The caller has to ensure that __first2 can hold at least N uninitialized elements. If an exception is thrown the
529// already copied elements are destroyed in reverse order of their construction.
530template <class _Alloc, class _Iter1, class _Sent1, class _Iter2>
531_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _Iter2
532__uninitialized_allocator_copy(_Alloc& __alloc, _Iter1 __first1, _Sent1 __last1, _Iter2 __first2) {
533#ifndef _LIBCPP_NO_EXCEPTIONS
534 auto __destruct_first = __first2;
535 try {
536#endif
537 while (__first1 != __last1) {
538 allocator_traits<_Alloc>::construct(__alloc, std::__to_address(__first2), *__first1);
539 ++__first1;
540 ++__first2;
541 }
542#ifndef _LIBCPP_NO_EXCEPTIONS
543 } catch (...) {
544 _AllocatorDestroyRangeReverse<_Alloc, _Iter2>(__alloc, __destruct_first, __first2)();
545 throw;
546 }
547#endif
548 return __first2;
549}
550
551template <class _Alloc, class _Type>
552struct __allocator_has_trivial_copy_construct : _Not<__has_construct<_Alloc, _Type*, const _Type&> > {};
553
554template <class _Type>
555struct __allocator_has_trivial_copy_construct<allocator<_Type>, _Type> : true_type {};
556
557template <class _Alloc,
558 class _Type,
559 class _RawType = typename remove_const<_Type>::type,
560 __enable_if_t<
561 // using _RawType because of the allocator<T const> extension
562 is_trivially_copy_constructible<_RawType>::value && is_trivially_copy_assignable<_RawType>::value &&
563 __allocator_has_trivial_copy_construct<_Alloc, _RawType>::value>* = nullptr>
564_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _Type*
565__uninitialized_allocator_copy(_Alloc&, const _Type* __first1, const _Type* __last1, _Type* __first2) {
566 // TODO: Remove the const_cast once we drop support for std::allocator<T const>
567 if (__libcpp_is_constant_evaluated()) {
568 while (__first1 != __last1) {
569 std::__construct_at(std::__to_address(__first2), *__first1);
570 ++__first1;
571 ++__first2;
572 }
573 return __first2;
574 } else {
575 return std::copy(__first1, __last1, const_cast<_RawType*>(__first2));
576 }
577}
578
579// Move-construct the elements [__first1, __last1) into [__first2, __first2 + N)
580// if the move constructor is noexcept, where N is distance(__first1, __last1).
581//
582// Otherwise try to copy all elements. If an exception is thrown the already copied
583// elements are destroyed in reverse order of their construction.
584template <class _Alloc, class _Iter1, class _Sent1, class _Iter2>
585_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _Iter2 __uninitialized_allocator_move_if_noexcept(
586 _Alloc& __alloc, _Iter1 __first1, _Sent1 __last1, _Iter2 __first2) {
587 static_assert(__is_cpp17_move_insertable<_Alloc>::value,
588 "The specified type does not meet the requirements of Cpp17MoveInsertable");
589#ifndef _LIBCPP_NO_EXCEPTIONS
590 auto __destruct_first = __first2;
591 try {
592#endif
593 while (__first1 != __last1) {
594#ifndef _LIBCPP_NO_EXCEPTIONS
595 allocator_traits<_Alloc>::construct(__alloc, std::__to_address(__first2), std::move_if_noexcept(*__first1));
596#else
597 allocator_traits<_Alloc>::construct(__alloc, std::__to_address(__first2), std::move(*__first1));
598#endif
599 ++__first1;
600 ++__first2;
601 }
602#ifndef _LIBCPP_NO_EXCEPTIONS
603 } catch (...) {
604 _AllocatorDestroyRangeReverse<_Alloc, _Iter2>(__alloc, __destruct_first, __first2)();
605 throw;
606 }
607#endif
608 return __first2;
609}
610
611template <class _Alloc, class _Type>
612struct __allocator_has_trivial_move_construct : _Not<__has_construct<_Alloc, _Type*, _Type&&> > {};
613
614template <class _Type>
615struct __allocator_has_trivial_move_construct<allocator<_Type>, _Type> : true_type {};
616
617#ifndef _LIBCPP_COMPILER_GCC
618template <
619 class _Alloc,
620 class _Iter1,
621 class _Iter2,
622 class _Type = typename iterator_traits<_Iter1>::value_type,
623 class = __enable_if_t<is_trivially_move_constructible<_Type>::value && is_trivially_move_assignable<_Type>::value &&
624 __allocator_has_trivial_move_construct<_Alloc, _Type>::value> >
625_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _Iter2
626__uninitialized_allocator_move_if_noexcept(_Alloc&, _Iter1 __first1, _Iter1 __last1, _Iter2 __first2) {
627 if (__libcpp_is_constant_evaluated()) {
628 while (__first1 != __last1) {
629 std::__construct_at(std::__to_address(__first2), std::move(*__first1));
630 ++__first1;
631 ++__first2;
632 }
633 return __first2;
634 } else {
635 return std::move(__first1, __last1, __first2);
636 }
637}
638#endif // _LIBCPP_COMPILER_GCC
639
348_LIBCPP_END_NAMESPACE_STD640_LIBCPP_END_NAMESPACE_STD
349641
350#endif // _LIBCPP___MEMORY_UNINITIALIZED_ALGORITHMS_H642#endif // _LIBCPP___MEMORY_UNINITIALIZED_ALGORITHMS_H
lib/libcxx/include/__memory/unique_ptr.h+8-19
...@@ -13,20 +13,16 @@...@@ -13,20 +13,16 @@
13#include <__config>13#include <__config>
14#include <__functional/hash.h>14#include <__functional/hash.h>
15#include <__functional/operations.h>15#include <__functional/operations.h>
16#include <__functional_base>
17#include <__memory/allocator_traits.h> // __pointer16#include <__memory/allocator_traits.h> // __pointer
17#include <__memory/auto_ptr.h>
18#include <__memory/compressed_pair.h>18#include <__memory/compressed_pair.h>
19#include <__utility/forward.h>19#include <__utility/forward.h>
20#include <__utility/move.h>
20#include <cstddef>21#include <cstddef>
21#include <type_traits>22#include <type_traits>
22#include <utility>
23
24#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
25# include <__memory/auto_ptr.h>
26#endif
2723
28#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)24#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
29#pragma GCC system_header25# pragma GCC system_header
30#endif26#endif
3127
32_LIBCPP_BEGIN_NAMESPACE_STD28_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -47,10 +43,8 @@ struct _LIBCPP_TEMPLATE_VIS default_delete {...@@ -47,10 +43,8 @@ struct _LIBCPP_TEMPLATE_VIS default_delete {
47 0) _NOEXCEPT {}43 0) _NOEXCEPT {}
4844
49 _LIBCPP_INLINE_VISIBILITY void operator()(_Tp* __ptr) const _NOEXCEPT {45 _LIBCPP_INLINE_VISIBILITY void operator()(_Tp* __ptr) const _NOEXCEPT {
50 static_assert(sizeof(_Tp) > 0,46 static_assert(sizeof(_Tp) >= 0, "cannot delete an incomplete type");
51 "default_delete can not delete incomplete type");47 static_assert(!is_void<_Tp>::value, "cannot delete an incomplete type");
52 static_assert(!is_void<_Tp>::value,
53 "default_delete can not delete incomplete type");
54 delete __ptr;48 delete __ptr;
55 }49 }
56};50};
...@@ -78,10 +72,7 @@ public:...@@ -78,10 +72,7 @@ public:
78 _LIBCPP_INLINE_VISIBILITY72 _LIBCPP_INLINE_VISIBILITY
79 typename _EnableIfConvertible<_Up>::type73 typename _EnableIfConvertible<_Up>::type
80 operator()(_Up* __ptr) const _NOEXCEPT {74 operator()(_Up* __ptr) const _NOEXCEPT {
81 static_assert(sizeof(_Tp) > 0,75 static_assert(sizeof(_Up) >= 0, "cannot delete an incomplete type");
82 "default_delete can not delete incomplete type");
83 static_assert(!is_void<_Tp>::value,
84 "default_delete can not delete void type");
85 delete[] __ptr;76 delete[] __ptr;
86 }77 }
87};78};
...@@ -144,7 +135,7 @@ private:...@@ -144,7 +135,7 @@ private:
144 typename __dependent_type<_DeleterSFINAE, _Dummy>::__bad_rval_ref_type;135 typename __dependent_type<_DeleterSFINAE, _Dummy>::__bad_rval_ref_type;
145136
146 template <bool _Dummy, class _Deleter = typename __dependent_type<137 template <bool _Dummy, class _Deleter = typename __dependent_type<
147 __identity<deleter_type>, _Dummy>::type>138 __type_identity<deleter_type>, _Dummy>::type>
148 using _EnableIfDeleterDefaultConstructible _LIBCPP_NODEBUG =139 using _EnableIfDeleterDefaultConstructible _LIBCPP_NODEBUG =
149 typename enable_if<is_default_constructible<_Deleter>::value &&140 typename enable_if<is_default_constructible<_Deleter>::value &&
150 !is_pointer<_Deleter>::value>::type;141 !is_pointer<_Deleter>::value>::type;
...@@ -264,7 +255,6 @@ public:...@@ -264,7 +255,6 @@ public:
264 unique_ptr& operator=(unique_ptr const&) = delete;255 unique_ptr& operator=(unique_ptr const&) = delete;
265#endif256#endif
266257
267
268 _LIBCPP_INLINE_VISIBILITY258 _LIBCPP_INLINE_VISIBILITY
269 ~unique_ptr() { reset(); }259 ~unique_ptr() { reset(); }
270260
...@@ -359,7 +349,7 @@ private:...@@ -359,7 +349,7 @@ private:
359 typename __dependent_type<_DeleterSFINAE, _Dummy>::__bad_rval_ref_type;349 typename __dependent_type<_DeleterSFINAE, _Dummy>::__bad_rval_ref_type;
360350
361 template <bool _Dummy, class _Deleter = typename __dependent_type<351 template <bool _Dummy, class _Deleter = typename __dependent_type<
362 __identity<deleter_type>, _Dummy>::type>352 __type_identity<deleter_type>, _Dummy>::type>
363 using _EnableIfDeleterDefaultConstructible _LIBCPP_NODEBUG =353 using _EnableIfDeleterDefaultConstructible _LIBCPP_NODEBUG =
364 typename enable_if<is_default_constructible<_Deleter>::value &&354 typename enable_if<is_default_constructible<_Deleter>::value &&
365 !is_pointer<_Deleter>::value>::type;355 !is_pointer<_Deleter>::value>::type;
...@@ -486,7 +476,6 @@ public:...@@ -486,7 +476,6 @@ public:
486 unique_ptr(unique_ptr const&) = delete;476 unique_ptr(unique_ptr const&) = delete;
487 unique_ptr& operator=(unique_ptr const&) = delete;477 unique_ptr& operator=(unique_ptr const&) = delete;
488#endif478#endif
489
490public:479public:
491 _LIBCPP_INLINE_VISIBILITY480 _LIBCPP_INLINE_VISIBILITY
492 ~unique_ptr() { reset(); }481 ~unique_ptr() { reset(); }
lib/libcxx/include/__memory/uses_allocator.h+4-5
...@@ -15,7 +15,7 @@...@@ -15,7 +15,7 @@
15#include <type_traits>15#include <type_traits>
1616
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header18# pragma GCC system_header
19#endif19#endif
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -24,11 +24,10 @@ template <class _Tp>...@@ -24,11 +24,10 @@ template <class _Tp>
24struct __has_allocator_type24struct __has_allocator_type
25{25{
26private:26private:
27 struct __two {char __lx; char __lxx;};27 template <class _Up> static false_type __test(...);
28 template <class _Up> static __two __test(...);28 template <class _Up> static true_type __test(typename _Up::allocator_type* = 0);
29 template <class _Up> static char __test(typename _Up::allocator_type* = 0);
30public:29public:
31 static const bool value = sizeof(__test<_Tp>(0)) == 1;30 static const bool value = decltype(__test<_Tp>(0))::value;
32};31};
3332
34template <class _Tp, class _Alloc, bool = __has_allocator_type<_Tp>::value>33template <class _Tp, class _Alloc, bool = __has_allocator_type<_Tp>::value>
lib/libcxx/include/__mutex_base+7-12
...@@ -10,15 +10,18 @@...@@ -10,15 +10,18 @@
10#ifndef _LIBCPP___MUTEX_BASE10#ifndef _LIBCPP___MUTEX_BASE
11#define _LIBCPP___MUTEX_BASE11#define _LIBCPP___MUTEX_BASE
1212
13#include <__chrono/duration.h>
14#include <__chrono/steady_clock.h>
15#include <__chrono/system_clock.h>
16#include <__chrono/time_point.h>
13#include <__config>17#include <__config>
14#include <__threading_support>18#include <__threading_support>
15#include <chrono>
16#include <ratio>19#include <ratio>
17#include <system_error>20#include <system_error>
18#include <time.h>21#include <time.h>
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
2326
24_LIBCPP_PUSH_MACROS27_LIBCPP_PUSH_MACROS
...@@ -335,11 +338,7 @@ private:...@@ -335,11 +338,7 @@ private:
335338
336template <class _Rep, class _Period>339template <class _Rep, class _Period>
337inline _LIBCPP_INLINE_VISIBILITY340inline _LIBCPP_INLINE_VISIBILITY
338typename enable_if341__enable_if_t<is_floating_point<_Rep>::value, chrono::nanoseconds>
339<
340 is_floating_point<_Rep>::value,
341 chrono::nanoseconds
342>::type
343__safe_nanosecond_cast(chrono::duration<_Rep, _Period> __d)342__safe_nanosecond_cast(chrono::duration<_Rep, _Period> __d)
344{343{
345 using namespace chrono;344 using namespace chrono;
...@@ -362,11 +361,7 @@ __safe_nanosecond_cast(chrono::duration<_Rep, _Period> __d)...@@ -362,11 +361,7 @@ __safe_nanosecond_cast(chrono::duration<_Rep, _Period> __d)
362361
363template <class _Rep, class _Period>362template <class _Rep, class _Period>
364inline _LIBCPP_INLINE_VISIBILITY363inline _LIBCPP_INLINE_VISIBILITY
365typename enable_if364__enable_if_t<!is_floating_point<_Rep>::value, chrono::nanoseconds>
366<
367 !is_floating_point<_Rep>::value,
368 chrono::nanoseconds
369>::type
370__safe_nanosecond_cast(chrono::duration<_Rep, _Period> __d)365__safe_nanosecond_cast(chrono::duration<_Rep, _Period> __d)
371{366{
372 using namespace chrono;367 using namespace chrono;
lib/libcxx/include/__node_handle+2-2
...@@ -58,13 +58,13 @@ public:...@@ -58,13 +58,13 @@ public:
5858
59*/59*/
6060
61#include <__assert>
61#include <__config>62#include <__config>
62#include <__debug>
63#include <memory>63#include <memory>
64#include <optional>64#include <optional>
6565
66#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)66#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
67#pragma GCC system_header67# pragma GCC system_header
68#endif68#endif
6969
70_LIBCPP_BEGIN_NAMESPACE_STD70_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__nullptr deleted-61
...@@ -1,61 +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_NULLPTR
11#define _LIBCPP_NULLPTR
12
13#include <__config>
14
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16#pragma GCC system_header
17#endif
18
19#ifdef _LIBCPP_HAS_NO_NULLPTR
20
21_LIBCPP_BEGIN_NAMESPACE_STD
22
23struct _LIBCPP_TEMPLATE_VIS nullptr_t
24{
25 void* __lx;
26
27 struct __nat {int __for_bool_;};
28
29 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR nullptr_t() : __lx(0) {}
30 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR nullptr_t(int __nat::*) : __lx(0) {}
31
32 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR operator int __nat::*() const {return 0;}
33
34 template <class _Tp>
35 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
36 operator _Tp* () const {return 0;}
37
38 template <class _Tp, class _Up>
39 _LIBCPP_INLINE_VISIBILITY
40 operator _Tp _Up::* () const {return 0;}
41
42 friend _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bool operator==(nullptr_t, nullptr_t) {return true;}
43 friend _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bool operator!=(nullptr_t, nullptr_t) {return false;}
44};
45
46inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR nullptr_t __get_nullptr_t() {return nullptr_t(0);}
47
48#define nullptr _VSTD::__get_nullptr_t()
49
50_LIBCPP_END_NAMESPACE_STD
51
52#else // _LIBCPP_HAS_NO_NULLPTR
53
54namespace std
55{
56 typedef decltype(nullptr) nullptr_t;
57} // namespace std
58
59#endif // _LIBCPP_HAS_NO_NULLPTR
60
61#endif // _LIBCPP_NULLPTR
lib/libcxx/include/__numeric/accumulate.h+1-1
...@@ -14,7 +14,7 @@...@@ -14,7 +14,7 @@
14#include <__utility/move.h>14#include <__utility/move.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
18#endif18#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__numeric/gcd_lcm.h+1-1
...@@ -10,8 +10,8 @@...@@ -10,8 +10,8 @@
10#ifndef _LIBCPP___NUMERIC_GCD_LCM_H10#ifndef _LIBCPP___NUMERIC_GCD_LCM_H
11#define _LIBCPP___NUMERIC_GCD_LCM_H11#define _LIBCPP___NUMERIC_GCD_LCM_H
1212
13#include <__assert>
13#include <__config>14#include <__config>
14#include <__debug>
15#include <limits>15#include <limits>
16#include <type_traits>16#include <type_traits>
1717
lib/libcxx/include/__numeric/inner_product.h+1-1
...@@ -14,7 +14,7 @@...@@ -14,7 +14,7 @@
14#include <__utility/move.h>14#include <__utility/move.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
18#endif18#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__numeric/iota.h+3-3
...@@ -21,10 +21,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -21,10 +21,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD
21template <class _ForwardIterator, class _Tp>21template <class _ForwardIterator, class _Tp>
22_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1722_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
23void23void
24iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __value_)24iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __value)
25{25{
26 for (; __first != __last; ++__first, (void) ++__value_)26 for (; __first != __last; ++__first, (void) ++__value)
27 *__first = __value_;27 *__first = __value;
28}28}
2929
30_LIBCPP_END_NAMESPACE_STD30_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__random/bernoulli_distribution.h+3-1
...@@ -10,11 +10,12 @@...@@ -10,11 +10,12 @@
10#define _LIBCPP___RANDOM_BERNOULLI_DISTRIBUTION_H10#define _LIBCPP___RANDOM_BERNOULLI_DISTRIBUTION_H
1111
12#include <__config>12#include <__config>
13#include <__random/is_valid.h>
13#include <__random/uniform_real_distribution.h>14#include <__random/uniform_real_distribution.h>
14#include <iosfwd>15#include <iosfwd>
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
18#endif19#endif
1920
20_LIBCPP_PUSH_MACROS21_LIBCPP_PUSH_MACROS
...@@ -103,6 +104,7 @@ inline...@@ -103,6 +104,7 @@ inline
103bernoulli_distribution::result_type104bernoulli_distribution::result_type
104bernoulli_distribution::operator()(_URNG& __g, const param_type& __p)105bernoulli_distribution::operator()(_URNG& __g, const param_type& __p)
105{106{
107 static_assert(__libcpp_random_is_valid_urng<_URNG>::value, "");
106 uniform_real_distribution<double> __gen;108 uniform_real_distribution<double> __gen;
107 return __gen(__g) < __p.p();109 return __gen(__g) < __p.p();
108}110}
lib/libcxx/include/__random/binomial_distribution.h+4-1
...@@ -10,12 +10,13 @@...@@ -10,12 +10,13 @@
10#define _LIBCPP___RANDOM_BINOMIAL_DISTRIBUTION_H10#define _LIBCPP___RANDOM_BINOMIAL_DISTRIBUTION_H
1111
12#include <__config>12#include <__config>
13#include <__random/is_valid.h>
13#include <__random/uniform_real_distribution.h>14#include <__random/uniform_real_distribution.h>
14#include <cmath>15#include <cmath>
15#include <iosfwd>16#include <iosfwd>
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
19#endif20#endif
2021
21_LIBCPP_PUSH_MACROS22_LIBCPP_PUSH_MACROS
...@@ -26,6 +27,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -26,6 +27,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
26template<class _IntType = int>27template<class _IntType = int>
27class _LIBCPP_TEMPLATE_VIS binomial_distribution28class _LIBCPP_TEMPLATE_VIS binomial_distribution
28{29{
30 static_assert(__libcpp_random_is_valid_inttype<_IntType>::value, "IntType must be a supported integer type");
29public:31public:
30 // types32 // types
31 typedef _IntType result_type;33 typedef _IntType result_type;
...@@ -146,6 +148,7 @@ template<class _URNG>...@@ -146,6 +148,7 @@ template<class _URNG>
146_IntType148_IntType
147binomial_distribution<_IntType>::operator()(_URNG& __g, const param_type& __pr)149binomial_distribution<_IntType>::operator()(_URNG& __g, const param_type& __pr)
148{150{
151 static_assert(__libcpp_random_is_valid_urng<_URNG>::value, "");
149 if (__pr.__t_ == 0 || __pr.__p_ == 0)152 if (__pr.__t_ == 0 || __pr.__p_ == 0)
150 return 0;153 return 0;
151 if (__pr.__p_ == 1)154 if (__pr.__p_ == 1)
lib/libcxx/include/__random/cauchy_distribution.h+3-1
...@@ -10,13 +10,14 @@...@@ -10,13 +10,14 @@
10#define _LIBCPP___RANDOM_CAUCHY_DISTRIBUTION_H10#define _LIBCPP___RANDOM_CAUCHY_DISTRIBUTION_H
1111
12#include <__config>12#include <__config>
13#include <__random/is_valid.h>
13#include <__random/uniform_real_distribution.h>14#include <__random/uniform_real_distribution.h>
14#include <cmath>15#include <cmath>
15#include <iosfwd>16#include <iosfwd>
16#include <limits>17#include <limits>
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
20#endif21#endif
2122
22_LIBCPP_PUSH_MACROS23_LIBCPP_PUSH_MACROS
...@@ -116,6 +117,7 @@ inline...@@ -116,6 +117,7 @@ inline
116_RealType117_RealType
117cauchy_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)118cauchy_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
118{119{
120 static_assert(__libcpp_random_is_valid_urng<_URNG>::value, "");
119 uniform_real_distribution<result_type> __gen;121 uniform_real_distribution<result_type> __gen;
120 // purposefully let tan arg get as close to pi/2 as it wants, tan will return a finite122 // purposefully let tan arg get as close to pi/2 as it wants, tan will return a finite
121 return __p.a() + __p.b() * _VSTD::tan(3.1415926535897932384626433832795 * __gen(__g));123 return __p.a() + __p.b() * _VSTD::tan(3.1415926535897932384626433832795 * __gen(__g));
lib/libcxx/include/__random/chi_squared_distribution.h+1-1
...@@ -15,7 +15,7 @@...@@ -15,7 +15,7 @@
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)
18#pragma GCC system_header18# pragma GCC system_header
19#endif19#endif
2020
21_LIBCPP_PUSH_MACROS21_LIBCPP_PUSH_MACROS
lib/libcxx/include/__random/clamp_to_integral.h+1-1
...@@ -15,7 +15,7 @@...@@ -15,7 +15,7 @@
15#include <type_traits>15#include <type_traits>
1616
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header18# pragma GCC system_header
19#endif19#endif
2020
21_LIBCPP_PUSH_MACROS21_LIBCPP_PUSH_MACROS
lib/libcxx/include/__random/default_random_engine.h+1-1
...@@ -13,7 +13,7 @@...@@ -13,7 +13,7 @@
13#include <__random/linear_congruential_engine.h>13#include <__random/linear_congruential_engine.h>
1414
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16#pragma GCC system_header16# pragma GCC system_header
17#endif17#endif
1818
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__random/discard_block_engine.h+1-1
...@@ -17,7 +17,7 @@...@@ -17,7 +17,7 @@
17#include <type_traits>17#include <type_traits>
1818
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20#pragma GCC system_header20# pragma GCC system_header
21#endif21#endif
2222
23_LIBCPP_PUSH_MACROS23_LIBCPP_PUSH_MACROS
lib/libcxx/include/__random/discrete_distribution.h+4-1
...@@ -11,6 +11,7 @@...@@ -11,6 +11,7 @@
1111
12#include <__algorithm/upper_bound.h>12#include <__algorithm/upper_bound.h>
13#include <__config>13#include <__config>
14#include <__random/is_valid.h>
14#include <__random/uniform_real_distribution.h>15#include <__random/uniform_real_distribution.h>
15#include <cstddef>16#include <cstddef>
16#include <iosfwd>17#include <iosfwd>
...@@ -18,7 +19,7 @@...@@ -18,7 +19,7 @@
18#include <vector>19#include <vector>
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
22#endif23#endif
2324
24_LIBCPP_PUSH_MACROS25_LIBCPP_PUSH_MACROS
...@@ -29,6 +30,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -29,6 +30,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
29template<class _IntType = int>30template<class _IntType = int>
30class _LIBCPP_TEMPLATE_VIS discrete_distribution31class _LIBCPP_TEMPLATE_VIS discrete_distribution
31{32{
33 static_assert(__libcpp_random_is_valid_inttype<_IntType>::value, "IntType must be a supported integer type");
32public:34public:
33 // types35 // types
34 typedef _IntType result_type;36 typedef _IntType result_type;
...@@ -211,6 +213,7 @@ template<class _URNG>...@@ -211,6 +213,7 @@ template<class _URNG>
211_IntType213_IntType
212discrete_distribution<_IntType>::operator()(_URNG& __g, const param_type& __p)214discrete_distribution<_IntType>::operator()(_URNG& __g, const param_type& __p)
213{215{
216 static_assert(__libcpp_random_is_valid_urng<_URNG>::value, "");
214 uniform_real_distribution<double> __gen;217 uniform_real_distribution<double> __gen;
215 return static_cast<_IntType>(218 return static_cast<_IntType>(
216 _VSTD::upper_bound(__p.__p_.begin(), __p.__p_.end(), __gen(__g)) -219 _VSTD::upper_bound(__p.__p_.begin(), __p.__p_.end(), __gen(__g)) -
lib/libcxx/include/__random/exponential_distribution.h+3-1
...@@ -11,13 +11,14 @@...@@ -11,13 +11,14 @@
1111
12#include <__config>12#include <__config>
13#include <__random/generate_canonical.h>13#include <__random/generate_canonical.h>
14#include <__random/is_valid.h>
14#include <__random/uniform_real_distribution.h>15#include <__random/uniform_real_distribution.h>
15#include <cmath>16#include <cmath>
16#include <iosfwd>17#include <iosfwd>
17#include <limits>18#include <limits>
1819
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20#pragma GCC system_header21# pragma GCC system_header
21#endif22#endif
2223
23_LIBCPP_PUSH_MACROS24_LIBCPP_PUSH_MACROS
...@@ -109,6 +110,7 @@ template<class _URNG>...@@ -109,6 +110,7 @@ template<class _URNG>
109_RealType110_RealType
110exponential_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)111exponential_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
111{112{
113 static_assert(__libcpp_random_is_valid_urng<_URNG>::value, "");
112 return -_VSTD::log114 return -_VSTD::log
113 (115 (
114 result_type(1) -116 result_type(1) -
lib/libcxx/include/__random/extreme_value_distribution.h+3-1
...@@ -10,13 +10,14 @@...@@ -10,13 +10,14 @@
10#define _LIBCPP___RANDOM_EXTREME_VALUE_DISTRIBUTION_H10#define _LIBCPP___RANDOM_EXTREME_VALUE_DISTRIBUTION_H
1111
12#include <__config>12#include <__config>
13#include <__random/is_valid.h>
13#include <__random/uniform_real_distribution.h>14#include <__random/uniform_real_distribution.h>
14#include <cmath>15#include <cmath>
15#include <iosfwd>16#include <iosfwd>
16#include <limits>17#include <limits>
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
20#endif21#endif
2122
22_LIBCPP_PUSH_MACROS23_LIBCPP_PUSH_MACROS
...@@ -116,6 +117,7 @@ template<class _URNG>...@@ -116,6 +117,7 @@ template<class _URNG>
116_RealType117_RealType
117extreme_value_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)118extreme_value_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
118{119{
120 static_assert(__libcpp_random_is_valid_urng<_URNG>::value, "");
119 return __p.a() - __p.b() *121 return __p.a() - __p.b() *
120 _VSTD::log(-_VSTD::log(1-uniform_real_distribution<result_type>()(__g)));122 _VSTD::log(-_VSTD::log(1-uniform_real_distribution<result_type>()(__g)));
121}123}
lib/libcxx/include/__random/fisher_f_distribution.h+3-1
...@@ -11,11 +11,12 @@...@@ -11,11 +11,12 @@
1111
12#include <__config>12#include <__config>
13#include <__random/gamma_distribution.h>13#include <__random/gamma_distribution.h>
14#include <__random/is_valid.h>
14#include <iosfwd>15#include <iosfwd>
15#include <limits>16#include <limits>
1617
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header19# pragma GCC system_header
19#endif20#endif
2021
21_LIBCPP_PUSH_MACROS22_LIBCPP_PUSH_MACROS
...@@ -114,6 +115,7 @@ template<class _URNG>...@@ -114,6 +115,7 @@ template<class _URNG>
114_RealType115_RealType
115fisher_f_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)116fisher_f_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
116{117{
118 static_assert(__libcpp_random_is_valid_urng<_URNG>::value, "");
117 gamma_distribution<result_type> __gdm(__p.m() * result_type(.5));119 gamma_distribution<result_type> __gdm(__p.m() * result_type(.5));
118 gamma_distribution<result_type> __gdn(__p.n() * result_type(.5));120 gamma_distribution<result_type> __gdn(__p.n() * result_type(.5));
119 return __p.n() * __gdm(__g) / (__p.m() * __gdn(__g));121 return __p.n() * __gdm(__g) / (__p.m() * __gdn(__g));
lib/libcxx/include/__random/gamma_distribution.h+3-1
...@@ -11,13 +11,14 @@...@@ -11,13 +11,14 @@
1111
12#include <__config>12#include <__config>
13#include <__random/exponential_distribution.h>13#include <__random/exponential_distribution.h>
14#include <__random/is_valid.h>
14#include <__random/uniform_real_distribution.h>15#include <__random/uniform_real_distribution.h>
15#include <cmath>16#include <cmath>
16#include <iosfwd>17#include <iosfwd>
17#include <limits>18#include <limits>
1819
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20#pragma GCC system_header21# pragma GCC system_header
21#endif22#endif
2223
23_LIBCPP_PUSH_MACROS24_LIBCPP_PUSH_MACROS
...@@ -117,6 +118,7 @@ template<class _URNG>...@@ -117,6 +118,7 @@ template<class _URNG>
117_RealType118_RealType
118gamma_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)119gamma_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
119{120{
121 static_assert(__libcpp_random_is_valid_urng<_URNG>::value, "");
120 result_type __a = __p.alpha();122 result_type __a = __p.alpha();
121 uniform_real_distribution<result_type> __gen(0, 1);123 uniform_real_distribution<result_type> __gen(0, 1);
122 exponential_distribution<result_type> __egen;124 exponential_distribution<result_type> __egen;
lib/libcxx/include/__random/generate_canonical.h+1-1
...@@ -16,7 +16,7 @@...@@ -16,7 +16,7 @@
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)
19#pragma GCC system_header19# pragma GCC system_header
20#endif20#endif
2121
22_LIBCPP_PUSH_MACROS22_LIBCPP_PUSH_MACROS
lib/libcxx/include/__random/geometric_distribution.h+3-1
...@@ -10,12 +10,13 @@...@@ -10,12 +10,13 @@
10#define _LIBCPP___RANDOM_GEOMETRIC_DISTRIBUTION_H10#define _LIBCPP___RANDOM_GEOMETRIC_DISTRIBUTION_H
1111
12#include <__config>12#include <__config>
13#include <__random/is_valid.h>
13#include <__random/negative_binomial_distribution.h>14#include <__random/negative_binomial_distribution.h>
14#include <iosfwd>15#include <iosfwd>
15#include <limits>16#include <limits>
1617
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header19# pragma GCC system_header
19#endif20#endif
2021
21_LIBCPP_PUSH_MACROS22_LIBCPP_PUSH_MACROS
...@@ -26,6 +27,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -26,6 +27,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
26template<class _IntType = int>27template<class _IntType = int>
27class _LIBCPP_TEMPLATE_VIS geometric_distribution28class _LIBCPP_TEMPLATE_VIS geometric_distribution
28{29{
30 static_assert(__libcpp_random_is_valid_inttype<_IntType>::value, "IntType must be a supported integer type");
29public:31public:
30 // types32 // types
31 typedef _IntType result_type;33 typedef _IntType result_type;
lib/libcxx/include/__random/independent_bits_engine.h+1-1
...@@ -18,7 +18,7 @@...@@ -18,7 +18,7 @@
18#include <type_traits>18#include <type_traits>
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
22#endif22#endif
2323
24_LIBCPP_PUSH_MACROS24_LIBCPP_PUSH_MACROS
lib/libcxx/include/__random/is_seed_sequence.h+1-1
...@@ -13,7 +13,7 @@...@@ -13,7 +13,7 @@
13#include <type_traits>13#include <type_traits>
1414
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16#pragma GCC system_header16# pragma GCC system_header
17#endif17#endif
1818
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__random/is_valid.h created+61
...@@ -0,0 +1,61 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___RANDOM_IS_VALID_H
10#define _LIBCPP___RANDOM_IS_VALID_H
11
12#include <__config>
13#include <cstdint>
14#include <type_traits>
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// [rand.req.genl]/1.5:
23// The effect of instantiating a template that has a template type parameter
24// named IntType is undefined unless the corresponding template argument is
25// cv-unqualified and is one of short, int, long, long long, unsigned short,
26// unsigned int, unsigned long, or unsigned long long.
27
28template<class> struct __libcpp_random_is_valid_inttype : false_type {};
29template<> struct __libcpp_random_is_valid_inttype<int8_t> : true_type {}; // extension
30template<> struct __libcpp_random_is_valid_inttype<short> : true_type {};
31template<> struct __libcpp_random_is_valid_inttype<int> : true_type {};
32template<> struct __libcpp_random_is_valid_inttype<long> : true_type {};
33template<> struct __libcpp_random_is_valid_inttype<long long> : true_type {};
34template<> struct __libcpp_random_is_valid_inttype<uint8_t> : true_type {}; // extension
35template<> struct __libcpp_random_is_valid_inttype<unsigned short> : true_type {};
36template<> struct __libcpp_random_is_valid_inttype<unsigned int> : true_type {};
37template<> struct __libcpp_random_is_valid_inttype<unsigned long> : true_type {};
38template<> struct __libcpp_random_is_valid_inttype<unsigned long long> : true_type {};
39
40#ifndef _LIBCPP_HAS_NO_INT128
41template<> struct __libcpp_random_is_valid_inttype<__int128_t> : true_type {}; // extension
42template<> struct __libcpp_random_is_valid_inttype<__uint128_t> : true_type {}; // extension
43#endif // _LIBCPP_HAS_NO_INT128
44
45// [rand.req.urng]/3:
46// A class G meets the uniform random bit generator requirements if G models
47// uniform_random_bit_generator, invoke_result_t<G&> is an unsigned integer type,
48// and G provides a nested typedef-name result_type that denotes the same type
49// as invoke_result_t<G&>.
50// (In particular, reject URNGs with signed result_types; our distributions cannot
51// handle such generator types.)
52
53template<class, class = void> struct __libcpp_random_is_valid_urng : false_type {};
54template<class _Gp> struct __libcpp_random_is_valid_urng<_Gp, __enable_if_t<
55 is_unsigned<typename _Gp::result_type>::value &&
56 _IsSame<decltype(declval<_Gp&>()()), typename _Gp::result_type>::value
57> > : true_type {};
58
59_LIBCPP_END_NAMESPACE_STD
60
61#endif // _LIBCPP___RANDOM_IS_VALID_H
lib/libcxx/include/__random/knuth_b.h+1-1
...@@ -14,7 +14,7 @@...@@ -14,7 +14,7 @@
14#include <__random/shuffle_order_engine.h>14#include <__random/shuffle_order_engine.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
18#endif18#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__random/linear_congruential_engine.h+3-3
...@@ -16,7 +16,7 @@...@@ -16,7 +16,7 @@
16#include <type_traits>16#include <type_traits>
1717
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19#pragma GCC system_header19# pragma GCC system_header
20#endif20#endif
2121
22_LIBCPP_PUSH_MACROS22_LIBCPP_PUSH_MACROS
...@@ -218,8 +218,8 @@ private:...@@ -218,8 +218,8 @@ private:
218 static_assert(__m == 0 || __c < __m, "linear_congruential_engine invalid parameters");218 static_assert(__m == 0 || __c < __m, "linear_congruential_engine invalid parameters");
219 static_assert(is_unsigned<_UIntType>::value, "_UIntType must be unsigned type");219 static_assert(is_unsigned<_UIntType>::value, "_UIntType must be unsigned type");
220public:220public:
221 static _LIBCPP_CONSTEXPR const result_type _Min = __c == 0u ? 1u: 0u;221 static _LIBCPP_CONSTEXPR const result_type _Min = __c == 0u ? 1u : 0u;
222 static _LIBCPP_CONSTEXPR const result_type _Max = __m - 1u;222 static _LIBCPP_CONSTEXPR const result_type _Max = __m - _UIntType(1u);
223 static_assert(_Min < _Max, "linear_congruential_engine invalid parameters");223 static_assert(_Min < _Max, "linear_congruential_engine invalid parameters");
224224
225 // engine characteristics225 // engine characteristics
lib/libcxx/include/__random/log2.h+1-1
...@@ -14,7 +14,7 @@...@@ -14,7 +14,7 @@
14#include <type_traits>14#include <type_traits>
1515
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17#pragma GCC system_header17# pragma GCC system_header
18#endif18#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__random/lognormal_distribution.h+1-1
...@@ -16,7 +16,7 @@...@@ -16,7 +16,7 @@
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)
19#pragma GCC system_header19# pragma GCC system_header
20#endif20#endif
2121
22_LIBCPP_PUSH_MACROS22_LIBCPP_PUSH_MACROS
lib/libcxx/include/__random/mersenne_twister_engine.h+1-1
...@@ -20,7 +20,7 @@...@@ -20,7 +20,7 @@
20#include <type_traits>20#include <type_traits>
2121
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23#pragma GCC system_header23# pragma GCC system_header
24#endif24#endif
2525
26_LIBCPP_PUSH_MACROS26_LIBCPP_PUSH_MACROS
lib/libcxx/include/__random/negative_binomial_distribution.h+9-2
...@@ -12,12 +12,13 @@...@@ -12,12 +12,13 @@
12#include <__config>12#include <__config>
13#include <__random/bernoulli_distribution.h>13#include <__random/bernoulli_distribution.h>
14#include <__random/gamma_distribution.h>14#include <__random/gamma_distribution.h>
15#include <__random/is_valid.h>
15#include <__random/poisson_distribution.h>16#include <__random/poisson_distribution.h>
16#include <iosfwd>17#include <iosfwd>
17#include <limits>18#include <limits>
1819
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20#pragma GCC system_header21# pragma GCC system_header
21#endif22#endif
2223
23_LIBCPP_PUSH_MACROS24_LIBCPP_PUSH_MACROS
...@@ -28,6 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -28,6 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
28template<class _IntType = int>29template<class _IntType = int>
29class _LIBCPP_TEMPLATE_VIS negative_binomial_distribution30class _LIBCPP_TEMPLATE_VIS negative_binomial_distribution
30{31{
32 static_assert(__libcpp_random_is_valid_inttype<_IntType>::value, "IntType must be a supported integer type");
31public:33public:
32 // types34 // types
33 typedef _IntType result_type;35 typedef _IntType result_type;
...@@ -116,9 +118,12 @@ template<class _URNG>...@@ -116,9 +118,12 @@ template<class _URNG>
116_IntType118_IntType
117negative_binomial_distribution<_IntType>::operator()(_URNG& __urng, const param_type& __pr)119negative_binomial_distribution<_IntType>::operator()(_URNG& __urng, const param_type& __pr)
118{120{
121 static_assert(__libcpp_random_is_valid_urng<_URNG>::value, "");
119 result_type __k = __pr.k();122 result_type __k = __pr.k();
120 double __p = __pr.p();123 double __p = __pr.p();
121 if (__k <= 21 * __p)124 // When the number of bits in _IntType is small, we are too likely to
125 // overflow __f below to use this technique.
126 if (__k <= 21 * __p && sizeof(_IntType) > 1)
122 {127 {
123 bernoulli_distribution __gen(__p);128 bernoulli_distribution __gen(__p);
124 result_type __f = 0;129 result_type __f = 0;
...@@ -130,6 +135,8 @@ negative_binomial_distribution<_IntType>::operator()(_URNG& __urng, const param_...@@ -130,6 +135,8 @@ negative_binomial_distribution<_IntType>::operator()(_URNG& __urng, const param_
130 else135 else
131 ++__f;136 ++__f;
132 }137 }
138 _LIBCPP_ASSERT(__f >= 0, "std::negative_binomial_distribution should never produce negative values. "
139 "This is almost certainly a signed integer overflow issue on __f.");
133 return __f;140 return __f;
134 }141 }
135 return poisson_distribution<result_type>(gamma_distribution<double>142 return poisson_distribution<result_type>(gamma_distribution<double>
lib/libcxx/include/__random/normal_distribution.h+3-1
...@@ -10,13 +10,14 @@...@@ -10,13 +10,14 @@
10#define _LIBCPP___RANDOM_NORMAL_DISTRIBUTION_H10#define _LIBCPP___RANDOM_NORMAL_DISTRIBUTION_H
1111
12#include <__config>12#include <__config>
13#include <__random/is_valid.h>
13#include <__random/uniform_real_distribution.h>14#include <__random/uniform_real_distribution.h>
14#include <cmath>15#include <cmath>
15#include <iosfwd>16#include <iosfwd>
16#include <limits>17#include <limits>
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
20#endif21#endif
2122
22_LIBCPP_PUSH_MACROS23_LIBCPP_PUSH_MACROS
...@@ -131,6 +132,7 @@ template<class _URNG>...@@ -131,6 +132,7 @@ template<class _URNG>
131_RealType132_RealType
132normal_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)133normal_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
133{134{
135 static_assert(__libcpp_random_is_valid_urng<_URNG>::value, "");
134 result_type _Up;136 result_type _Up;
135 if (_V_hot_)137 if (_V_hot_)
136 {138 {
lib/libcxx/include/__random/piecewise_constant_distribution.h+13-11
...@@ -11,13 +11,14 @@...@@ -11,13 +11,14 @@
1111
12#include <__algorithm/upper_bound.h>12#include <__algorithm/upper_bound.h>
13#include <__config>13#include <__config>
14#include <__random/is_valid.h>
14#include <__random/uniform_real_distribution.h>15#include <__random/uniform_real_distribution.h>
15#include <iosfwd>16#include <iosfwd>
16#include <numeric>17#include <numeric>
17#include <vector>18#include <vector>
1819
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20#pragma GCC system_header21# pragma GCC system_header
21#endif22#endif
2223
23_LIBCPP_PUSH_MACROS24_LIBCPP_PUSH_MACROS
...@@ -42,8 +43,8 @@ public:...@@ -42,8 +43,8 @@ public:
4243
43 param_type();44 param_type();
44 template<class _InputIteratorB, class _InputIteratorW>45 template<class _InputIteratorB, class _InputIteratorW>
45 param_type(_InputIteratorB __fB, _InputIteratorB __lB,46 param_type(_InputIteratorB __f_b, _InputIteratorB __l_b,
46 _InputIteratorW __fW);47 _InputIteratorW __f_w);
47#ifndef _LIBCPP_CXX03_LANG48#ifndef _LIBCPP_CXX03_LANG
48 template<class _UnaryOperation>49 template<class _UnaryOperation>
49 param_type(initializer_list<result_type> __bl, _UnaryOperation __fw);50 param_type(initializer_list<result_type> __bl, _UnaryOperation __fw);
...@@ -93,10 +94,10 @@ public:...@@ -93,10 +94,10 @@ public:
93 piecewise_constant_distribution() {}94 piecewise_constant_distribution() {}
94 template<class _InputIteratorB, class _InputIteratorW>95 template<class _InputIteratorB, class _InputIteratorW>
95 _LIBCPP_INLINE_VISIBILITY96 _LIBCPP_INLINE_VISIBILITY
96 piecewise_constant_distribution(_InputIteratorB __fB,97 piecewise_constant_distribution(_InputIteratorB __f_b,
97 _InputIteratorB __lB,98 _InputIteratorB __l_b,
98 _InputIteratorW __fW)99 _InputIteratorW __f_w)
99 : __p_(__fB, __lB, __fW) {}100 : __p_(__f_b, __l_b, __f_w) {}
100101
101#ifndef _LIBCPP_CXX03_LANG102#ifndef _LIBCPP_CXX03_LANG
102 template<class _UnaryOperation>103 template<class _UnaryOperation>
...@@ -214,8 +215,8 @@ piecewise_constant_distribution<_RealType>::param_type::param_type()...@@ -214,8 +215,8 @@ piecewise_constant_distribution<_RealType>::param_type::param_type()
214template<class _RealType>215template<class _RealType>
215template<class _InputIteratorB, class _InputIteratorW>216template<class _InputIteratorB, class _InputIteratorW>
216piecewise_constant_distribution<_RealType>::param_type::param_type(217piecewise_constant_distribution<_RealType>::param_type::param_type(
217 _InputIteratorB __fB, _InputIteratorB __lB, _InputIteratorW __fW)218 _InputIteratorB __f_b, _InputIteratorB __l_b, _InputIteratorW __f_w)
218 : __b_(__fB, __lB)219 : __b_(__f_b, __l_b)
219{220{
220 if (__b_.size() < 2)221 if (__b_.size() < 2)
221 {222 {
...@@ -228,8 +229,8 @@ piecewise_constant_distribution<_RealType>::param_type::param_type(...@@ -228,8 +229,8 @@ piecewise_constant_distribution<_RealType>::param_type::param_type(
228 else229 else
229 {230 {
230 __densities_.reserve(__b_.size() - 1);231 __densities_.reserve(__b_.size() - 1);
231 for (size_t __i = 0; __i < __b_.size() - 1; ++__i, ++__fW)232 for (size_t __i = 0; __i < __b_.size() - 1; ++__i, ++__f_w)
232 __densities_.push_back(*__fW);233 __densities_.push_back(*__f_w);
233 __init();234 __init();
234 }235 }
235}236}
...@@ -284,6 +285,7 @@ template<class _URNG>...@@ -284,6 +285,7 @@ template<class _URNG>
284_RealType285_RealType
285piecewise_constant_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)286piecewise_constant_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
286{287{
288 static_assert(__libcpp_random_is_valid_urng<_URNG>::value, "");
287 typedef uniform_real_distribution<result_type> _Gen;289 typedef uniform_real_distribution<result_type> _Gen;
288 result_type __u = _Gen()(__g);290 result_type __u = _Gen()(__g);
289 ptrdiff_t __k = _VSTD::upper_bound(__p.__areas_.begin(), __p.__areas_.end(),291 ptrdiff_t __k = _VSTD::upper_bound(__p.__areas_.begin(), __p.__areas_.end(),
lib/libcxx/include/__random/piecewise_linear_distribution.h+13-11
...@@ -11,13 +11,14 @@...@@ -11,13 +11,14 @@
1111
12#include <__algorithm/upper_bound.h>12#include <__algorithm/upper_bound.h>
13#include <__config>13#include <__config>
14#include <__random/is_valid.h>
14#include <__random/uniform_real_distribution.h>15#include <__random/uniform_real_distribution.h>
15#include <iosfwd>16#include <iosfwd>
16#include <numeric>17#include <numeric>
17#include <vector>18#include <vector>
1819
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20#pragma GCC system_header21# pragma GCC system_header
21#endif22#endif
2223
23_LIBCPP_PUSH_MACROS24_LIBCPP_PUSH_MACROS
...@@ -42,8 +43,8 @@ public:...@@ -42,8 +43,8 @@ public:
4243
43 param_type();44 param_type();
44 template<class _InputIteratorB, class _InputIteratorW>45 template<class _InputIteratorB, class _InputIteratorW>
45 param_type(_InputIteratorB __fB, _InputIteratorB __lB,46 param_type(_InputIteratorB __f_b, _InputIteratorB __l_b,
46 _InputIteratorW __fW);47 _InputIteratorW __f_w);
47#ifndef _LIBCPP_CXX03_LANG48#ifndef _LIBCPP_CXX03_LANG
48 template<class _UnaryOperation>49 template<class _UnaryOperation>
49 param_type(initializer_list<result_type> __bl, _UnaryOperation __fw);50 param_type(initializer_list<result_type> __bl, _UnaryOperation __fw);
...@@ -93,10 +94,10 @@ public:...@@ -93,10 +94,10 @@ public:
93 piecewise_linear_distribution() {}94 piecewise_linear_distribution() {}
94 template<class _InputIteratorB, class _InputIteratorW>95 template<class _InputIteratorB, class _InputIteratorW>
95 _LIBCPP_INLINE_VISIBILITY96 _LIBCPP_INLINE_VISIBILITY
96 piecewise_linear_distribution(_InputIteratorB __fB,97 piecewise_linear_distribution(_InputIteratorB __f_b,
97 _InputIteratorB __lB,98 _InputIteratorB __l_b,
98 _InputIteratorW __fW)99 _InputIteratorW __f_w)
99 : __p_(__fB, __lB, __fW) {}100 : __p_(__f_b, __l_b, __f_w) {}
100101
101#ifndef _LIBCPP_CXX03_LANG102#ifndef _LIBCPP_CXX03_LANG
102 template<class _UnaryOperation>103 template<class _UnaryOperation>
...@@ -218,8 +219,8 @@ piecewise_linear_distribution<_RealType>::param_type::param_type()...@@ -218,8 +219,8 @@ piecewise_linear_distribution<_RealType>::param_type::param_type()
218template<class _RealType>219template<class _RealType>
219template<class _InputIteratorB, class _InputIteratorW>220template<class _InputIteratorB, class _InputIteratorW>
220piecewise_linear_distribution<_RealType>::param_type::param_type(221piecewise_linear_distribution<_RealType>::param_type::param_type(
221 _InputIteratorB __fB, _InputIteratorB __lB, _InputIteratorW __fW)222 _InputIteratorB __f_b, _InputIteratorB __l_b, _InputIteratorW __f_w)
222 : __b_(__fB, __lB)223 : __b_(__f_b, __l_b)
223{224{
224 if (__b_.size() < 2)225 if (__b_.size() < 2)
225 {226 {
...@@ -232,8 +233,8 @@ piecewise_linear_distribution<_RealType>::param_type::param_type(...@@ -232,8 +233,8 @@ piecewise_linear_distribution<_RealType>::param_type::param_type(
232 else233 else
233 {234 {
234 __densities_.reserve(__b_.size());235 __densities_.reserve(__b_.size());
235 for (size_t __i = 0; __i < __b_.size(); ++__i, ++__fW)236 for (size_t __i = 0; __i < __b_.size(); ++__i, ++__f_w)
236 __densities_.push_back(*__fW);237 __densities_.push_back(*__f_w);
237 __init();238 __init();
238 }239 }
239}240}
...@@ -289,6 +290,7 @@ template<class _URNG>...@@ -289,6 +290,7 @@ template<class _URNG>
289_RealType290_RealType
290piecewise_linear_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)291piecewise_linear_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
291{292{
293 static_assert(__libcpp_random_is_valid_urng<_URNG>::value, "");
292 typedef uniform_real_distribution<result_type> _Gen;294 typedef uniform_real_distribution<result_type> _Gen;
293 result_type __u = _Gen()(__g);295 result_type __u = _Gen()(__g);
294 ptrdiff_t __k = _VSTD::upper_bound(__p.__areas_.begin(), __p.__areas_.end(),296 ptrdiff_t __k = _VSTD::upper_bound(__p.__areas_.begin(), __p.__areas_.end(),
lib/libcxx/include/__random/poisson_distribution.h+4-1
...@@ -12,6 +12,7 @@...@@ -12,6 +12,7 @@
12#include <__config>12#include <__config>
13#include <__random/clamp_to_integral.h>13#include <__random/clamp_to_integral.h>
14#include <__random/exponential_distribution.h>14#include <__random/exponential_distribution.h>
15#include <__random/is_valid.h>
15#include <__random/normal_distribution.h>16#include <__random/normal_distribution.h>
16#include <__random/uniform_real_distribution.h>17#include <__random/uniform_real_distribution.h>
17#include <cmath>18#include <cmath>
...@@ -19,7 +20,7 @@...@@ -19,7 +20,7 @@
19#include <limits>20#include <limits>
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
25_LIBCPP_PUSH_MACROS26_LIBCPP_PUSH_MACROS
...@@ -30,6 +31,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -30,6 +31,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
30template<class _IntType = int>31template<class _IntType = int>
31class _LIBCPP_TEMPLATE_VIS poisson_distribution32class _LIBCPP_TEMPLATE_VIS poisson_distribution
32{33{
34 static_assert(__libcpp_random_is_valid_inttype<_IntType>::value, "IntType must be a supported integer type");
33public:35public:
34 // types36 // types
35 typedef _IntType result_type;37 typedef _IntType result_type;
...@@ -157,6 +159,7 @@ template<class _URNG>...@@ -157,6 +159,7 @@ template<class _URNG>
157_IntType159_IntType
158poisson_distribution<_IntType>::operator()(_URNG& __urng, const param_type& __pr)160poisson_distribution<_IntType>::operator()(_URNG& __urng, const param_type& __pr)
159{161{
162 static_assert(__libcpp_random_is_valid_urng<_URNG>::value, "");
160 double __tx;163 double __tx;
161 uniform_real_distribution<double> __urd;164 uniform_real_distribution<double> __urd;
162 if (__pr.__mean_ < 10)165 if (__pr.__mean_ < 10)
lib/libcxx/include/__random/random_device.h+4-8
...@@ -13,7 +13,7 @@...@@ -13,7 +13,7 @@
13#include <string>13#include <string>
1414
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16#pragma GCC system_header16# pragma GCC system_header
17#endif17#endif
1818
19_LIBCPP_PUSH_MACROS19_LIBCPP_PUSH_MACROS
...@@ -28,10 +28,8 @@ class _LIBCPP_TYPE_VIS random_device...@@ -28,10 +28,8 @@ class _LIBCPP_TYPE_VIS random_device
28#ifdef _LIBCPP_USING_DEV_RANDOM28#ifdef _LIBCPP_USING_DEV_RANDOM
29 int __f_;29 int __f_;
30#elif !defined(_LIBCPP_ABI_NO_RANDOM_DEVICE_COMPATIBILITY_LAYOUT)30#elif !defined(_LIBCPP_ABI_NO_RANDOM_DEVICE_COMPATIBILITY_LAYOUT)
31# if defined(__clang__)31 _LIBCPP_DIAGNOSTIC_PUSH
32# pragma clang diagnostic push32 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wunused-private-field")
33# pragma clang diagnostic ignored "-Wunused-private-field"
34# endif
3533
36 // Apple platforms used to use the `_LIBCPP_USING_DEV_RANDOM` code path, and now34 // Apple platforms used to use the `_LIBCPP_USING_DEV_RANDOM` code path, and now
37 // use `arc4random()` as of this comment. In order to avoid breaking the ABI, we35 // use `arc4random()` as of this comment. In order to avoid breaking the ABI, we
...@@ -42,9 +40,7 @@ class _LIBCPP_TYPE_VIS random_device...@@ -42,9 +40,7 @@ class _LIBCPP_TYPE_VIS random_device
4240
43 // ... vendors can add workarounds here if they switch to a different representation ...41 // ... vendors can add workarounds here if they switch to a different representation ...
4442
45# if defined(__clang__)43 _LIBCPP_DIAGNOSTIC_POP
46# pragma clang diagnostic pop
47# endif
48#endif44#endif
4945
50public:46public:
lib/libcxx/include/__random/ranlux.h+1-1
...@@ -15,7 +15,7 @@...@@ -15,7 +15,7 @@
15#include <cstdint>15#include <cstdint>
1616
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header18# pragma GCC system_header
19#endif19#endif
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__random/seed_seq.h+50-26
...@@ -17,7 +17,7 @@...@@ -17,7 +17,7 @@
17#include <vector>17#include <vector>
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
21#endif21#endif
2222
23_LIBCPP_PUSH_MACROS23_LIBCPP_PUSH_MACROS
...@@ -109,39 +109,63 @@ seed_seq::generate(_RandomAccessIterator __first, _RandomAccessIterator __last)...@@ -109,39 +109,63 @@ seed_seq::generate(_RandomAccessIterator __first, _RandomAccessIterator __last)
109 __first[__q] += __r;109 __first[__q] += __r;
110 __first[0] = __r;110 __first[0] = __r;
111 }111 }
112 // Initialize indexing terms used with if statements as an optimization to
113 // avoid calculating modulo n on every loop iteration for each term.
114 size_t __kmodn = 0; // __k % __n
115 size_t __k1modn = __n - 1; // (__k - 1) % __n
116 size_t __kpmodn = __p % __n; // (__k + __p) % __n
117 size_t __kqmodn = __q % __n; // (__k + __q) % __n
118
112 for (size_t __k = 1; __k <= __s; ++__k)119 for (size_t __k = 1; __k <= __s; ++__k)
113 {120 {
114 const size_t __kmodn = __k % __n;121 if (++__kmodn == __n)
115 const size_t __kpmodn = (__k + __p) % __n;122 __kmodn = 0;
116 result_type __r = 1664525 * _Tp(__first[__kmodn] ^ __first[__kpmodn]123 if (++__k1modn == __n)
117 ^ __first[(__k - 1) % __n]);124 __k1modn = 0;
118 __first[__kpmodn] += __r;125 if (++__kpmodn == __n)
119 __r += __kmodn + __v_[__k-1];126 __kpmodn = 0;
120 __first[(__k + __q) % __n] += __r;127 if (++__kqmodn == __n)
121 __first[__kmodn] = __r;128 __kqmodn = 0;
129
130 result_type __r = 1664525 * _Tp(__first[__kmodn] ^ __first[__kpmodn] ^ __first[__k1modn]);
131 __first[__kpmodn] += __r;
132 __r += __kmodn + __v_[__k - 1];
133 __first[__kqmodn] += __r;
134 __first[__kmodn] = __r;
122 }135 }
123 for (size_t __k = __s + 1; __k < __m; ++__k)136 for (size_t __k = __s + 1; __k < __m; ++__k)
124 {137 {
125 const size_t __kmodn = __k % __n;138 if (++__kmodn == __n)
126 const size_t __kpmodn = (__k + __p) % __n;139 __kmodn = 0;
127 result_type __r = 1664525 * _Tp(__first[__kmodn] ^ __first[__kpmodn]140 if (++__k1modn == __n)
128 ^ __first[(__k - 1) % __n]);141 __k1modn = 0;
129 __first[__kpmodn] += __r;142 if (++__kpmodn == __n)
130 __r += __kmodn;143 __kpmodn = 0;
131 __first[(__k + __q) % __n] += __r;144 if (++__kqmodn == __n)
132 __first[__kmodn] = __r;145 __kqmodn = 0;
146
147 result_type __r = 1664525 * _Tp(__first[__kmodn] ^ __first[__kpmodn] ^ __first[__k1modn]);
148 __first[__kpmodn] += __r;
149 __r += __kmodn;
150 __first[__kqmodn] += __r;
151 __first[__kmodn] = __r;
133 }152 }
134 for (size_t __k = __m; __k < __m + __n; ++__k)153 for (size_t __k = __m; __k < __m + __n; ++__k)
135 {154 {
136 const size_t __kmodn = __k % __n;155 if (++__kmodn == __n)
137 const size_t __kpmodn = (__k + __p) % __n;156 __kmodn = 0;
138 result_type __r = 1566083941 * _Tp(__first[__kmodn] +157 if (++__k1modn == __n)
139 __first[__kpmodn] +158 __k1modn = 0;
140 __first[(__k - 1) % __n]);159 if (++__kpmodn == __n)
141 __first[__kpmodn] ^= __r;160 __kpmodn = 0;
142 __r -= __kmodn;161 if (++__kqmodn == __n)
143 __first[(__k + __q) % __n] ^= __r;162 __kqmodn = 0;
144 __first[__kmodn] = __r;163
164 result_type __r = 1566083941 * _Tp(__first[__kmodn] + __first[__kpmodn] + __first[__k1modn]);
165 __first[__kpmodn] ^= __r;
166 __r -= __kmodn;
167 __first[__kqmodn] ^= __r;
168 __first[__kmodn] = __r;
145 }169 }
146 }170 }
147}171}
lib/libcxx/include/__random/shuffle_order_engine.h+1-1
...@@ -18,7 +18,7 @@...@@ -18,7 +18,7 @@
18#include <type_traits>18#include <type_traits>
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
22#endif22#endif
2323
24_LIBCPP_PUSH_MACROS24_LIBCPP_PUSH_MACROS
lib/libcxx/include/__random/student_t_distribution.h+3-1
...@@ -11,13 +11,14 @@...@@ -11,13 +11,14 @@
1111
12#include <__config>12#include <__config>
13#include <__random/gamma_distribution.h>13#include <__random/gamma_distribution.h>
14#include <__random/is_valid.h>
14#include <__random/normal_distribution.h>15#include <__random/normal_distribution.h>
15#include <cmath>16#include <cmath>
16#include <iosfwd>17#include <iosfwd>
17#include <limits>18#include <limits>
1819
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20#pragma GCC system_header21# pragma GCC system_header
21#endif22#endif
2223
23_LIBCPP_PUSH_MACROS24_LIBCPP_PUSH_MACROS
...@@ -111,6 +112,7 @@ template<class _URNG>...@@ -111,6 +112,7 @@ template<class _URNG>
111_RealType112_RealType
112student_t_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)113student_t_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
113{114{
115 static_assert(__libcpp_random_is_valid_urng<_URNG>::value, "");
114 gamma_distribution<result_type> __gd(__p.n() * .5, 2);116 gamma_distribution<result_type> __gd(__p.n() * .5, 2);
115 return __nd_(__g) * _VSTD::sqrt(__p.n()/__gd(__g));117 return __nd_(__g) * _VSTD::sqrt(__p.n()/__gd(__g));
116}118}
lib/libcxx/include/__random/subtract_with_carry_engine.h+1-1
...@@ -21,7 +21,7 @@...@@ -21,7 +21,7 @@
21#include <type_traits>21#include <type_traits>
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
25#endif25#endif
2626
27_LIBCPP_PUSH_MACROS27_LIBCPP_PUSH_MACROS
lib/libcxx/include/__random/uniform_int_distribution.h+5-2
...@@ -11,6 +11,7 @@...@@ -11,6 +11,7 @@
1111
12#include <__bits>12#include <__bits>
13#include <__config>13#include <__config>
14#include <__random/is_valid.h>
14#include <__random/log2.h>15#include <__random/log2.h>
15#include <bit>16#include <bit>
16#include <cstddef>17#include <cstddef>
...@@ -20,7 +21,7 @@...@@ -20,7 +21,7 @@
20#include <type_traits>21#include <type_traits>
2122
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23#pragma GCC system_header24# pragma GCC system_header
24#endif25#endif
2526
26_LIBCPP_PUSH_MACROS27_LIBCPP_PUSH_MACROS
...@@ -155,9 +156,10 @@ __independent_bits_engine<_Engine, _UIntType>::__eval(true_type)...@@ -155,9 +156,10 @@ __independent_bits_engine<_Engine, _UIntType>::__eval(true_type)
155 return _Sp;156 return _Sp;
156}157}
157158
158template<class _IntType = int> // __int128_t is also supported as an extension here159template<class _IntType = int>
159class uniform_int_distribution160class uniform_int_distribution
160{161{
162 static_assert(__libcpp_random_is_valid_inttype<_IntType>::value, "IntType must be a supported integer type");
161public:163public:
162 // types164 // types
163 typedef _IntType result_type;165 typedef _IntType result_type;
...@@ -230,6 +232,7 @@ typename uniform_int_distribution<_IntType>::result_type...@@ -230,6 +232,7 @@ typename uniform_int_distribution<_IntType>::result_type
230uniform_int_distribution<_IntType>::operator()(_URNG& __g, const param_type& __p)232uniform_int_distribution<_IntType>::operator()(_URNG& __g, const param_type& __p)
231_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK233_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
232{234{
235 static_assert(__libcpp_random_is_valid_urng<_URNG>::value, "");
233 typedef typename conditional<sizeof(result_type) <= sizeof(uint32_t), uint32_t,236 typedef typename conditional<sizeof(result_type) <= sizeof(uint32_t), uint32_t,
234 typename make_unsigned<result_type>::type>::type _UIntType;237 typename make_unsigned<result_type>::type>::type _UIntType;
235 const _UIntType _Rp = _UIntType(__p.b()) - _UIntType(__p.a()) + _UIntType(1);238 const _UIntType _Rp = _UIntType(__p.b()) - _UIntType(__p.a()) + _UIntType(1);
lib/libcxx/include/__random/uniform_random_bit_generator.h+3-3
...@@ -16,7 +16,7 @@...@@ -16,7 +16,7 @@
16#include <type_traits>16#include <type_traits>
1717
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19#pragma GCC system_header19# pragma GCC system_header
20#endif20#endif
2121
22_LIBCPP_PUSH_MACROS22_LIBCPP_PUSH_MACROS
...@@ -24,7 +24,7 @@ _LIBCPP_PUSH_MACROS...@@ -24,7 +24,7 @@ _LIBCPP_PUSH_MACROS
2424
25_LIBCPP_BEGIN_NAMESPACE_STD25_LIBCPP_BEGIN_NAMESPACE_STD
2626
27#if !defined(_LIBCPP_HAS_NO_CONCEPTS)27#if _LIBCPP_STD_VER > 17
2828
29// [rand.req.urng]29// [rand.req.urng]
30template<class _Gen>30template<class _Gen>
...@@ -36,7 +36,7 @@ concept uniform_random_bit_generator =...@@ -36,7 +36,7 @@ concept uniform_random_bit_generator =
36 requires bool_constant<(_Gen::min() < _Gen::max())>::value;36 requires bool_constant<(_Gen::min() < _Gen::max())>::value;
37 };37 };
3838
39#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)39#endif // _LIBCPP_STD_VER > 17
4040
41_LIBCPP_END_NAMESPACE_STD41_LIBCPP_END_NAMESPACE_STD
4242
lib/libcxx/include/__random/uniform_real_distribution.h+3-1
...@@ -11,12 +11,13 @@...@@ -11,12 +11,13 @@
1111
12#include <__config>12#include <__config>
13#include <__random/generate_canonical.h>13#include <__random/generate_canonical.h>
14#include <__random/is_valid.h>
14#include <iosfwd>15#include <iosfwd>
15#include <limits>16#include <limits>
16#include <type_traits>17#include <type_traits>
1718
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19#pragma GCC system_header20# pragma GCC system_header
20#endif21#endif
2122
22_LIBCPP_PUSH_MACROS23_LIBCPP_PUSH_MACROS
...@@ -115,6 +116,7 @@ inline...@@ -115,6 +116,7 @@ inline
115typename uniform_real_distribution<_RealType>::result_type116typename uniform_real_distribution<_RealType>::result_type
116uniform_real_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)117uniform_real_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
117{118{
119 static_assert(__libcpp_random_is_valid_urng<_URNG>::value, "");
118 return (__p.b() - __p.a())120 return (__p.b() - __p.a())
119 * _VSTD::generate_canonical<_RealType, numeric_limits<_RealType>::digits>(__g)121 * _VSTD::generate_canonical<_RealType, numeric_limits<_RealType>::digits>(__g)
120 + __p.a();122 + __p.a();
lib/libcxx/include/__random/weibull_distribution.h+1-1
...@@ -16,7 +16,7 @@...@@ -16,7 +16,7 @@
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)
19#pragma GCC system_header19# pragma GCC system_header
20#endif20#endif
2121
22_LIBCPP_PUSH_MACROS22_LIBCPP_PUSH_MACROS
lib/libcxx/include/__ranges/access.h+7-10
...@@ -14,18 +14,16 @@...@@ -14,18 +14,16 @@
14#include <__iterator/concepts.h>14#include <__iterator/concepts.h>
15#include <__iterator/readable_traits.h>15#include <__iterator/readable_traits.h>
16#include <__ranges/enable_borrowed_range.h>16#include <__ranges/enable_borrowed_range.h>
17#include <__utility/as_const.h>
18#include <__utility/auto_cast.h>17#include <__utility/auto_cast.h>
19#include <concepts>
20#include <type_traits>18#include <type_traits>
2119
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23#pragma GCC system_header21# pragma GCC system_header
24#endif22#endif
2523
26_LIBCPP_BEGIN_NAMESPACE_STD24_LIBCPP_BEGIN_NAMESPACE_STD
2725
28#if !defined(_LIBCPP_HAS_NO_CONCEPTS)26#if _LIBCPP_STD_VER > 17
2927
30namespace ranges {28namespace ranges {
31 template <class _Tp>29 template <class _Tp>
...@@ -60,14 +58,14 @@ namespace __begin {...@@ -60,14 +58,14 @@ namespace __begin {
60 struct __fn {58 struct __fn {
61 template <class _Tp>59 template <class _Tp>
62 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp (&__t)[]) const noexcept60 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp (&__t)[]) const noexcept
63 requires (sizeof(_Tp) != 0) // Disallow incomplete element types.61 requires (sizeof(_Tp) >= 0) // Disallow incomplete element types.
64 {62 {
65 return __t + 0;63 return __t + 0;
66 }64 }
6765
68 template <class _Tp, size_t _Np>66 template <class _Tp, size_t _Np>
69 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp (&__t)[_Np]) const noexcept67 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp (&__t)[_Np]) const noexcept
70 requires (sizeof(_Tp) != 0) // Disallow incomplete element types.68 requires (sizeof(_Tp) >= 0) // Disallow incomplete element types.
71 {69 {
72 return __t + 0;70 return __t + 0;
73 }71 }
...@@ -130,11 +128,10 @@ namespace __end {...@@ -130,11 +128,10 @@ namespace __end {
130 { _LIBCPP_AUTO_CAST(end(__t)) } -> sentinel_for<iterator_t<_Tp>>;128 { _LIBCPP_AUTO_CAST(end(__t)) } -> sentinel_for<iterator_t<_Tp>>;
131 };129 };
132130
133 class __fn {131 struct __fn {
134 public:
135 template <class _Tp, size_t _Np>132 template <class _Tp, size_t _Np>
136 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp (&__t)[_Np]) const noexcept133 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp (&__t)[_Np]) const noexcept
137 requires (sizeof(_Tp) != 0) // Disallow incomplete element types.134 requires (sizeof(_Tp) >= 0) // Disallow incomplete element types.
138 {135 {
139 return __t + _Np;136 return __t + _Np;
140 }137 }
...@@ -220,7 +217,7 @@ inline namespace __cpo {...@@ -220,7 +217,7 @@ inline namespace __cpo {
220} // namespace __cpo217} // namespace __cpo
221} // namespace ranges218} // namespace ranges
222219
223#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)220#endif // _LIBCPP_STD_VER > 17
224221
225_LIBCPP_END_NAMESPACE_STD222_LIBCPP_END_NAMESPACE_STD
226223
lib/libcxx/include/__ranges/all.h+13-12
...@@ -23,12 +23,12 @@...@@ -23,12 +23,12 @@
23#include <type_traits>23#include <type_traits>
2424
25#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)25#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
26#pragma GCC system_header26# pragma GCC system_header
27#endif27#endif
2828
29_LIBCPP_BEGIN_NAMESPACE_STD29_LIBCPP_BEGIN_NAMESPACE_STD
3030
31#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)31#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
3232
33namespace ranges::views {33namespace ranges::views {
3434
...@@ -38,30 +38,31 @@ namespace __all {...@@ -38,30 +38,31 @@ namespace __all {
38 requires ranges::view<decay_t<_Tp>>38 requires ranges::view<decay_t<_Tp>>
39 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI39 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
40 constexpr auto operator()(_Tp&& __t) const40 constexpr auto operator()(_Tp&& __t) const
41 noexcept(noexcept(_LIBCPP_AUTO_CAST(_VSTD::forward<_Tp>(__t))))41 noexcept(noexcept(_LIBCPP_AUTO_CAST(std::forward<_Tp>(__t))))
42 -> decltype(_LIBCPP_AUTO_CAST(std::forward<_Tp>(__t)))
42 {43 {
43 return _LIBCPP_AUTO_CAST(_VSTD::forward<_Tp>(__t));44 return _LIBCPP_AUTO_CAST(std::forward<_Tp>(__t));
44 }45 }
4546
46 template<class _Tp>47 template<class _Tp>
47 requires (!ranges::view<decay_t<_Tp>>) &&48 requires (!ranges::view<decay_t<_Tp>>) &&
48 requires (_Tp&& __t) { ranges::ref_view{_VSTD::forward<_Tp>(__t)}; }49 requires (_Tp&& __t) { ranges::ref_view{std::forward<_Tp>(__t)}; }
49 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI50 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
50 constexpr auto operator()(_Tp&& __t) const51 constexpr auto operator()(_Tp&& __t) const
51 noexcept(noexcept(ranges::ref_view{_VSTD::forward<_Tp>(__t)}))52 noexcept(noexcept(ranges::ref_view{std::forward<_Tp>(__t)}))
52 {53 {
53 return ranges::ref_view{_VSTD::forward<_Tp>(__t)};54 return ranges::ref_view{std::forward<_Tp>(__t)};
54 }55 }
5556
56 template<class _Tp>57 template<class _Tp>
57 requires (!ranges::view<decay_t<_Tp>> &&58 requires (!ranges::view<decay_t<_Tp>> &&
58 !requires (_Tp&& __t) { ranges::ref_view{_VSTD::forward<_Tp>(__t)}; } &&59 !requires (_Tp&& __t) { ranges::ref_view{std::forward<_Tp>(__t)}; } &&
59 requires (_Tp&& __t) { ranges::owning_view{_VSTD::forward<_Tp>(__t)}; })60 requires (_Tp&& __t) { ranges::owning_view{std::forward<_Tp>(__t)}; })
60 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI61 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
61 constexpr auto operator()(_Tp&& __t) const62 constexpr auto operator()(_Tp&& __t) const
62 noexcept(noexcept(ranges::owning_view{_VSTD::forward<_Tp>(__t)}))63 noexcept(noexcept(ranges::owning_view{std::forward<_Tp>(__t)}))
63 {64 {
64 return ranges::owning_view{_VSTD::forward<_Tp>(__t)};65 return ranges::owning_view{std::forward<_Tp>(__t)};
65 }66 }
66 };67 };
67} // namespace __all68} // namespace __all
...@@ -75,7 +76,7 @@ using all_t = decltype(views::all(declval<_Range>()));...@@ -75,7 +76,7 @@ using all_t = decltype(views::all(declval<_Range>()));
7576
76} // namespace ranges::views77} // namespace ranges::views
7778
78#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)79#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
7980
80_LIBCPP_END_NAMESPACE_STD81_LIBCPP_END_NAMESPACE_STD
8182
lib/libcxx/include/__ranges/common_view.h+11-11
...@@ -25,12 +25,12 @@...@@ -25,12 +25,12 @@
25#include <type_traits>25#include <type_traits>
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
29#endif29#endif
3030
31_LIBCPP_BEGIN_NAMESPACE_STD31_LIBCPP_BEGIN_NAMESPACE_STD
3232
33#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)33#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
3434
35namespace ranges {35namespace ranges {
3636
...@@ -44,13 +44,13 @@ public:...@@ -44,13 +44,13 @@ public:
44 common_view() requires default_initializable<_View> = default;44 common_view() requires default_initializable<_View> = default;
4545
46 _LIBCPP_HIDE_FROM_ABI46 _LIBCPP_HIDE_FROM_ABI
47 constexpr explicit common_view(_View __v) : __base_(_VSTD::move(__v)) { }47 constexpr explicit common_view(_View __v) : __base_(std::move(__v)) { }
4848
49 _LIBCPP_HIDE_FROM_ABI49 _LIBCPP_HIDE_FROM_ABI
50 constexpr _View base() const& requires copy_constructible<_View> { return __base_; }50 constexpr _View base() const& requires copy_constructible<_View> { return __base_; }
5151
52 _LIBCPP_HIDE_FROM_ABI52 _LIBCPP_HIDE_FROM_ABI
53 constexpr _View base() && { return _VSTD::move(__base_); }53 constexpr _View base() && { return std::move(__base_); }
5454
55 _LIBCPP_HIDE_FROM_ABI55 _LIBCPP_HIDE_FROM_ABI
56 constexpr auto begin() {56 constexpr auto begin() {
...@@ -109,16 +109,16 @@ namespace __common {...@@ -109,16 +109,16 @@ namespace __common {
109 requires common_range<_Range>109 requires common_range<_Range>
110 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI110 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
111 constexpr auto operator()(_Range&& __range) const111 constexpr auto operator()(_Range&& __range) const
112 noexcept(noexcept(views::all(_VSTD::forward<_Range>(__range))))112 noexcept(noexcept(views::all(std::forward<_Range>(__range))))
113 -> decltype( views::all(_VSTD::forward<_Range>(__range)))113 -> decltype( views::all(std::forward<_Range>(__range)))
114 { return views::all(_VSTD::forward<_Range>(__range)); }114 { return views::all(std::forward<_Range>(__range)); }
115115
116 template<class _Range>116 template<class _Range>
117 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI117 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
118 constexpr auto operator()(_Range&& __range) const118 constexpr auto operator()(_Range&& __range) const
119 noexcept(noexcept(common_view{_VSTD::forward<_Range>(__range)}))119 noexcept(noexcept(common_view{std::forward<_Range>(__range)}))
120 -> decltype( common_view{_VSTD::forward<_Range>(__range)})120 -> decltype( common_view{std::forward<_Range>(__range)})
121 { return common_view{_VSTD::forward<_Range>(__range)}; }121 { return common_view{std::forward<_Range>(__range)}; }
122 };122 };
123} // namespace __common123} // namespace __common
124124
...@@ -128,7 +128,7 @@ inline namespace __cpo {...@@ -128,7 +128,7 @@ inline namespace __cpo {
128} // namespace views128} // namespace views
129} // namespace ranges129} // namespace ranges
130130
131#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)131#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
132132
133_LIBCPP_END_NAMESPACE_STD133_LIBCPP_END_NAMESPACE_STD
134134
lib/libcxx/include/__ranges/concepts.h+3-3
...@@ -27,12 +27,12 @@...@@ -27,12 +27,12 @@
27#include <type_traits>27#include <type_traits>
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
31#endif31#endif
3232
33_LIBCPP_BEGIN_NAMESPACE_STD33_LIBCPP_BEGIN_NAMESPACE_STD
3434
35#if !defined(_LIBCPP_HAS_NO_CONCEPTS)35#if _LIBCPP_STD_VER > 17
3636
37namespace ranges {37namespace ranges {
3838
...@@ -135,7 +135,7 @@ namespace ranges {...@@ -135,7 +135,7 @@ namespace ranges {
135135
136} // namespace ranges136} // namespace ranges
137137
138#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)138#endif // _LIBCPP_STD_VER > 17
139139
140_LIBCPP_END_NAMESPACE_STD140_LIBCPP_END_NAMESPACE_STD
141141
lib/libcxx/include/__ranges/copyable_box.h+18-18
...@@ -19,12 +19,12 @@...@@ -19,12 +19,12 @@
19#include <type_traits>19#include <type_traits>
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
23#endif23#endif
2424
25_LIBCPP_BEGIN_NAMESPACE_STD25_LIBCPP_BEGIN_NAMESPACE_STD
2626
27#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
2828
29// __copyable_box allows turning a type that is copy-constructible (but maybe not copy-assignable) into29// __copyable_box allows turning a type that is copy-constructible (but maybe not copy-assignable) into
30// a type that is both copy-constructible and copy-assignable. It does that by introducing an empty state30// a type that is both copy-constructible and copy-assignable. It does that by introducing an empty state
...@@ -41,7 +41,7 @@ namespace ranges {...@@ -41,7 +41,7 @@ namespace ranges {
41 // Primary template - uses std::optional and introduces an empty state in case assignment fails.41 // Primary template - uses std::optional and introduces an empty state in case assignment fails.
42 template<__copy_constructible_object _Tp>42 template<__copy_constructible_object _Tp>
43 class __copyable_box {43 class __copyable_box {
44 [[no_unique_address]] optional<_Tp> __val_;44 _LIBCPP_NO_UNIQUE_ADDRESS optional<_Tp> __val_;
4545
46 public:46 public:
47 template<class ..._Args>47 template<class ..._Args>
...@@ -49,7 +49,7 @@ namespace ranges {...@@ -49,7 +49,7 @@ namespace ranges {
49 _LIBCPP_HIDE_FROM_ABI49 _LIBCPP_HIDE_FROM_ABI
50 constexpr explicit __copyable_box(in_place_t, _Args&& ...__args)50 constexpr explicit __copyable_box(in_place_t, _Args&& ...__args)
51 noexcept(is_nothrow_constructible_v<_Tp, _Args...>)51 noexcept(is_nothrow_constructible_v<_Tp, _Args...>)
52 : __val_(in_place, _VSTD::forward<_Args>(__args)...)52 : __val_(in_place, std::forward<_Args>(__args)...)
53 { }53 { }
5454
55 _LIBCPP_HIDE_FROM_ABI55 _LIBCPP_HIDE_FROM_ABI
...@@ -65,7 +65,7 @@ namespace ranges {...@@ -65,7 +65,7 @@ namespace ranges {
65 constexpr __copyable_box& operator=(__copyable_box const& __other)65 constexpr __copyable_box& operator=(__copyable_box const& __other)
66 noexcept(is_nothrow_copy_constructible_v<_Tp>)66 noexcept(is_nothrow_copy_constructible_v<_Tp>)
67 {67 {
68 if (this != _VSTD::addressof(__other)) {68 if (this != std::addressof(__other)) {
69 if (__other.__has_value()) __val_.emplace(*__other);69 if (__other.__has_value()) __val_.emplace(*__other);
70 else __val_.reset();70 else __val_.reset();
71 }71 }
...@@ -79,8 +79,8 @@ namespace ranges {...@@ -79,8 +79,8 @@ namespace ranges {
79 constexpr __copyable_box& operator=(__copyable_box&& __other)79 constexpr __copyable_box& operator=(__copyable_box&& __other)
80 noexcept(is_nothrow_move_constructible_v<_Tp>)80 noexcept(is_nothrow_move_constructible_v<_Tp>)
81 {81 {
82 if (this != _VSTD::addressof(__other)) {82 if (this != std::addressof(__other)) {
83 if (__other.__has_value()) __val_.emplace(_VSTD::move(*__other));83 if (__other.__has_value()) __val_.emplace(std::move(*__other));
84 else __val_.reset();84 else __val_.reset();
85 }85 }
86 return *this;86 return *this;
...@@ -116,7 +116,7 @@ namespace ranges {...@@ -116,7 +116,7 @@ namespace ranges {
116 template<__copy_constructible_object _Tp>116 template<__copy_constructible_object _Tp>
117 requires __doesnt_need_empty_state_for_copy<_Tp> && __doesnt_need_empty_state_for_move<_Tp>117 requires __doesnt_need_empty_state_for_copy<_Tp> && __doesnt_need_empty_state_for_move<_Tp>
118 class __copyable_box<_Tp> {118 class __copyable_box<_Tp> {
119 [[no_unique_address]] _Tp __val_;119 _LIBCPP_NO_UNIQUE_ADDRESS _Tp __val_;
120120
121 public:121 public:
122 template<class ..._Args>122 template<class ..._Args>
...@@ -124,7 +124,7 @@ namespace ranges {...@@ -124,7 +124,7 @@ namespace ranges {
124 _LIBCPP_HIDE_FROM_ABI124 _LIBCPP_HIDE_FROM_ABI
125 constexpr explicit __copyable_box(in_place_t, _Args&& ...__args)125 constexpr explicit __copyable_box(in_place_t, _Args&& ...__args)
126 noexcept(is_nothrow_constructible_v<_Tp, _Args...>)126 noexcept(is_nothrow_constructible_v<_Tp, _Args...>)
127 : __val_(_VSTD::forward<_Args>(__args)...)127 : __val_(std::forward<_Args>(__args)...)
128 { }128 { }
129129
130 _LIBCPP_HIDE_FROM_ABI130 _LIBCPP_HIDE_FROM_ABI
...@@ -144,9 +144,9 @@ namespace ranges {...@@ -144,9 +144,9 @@ namespace ranges {
144 _LIBCPP_HIDE_FROM_ABI144 _LIBCPP_HIDE_FROM_ABI
145 constexpr __copyable_box& operator=(__copyable_box const& __other) noexcept {145 constexpr __copyable_box& operator=(__copyable_box const& __other) noexcept {
146 static_assert(is_nothrow_copy_constructible_v<_Tp>);146 static_assert(is_nothrow_copy_constructible_v<_Tp>);
147 if (this != _VSTD::addressof(__other)) {147 if (this != std::addressof(__other)) {
148 _VSTD::destroy_at(_VSTD::addressof(__val_));148 std::destroy_at(std::addressof(__val_));
149 _VSTD::construct_at(_VSTD::addressof(__val_), __other.__val_);149 std::construct_at(std::addressof(__val_), __other.__val_);
150 }150 }
151 return *this;151 return *this;
152 }152 }
...@@ -154,9 +154,9 @@ namespace ranges {...@@ -154,9 +154,9 @@ namespace ranges {
154 _LIBCPP_HIDE_FROM_ABI154 _LIBCPP_HIDE_FROM_ABI
155 constexpr __copyable_box& operator=(__copyable_box&& __other) noexcept {155 constexpr __copyable_box& operator=(__copyable_box&& __other) noexcept {
156 static_assert(is_nothrow_move_constructible_v<_Tp>);156 static_assert(is_nothrow_move_constructible_v<_Tp>);
157 if (this != _VSTD::addressof(__other)) {157 if (this != std::addressof(__other)) {
158 _VSTD::destroy_at(_VSTD::addressof(__val_));158 std::destroy_at(std::addressof(__val_));
159 _VSTD::construct_at(_VSTD::addressof(__val_), _VSTD::move(__other.__val_));159 std::construct_at(std::addressof(__val_), std::move(__other.__val_));
160 }160 }
161 return *this;161 return *this;
162 }162 }
...@@ -164,14 +164,14 @@ namespace ranges {...@@ -164,14 +164,14 @@ namespace ranges {
164 _LIBCPP_HIDE_FROM_ABI constexpr _Tp const& operator*() const noexcept { return __val_; }164 _LIBCPP_HIDE_FROM_ABI constexpr _Tp const& operator*() const noexcept { return __val_; }
165 _LIBCPP_HIDE_FROM_ABI constexpr _Tp& operator*() noexcept { return __val_; }165 _LIBCPP_HIDE_FROM_ABI constexpr _Tp& operator*() noexcept { return __val_; }
166166
167 _LIBCPP_HIDE_FROM_ABI constexpr const _Tp *operator->() const noexcept { return _VSTD::addressof(__val_); }167 _LIBCPP_HIDE_FROM_ABI constexpr const _Tp *operator->() const noexcept { return std::addressof(__val_); }
168 _LIBCPP_HIDE_FROM_ABI constexpr _Tp *operator->() noexcept { return _VSTD::addressof(__val_); }168 _LIBCPP_HIDE_FROM_ABI constexpr _Tp *operator->() noexcept { return std::addressof(__val_); }
169169
170 _LIBCPP_HIDE_FROM_ABI constexpr bool __has_value() const noexcept { return true; }170 _LIBCPP_HIDE_FROM_ABI constexpr bool __has_value() const noexcept { return true; }
171 };171 };
172} // namespace ranges172} // namespace ranges
173173
174#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)174#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
175175
176_LIBCPP_END_NAMESPACE_STD176_LIBCPP_END_NAMESPACE_STD
177177
lib/libcxx/include/__ranges/counted.h+11-11
...@@ -24,12 +24,12 @@...@@ -24,12 +24,12 @@
24#include <type_traits>24#include <type_traits>
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
28#endif28#endif
2929
30_LIBCPP_BEGIN_NAMESPACE_STD30_LIBCPP_BEGIN_NAMESPACE_STD
3131
32#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)32#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
3333
34namespace ranges::views {34namespace ranges::views {
3535
...@@ -39,9 +39,9 @@ namespace __counted {...@@ -39,9 +39,9 @@ namespace __counted {
39 template<contiguous_iterator _It>39 template<contiguous_iterator _It>
40 _LIBCPP_HIDE_FROM_ABI40 _LIBCPP_HIDE_FROM_ABI
41 static constexpr auto __go(_It __it, iter_difference_t<_It> __count)41 static constexpr auto __go(_It __it, iter_difference_t<_It> __count)
42 noexcept(noexcept(span(_VSTD::to_address(__it), static_cast<size_t>(__count))))42 noexcept(noexcept(span(std::to_address(__it), static_cast<size_t>(__count))))
43 // Deliberately omit return-type SFINAE, because to_address is not SFINAE-friendly43 // Deliberately omit return-type SFINAE, because to_address is not SFINAE-friendly
44 { return span(_VSTD::to_address(__it), static_cast<size_t>(__count)); }44 { return span(std::to_address(__it), static_cast<size_t>(__count)); }
4545
46 template<random_access_iterator _It>46 template<random_access_iterator _It>
47 _LIBCPP_HIDE_FROM_ABI47 _LIBCPP_HIDE_FROM_ABI
...@@ -53,17 +53,17 @@ namespace __counted {...@@ -53,17 +53,17 @@ namespace __counted {
53 template<class _It>53 template<class _It>
54 _LIBCPP_HIDE_FROM_ABI54 _LIBCPP_HIDE_FROM_ABI
55 static constexpr auto __go(_It __it, iter_difference_t<_It> __count)55 static constexpr auto __go(_It __it, iter_difference_t<_It> __count)
56 noexcept(noexcept(subrange(counted_iterator(_VSTD::move(__it), __count), default_sentinel)))56 noexcept(noexcept(subrange(counted_iterator(std::move(__it), __count), default_sentinel)))
57 -> decltype( subrange(counted_iterator(_VSTD::move(__it), __count), default_sentinel))57 -> decltype( subrange(counted_iterator(std::move(__it), __count), default_sentinel))
58 { return subrange(counted_iterator(_VSTD::move(__it), __count), default_sentinel); }58 { return subrange(counted_iterator(std::move(__it), __count), default_sentinel); }
5959
60 template<class _It, convertible_to<iter_difference_t<_It>> _Diff>60 template<class _It, convertible_to<iter_difference_t<_It>> _Diff>
61 requires input_or_output_iterator<decay_t<_It>>61 requires input_or_output_iterator<decay_t<_It>>
62 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI62 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
63 constexpr auto operator()(_It&& __it, _Diff&& __count) const63 constexpr auto operator()(_It&& __it, _Diff&& __count) const
64 noexcept(noexcept(__go(_VSTD::forward<_It>(__it), _VSTD::forward<_Diff>(__count))))64 noexcept(noexcept(__go(std::forward<_It>(__it), std::forward<_Diff>(__count))))
65 -> decltype( __go(_VSTD::forward<_It>(__it), _VSTD::forward<_Diff>(__count)))65 -> decltype( __go(std::forward<_It>(__it), std::forward<_Diff>(__count)))
66 { return __go(_VSTD::forward<_It>(__it), _VSTD::forward<_Diff>(__count)); }66 { return __go(std::forward<_It>(__it), std::forward<_Diff>(__count)); }
67 };67 };
6868
69} // namespace __counted69} // namespace __counted
...@@ -74,7 +74,7 @@ inline namespace __cpo {...@@ -74,7 +74,7 @@ inline namespace __cpo {
7474
75} // namespace ranges::views75} // namespace ranges::views
7676
77#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)77#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
7878
79_LIBCPP_END_NAMESPACE_STD79_LIBCPP_END_NAMESPACE_STD
8080
lib/libcxx/include/__ranges/dangling.h+3-3
...@@ -16,12 +16,12 @@...@@ -16,12 +16,12 @@
16#include <type_traits>16#include <type_traits>
1717
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19#pragma GCC system_header19# pragma GCC system_header
20#endif20#endif
2121
22_LIBCPP_BEGIN_NAMESPACE_STD22_LIBCPP_BEGIN_NAMESPACE_STD
2323
24#if !defined(_LIBCPP_HAS_NO_CONCEPTS)24#if _LIBCPP_STD_VER > 17
2525
26namespace ranges {26namespace ranges {
27struct dangling {27struct dangling {
...@@ -35,7 +35,7 @@ using borrowed_iterator_t = _If<borrowed_range<_Rp>, iterator_t<_Rp>, dangling>;...@@ -35,7 +35,7 @@ using borrowed_iterator_t = _If<borrowed_range<_Rp>, iterator_t<_Rp>, dangling>;
35// borrowed_subrange_t defined in <__ranges/subrange.h>35// borrowed_subrange_t defined in <__ranges/subrange.h>
36} // namespace ranges36} // namespace ranges
3737
38#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)38#endif // _LIBCPP_STD_VER > 17
3939
40_LIBCPP_END_NAMESPACE_STD40_LIBCPP_END_NAMESPACE_STD
4141
lib/libcxx/include/__ranges/data.h+5-5
...@@ -19,12 +19,12 @@...@@ -19,12 +19,12 @@
19#include <type_traits>19#include <type_traits>
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
23#endif23#endif
2424
25_LIBCPP_BEGIN_NAMESPACE_STD25_LIBCPP_BEGIN_NAMESPACE_STD
2626
27#if !defined(_LIBCPP_HAS_NO_CONCEPTS)27#if _LIBCPP_STD_VER > 17
2828
29// [range.prim.data]29// [range.prim.data]
3030
...@@ -60,8 +60,8 @@ namespace __data {...@@ -60,8 +60,8 @@ namespace __data {
60 template<__ranges_begin_invocable _Tp>60 template<__ranges_begin_invocable _Tp>
61 _LIBCPP_HIDE_FROM_ABI61 _LIBCPP_HIDE_FROM_ABI
62 constexpr auto operator()(_Tp&& __t) const62 constexpr auto operator()(_Tp&& __t) const
63 noexcept(noexcept(_VSTD::to_address(ranges::begin(__t)))) {63 noexcept(noexcept(std::to_address(ranges::begin(__t)))) {
64 return _VSTD::to_address(ranges::begin(__t));64 return std::to_address(ranges::begin(__t));
65 }65 }
66 };66 };
67} // namespace __data67} // namespace __data
...@@ -99,7 +99,7 @@ inline namespace __cpo {...@@ -99,7 +99,7 @@ inline namespace __cpo {
99} // namespace __cpo99} // namespace __cpo
100} // namespace ranges100} // namespace ranges
101101
102#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)102#endif // _LIBCPP_STD_VER > 17
103103
104_LIBCPP_END_NAMESPACE_STD104_LIBCPP_END_NAMESPACE_STD
105105
lib/libcxx/include/__ranges/drop_view.h+190-11
...@@ -9,29 +9,43 @@...@@ -9,29 +9,43 @@
9#ifndef _LIBCPP___RANGES_DROP_VIEW_H9#ifndef _LIBCPP___RANGES_DROP_VIEW_H
10#define _LIBCPP___RANGES_DROP_VIEW_H10#define _LIBCPP___RANGES_DROP_VIEW_H
1111
12#include <__algorithm/min.h>
13#include <__assert>
12#include <__config>14#include <__config>
13#include <__debug>15#include <__functional/bind_back.h>
16#include <__fwd/span.h>
17#include <__fwd/string_view.h>
14#include <__iterator/concepts.h>18#include <__iterator/concepts.h>
19#include <__iterator/distance.h>
15#include <__iterator/iterator_traits.h>20#include <__iterator/iterator_traits.h>
16#include <__iterator/next.h>21#include <__iterator/next.h>
17#include <__ranges/access.h>22#include <__ranges/access.h>
18#include <__ranges/all.h>23#include <__ranges/all.h>
19#include <__ranges/concepts.h>24#include <__ranges/concepts.h>
25#include <__ranges/empty_view.h>
20#include <__ranges/enable_borrowed_range.h>26#include <__ranges/enable_borrowed_range.h>
27#include <__ranges/iota_view.h>
21#include <__ranges/non_propagating_cache.h>28#include <__ranges/non_propagating_cache.h>
29#include <__ranges/range_adaptor.h>
22#include <__ranges/size.h>30#include <__ranges/size.h>
31#include <__ranges/subrange.h>
23#include <__ranges/view_interface.h>32#include <__ranges/view_interface.h>
33#include <__utility/auto_cast.h>
34#include <__utility/forward.h>
24#include <__utility/move.h>35#include <__utility/move.h>
25#include <concepts>36#include <concepts>
26#include <type_traits>37#include <type_traits>
2738
28#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)39#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
29#pragma GCC system_header40# pragma GCC system_header
30#endif41#endif
3142
43_LIBCPP_PUSH_MACROS
44#include <__undef_macros>
45
32_LIBCPP_BEGIN_NAMESPACE_STD46_LIBCPP_BEGIN_NAMESPACE_STD
3347
34#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)48#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
3549
36namespace ranges {50namespace ranges {
37 template<view _View>51 template<view _View>
...@@ -45,7 +59,7 @@ namespace ranges {...@@ -45,7 +59,7 @@ namespace ranges {
45 // one can't call begin() on it more than once.59 // one can't call begin() on it more than once.
46 static constexpr bool _UseCache = forward_range<_View> && !(random_access_range<_View> && sized_range<_View>);60 static constexpr bool _UseCache = forward_range<_View> && !(random_access_range<_View> && sized_range<_View>);
47 using _Cache = _If<_UseCache, __non_propagating_cache<iterator_t<_View>>, __empty_cache>;61 using _Cache = _If<_UseCache, __non_propagating_cache<iterator_t<_View>>, __empty_cache>;
48 [[no_unique_address]] _Cache __cached_begin_ = _Cache();62 _LIBCPP_NO_UNIQUE_ADDRESS _Cache __cached_begin_ = _Cache();
49 range_difference_t<_View> __count_ = 0;63 range_difference_t<_View> __count_ = 0;
50 _View __base_ = _View();64 _View __base_ = _View();
5165
...@@ -55,13 +69,13 @@ public:...@@ -55,13 +69,13 @@ public:
55 _LIBCPP_HIDE_FROM_ABI69 _LIBCPP_HIDE_FROM_ABI
56 constexpr drop_view(_View __base, range_difference_t<_View> __count)70 constexpr drop_view(_View __base, range_difference_t<_View> __count)
57 : __count_(__count)71 : __count_(__count)
58 , __base_(_VSTD::move(__base))72 , __base_(std::move(__base))
59 {73 {
60 _LIBCPP_ASSERT(__count_ >= 0, "count must be greater than or equal to zero.");74 _LIBCPP_ASSERT(__count_ >= 0, "count must be greater than or equal to zero.");
61 }75 }
6276
63 _LIBCPP_HIDE_FROM_ABI constexpr _View base() const& requires copy_constructible<_View> { return __base_; }77 _LIBCPP_HIDE_FROM_ABI constexpr _View base() const& requires copy_constructible<_View> { return __base_; }
64 _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return _VSTD::move(__base_); }78 _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); }
6579
66 _LIBCPP_HIDE_FROM_ABI80 _LIBCPP_HIDE_FROM_ABI
67 constexpr auto begin()81 constexpr auto begin()
...@@ -113,15 +127,180 @@ public:...@@ -113,15 +127,180 @@ public:
113 { return __size(*this); }127 { return __size(*this); }
114 };128 };
115129
116 template<class _Range>130template<class _Range>
117 drop_view(_Range&&, range_difference_t<_Range>) -> drop_view<views::all_t<_Range>>;131drop_view(_Range&&, range_difference_t<_Range>) -> drop_view<views::all_t<_Range>>;
132
133template<class _Tp>
134inline constexpr bool enable_borrowed_range<drop_view<_Tp>> = enable_borrowed_range<_Tp>;
135
136namespace views {
137namespace __drop {
138
139template <class _Tp>
140inline constexpr bool __is_empty_view = false;
141
142template <class _Tp>
143inline constexpr bool __is_empty_view<empty_view<_Tp>> = true;
144
145template <class _Tp>
146inline constexpr bool __is_passthrough_specialization = false;
147
148template <class _Tp, size_t _Extent>
149inline constexpr bool __is_passthrough_specialization<span<_Tp, _Extent>> = true;
150
151template <class _CharT, class _Traits>
152inline constexpr bool __is_passthrough_specialization<basic_string_view<_CharT, _Traits>> = true;
153
154template <class _Np, class _Bound>
155inline constexpr bool __is_passthrough_specialization<iota_view<_Np, _Bound>> = true;
156
157template <class _Iter, class _Sent, subrange_kind _Kind>
158inline constexpr bool __is_passthrough_specialization<subrange<_Iter, _Sent, _Kind>> =
159 !subrange<_Iter, _Sent, _Kind>::_StoreSize;
160
161template <class _Tp>
162inline constexpr bool __is_subrange_specialization_with_store_size = false;
163
164template <class _Iter, class _Sent, subrange_kind _Kind>
165inline constexpr bool __is_subrange_specialization_with_store_size<subrange<_Iter, _Sent, _Kind>> =
166 subrange<_Iter, _Sent, _Kind>::_StoreSize;
167
168template <class _Tp>
169struct __passthrough_type;
170
171template <class _Tp, size_t _Extent>
172struct __passthrough_type<span<_Tp, _Extent>> {
173 using type = span<_Tp>;
174};
175
176template <class _CharT, class _Traits>
177struct __passthrough_type<basic_string_view<_CharT, _Traits>> {
178 using type = basic_string_view<_CharT, _Traits>;
179};
180
181template <class _Np, class _Bound>
182struct __passthrough_type<iota_view<_Np, _Bound>> {
183 using type = iota_view<_Np, _Bound>;
184};
185
186template <class _Iter, class _Sent, subrange_kind _Kind>
187struct __passthrough_type<subrange<_Iter, _Sent, _Kind>> {
188 using type = subrange<_Iter, _Sent, _Kind>;
189};
190
191template <class _Tp>
192using __passthrough_type_t = typename __passthrough_type<_Tp>::type;
193
194struct __fn {
195 // [range.drop.overview]: the `empty_view` case.
196 template <class _Range, convertible_to<range_difference_t<_Range>> _Np>
197 requires __is_empty_view<remove_cvref_t<_Range>>
198 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
199 constexpr auto operator()(_Range&& __range, _Np&&) const
200 noexcept(noexcept(_LIBCPP_AUTO_CAST(std::forward<_Range>(__range))))
201 -> decltype( _LIBCPP_AUTO_CAST(std::forward<_Range>(__range)))
202 { return _LIBCPP_AUTO_CAST(std::forward<_Range>(__range)); }
203
204 // [range.drop.overview]: the `span | basic_string_view | iota_view | subrange (StoreSize == false)` case.
205 template <class _Range,
206 convertible_to<range_difference_t<_Range>> _Np,
207 class _RawRange = remove_cvref_t<_Range>,
208 class _Dist = range_difference_t<_Range>>
209 requires (!__is_empty_view<_RawRange> &&
210 random_access_range<_RawRange> &&
211 sized_range<_RawRange> &&
212 __is_passthrough_specialization<_RawRange>)
213 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
214 constexpr auto operator()(_Range&& __rng, _Np&& __n) const
215 noexcept(noexcept(__passthrough_type_t<_RawRange>(
216 ranges::begin(__rng) + std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n)),
217 ranges::end(__rng)
218 )))
219 -> decltype( __passthrough_type_t<_RawRange>(
220 // Note: deliberately not forwarding `__rng` to guard against double moves.
221 ranges::begin(__rng) + std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n)),
222 ranges::end(__rng)
223 ))
224 { return __passthrough_type_t<_RawRange>(
225 ranges::begin(__rng) + std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n)),
226 ranges::end(__rng)
227 ); }
228
229 // [range.drop.overview]: the `subrange (StoreSize == true)` case.
230 template <class _Range,
231 convertible_to<range_difference_t<_Range>> _Np,
232 class _RawRange = remove_cvref_t<_Range>,
233 class _Dist = range_difference_t<_Range>>
234 requires (!__is_empty_view<_RawRange> &&
235 random_access_range<_RawRange> &&
236 sized_range<_RawRange> &&
237 __is_subrange_specialization_with_store_size<_RawRange>)
238 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
239 constexpr auto operator()(_Range&& __rng, _Np&& __n) const
240 noexcept(noexcept(_RawRange(
241 ranges::begin(__rng) + std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n)),
242 ranges::end(__rng),
243 std::__to_unsigned_like(ranges::distance(__rng) -
244 std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n)))
245 )))
246 -> decltype( _RawRange(
247 // Note: deliberately not forwarding `__rng` to guard against double moves.
248 ranges::begin(__rng) + std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n)),
249 ranges::end(__rng),
250 std::__to_unsigned_like(ranges::distance(__rng) -
251 std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n)))
252 ))
253 {
254 // Introducing local variables avoids calculating `min` and `distance` twice (at the cost of diverging from the
255 // expression used in the `noexcept` clause and the return statement).
256 auto dist = ranges::distance(__rng);
257 auto clamped = std::min<_Dist>(dist, std::forward<_Np>(__n));
258 return _RawRange(
259 ranges::begin(__rng) + clamped,
260 ranges::end(__rng),
261 std::__to_unsigned_like(dist - clamped)
262 );}
263
264 // [range.drop.overview]: the "otherwise" case.
265 template <class _Range, convertible_to<range_difference_t<_Range>> _Np,
266 class _RawRange = remove_cvref_t<_Range>>
267 // Note: without specifically excluding the other cases, GCC sees this overload as ambiguous with the other
268 // overloads.
269 requires (!(__is_empty_view<_RawRange> ||
270 (__is_subrange_specialization_with_store_size<_RawRange> &&
271 sized_range<_RawRange> &&
272 random_access_range<_RawRange>) ||
273 (__is_passthrough_specialization<_RawRange> &&
274 sized_range<_RawRange> &&
275 random_access_range<_RawRange>)
276 ))
277 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
278 constexpr auto operator()(_Range&& __range, _Np&& __n) const
279 noexcept(noexcept(drop_view(std::forward<_Range>(__range), std::forward<_Np>(__n))))
280 -> decltype( drop_view(std::forward<_Range>(__range), std::forward<_Np>(__n)))
281 { return drop_view(std::forward<_Range>(__range), std::forward<_Np>(__n)); }
282
283 template <class _Np>
284 requires constructible_from<decay_t<_Np>, _Np>
285 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
286 constexpr auto operator()(_Np&& __n) const
287 noexcept(is_nothrow_constructible_v<decay_t<_Np>, _Np>)
288 { return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Np>(__n))); }
289};
290
291} // namespace __drop
292
293inline namespace __cpo {
294 inline constexpr auto drop = __drop::__fn{};
295} // namespace __cpo
296} // namespace views
118297
119 template<class _Tp>
120 inline constexpr bool enable_borrowed_range<drop_view<_Tp>> = enable_borrowed_range<_Tp>;
121} // namespace ranges298} // namespace ranges
122299
123#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)300#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
124301
125_LIBCPP_END_NAMESPACE_STD302_LIBCPP_END_NAMESPACE_STD
126303
304_LIBCPP_POP_MACROS
305
127#endif // _LIBCPP___RANGES_DROP_VIEW_H306#endif // _LIBCPP___RANGES_DROP_VIEW_H
lib/libcxx/include/__ranges/empty.h+3-3
...@@ -17,12 +17,12 @@...@@ -17,12 +17,12 @@
17#include <type_traits>17#include <type_traits>
1818
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20#pragma GCC system_header20# pragma GCC system_header
21#endif21#endif
2222
23_LIBCPP_BEGIN_NAMESPACE_STD23_LIBCPP_BEGIN_NAMESPACE_STD
2424
25#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)25#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
2626
27// [range.prim.empty]27// [range.prim.empty]
2828
...@@ -75,7 +75,7 @@ inline namespace __cpo {...@@ -75,7 +75,7 @@ inline namespace __cpo {
75} // namespace __cpo75} // namespace __cpo
76} // namespace ranges76} // namespace ranges
7777
78#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)78#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
7979
80_LIBCPP_END_NAMESPACE_STD80_LIBCPP_END_NAMESPACE_STD
8181
lib/libcxx/include/__ranges/empty_view.h+10-3
...@@ -15,12 +15,12 @@...@@ -15,12 +15,12 @@
15#include <type_traits>15#include <type_traits>
1616
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header18# pragma GCC system_header
19#endif19#endif
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
23#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)23#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
2424
25namespace ranges {25namespace ranges {
26 template<class _Tp>26 template<class _Tp>
...@@ -36,9 +36,16 @@ namespace ranges {...@@ -36,9 +36,16 @@ namespace ranges {
3636
37 template<class _Tp>37 template<class _Tp>
38 inline constexpr bool enable_borrowed_range<empty_view<_Tp>> = true;38 inline constexpr bool enable_borrowed_range<empty_view<_Tp>> = true;
39
40 namespace views {
41
42 template <class _Tp>
43 inline constexpr empty_view<_Tp> empty{};
44
45 } // namespace views
39} // namespace ranges46} // namespace ranges
4047
41#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)48#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
4249
43_LIBCPP_END_NAMESPACE_STD50_LIBCPP_END_NAMESPACE_STD
4451
lib/libcxx/include/__ranges/enable_borrowed_range.h+3-3
...@@ -17,12 +17,12 @@...@@ -17,12 +17,12 @@
17#include <__config>17#include <__config>
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
21#endif21#endif
2222
23_LIBCPP_BEGIN_NAMESPACE_STD23_LIBCPP_BEGIN_NAMESPACE_STD
2424
25#if !defined(_LIBCPP_HAS_NO_CONCEPTS)25#if _LIBCPP_STD_VER > 17
2626
27namespace ranges {27namespace ranges {
2828
...@@ -33,7 +33,7 @@ inline constexpr bool enable_borrowed_range = false;...@@ -33,7 +33,7 @@ inline constexpr bool enable_borrowed_range = false;
3333
34} // namespace ranges34} // namespace ranges
3535
36#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)36#endif // _LIBCPP_STD_VER > 17
3737
38_LIBCPP_END_NAMESPACE_STD38_LIBCPP_END_NAMESPACE_STD
3939
lib/libcxx/include/__ranges/enable_view.h+3-3
...@@ -15,12 +15,12 @@...@@ -15,12 +15,12 @@
15#include <type_traits>15#include <type_traits>
1616
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header18# pragma GCC system_header
19#endif19#endif
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
23#if !defined(_LIBCPP_HAS_NO_CONCEPTS)23#if _LIBCPP_STD_VER > 17
2424
25namespace ranges {25namespace ranges {
2626
...@@ -40,7 +40,7 @@ inline constexpr bool enable_view = derived_from<_Tp, view_base> ||...@@ -40,7 +40,7 @@ inline constexpr bool enable_view = derived_from<_Tp, view_base> ||
4040
41} // namespace ranges41} // namespace ranges
4242
43#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)43#endif // _LIBCPP_STD_VER > 17
4444
45_LIBCPP_END_NAMESPACE_STD45_LIBCPP_END_NAMESPACE_STD
4646
lib/libcxx/include/__ranges/filter_view.h created+259
...@@ -0,0 +1,259 @@
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___RANGES_FILTER_VIEW_H
10#define _LIBCPP___RANGES_FILTER_VIEW_H
11
12#include <__algorithm/ranges_find_if.h>
13#include <__config>
14#include <__debug>
15#include <__functional/bind_back.h>
16#include <__functional/invoke.h>
17#include <__functional/reference_wrapper.h>
18#include <__iterator/concepts.h>
19#include <__iterator/iter_move.h>
20#include <__iterator/iter_swap.h>
21#include <__iterator/iterator_traits.h>
22#include <__memory/addressof.h>
23#include <__ranges/access.h>
24#include <__ranges/all.h>
25#include <__ranges/concepts.h>
26#include <__ranges/copyable_box.h>
27#include <__ranges/non_propagating_cache.h>
28#include <__ranges/range_adaptor.h>
29#include <__ranges/view_interface.h>
30#include <__utility/forward.h>
31#include <__utility/in_place.h>
32#include <__utility/move.h>
33#include <concepts>
34#include <type_traits>
35
36#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
37# pragma GCC system_header
38#endif
39
40_LIBCPP_BEGIN_NAMESPACE_STD
41
42#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
43
44namespace ranges {
45 template<input_range _View, indirect_unary_predicate<iterator_t<_View>> _Pred>
46 requires view<_View> && is_object_v<_Pred>
47 class filter_view : public view_interface<filter_view<_View, _Pred>> {
48 _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View();
49 _LIBCPP_NO_UNIQUE_ADDRESS __copyable_box<_Pred> __pred_;
50
51 // We cache the result of begin() to allow providing an amortized O(1) begin() whenever
52 // the underlying range is at least a forward_range.
53 static constexpr bool _UseCache = forward_range<_View>;
54 using _Cache = _If<_UseCache, __non_propagating_cache<iterator_t<_View>>, __empty_cache>;
55 _LIBCPP_NO_UNIQUE_ADDRESS _Cache __cached_begin_ = _Cache();
56
57 class __iterator;
58 class __sentinel;
59
60 public:
61 _LIBCPP_HIDE_FROM_ABI
62 filter_view() requires default_initializable<_View> && default_initializable<_Pred> = default;
63
64 _LIBCPP_HIDE_FROM_ABI
65 constexpr filter_view(_View __base, _Pred __pred)
66 : __base_(std::move(__base)), __pred_(in_place, std::move(__pred))
67 { }
68
69 template<class _Vp = _View>
70 _LIBCPP_HIDE_FROM_ABI
71 constexpr _View base() const& requires copy_constructible<_Vp> { return __base_; }
72 _LIBCPP_HIDE_FROM_ABI
73 constexpr _View base() && { return std::move(__base_); }
74
75 _LIBCPP_HIDE_FROM_ABI
76 constexpr _Pred const& pred() const { return *__pred_; }
77
78 _LIBCPP_HIDE_FROM_ABI
79 constexpr __iterator begin() {
80 _LIBCPP_ASSERT(__pred_.__has_value(), "Trying to call begin() on a filter_view that does not have a valid predicate.");
81 if constexpr (_UseCache) {
82 if (!__cached_begin_.__has_value()) {
83 __cached_begin_.__emplace(ranges::find_if(__base_, std::ref(*__pred_)));
84 }
85 return {*this, *__cached_begin_};
86 } else {
87 return {*this, ranges::find_if(__base_, std::ref(*__pred_))};
88 }
89 }
90
91 _LIBCPP_HIDE_FROM_ABI
92 constexpr auto end() {
93 if constexpr (common_range<_View>)
94 return __iterator{*this, ranges::end(__base_)};
95 else
96 return __sentinel{*this};
97 }
98 };
99
100 template<class _Range, class _Pred>
101 filter_view(_Range&&, _Pred) -> filter_view<views::all_t<_Range>, _Pred>;
102
103 template<class _View>
104 struct __filter_iterator_category { };
105
106 template<forward_range _View>
107 struct __filter_iterator_category<_View> {
108 using _Cat = typename iterator_traits<iterator_t<_View>>::iterator_category;
109 using iterator_category =
110 _If<derived_from<_Cat, bidirectional_iterator_tag>, bidirectional_iterator_tag,
111 _If<derived_from<_Cat, forward_iterator_tag>, forward_iterator_tag,
112 /* else */ _Cat
113 >>;
114 };
115
116 template<input_range _View, indirect_unary_predicate<iterator_t<_View>> _Pred>
117 requires view<_View> && is_object_v<_Pred>
118 class filter_view<_View, _Pred>::__iterator : public __filter_iterator_category<_View> {
119 public:
120 _LIBCPP_NO_UNIQUE_ADDRESS iterator_t<_View> __current_ = iterator_t<_View>();
121 _LIBCPP_NO_UNIQUE_ADDRESS filter_view* __parent_ = nullptr;
122
123 using iterator_concept =
124 _If<bidirectional_range<_View>, bidirectional_iterator_tag,
125 _If<forward_range<_View>, forward_iterator_tag,
126 /* else */ input_iterator_tag
127 >>;
128 // using iterator_category = inherited;
129 using value_type = range_value_t<_View>;
130 using difference_type = range_difference_t<_View>;
131
132 _LIBCPP_HIDE_FROM_ABI
133 __iterator() requires default_initializable<iterator_t<_View>> = default;
134
135 _LIBCPP_HIDE_FROM_ABI
136 constexpr __iterator(filter_view& __parent, iterator_t<_View> __current)
137 : __current_(std::move(__current)), __parent_(std::addressof(__parent))
138 { }
139
140 _LIBCPP_HIDE_FROM_ABI
141 constexpr iterator_t<_View> const& base() const& noexcept { return __current_; }
142 _LIBCPP_HIDE_FROM_ABI
143 constexpr iterator_t<_View> base() && { return std::move(__current_); }
144
145 _LIBCPP_HIDE_FROM_ABI
146 constexpr range_reference_t<_View> operator*() const { return *__current_; }
147 _LIBCPP_HIDE_FROM_ABI
148 constexpr iterator_t<_View> operator->() const
149 requires __has_arrow<iterator_t<_View>> && copyable<iterator_t<_View>>
150 {
151 return __current_;
152 }
153
154 _LIBCPP_HIDE_FROM_ABI
155 constexpr __iterator& operator++() {
156 __current_ = ranges::find_if(std::move(++__current_), ranges::end(__parent_->__base_),
157 std::ref(*__parent_->__pred_));
158 return *this;
159 }
160 _LIBCPP_HIDE_FROM_ABI
161 constexpr void operator++(int) { ++*this; }
162 _LIBCPP_HIDE_FROM_ABI
163 constexpr __iterator operator++(int) requires forward_range<_View> {
164 auto __tmp = *this;
165 ++*this;
166 return __tmp;
167 }
168
169 _LIBCPP_HIDE_FROM_ABI
170 constexpr __iterator& operator--() requires bidirectional_range<_View> {
171 do {
172 --__current_;
173 } while (!std::invoke(*__parent_->__pred_, *__current_));
174 return *this;
175 }
176 _LIBCPP_HIDE_FROM_ABI
177 constexpr __iterator operator--(int) requires bidirectional_range<_View> {
178 auto tmp = *this;
179 --*this;
180 return tmp;
181 }
182
183 _LIBCPP_HIDE_FROM_ABI
184 friend constexpr bool operator==(__iterator const& __x, __iterator const& __y)
185 requires equality_comparable<iterator_t<_View>>
186 {
187 return __x.__current_ == __y.__current_;
188 }
189
190 _LIBCPP_HIDE_FROM_ABI
191 friend constexpr range_rvalue_reference_t<_View> iter_move(__iterator const& __it)
192 noexcept(noexcept(ranges::iter_move(__it.__current_)))
193 {
194 return ranges::iter_move(__it.__current_);
195 }
196
197 _LIBCPP_HIDE_FROM_ABI
198 friend constexpr void iter_swap(__iterator const& __x, __iterator const& __y)
199 noexcept(noexcept(ranges::iter_swap(__x.__current_, __y.__current_)))
200 requires indirectly_swappable<iterator_t<_View>>
201 {
202 return ranges::iter_swap(__x.__current_, __y.__current_);
203 }
204 };
205
206 template<input_range _View, indirect_unary_predicate<iterator_t<_View>> _Pred>
207 requires view<_View> && is_object_v<_Pred>
208 class filter_view<_View, _Pred>::__sentinel {
209 public:
210 sentinel_t<_View> __end_ = sentinel_t<_View>();
211
212 _LIBCPP_HIDE_FROM_ABI
213 __sentinel() = default;
214
215 _LIBCPP_HIDE_FROM_ABI
216 constexpr explicit __sentinel(filter_view& __parent)
217 : __end_(ranges::end(__parent.__base_))
218 { }
219
220 _LIBCPP_HIDE_FROM_ABI
221 constexpr sentinel_t<_View> base() const { return __end_; }
222
223 _LIBCPP_HIDE_FROM_ABI
224 friend constexpr bool operator==(__iterator const& __x, __sentinel const& __y) {
225 return __x.__current_ == __y.__end_;
226 }
227 };
228
229namespace views {
230namespace __filter {
231 struct __fn {
232 template<class _Range, class _Pred>
233 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
234 constexpr auto operator()(_Range&& __range, _Pred&& __pred) const
235 noexcept(noexcept(filter_view(std::forward<_Range>(__range), std::forward<_Pred>(__pred))))
236 -> decltype( filter_view(std::forward<_Range>(__range), std::forward<_Pred>(__pred)))
237 { return filter_view(std::forward<_Range>(__range), std::forward<_Pred>(__pred)); }
238
239 template<class _Pred>
240 requires constructible_from<decay_t<_Pred>, _Pred>
241 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
242 constexpr auto operator()(_Pred&& __pred) const
243 noexcept(is_nothrow_constructible_v<decay_t<_Pred>, _Pred>)
244 { return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Pred>(__pred))); }
245 };
246} // namespace __filter
247
248inline namespace __cpo {
249 inline constexpr auto filter = __filter::__fn{};
250} // namespace __cpo
251} // namespace views
252
253} // namespace ranges
254
255#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
256
257_LIBCPP_END_NAMESPACE_STD
258
259#endif // _LIBCPP___RANGES_FILTER_VIEW_H
lib/libcxx/include/__ranges/iota_view.h+58-58
...@@ -9,6 +9,7 @@...@@ -9,6 +9,7 @@
9#ifndef _LIBCPP___RANGES_IOTA_VIEW_H9#ifndef _LIBCPP___RANGES_IOTA_VIEW_H
10#define _LIBCPP___RANGES_IOTA_VIEW_H10#define _LIBCPP___RANGES_IOTA_VIEW_H
1111
12#include <__assert>
12#include <__compare/three_way_comparable.h>13#include <__compare/three_way_comparable.h>
13#include <__concepts/arithmetic.h>14#include <__concepts/arithmetic.h>
14#include <__concepts/constructible.h>15#include <__concepts/constructible.h>
...@@ -20,7 +21,6 @@...@@ -20,7 +21,6 @@
20#include <__concepts/semiregular.h>21#include <__concepts/semiregular.h>
21#include <__concepts/totally_ordered.h>22#include <__concepts/totally_ordered.h>
22#include <__config>23#include <__config>
23#include <__debug>
24#include <__functional/ranges_operations.h>24#include <__functional/ranges_operations.h>
25#include <__iterator/concepts.h>25#include <__iterator/concepts.h>
26#include <__iterator/incrementable_traits.h>26#include <__iterator/incrementable_traits.h>
...@@ -34,12 +34,12 @@...@@ -34,12 +34,12 @@
34#include <type_traits>34#include <type_traits>
3535
36#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)36#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
37#pragma GCC system_header37# pragma GCC system_header
38#endif38#endif
3939
40_LIBCPP_BEGIN_NAMESPACE_STD40_LIBCPP_BEGIN_NAMESPACE_STD
4141
42#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)42#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
4343
44namespace ranges {44namespace ranges {
45 template<class _Int>45 template<class _Int>
...@@ -90,9 +90,9 @@ namespace ranges {...@@ -90,9 +90,9 @@ namespace ranges {
90 using iterator_category = input_iterator_tag;90 using iterator_category = input_iterator_tag;
91 };91 };
9292
93 template<weakly_incrementable _Start, semiregular _Bound = unreachable_sentinel_t>93 template <weakly_incrementable _Start, semiregular _BoundSentinel = unreachable_sentinel_t>
94 requires __weakly_equality_comparable_with<_Start, _Bound> && copyable<_Start>94 requires __weakly_equality_comparable_with<_Start, _BoundSentinel> && copyable<_Start>
95 class iota_view : public view_interface<iota_view<_Start, _Bound>> {95 class iota_view : public view_interface<iota_view<_Start, _BoundSentinel>> {
96 struct __iterator : public __iota_iterator_category<_Start> {96 struct __iterator : public __iota_iterator_category<_Start> {
97 friend class iota_view;97 friend class iota_view;
9898
...@@ -111,7 +111,7 @@ namespace ranges {...@@ -111,7 +111,7 @@ namespace ranges {
111 __iterator() requires default_initializable<_Start> = default;111 __iterator() requires default_initializable<_Start> = default;
112112
113 _LIBCPP_HIDE_FROM_ABI113 _LIBCPP_HIDE_FROM_ABI
114 constexpr explicit __iterator(_Start __value) : __value_(_VSTD::move(__value)) {}114 constexpr explicit __iterator(_Start __value) : __value_(std::move(__value)) {}
115115
116 _LIBCPP_HIDE_FROM_ABI116 _LIBCPP_HIDE_FROM_ABI
117 constexpr _Start operator*() const noexcept(is_nothrow_copy_constructible_v<_Start>) {117 constexpr _Start operator*() const noexcept(is_nothrow_copy_constructible_v<_Start>) {
...@@ -271,127 +271,127 @@ namespace ranges {...@@ -271,127 +271,127 @@ namespace ranges {
271 friend class iota_view;271 friend class iota_view;
272272
273 private:273 private:
274 _Bound __bound_ = _Bound();274 _BoundSentinel __bound_sentinel_ = _BoundSentinel();
275275
276 public:276 public:
277 _LIBCPP_HIDE_FROM_ABI277 _LIBCPP_HIDE_FROM_ABI
278 __sentinel() = default;278 __sentinel() = default;
279 constexpr explicit __sentinel(_Bound __bound) : __bound_(_VSTD::move(__bound)) {}279 constexpr explicit __sentinel(_BoundSentinel __bound_sentinel) : __bound_sentinel_(std::move(__bound_sentinel)) {}
280280
281 _LIBCPP_HIDE_FROM_ABI281 _LIBCPP_HIDE_FROM_ABI
282 friend constexpr bool operator==(const __iterator& __x, const __sentinel& __y) {282 friend constexpr bool operator==(const __iterator& __x, const __sentinel& __y) {
283 return __x.__value_ == __y.__bound_;283 return __x.__value_ == __y.__bound_sentinel_;
284 }284 }
285285
286 _LIBCPP_HIDE_FROM_ABI286 _LIBCPP_HIDE_FROM_ABI
287 friend constexpr iter_difference_t<_Start> operator-(const __iterator& __x, const __sentinel& __y)287 friend constexpr iter_difference_t<_Start> operator-(const __iterator& __x, const __sentinel& __y)
288 requires sized_sentinel_for<_Bound, _Start>288 requires sized_sentinel_for<_BoundSentinel, _Start>
289 {289 {
290 return __x.__value_ - __y.__bound_;290 return __x.__value_ - __y.__bound_sentinel_;
291 }291 }
292292
293 _LIBCPP_HIDE_FROM_ABI293 _LIBCPP_HIDE_FROM_ABI
294 friend constexpr iter_difference_t<_Start> operator-(const __sentinel& __x, const __iterator& __y)294 friend constexpr iter_difference_t<_Start> operator-(const __sentinel& __x, const __iterator& __y)
295 requires sized_sentinel_for<_Bound, _Start>295 requires sized_sentinel_for<_BoundSentinel, _Start>
296 {296 {
297 return -(__y - __x);297 return -(__y - __x);
298 }298 }
299 };299 };
300300
301 _Start __value_ = _Start();301 _Start __value_ = _Start();
302 _Bound __bound_ = _Bound();302 _BoundSentinel __bound_sentinel_ = _BoundSentinel();
303303
304 public:304 public:
305 _LIBCPP_HIDE_FROM_ABI305 _LIBCPP_HIDE_FROM_ABI
306 iota_view() requires default_initializable<_Start> = default;306 iota_view() requires default_initializable<_Start> = default;
307307
308 _LIBCPP_HIDE_FROM_ABI308 _LIBCPP_HIDE_FROM_ABI
309 constexpr explicit iota_view(_Start __value) : __value_(_VSTD::move(__value)) { }309 constexpr explicit iota_view(_Start __value) : __value_(std::move(__value)) { }
310310
311 _LIBCPP_HIDE_FROM_ABI311 _LIBCPP_HIDE_FROM_ABI
312 constexpr iota_view(type_identity_t<_Start> __value, type_identity_t<_Bound> __bound)312 constexpr iota_view(type_identity_t<_Start> __value, type_identity_t<_BoundSentinel> __bound_sentinel)
313 : __value_(_VSTD::move(__value)), __bound_(_VSTD::move(__bound)) {313 : __value_(std::move(__value)), __bound_sentinel_(std::move(__bound_sentinel)) {
314 // Validate the precondition if possible.314 // Validate the precondition if possible.
315 if constexpr (totally_ordered_with<_Start, _Bound>) {315 if constexpr (totally_ordered_with<_Start, _BoundSentinel>) {
316 _LIBCPP_ASSERT(ranges::less_equal()(__value_, __bound_),316 _LIBCPP_ASSERT(ranges::less_equal()(__value_, __bound_sentinel_),
317 "Precondition violated: value is greater than bound.");317 "Precondition violated: value is greater than bound.");
318 }318 }
319 }319 }
320320
321 _LIBCPP_HIDE_FROM_ABI321 _LIBCPP_HIDE_FROM_ABI
322 constexpr iota_view(__iterator __first, __iterator __last)322 constexpr iota_view(__iterator __first, __iterator __last)
323 requires same_as<_Start, _Bound>323 requires same_as<_Start, _BoundSentinel>
324 : iota_view(_VSTD::move(__first.__value_), _VSTD::move(__last.__value_)) {}324 : iota_view(std::move(__first.__value_), std::move(__last.__value_)) {}
325325
326 _LIBCPP_HIDE_FROM_ABI326 _LIBCPP_HIDE_FROM_ABI
327 constexpr iota_view(__iterator __first, _Bound __last)327 constexpr iota_view(__iterator __first, _BoundSentinel __last)
328 requires same_as<_Bound, unreachable_sentinel_t>328 requires same_as<_BoundSentinel, unreachable_sentinel_t>
329 : iota_view(_VSTD::move(__first.__value_), _VSTD::move(__last)) {}329 : iota_view(std::move(__first.__value_), std::move(__last)) {}
330330
331 _LIBCPP_HIDE_FROM_ABI331 _LIBCPP_HIDE_FROM_ABI
332 constexpr iota_view(__iterator __first, __sentinel __last)332 constexpr iota_view(__iterator __first, __sentinel __last)
333 requires (!same_as<_Start, _Bound> && !same_as<_Start, unreachable_sentinel_t>)333 requires(!same_as<_Start, _BoundSentinel> && !same_as<_Start, unreachable_sentinel_t>)
334 : iota_view(_VSTD::move(__first.__value_), _VSTD::move(__last.__bound_)) {}334 : iota_view(std::move(__first.__value_), std::move(__last.__bound_sentinel_)) {}
335335
336 _LIBCPP_HIDE_FROM_ABI336 _LIBCPP_HIDE_FROM_ABI
337 constexpr __iterator begin() const { return __iterator{__value_}; }337 constexpr __iterator begin() const { return __iterator{__value_}; }
338338
339 _LIBCPP_HIDE_FROM_ABI339 _LIBCPP_HIDE_FROM_ABI
340 constexpr auto end() const {340 constexpr auto end() const {
341 if constexpr (same_as<_Bound, unreachable_sentinel_t>)341 if constexpr (same_as<_BoundSentinel, unreachable_sentinel_t>)
342 return unreachable_sentinel;342 return unreachable_sentinel;
343 else343 else
344 return __sentinel{__bound_};344 return __sentinel{__bound_sentinel_};
345 }345 }
346346
347 _LIBCPP_HIDE_FROM_ABI347 _LIBCPP_HIDE_FROM_ABI
348 constexpr __iterator end() const requires same_as<_Start, _Bound> {348 constexpr __iterator end() const
349 return __iterator{__bound_};349 requires same_as<_Start, _BoundSentinel>
350 {
351 return __iterator{__bound_sentinel_};
350 }352 }
351353
352 _LIBCPP_HIDE_FROM_ABI354 _LIBCPP_HIDE_FROM_ABI
353 constexpr auto size() const355 constexpr auto size() const
354 requires (same_as<_Start, _Bound> && __advanceable<_Start>) ||356 requires(same_as<_Start, _BoundSentinel> && __advanceable<_Start>) ||
355 (integral<_Start> && integral<_Bound>) ||357 (integral<_Start> && integral<_BoundSentinel>) || sized_sentinel_for<_BoundSentinel, _Start>
356 sized_sentinel_for<_Bound, _Start>
357 {358 {
358 if constexpr (__integer_like<_Start> && __integer_like<_Bound>) {359 if constexpr (__integer_like<_Start> && __integer_like<_BoundSentinel>) {
359 if (__value_ < 0) {360 if (__value_ < 0) {
360 if (__bound_ < 0) {361 if (__bound_sentinel_ < 0) {
361 return _VSTD::__to_unsigned_like(-__value_) - _VSTD::__to_unsigned_like(-__bound_);362 return std::__to_unsigned_like(-__value_) - std::__to_unsigned_like(-__bound_sentinel_);
362 }363 }
363 return _VSTD::__to_unsigned_like(__bound_) + _VSTD::__to_unsigned_like(-__value_);364 return std::__to_unsigned_like(__bound_sentinel_) + std::__to_unsigned_like(-__value_);
364 }365 }
365 return _VSTD::__to_unsigned_like(__bound_) - _VSTD::__to_unsigned_like(__value_);366 return std::__to_unsigned_like(__bound_sentinel_) - std::__to_unsigned_like(__value_);
366 }367 }
367 return _VSTD::__to_unsigned_like(__bound_ - __value_);368 return std::__to_unsigned_like(__bound_sentinel_ - __value_);
368 }369 }
369 };370 };
370371
371 template<class _Start, class _Bound>372 template <class _Start, class _BoundSentinel>
372 requires (!__integer_like<_Start> || !__integer_like<_Bound> ||373 requires(!__integer_like<_Start> || !__integer_like<_BoundSentinel> ||
373 (__signed_integer_like<_Start> == __signed_integer_like<_Bound>))374 (__signed_integer_like<_Start> == __signed_integer_like<_BoundSentinel>))
374 iota_view(_Start, _Bound) -> iota_view<_Start, _Bound>;375 iota_view(_Start, _BoundSentinel) -> iota_view<_Start, _BoundSentinel>;
375376
376 template<class _Start, class _Bound>377 template <class _Start, class _BoundSentinel>
377 inline constexpr bool enable_borrowed_range<iota_view<_Start, _Bound>> = true;378 inline constexpr bool enable_borrowed_range<iota_view<_Start, _BoundSentinel>> = true;
378379
379namespace views {380 namespace views {
380namespace __iota {381 namespace __iota {
381 struct __fn {382 struct __fn {
382 template<class _Start>383 template<class _Start>
383 _LIBCPP_HIDE_FROM_ABI384 _LIBCPP_HIDE_FROM_ABI
384 constexpr auto operator()(_Start&& __start) const385 constexpr auto operator()(_Start&& __start) const
385 noexcept(noexcept(ranges::iota_view(_VSTD::forward<_Start>(__start))))386 noexcept(noexcept(ranges::iota_view(std::forward<_Start>(__start))))
386 -> decltype( ranges::iota_view(_VSTD::forward<_Start>(__start)))387 -> decltype( ranges::iota_view(std::forward<_Start>(__start)))
387 { return ranges::iota_view(_VSTD::forward<_Start>(__start)); }388 { return ranges::iota_view(std::forward<_Start>(__start)); }
388389
389 template<class _Start, class _Bound>390 template <class _Start, class _BoundSentinel>
390 _LIBCPP_HIDE_FROM_ABI391 _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Start&& __start, _BoundSentinel&& __bound_sentinel) const
391 constexpr auto operator()(_Start&& __start, _Bound&& __bound) const392 noexcept(noexcept(ranges::iota_view(std::forward<_Start>(__start), std::forward<_BoundSentinel>(__bound_sentinel))))
392 noexcept(noexcept(ranges::iota_view(_VSTD::forward<_Start>(__start), _VSTD::forward<_Bound>(__bound))))393 -> decltype( ranges::iota_view(std::forward<_Start>(__start), std::forward<_BoundSentinel>(__bound_sentinel)))
393 -> decltype( ranges::iota_view(_VSTD::forward<_Start>(__start), _VSTD::forward<_Bound>(__bound)))394 { return ranges::iota_view(std::forward<_Start>(__start), std::forward<_BoundSentinel>(__bound_sentinel)); }
394 { return ranges::iota_view(_VSTD::forward<_Start>(__start), _VSTD::forward<_Bound>(__bound)); }
395 };395 };
396} // namespace __iota396} // namespace __iota
397397
...@@ -401,7 +401,7 @@ inline namespace __cpo {...@@ -401,7 +401,7 @@ inline namespace __cpo {
401} // namespace views401} // namespace views
402} // namespace ranges402} // namespace ranges
403403
404#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)404#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
405405
406_LIBCPP_END_NAMESPACE_STD406_LIBCPP_END_NAMESPACE_STD
407407
lib/libcxx/include/__ranges/join_view.h+40-20
...@@ -9,28 +9,33 @@...@@ -9,28 +9,33 @@
9#ifndef _LIBCPP___RANGES_JOIN_VIEW_H9#ifndef _LIBCPP___RANGES_JOIN_VIEW_H
10#define _LIBCPP___RANGES_JOIN_VIEW_H10#define _LIBCPP___RANGES_JOIN_VIEW_H
1111
12#include <__concepts/constructible.h>
13#include <__concepts/convertible_to.h>
14#include <__concepts/copyable.h>
15#include <__concepts/derived_from.h>
16#include <__concepts/equality_comparable.h>
12#include <__config>17#include <__config>
13#include <__iterator/concepts.h>18#include <__iterator/concepts.h>
19#include <__iterator/iter_move.h>
20#include <__iterator/iter_swap.h>
14#include <__iterator/iterator_traits.h>21#include <__iterator/iterator_traits.h>
15#include <__ranges/access.h>22#include <__ranges/access.h>
16#include <__ranges/all.h>23#include <__ranges/all.h>
17#include <__ranges/concepts.h>24#include <__ranges/concepts.h>
18#include <__ranges/non_propagating_cache.h>25#include <__ranges/non_propagating_cache.h>
19#include <__ranges/ref_view.h>26#include <__ranges/range_adaptor.h>
20#include <__ranges/subrange.h>
21#include <__ranges/view_interface.h>27#include <__ranges/view_interface.h>
22#include <__utility/declval.h>
23#include <__utility/forward.h>28#include <__utility/forward.h>
24#include <optional>29#include <optional>
25#include <type_traits>30#include <type_traits>
2631
27#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)32#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
28#pragma GCC system_header33# pragma GCC system_header
29#endif34#endif
3035
31_LIBCPP_BEGIN_NAMESPACE_STD36_LIBCPP_BEGIN_NAMESPACE_STD
3237
33#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)38#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
3439
35namespace ranges {40namespace ranges {
36 template<class>41 template<class>
...@@ -45,7 +50,8 @@ namespace ranges {...@@ -45,7 +50,8 @@ namespace ranges {
45 using _InnerC = typename iterator_traits<iterator_t<range_reference_t<_View>>>::iterator_category;50 using _InnerC = typename iterator_traits<iterator_t<range_reference_t<_View>>>::iterator_category;
4651
47 using iterator_category = _If<52 using iterator_category = _If<
48 derived_from<_OuterC, bidirectional_iterator_tag> && derived_from<_InnerC, bidirectional_iterator_tag>,53 derived_from<_OuterC, bidirectional_iterator_tag> && derived_from<_InnerC, bidirectional_iterator_tag> &&
54 common_range<range_reference_t<_View>>,
49 bidirectional_iterator_tag,55 bidirectional_iterator_tag,
50 _If<56 _If<
51 derived_from<_OuterC, forward_iterator_tag> && derived_from<_InnerC, forward_iterator_tag>,57 derived_from<_OuterC, forward_iterator_tag> && derived_from<_InnerC, forward_iterator_tag>,
...@@ -67,8 +73,8 @@ namespace ranges {...@@ -67,8 +73,8 @@ namespace ranges {
6773
68 static constexpr bool _UseCache = !is_reference_v<_InnerRange>;74 static constexpr bool _UseCache = !is_reference_v<_InnerRange>;
69 using _Cache = _If<_UseCache, __non_propagating_cache<remove_cvref_t<_InnerRange>>, __empty_cache>;75 using _Cache = _If<_UseCache, __non_propagating_cache<remove_cvref_t<_InnerRange>>, __empty_cache>;
70 [[no_unique_address]] _Cache __cache_;76 _LIBCPP_NO_UNIQUE_ADDRESS _Cache __cache_;
71 _View __base_ = _View(); // TODO: [[no_unique_address]] makes clang crash! File a bug :)77 _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View();
7278
73 public:79 public:
74 _LIBCPP_HIDE_FROM_ABI80 _LIBCPP_HIDE_FROM_ABI
...@@ -76,13 +82,13 @@ namespace ranges {...@@ -76,13 +82,13 @@ namespace ranges {
7682
77 _LIBCPP_HIDE_FROM_ABI83 _LIBCPP_HIDE_FROM_ABI
78 constexpr explicit join_view(_View __base)84 constexpr explicit join_view(_View __base)
79 : __base_(_VSTD::move(__base)) {}85 : __base_(std::move(__base)) {}
8086
81 _LIBCPP_HIDE_FROM_ABI87 _LIBCPP_HIDE_FROM_ABI
82 constexpr _View base() const& requires copy_constructible<_View> { return __base_; }88 constexpr _View base() const& requires copy_constructible<_View> { return __base_; }
8389
84 _LIBCPP_HIDE_FROM_ABI90 _LIBCPP_HIDE_FROM_ABI
85 constexpr _View base() && { return _VSTD::move(__base_); }91 constexpr _View base() && { return std::move(__base_); }
8692
87 _LIBCPP_HIDE_FROM_ABI93 _LIBCPP_HIDE_FROM_ABI
88 constexpr auto begin() {94 constexpr auto begin() {
...@@ -152,7 +158,7 @@ namespace ranges {...@@ -152,7 +158,7 @@ namespace ranges {
152 _LIBCPP_HIDE_FROM_ABI158 _LIBCPP_HIDE_FROM_ABI
153 constexpr __sentinel(__sentinel<!_Const> __s)159 constexpr __sentinel(__sentinel<!_Const> __s)
154 requires _Const && convertible_to<sentinel_t<_View>, sentinel_t<_Base>>160 requires _Const && convertible_to<sentinel_t<_View>, sentinel_t<_Base>>
155 : __end_(_VSTD::move(__s.__end_)) {}161 : __end_(std::move(__s.__end_)) {}
156162
157 template<bool _OtherConst>163 template<bool _OtherConst>
158 requires sentinel_for<sentinel_t<_Base>, iterator_t<__maybe_const<_OtherConst, _View>>>164 requires sentinel_for<sentinel_t<_Base>, iterator_t<__maybe_const<_OtherConst, _View>>>
...@@ -204,7 +210,8 @@ namespace ranges {...@@ -204,7 +210,8 @@ namespace ranges {
204210
205 public:211 public:
206 using iterator_concept = _If<212 using iterator_concept = _If<
207 __ref_is_glvalue && bidirectional_range<_Base> && bidirectional_range<range_reference_t<_Base>>,213 __ref_is_glvalue && bidirectional_range<_Base> && bidirectional_range<range_reference_t<_Base>> &&
214 common_range<range_reference_t<_Base>>,
208 bidirectional_iterator_tag,215 bidirectional_iterator_tag,
209 _If<216 _If<
210 __ref_is_glvalue && forward_range<_Base> && forward_range<range_reference_t<_Base>>,217 __ref_is_glvalue && forward_range<_Base> && forward_range<range_reference_t<_Base>>,
...@@ -223,8 +230,8 @@ namespace ranges {...@@ -223,8 +230,8 @@ namespace ranges {
223230
224 _LIBCPP_HIDE_FROM_ABI231 _LIBCPP_HIDE_FROM_ABI
225 constexpr __iterator(_Parent& __parent, _Outer __outer)232 constexpr __iterator(_Parent& __parent, _Outer __outer)
226 : __outer_(_VSTD::move(__outer))233 : __outer_(std::move(__outer))
227 , __parent_(_VSTD::addressof(__parent)) {234 , __parent_(std::addressof(__parent)) {
228 __satisfy();235 __satisfy();
229 }236 }
230237
...@@ -233,8 +240,8 @@ namespace ranges {...@@ -233,8 +240,8 @@ namespace ranges {
233 requires _Const &&240 requires _Const &&
234 convertible_to<iterator_t<_View>, _Outer> &&241 convertible_to<iterator_t<_View>, _Outer> &&
235 convertible_to<iterator_t<_InnerRange>, _Inner>242 convertible_to<iterator_t<_InnerRange>, _Inner>
236 : __outer_(_VSTD::move(__i.__outer_))243 : __outer_(std::move(__i.__outer_))
237 , __inner_(_VSTD::move(__i.__inner_))244 , __inner_(std::move(__i.__inner_))
238 , __parent_(__i.__parent_) {}245 , __parent_(__i.__parent_) {}
239246
240 _LIBCPP_HIDE_FROM_ABI247 _LIBCPP_HIDE_FROM_ABI
...@@ -338,12 +345,25 @@ namespace ranges {...@@ -338,12 +345,25 @@ namespace ranges {
338345
339 template<class _Range>346 template<class _Range>
340 explicit join_view(_Range&&) -> join_view<views::all_t<_Range>>;347 explicit join_view(_Range&&) -> join_view<views::all_t<_Range>>;
341348
349namespace views {
350namespace __join_view {
351struct __fn : __range_adaptor_closure<__fn> {
352 template<class _Range>
353 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
354 constexpr auto operator()(_Range&& __range) const
355 noexcept(noexcept(join_view<all_t<_Range&&>>(std::forward<_Range>(__range))))
356 -> decltype( join_view<all_t<_Range&&>>(std::forward<_Range>(__range)))
357 { return join_view<all_t<_Range&&>>(std::forward<_Range>(__range)); }
358};
359} // namespace __join_view
360inline namespace __cpo {
361 inline constexpr auto join = __join_view::__fn{};
362} // namespace __cpo
363} // namespace views
342} // namespace ranges364} // namespace ranges
343365
344#undef _CONSTEXPR_TERNARY366#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
345
346#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
347367
348_LIBCPP_END_NAMESPACE_STD368_LIBCPP_END_NAMESPACE_STD
349369
lib/libcxx/include/__ranges/lazy_split_view.h created+465
...@@ -0,0 +1,465 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___RANGES_LAZY_SPLIT_VIEW_H
11#define _LIBCPP___RANGES_LAZY_SPLIT_VIEW_H
12
13#include <__algorithm/in_in_result.h>
14#include <__algorithm/ranges_find.h>
15#include <__algorithm/ranges_mismatch.h>
16#include <__concepts/constructible.h>
17#include <__concepts/convertible_to.h>
18#include <__concepts/derived_from.h>
19#include <__config>
20#include <__functional/bind_back.h>
21#include <__functional/ranges_operations.h>
22#include <__iterator/concepts.h>
23#include <__iterator/default_sentinel.h>
24#include <__iterator/incrementable_traits.h>
25#include <__iterator/indirectly_comparable.h>
26#include <__iterator/iter_move.h>
27#include <__iterator/iter_swap.h>
28#include <__iterator/iterator_traits.h>
29#include <__memory/addressof.h>
30#include <__ranges/access.h>
31#include <__ranges/all.h>
32#include <__ranges/concepts.h>
33#include <__ranges/non_propagating_cache.h>
34#include <__ranges/range_adaptor.h>
35#include <__ranges/single_view.h>
36#include <__ranges/subrange.h>
37#include <__ranges/view_interface.h>
38#include <__utility/forward.h>
39#include <__utility/move.h>
40#include <type_traits>
41
42#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
43# pragma GCC system_header
44#endif
45
46_LIBCPP_BEGIN_NAMESPACE_STD
47
48#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
49
50namespace ranges {
51
52template <auto> struct __require_constant;
53
54template <class _Range>
55concept __tiny_range =
56 sized_range<_Range> &&
57 requires { typename __require_constant<remove_reference_t<_Range>::size()>; } &&
58 (remove_reference_t<_Range>::size() <= 1);
59
60template <input_range _View, forward_range _Pattern>
61 requires view<_View> && view<_Pattern> &&
62 indirectly_comparable<iterator_t<_View>, iterator_t<_Pattern>, ranges::equal_to> &&
63 (forward_range<_View> || __tiny_range<_Pattern>)
64class lazy_split_view : public view_interface<lazy_split_view<_View, _Pattern>> {
65
66 _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View();
67 _LIBCPP_NO_UNIQUE_ADDRESS _Pattern __pattern_ = _Pattern();
68
69 using _MaybeCurrent = _If<!forward_range<_View>, __non_propagating_cache<iterator_t<_View>>, __empty_cache>;
70 _LIBCPP_NO_UNIQUE_ADDRESS _MaybeCurrent __current_ = _MaybeCurrent();
71
72 template <bool> struct __outer_iterator;
73 template <bool> struct __inner_iterator;
74
75public:
76 _LIBCPP_HIDE_FROM_ABI
77 lazy_split_view()
78 requires default_initializable<_View> && default_initializable<_Pattern> = default;
79
80 _LIBCPP_HIDE_FROM_ABI
81 constexpr lazy_split_view(_View __base, _Pattern __pattern)
82 : __base_(std::move(__base)), __pattern_(std::move(__pattern)) {}
83
84 template <input_range _Range>
85 requires constructible_from<_View, views::all_t<_Range>> &&
86 constructible_from<_Pattern, single_view<range_value_t<_Range>>>
87 _LIBCPP_HIDE_FROM_ABI
88 constexpr lazy_split_view(_Range&& __r, range_value_t<_Range> __e)
89 : __base_(views::all(std::forward<_Range>(__r)))
90 , __pattern_(views::single(std::move(__e))) {}
91
92 _LIBCPP_HIDE_FROM_ABI
93 constexpr _View base() const& requires copy_constructible<_View> { return __base_; }
94 _LIBCPP_HIDE_FROM_ABI
95 constexpr _View base() && { return std::move(__base_); }
96
97 _LIBCPP_HIDE_FROM_ABI
98 constexpr auto begin() {
99 if constexpr (forward_range<_View>) {
100 return __outer_iterator<__simple_view<_View> && __simple_view<_Pattern>>{*this, ranges::begin(__base_)};
101 } else {
102 __current_.__emplace(ranges::begin(__base_));
103 return __outer_iterator<false>{*this};
104 }
105 }
106
107 _LIBCPP_HIDE_FROM_ABI
108 constexpr auto begin() const requires forward_range<_View> && forward_range<const _View> {
109 return __outer_iterator<true>{*this, ranges::begin(__base_)};
110 }
111
112 _LIBCPP_HIDE_FROM_ABI
113 constexpr auto end() requires forward_range<_View> && common_range<_View> {
114 return __outer_iterator<__simple_view<_View> && __simple_view<_Pattern>>{*this, ranges::end(__base_)};
115 }
116
117 _LIBCPP_HIDE_FROM_ABI
118 constexpr auto end() const {
119 if constexpr (forward_range<_View> && forward_range<const _View> && common_range<const _View>) {
120 return __outer_iterator<true>{*this, ranges::end(__base_)};
121 } else {
122 return default_sentinel;
123 }
124 }
125
126private:
127
128 template <class>
129 struct __outer_iterator_category {};
130
131 template <forward_range _Tp>
132 struct __outer_iterator_category<_Tp> {
133 using iterator_category = input_iterator_tag;
134 };
135
136 template <bool _Const>
137 struct __outer_iterator : __outer_iterator_category<__maybe_const<_Const, _View>> {
138 private:
139 template <bool>
140 friend struct __inner_iterator;
141 friend __outer_iterator<true>;
142
143 using _Parent = __maybe_const<_Const, lazy_split_view>;
144 using _Base = __maybe_const<_Const, _View>;
145
146 _Parent* __parent_ = nullptr;
147 using _MaybeCurrent = _If<forward_range<_View>, iterator_t<_Base>, __empty_cache>;
148 _LIBCPP_NO_UNIQUE_ADDRESS _MaybeCurrent __current_ = _MaybeCurrent();
149 bool __trailing_empty_ = false;
150
151 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
152 constexpr auto& __current() noexcept {
153 if constexpr (forward_range<_View>) {
154 return __current_;
155 } else {
156 return *__parent_->__current_;
157 }
158 }
159
160 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
161 constexpr const auto& __current() const noexcept {
162 if constexpr (forward_range<_View>) {
163 return __current_;
164 } else {
165 return *__parent_->__current_;
166 }
167 }
168
169 // Workaround for the GCC issue that doesn't allow calling `__parent_->__base_` from friend functions (because
170 // `__base_` is private).
171 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
172 constexpr auto& __parent_base() const noexcept {
173 return __parent_->__base_;
174 }
175
176 public:
177 // using iterator_category = inherited;
178 using iterator_concept = conditional_t<forward_range<_Base>, forward_iterator_tag, input_iterator_tag>;
179 using difference_type = range_difference_t<_Base>;
180
181 struct value_type : view_interface<value_type> {
182 private:
183 __outer_iterator __i_ = __outer_iterator();
184
185 public:
186 _LIBCPP_HIDE_FROM_ABI
187 value_type() = default;
188 _LIBCPP_HIDE_FROM_ABI
189 constexpr explicit value_type(__outer_iterator __i)
190 : __i_(std::move(__i)) {}
191
192 _LIBCPP_HIDE_FROM_ABI
193 constexpr __inner_iterator<_Const> begin() const { return __inner_iterator<_Const>{__i_}; }
194 _LIBCPP_HIDE_FROM_ABI
195 constexpr default_sentinel_t end() const noexcept { return default_sentinel; }
196 };
197
198 _LIBCPP_HIDE_FROM_ABI
199 __outer_iterator() = default;
200
201 _LIBCPP_HIDE_FROM_ABI
202 constexpr explicit __outer_iterator(_Parent& __parent)
203 requires (!forward_range<_Base>)
204 : __parent_(std::addressof(__parent)) {}
205
206 _LIBCPP_HIDE_FROM_ABI
207 constexpr __outer_iterator(_Parent& __parent, iterator_t<_Base> __current)
208 requires forward_range<_Base>
209 : __parent_(std::addressof(__parent)), __current_(std::move(__current)) {}
210
211 _LIBCPP_HIDE_FROM_ABI
212 constexpr __outer_iterator(__outer_iterator<!_Const> __i)
213 requires _Const && convertible_to<iterator_t<_View>, iterator_t<_Base>>
214 : __parent_(__i.__parent_), __current_(std::move(__i.__current_)) {}
215
216 _LIBCPP_HIDE_FROM_ABI
217 constexpr value_type operator*() const { return value_type{*this}; }
218
219 _LIBCPP_HIDE_FROM_ABI
220 constexpr __outer_iterator& operator++() {
221 const auto __end = ranges::end(__parent_->__base_);
222 if (__current() == __end) {
223 __trailing_empty_ = false;
224 return *this;
225 }
226
227 const auto [__pbegin, __pend] = ranges::subrange{__parent_->__pattern_};
228 if (__pbegin == __pend) {
229 // Empty pattern: split on every element in the input range
230 ++__current();
231
232 } else if constexpr (__tiny_range<_Pattern>) {
233 // One-element pattern: we can use `ranges::find`.
234 __current() = ranges::find(std::move(__current()), __end, *__pbegin);
235 if (__current() != __end) {
236 // Make sure we point to after the separator we just found.
237 ++__current();
238 if (__current() == __end)
239 __trailing_empty_ = true;
240 }
241
242 } else {
243 // General case for n-element pattern.
244 do {
245 const auto [__b, __p] = ranges::mismatch(__current(), __end, __pbegin, __pend);
246 if (__p == __pend) {
247 __current() = __b;
248 if (__current() == __end) {
249 __trailing_empty_ = true;
250 }
251 break; // The pattern matched; skip it.
252 }
253 } while (++__current() != __end);
254 }
255
256 return *this;
257 }
258
259 _LIBCPP_HIDE_FROM_ABI
260 constexpr decltype(auto) operator++(int) {
261 if constexpr (forward_range<_Base>) {
262 auto __tmp = *this;
263 ++*this;
264 return __tmp;
265
266 } else {
267 ++*this;
268 }
269 }
270
271 _LIBCPP_HIDE_FROM_ABI
272 friend constexpr bool operator==(const __outer_iterator& __x, const __outer_iterator& __y)
273 requires forward_range<_Base> {
274 return __x.__current_ == __y.__current_ && __x.__trailing_empty_ == __y.__trailing_empty_;
275 }
276
277 _LIBCPP_HIDE_FROM_ABI
278 friend constexpr bool operator==(const __outer_iterator& __x, default_sentinel_t) {
279 _LIBCPP_ASSERT(__x.__parent_, "Cannot call comparison on a default-constructed iterator.");
280 return __x.__current() == ranges::end(__x.__parent_base()) && !__x.__trailing_empty_;
281 }
282 };
283
284 template <class>
285 struct __inner_iterator_category {};
286
287 template <forward_range _Tp>
288 struct __inner_iterator_category<_Tp> {
289 using iterator_category = _If<
290 derived_from<typename iterator_traits<iterator_t<_Tp>>::iterator_category, forward_iterator_tag>,
291 forward_iterator_tag,
292 typename iterator_traits<iterator_t<_Tp>>::iterator_category
293 >;
294 };
295
296 template <bool _Const>
297 struct __inner_iterator : __inner_iterator_category<__maybe_const<_Const, _View>> {
298 private:
299 using _Base = __maybe_const<_Const, _View>;
300 // Workaround for a GCC issue.
301 static constexpr bool _OuterConst = _Const;
302 __outer_iterator<_Const> __i_ = __outer_iterator<_OuterConst>();
303 bool __incremented_ = false;
304
305 // Note: these private functions are necessary because GCC doesn't allow calls to private members of `__i_` from
306 // free functions that are friends of `inner-iterator`.
307
308 _LIBCPP_HIDE_FROM_ABI
309 constexpr bool __is_done() const {
310 _LIBCPP_ASSERT(__i_.__parent_, "Cannot call comparison on a default-constructed iterator.");
311
312 auto [__pcur, __pend] = ranges::subrange{__i_.__parent_->__pattern_};
313 auto __end = ranges::end(__i_.__parent_->__base_);
314
315 if constexpr (__tiny_range<_Pattern>) {
316 const auto& __cur = __i_.__current();
317 if (__cur == __end)
318 return true;
319 if (__pcur == __pend)
320 return __incremented_;
321
322 return *__cur == *__pcur;
323
324 } else {
325 auto __cur = __i_.__current();
326 if (__cur == __end)
327 return true;
328 if (__pcur == __pend)
329 return __incremented_;
330
331 do {
332 if (*__cur != *__pcur)
333 return false;
334 if (++__pcur == __pend)
335 return true;
336 } while (++__cur != __end);
337
338 return false;
339 }
340 }
341
342 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
343 constexpr auto& __outer_current() noexcept {
344 return __i_.__current();
345 }
346
347 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
348 constexpr const auto& __outer_current() const noexcept {
349 return __i_.__current();
350 }
351
352 public:
353 // using iterator_category = inherited;
354 using iterator_concept = typename __outer_iterator<_Const>::iterator_concept;
355 using value_type = range_value_t<_Base>;
356 using difference_type = range_difference_t<_Base>;
357
358 _LIBCPP_HIDE_FROM_ABI
359 __inner_iterator() = default;
360
361 _LIBCPP_HIDE_FROM_ABI
362 constexpr explicit __inner_iterator(__outer_iterator<_Const> __i)
363 : __i_(std::move(__i)) {}
364
365 _LIBCPP_HIDE_FROM_ABI
366 constexpr const iterator_t<_Base>& base() const& noexcept { return __i_.__current(); }
367 _LIBCPP_HIDE_FROM_ABI
368 constexpr iterator_t<_Base> base() &&
369 requires forward_range<_View> { return std::move(__i_.__current()); }
370
371 _LIBCPP_HIDE_FROM_ABI
372 constexpr decltype(auto) operator*() const { return *__i_.__current(); }
373
374 _LIBCPP_HIDE_FROM_ABI
375 constexpr __inner_iterator& operator++() {
376 __incremented_ = true;
377
378 if constexpr (!forward_range<_Base>) {
379 if constexpr (_Pattern::size() == 0) {
380 return *this;
381 }
382 }
383
384 ++__i_.__current();
385 return *this;
386 }
387
388 _LIBCPP_HIDE_FROM_ABI
389 constexpr decltype(auto) operator++(int) {
390 if constexpr (forward_range<_Base>) {
391 auto __tmp = *this;
392 ++*this;
393 return __tmp;
394
395 } else {
396 ++*this;
397 }
398 }
399
400 _LIBCPP_HIDE_FROM_ABI
401 friend constexpr bool operator==(const __inner_iterator& __x, const __inner_iterator& __y)
402 requires forward_range<_Base> {
403 return __x.__outer_current() == __y.__outer_current();
404 }
405
406 _LIBCPP_HIDE_FROM_ABI
407 friend constexpr bool operator==(const __inner_iterator& __x, default_sentinel_t) {
408 return __x.__is_done();
409 }
410
411 _LIBCPP_HIDE_FROM_ABI
412 friend constexpr decltype(auto) iter_move(const __inner_iterator& __i)
413 noexcept(noexcept(ranges::iter_move(__i.__outer_current()))) {
414 return ranges::iter_move(__i.__outer_current());
415 }
416
417 _LIBCPP_HIDE_FROM_ABI
418 friend constexpr void iter_swap(const __inner_iterator& __x, const __inner_iterator& __y)
419 noexcept(noexcept(ranges::iter_swap(__x.__outer_current(), __y.__outer_current())))
420 requires indirectly_swappable<iterator_t<_Base>> {
421 ranges::iter_swap(__x.__outer_current(), __y.__outer_current());
422 }
423 };
424
425};
426
427template <class _Range, class _Pattern>
428lazy_split_view(_Range&&, _Pattern&&) -> lazy_split_view<views::all_t<_Range>, views::all_t<_Pattern>>;
429
430template <input_range _Range>
431lazy_split_view(_Range&&, range_value_t<_Range>)
432 -> lazy_split_view<views::all_t<_Range>, single_view<range_value_t<_Range>>>;
433
434namespace views {
435namespace __lazy_split_view {
436struct __fn : __range_adaptor_closure<__fn> {
437 template <class _Range, class _Pattern>
438 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
439 constexpr auto operator()(_Range&& __range, _Pattern&& __pattern) const
440 noexcept(noexcept(lazy_split_view(std::forward<_Range>(__range), std::forward<_Pattern>(__pattern))))
441 -> decltype( lazy_split_view(std::forward<_Range>(__range), std::forward<_Pattern>(__pattern)))
442 { return lazy_split_view(std::forward<_Range>(__range), std::forward<_Pattern>(__pattern)); }
443
444 template <class _Pattern>
445 requires constructible_from<decay_t<_Pattern>, _Pattern>
446 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
447 constexpr auto operator()(_Pattern&& __pattern) const
448 noexcept(is_nothrow_constructible_v<decay_t<_Pattern>, _Pattern>) {
449 return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Pattern>(__pattern)));
450 }
451};
452} // namespace __lazy_split_view
453
454inline namespace __cpo {
455 inline constexpr auto lazy_split = __lazy_split_view::__fn{};
456} // namespace __cpo
457} // namespace views
458
459} // namespace ranges
460
461#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
462
463_LIBCPP_END_NAMESPACE_STD
464
465#endif // _LIBCPP___RANGES_LAZY_SPLIT_VIEW_H
lib/libcxx/include/__ranges/non_propagating_cache.h+6-6
...@@ -19,12 +19,12 @@...@@ -19,12 +19,12 @@
19#include <type_traits>19#include <type_traits>
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
23#endif23#endif
2424
25_LIBCPP_BEGIN_NAMESPACE_STD25_LIBCPP_BEGIN_NAMESPACE_STD
2626
27#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
2828
29namespace ranges {29namespace ranges {
30 // __non_propagating_cache is a helper type that allows storing an optional value in it,30 // __non_propagating_cache is a helper type that allows storing an optional value in it,
...@@ -45,7 +45,7 @@ namespace ranges {...@@ -45,7 +45,7 @@ namespace ranges {
45 // constructing the contained type from an iterator.45 // constructing the contained type from an iterator.
46 struct __wrapper {46 struct __wrapper {
47 template<class ..._Args>47 template<class ..._Args>
48 constexpr explicit __wrapper(__forward_tag, _Args&& ...__args) : __t_(_VSTD::forward<_Args>(__args)...) { }48 constexpr explicit __wrapper(__forward_tag, _Args&& ...__args) : __t_(std::forward<_Args>(__args)...) { }
49 template<class _Fn>49 template<class _Fn>
50 constexpr explicit __wrapper(__from_tag, _Fn const& __f) : __t_(__f()) { }50 constexpr explicit __wrapper(__from_tag, _Fn const& __f) : __t_(__f()) { }
51 _Tp __t_;51 _Tp __t_;
...@@ -70,7 +70,7 @@ namespace ranges {...@@ -70,7 +70,7 @@ namespace ranges {
7070
71 _LIBCPP_HIDE_FROM_ABI71 _LIBCPP_HIDE_FROM_ABI
72 constexpr __non_propagating_cache& operator=(__non_propagating_cache const& __other) noexcept {72 constexpr __non_propagating_cache& operator=(__non_propagating_cache const& __other) noexcept {
73 if (this != _VSTD::addressof(__other)) {73 if (this != std::addressof(__other)) {
74 __value_.reset();74 __value_.reset();
75 }75 }
76 return *this;76 return *this;
...@@ -100,14 +100,14 @@ namespace ranges {...@@ -100,14 +100,14 @@ namespace ranges {
100 template<class ..._Args>100 template<class ..._Args>
101 _LIBCPP_HIDE_FROM_ABI101 _LIBCPP_HIDE_FROM_ABI
102 constexpr _Tp& __emplace(_Args&& ...__args) {102 constexpr _Tp& __emplace(_Args&& ...__args) {
103 return __value_.emplace(__forward_tag{}, _VSTD::forward<_Args>(__args)...).__t_;103 return __value_.emplace(__forward_tag{}, std::forward<_Args>(__args)...).__t_;
104 }104 }
105 };105 };
106106
107 struct __empty_cache { };107 struct __empty_cache { };
108} // namespace ranges108} // namespace ranges
109109
110#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)110#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
111111
112_LIBCPP_END_NAMESPACE_STD112_LIBCPP_END_NAMESPACE_STD
113113
lib/libcxx/include/__ranges/owning_view.h+6-6
...@@ -23,12 +23,12 @@...@@ -23,12 +23,12 @@
23#include <type_traits>23#include <type_traits>
2424
25#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)25#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
26#pragma GCC system_header26# pragma GCC system_header
27#endif27#endif
2828
29_LIBCPP_BEGIN_NAMESPACE_STD29_LIBCPP_BEGIN_NAMESPACE_STD
3030
31#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)31#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
3232
33namespace ranges {33namespace ranges {
34 template<range _Rp>34 template<range _Rp>
...@@ -38,15 +38,15 @@ namespace ranges {...@@ -38,15 +38,15 @@ namespace ranges {
3838
39public:39public:
40 owning_view() requires default_initializable<_Rp> = default;40 owning_view() requires default_initializable<_Rp> = default;
41 _LIBCPP_HIDE_FROM_ABI constexpr owning_view(_Rp&& __r) : __r_(_VSTD::move(__r)) {}41 _LIBCPP_HIDE_FROM_ABI constexpr owning_view(_Rp&& __r) : __r_(std::move(__r)) {}
4242
43 owning_view(owning_view&&) = default;43 owning_view(owning_view&&) = default;
44 owning_view& operator=(owning_view&&) = default;44 owning_view& operator=(owning_view&&) = default;
4545
46 _LIBCPP_HIDE_FROM_ABI constexpr _Rp& base() & noexcept { return __r_; }46 _LIBCPP_HIDE_FROM_ABI constexpr _Rp& base() & noexcept { return __r_; }
47 _LIBCPP_HIDE_FROM_ABI constexpr const _Rp& base() const& noexcept { return __r_; }47 _LIBCPP_HIDE_FROM_ABI constexpr const _Rp& base() const& noexcept { return __r_; }
48 _LIBCPP_HIDE_FROM_ABI constexpr _Rp&& base() && noexcept { return _VSTD::move(__r_); }48 _LIBCPP_HIDE_FROM_ABI constexpr _Rp&& base() && noexcept { return std::move(__r_); }
49 _LIBCPP_HIDE_FROM_ABI constexpr const _Rp&& base() const&& noexcept { return _VSTD::move(__r_); }49 _LIBCPP_HIDE_FROM_ABI constexpr const _Rp&& base() const&& noexcept { return std::move(__r_); }
5050
51 _LIBCPP_HIDE_FROM_ABI constexpr iterator_t<_Rp> begin() { return ranges::begin(__r_); }51 _LIBCPP_HIDE_FROM_ABI constexpr iterator_t<_Rp> begin() { return ranges::begin(__r_); }
52 _LIBCPP_HIDE_FROM_ABI constexpr sentinel_t<_Rp> end() { return ranges::end(__r_); }52 _LIBCPP_HIDE_FROM_ABI constexpr sentinel_t<_Rp> end() { return ranges::end(__r_); }
...@@ -74,7 +74,7 @@ public:...@@ -74,7 +74,7 @@ public:
7474
75} // namespace ranges75} // namespace ranges
7676
77#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)77#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
7878
79_LIBCPP_END_NAMESPACE_STD79_LIBCPP_END_NAMESPACE_STD
8080
lib/libcxx/include/__ranges/range_adaptor.h+6-6
...@@ -20,12 +20,12 @@...@@ -20,12 +20,12 @@
20#include <type_traits>20#include <type_traits>
2121
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23#pragma GCC system_header23# pragma GCC system_header
24#endif24#endif
2525
26_LIBCPP_BEGIN_NAMESPACE_STD26_LIBCPP_BEGIN_NAMESPACE_STD
2727
28#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)28#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
2929
30// CRTP base that one can derive from in order to be considered a range adaptor closure30// CRTP base that one can derive from in order to be considered a range adaptor closure
31// by the library. When deriving from this class, a pipe operator will be provided to31// by the library. When deriving from this class, a pipe operator will be provided to
...@@ -39,7 +39,7 @@ struct __range_adaptor_closure;...@@ -39,7 +39,7 @@ struct __range_adaptor_closure;
39// i.e. something that can be called via the `x | f` notation.39// i.e. something that can be called via the `x | f` notation.
40template <class _Fn>40template <class _Fn>
41struct __range_adaptor_closure_t : _Fn, __range_adaptor_closure<__range_adaptor_closure_t<_Fn>> {41struct __range_adaptor_closure_t : _Fn, __range_adaptor_closure<__range_adaptor_closure_t<_Fn>> {
42 constexpr explicit __range_adaptor_closure_t(_Fn&& __f) : _Fn(_VSTD::move(__f)) { }42 constexpr explicit __range_adaptor_closure_t(_Fn&& __f) : _Fn(std::move(__f)) { }
43};43};
4444
45template <class _Tp>45template <class _Tp>
...@@ -53,7 +53,7 @@ struct __range_adaptor_closure {...@@ -53,7 +53,7 @@ struct __range_adaptor_closure {
53 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI53 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
54 friend constexpr decltype(auto) operator|(_View&& __view, _Closure&& __closure)54 friend constexpr decltype(auto) operator|(_View&& __view, _Closure&& __closure)
55 noexcept(is_nothrow_invocable_v<_Closure, _View>)55 noexcept(is_nothrow_invocable_v<_Closure, _View>)
56 { return _VSTD::invoke(_VSTD::forward<_Closure>(__closure), _VSTD::forward<_View>(__view)); }56 { return std::invoke(std::forward<_Closure>(__closure), std::forward<_View>(__view)); }
5757
58 template <_RangeAdaptorClosure _Closure, _RangeAdaptorClosure _OtherClosure>58 template <_RangeAdaptorClosure _Closure, _RangeAdaptorClosure _OtherClosure>
59 requires same_as<_Tp, remove_cvref_t<_Closure>> &&59 requires same_as<_Tp, remove_cvref_t<_Closure>> &&
...@@ -63,10 +63,10 @@ struct __range_adaptor_closure {...@@ -63,10 +63,10 @@ struct __range_adaptor_closure {
63 friend constexpr auto operator|(_Closure&& __c1, _OtherClosure&& __c2)63 friend constexpr auto operator|(_Closure&& __c1, _OtherClosure&& __c2)
64 noexcept(is_nothrow_constructible_v<decay_t<_Closure>, _Closure> &&64 noexcept(is_nothrow_constructible_v<decay_t<_Closure>, _Closure> &&
65 is_nothrow_constructible_v<decay_t<_OtherClosure>, _OtherClosure>)65 is_nothrow_constructible_v<decay_t<_OtherClosure>, _OtherClosure>)
66 { return __range_adaptor_closure_t(_VSTD::__compose(_VSTD::forward<_OtherClosure>(__c2), _VSTD::forward<_Closure>(__c1))); }66 { return __range_adaptor_closure_t(std::__compose(std::forward<_OtherClosure>(__c2), std::forward<_Closure>(__c1))); }
67};67};
6868
69#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)69#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
7070
71_LIBCPP_END_NAMESPACE_STD71_LIBCPP_END_NAMESPACE_STD
7272
lib/libcxx/include/__ranges/rbegin.h created+130
...@@ -0,0 +1,130 @@
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___RANGES_RBEGIN_H
10#define _LIBCPP___RANGES_RBEGIN_H
11
12#include <__concepts/class_or_enum.h>
13#include <__concepts/same_as.h>
14#include <__config>
15#include <__iterator/concepts.h>
16#include <__iterator/readable_traits.h>
17#include <__iterator/reverse_iterator.h>
18#include <__ranges/access.h>
19#include <__utility/auto_cast.h>
20#include <type_traits>
21
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23# pragma GCC system_header
24#endif
25
26_LIBCPP_BEGIN_NAMESPACE_STD
27
28#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
29
30// [ranges.access.rbegin]
31
32namespace ranges {
33namespace __rbegin {
34template <class _Tp>
35concept __member_rbegin =
36 __can_borrow<_Tp> &&
37 __workaround_52970<_Tp> &&
38 requires(_Tp&& __t) {
39 { _LIBCPP_AUTO_CAST(__t.rbegin()) } -> input_or_output_iterator;
40 };
41
42void rbegin(auto&) = delete;
43void rbegin(const auto&) = delete;
44
45template <class _Tp>
46concept __unqualified_rbegin =
47 !__member_rbegin<_Tp> &&
48 __can_borrow<_Tp> &&
49 __class_or_enum<remove_cvref_t<_Tp>> &&
50 requires(_Tp&& __t) {
51 { _LIBCPP_AUTO_CAST(rbegin(__t)) } -> input_or_output_iterator;
52 };
53
54template <class _Tp>
55concept __can_reverse =
56 __can_borrow<_Tp> &&
57 !__member_rbegin<_Tp> &&
58 !__unqualified_rbegin<_Tp> &&
59 requires(_Tp&& __t) {
60 { ranges::begin(__t) } -> same_as<decltype(ranges::end(__t))>;
61 { ranges::begin(__t) } -> bidirectional_iterator;
62 };
63
64struct __fn {
65 template <class _Tp>
66 requires __member_rbegin<_Tp>
67 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
68 noexcept(noexcept(_LIBCPP_AUTO_CAST(__t.rbegin())))
69 {
70 return _LIBCPP_AUTO_CAST(__t.rbegin());
71 }
72
73 template <class _Tp>
74 requires __unqualified_rbegin<_Tp>
75 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
76 noexcept(noexcept(_LIBCPP_AUTO_CAST(rbegin(__t))))
77 {
78 return _LIBCPP_AUTO_CAST(rbegin(__t));
79 }
80
81 template <class _Tp>
82 requires __can_reverse<_Tp>
83 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
84 noexcept(noexcept(ranges::end(__t)))
85 {
86 return std::make_reverse_iterator(ranges::end(__t));
87 }
88
89 void operator()(auto&&) const = delete;
90};
91} // namespace __rbegin
92
93inline namespace __cpo {
94 inline constexpr auto rbegin = __rbegin::__fn{};
95} // namespace __cpo
96} // namespace ranges
97
98// [range.access.crbegin]
99
100namespace ranges {
101namespace __crbegin {
102struct __fn {
103 template <class _Tp>
104 requires is_lvalue_reference_v<_Tp&&>
105 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
106 constexpr auto operator()(_Tp&& __t) const
107 noexcept(noexcept(ranges::rbegin(static_cast<const remove_reference_t<_Tp>&>(__t))))
108 -> decltype( ranges::rbegin(static_cast<const remove_reference_t<_Tp>&>(__t)))
109 { return ranges::rbegin(static_cast<const remove_reference_t<_Tp>&>(__t)); }
110
111 template <class _Tp>
112 requires is_rvalue_reference_v<_Tp&&>
113 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
114 constexpr auto operator()(_Tp&& __t) const
115 noexcept(noexcept(ranges::rbegin(static_cast<const _Tp&&>(__t))))
116 -> decltype( ranges::rbegin(static_cast<const _Tp&&>(__t)))
117 { return ranges::rbegin(static_cast<const _Tp&&>(__t)); }
118};
119} // namespace __crbegin
120
121inline namespace __cpo {
122 inline constexpr auto crbegin = __crbegin::__fn{};
123} // namespace __cpo
124} // namespace ranges
125
126#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
127
128_LIBCPP_END_NAMESPACE_STD
129
130#endif // _LIBCPP___RANGES_RBEGIN_H
lib/libcxx/include/__ranges/ref_view.h+4-4
...@@ -26,12 +26,12 @@...@@ -26,12 +26,12 @@
26#include <type_traits>26#include <type_traits>
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
30#endif30#endif
3131
32_LIBCPP_BEGIN_NAMESPACE_STD32_LIBCPP_BEGIN_NAMESPACE_STD
3333
34#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)34#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
3535
36namespace ranges {36namespace ranges {
37 template<range _Range>37 template<range _Range>
...@@ -48,7 +48,7 @@ public:...@@ -48,7 +48,7 @@ public:
48 convertible_to<_Tp, _Range&> && requires { __fun(declval<_Tp>()); }48 convertible_to<_Tp, _Range&> && requires { __fun(declval<_Tp>()); }
49 _LIBCPP_HIDE_FROM_ABI49 _LIBCPP_HIDE_FROM_ABI
50 constexpr ref_view(_Tp&& __t)50 constexpr ref_view(_Tp&& __t)
51 : __range_(_VSTD::addressof(static_cast<_Range&>(_VSTD::forward<_Tp>(__t))))51 : __range_(std::addressof(static_cast<_Range&>(std::forward<_Tp>(__t))))
52 {}52 {}
5353
54 _LIBCPP_HIDE_FROM_ABI constexpr _Range& base() const { return *__range_; }54 _LIBCPP_HIDE_FROM_ABI constexpr _Range& base() const { return *__range_; }
...@@ -79,7 +79,7 @@ public:...@@ -79,7 +79,7 @@ public:
79 inline constexpr bool enable_borrowed_range<ref_view<_Tp>> = true;79 inline constexpr bool enable_borrowed_range<ref_view<_Tp>> = true;
80} // namespace ranges80} // namespace ranges
8181
82#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)82#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
8383
84_LIBCPP_END_NAMESPACE_STD84_LIBCPP_END_NAMESPACE_STD
8585
lib/libcxx/include/__ranges/rend.h created+134
...@@ -0,0 +1,134 @@
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___RANGES_REND_H
10#define _LIBCPP___RANGES_REND_H
11
12#include <__concepts/class_or_enum.h>
13#include <__concepts/same_as.h>
14#include <__config>
15#include <__iterator/concepts.h>
16#include <__iterator/readable_traits.h>
17#include <__iterator/reverse_iterator.h>
18#include <__ranges/access.h>
19#include <__ranges/rbegin.h>
20#include <__utility/auto_cast.h>
21#include <type_traits>
22
23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
24# pragma GCC system_header
25#endif
26
27_LIBCPP_BEGIN_NAMESPACE_STD
28
29#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
30
31// [range.access.rend]
32
33namespace ranges {
34namespace __rend {
35template <class _Tp>
36concept __member_rend =
37 __can_borrow<_Tp> &&
38 __workaround_52970<_Tp> &&
39 requires(_Tp&& __t) {
40 ranges::rbegin(__t);
41 { _LIBCPP_AUTO_CAST(__t.rend()) } -> sentinel_for<decltype(ranges::rbegin(__t))>;
42 };
43
44void rend(auto&) = delete;
45void rend(const auto&) = delete;
46
47template <class _Tp>
48concept __unqualified_rend =
49 !__member_rend<_Tp> &&
50 __can_borrow<_Tp> &&
51 __class_or_enum<remove_cvref_t<_Tp>> &&
52 requires(_Tp&& __t) {
53 ranges::rbegin(__t);
54 { _LIBCPP_AUTO_CAST(rend(__t)) } -> sentinel_for<decltype(ranges::rbegin(__t))>;
55 };
56
57template <class _Tp>
58concept __can_reverse =
59 __can_borrow<_Tp> &&
60 !__member_rend<_Tp> &&
61 !__unqualified_rend<_Tp> &&
62 requires(_Tp&& __t) {
63 { ranges::begin(__t) } -> same_as<decltype(ranges::end(__t))>;
64 { ranges::begin(__t) } -> bidirectional_iterator;
65 };
66
67class __fn {
68public:
69 template <class _Tp>
70 requires __member_rend<_Tp>
71 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
72 noexcept(noexcept(_LIBCPP_AUTO_CAST(__t.rend())))
73 {
74 return _LIBCPP_AUTO_CAST(__t.rend());
75 }
76
77 template <class _Tp>
78 requires __unqualified_rend<_Tp>
79 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
80 noexcept(noexcept(_LIBCPP_AUTO_CAST(rend(__t))))
81 {
82 return _LIBCPP_AUTO_CAST(rend(__t));
83 }
84
85 template <class _Tp>
86 requires __can_reverse<_Tp>
87 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
88 noexcept(noexcept(ranges::begin(__t)))
89 {
90 return std::make_reverse_iterator(ranges::begin(__t));
91 }
92
93 void operator()(auto&&) const = delete;
94};
95} // namespace __rend
96
97inline namespace __cpo {
98 inline constexpr auto rend = __rend::__fn{};
99} // namespace __cpo
100} // namespace ranges
101
102// [range.access.crend]
103
104namespace ranges {
105namespace __crend {
106struct __fn {
107 template <class _Tp>
108 requires is_lvalue_reference_v<_Tp&&>
109 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
110 constexpr auto operator()(_Tp&& __t) const
111 noexcept(noexcept(ranges::rend(static_cast<const remove_reference_t<_Tp>&>(__t))))
112 -> decltype( ranges::rend(static_cast<const remove_reference_t<_Tp>&>(__t)))
113 { return ranges::rend(static_cast<const remove_reference_t<_Tp>&>(__t)); }
114
115 template <class _Tp>
116 requires is_rvalue_reference_v<_Tp&&>
117 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
118 constexpr auto operator()(_Tp&& __t) const
119 noexcept(noexcept(ranges::rend(static_cast<const _Tp&&>(__t))))
120 -> decltype( ranges::rend(static_cast<const _Tp&&>(__t)))
121 { return ranges::rend(static_cast<const _Tp&&>(__t)); }
122};
123} // namespace __crend
124
125inline namespace __cpo {
126 inline constexpr auto crend = __crend::__fn{};
127} // namespace __cpo
128} // namespace ranges
129
130#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
131
132_LIBCPP_END_NAMESPACE_STD
133
134#endif // _LIBCPP___RANGES_REND_H
lib/libcxx/include/__ranges/reverse_view.h+24-24
...@@ -28,12 +28,12 @@...@@ -28,12 +28,12 @@
28#include <type_traits>28#include <type_traits>
2929
30#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)30#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
31#pragma GCC system_header31# pragma GCC system_header
32#endif32#endif
3333
34_LIBCPP_BEGIN_NAMESPACE_STD34_LIBCPP_BEGIN_NAMESPACE_STD
3535
36#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)36#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
3737
38namespace ranges {38namespace ranges {
39 template<view _View>39 template<view _View>
...@@ -43,21 +43,21 @@ namespace ranges {...@@ -43,21 +43,21 @@ namespace ranges {
43 // amortized O(1) begin() method.43 // amortized O(1) begin() method.
44 static constexpr bool _UseCache = !random_access_range<_View> && !common_range<_View>;44 static constexpr bool _UseCache = !random_access_range<_View> && !common_range<_View>;
45 using _Cache = _If<_UseCache, __non_propagating_cache<reverse_iterator<iterator_t<_View>>>, __empty_cache>;45 using _Cache = _If<_UseCache, __non_propagating_cache<reverse_iterator<iterator_t<_View>>>, __empty_cache>;
46 [[no_unique_address]] _Cache __cached_begin_ = _Cache();46 _LIBCPP_NO_UNIQUE_ADDRESS _Cache __cached_begin_ = _Cache();
47 [[no_unique_address]] _View __base_ = _View();47 _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View();
4848
49 public:49 public:
50 _LIBCPP_HIDE_FROM_ABI50 _LIBCPP_HIDE_FROM_ABI
51 reverse_view() requires default_initializable<_View> = default;51 reverse_view() requires default_initializable<_View> = default;
5252
53 _LIBCPP_HIDE_FROM_ABI53 _LIBCPP_HIDE_FROM_ABI
54 constexpr explicit reverse_view(_View __view) : __base_(_VSTD::move(__view)) {}54 constexpr explicit reverse_view(_View __view) : __base_(std::move(__view)) {}
5555
56 _LIBCPP_HIDE_FROM_ABI56 _LIBCPP_HIDE_FROM_ABI
57 constexpr _View base() const& requires copy_constructible<_View> { return __base_; }57 constexpr _View base() const& requires copy_constructible<_View> { return __base_; }
5858
59 _LIBCPP_HIDE_FROM_ABI59 _LIBCPP_HIDE_FROM_ABI
60 constexpr _View base() && { return _VSTD::move(__base_); }60 constexpr _View base() && { return std::move(__base_); }
6161
62 _LIBCPP_HIDE_FROM_ABI62 _LIBCPP_HIDE_FROM_ABI
63 constexpr reverse_iterator<iterator_t<_View>> begin() {63 constexpr reverse_iterator<iterator_t<_View>> begin() {
...@@ -65,7 +65,7 @@ namespace ranges {...@@ -65,7 +65,7 @@ namespace ranges {
65 if (__cached_begin_.__has_value())65 if (__cached_begin_.__has_value())
66 return *__cached_begin_;66 return *__cached_begin_;
6767
68 auto __tmp = _VSTD::make_reverse_iterator(ranges::next(ranges::begin(__base_), ranges::end(__base_)));68 auto __tmp = std::make_reverse_iterator(ranges::next(ranges::begin(__base_), ranges::end(__base_)));
69 if constexpr (_UseCache)69 if constexpr (_UseCache)
70 __cached_begin_.__emplace(__tmp);70 __cached_begin_.__emplace(__tmp);
71 return __tmp;71 return __tmp;
...@@ -73,22 +73,22 @@ namespace ranges {...@@ -73,22 +73,22 @@ namespace ranges {
7373
74 _LIBCPP_HIDE_FROM_ABI74 _LIBCPP_HIDE_FROM_ABI
75 constexpr reverse_iterator<iterator_t<_View>> begin() requires common_range<_View> {75 constexpr reverse_iterator<iterator_t<_View>> begin() requires common_range<_View> {
76 return _VSTD::make_reverse_iterator(ranges::end(__base_));76 return std::make_reverse_iterator(ranges::end(__base_));
77 }77 }
7878
79 _LIBCPP_HIDE_FROM_ABI79 _LIBCPP_HIDE_FROM_ABI
80 constexpr auto begin() const requires common_range<const _View> {80 constexpr auto begin() const requires common_range<const _View> {
81 return _VSTD::make_reverse_iterator(ranges::end(__base_));81 return std::make_reverse_iterator(ranges::end(__base_));
82 }82 }
8383
84 _LIBCPP_HIDE_FROM_ABI84 _LIBCPP_HIDE_FROM_ABI
85 constexpr reverse_iterator<iterator_t<_View>> end() {85 constexpr reverse_iterator<iterator_t<_View>> end() {
86 return _VSTD::make_reverse_iterator(ranges::begin(__base_));86 return std::make_reverse_iterator(ranges::begin(__base_));
87 }87 }
8888
89 _LIBCPP_HIDE_FROM_ABI89 _LIBCPP_HIDE_FROM_ABI
90 constexpr auto end() const requires common_range<const _View> {90 constexpr auto end() const requires common_range<const _View> {
91 return _VSTD::make_reverse_iterator(ranges::begin(__base_));91 return std::make_reverse_iterator(ranges::begin(__base_));
92 }92 }
9393
94 _LIBCPP_HIDE_FROM_ABI94 _LIBCPP_HIDE_FROM_ABI
...@@ -111,22 +111,22 @@ namespace ranges {...@@ -111,22 +111,22 @@ namespace ranges {
111 namespace views {111 namespace views {
112 namespace __reverse {112 namespace __reverse {
113 template<class _Tp>113 template<class _Tp>
114 constexpr bool __is_reverse_view = false;114 inline constexpr bool __is_reverse_view = false;
115115
116 template<class _Tp>116 template<class _Tp>
117 constexpr bool __is_reverse_view<reverse_view<_Tp>> = true;117 inline constexpr bool __is_reverse_view<reverse_view<_Tp>> = true;
118118
119 template<class _Tp>119 template<class _Tp>
120 constexpr bool __is_sized_reverse_subrange = false;120 inline constexpr bool __is_sized_reverse_subrange = false;
121121
122 template<class _Iter>122 template<class _Iter>
123 constexpr bool __is_sized_reverse_subrange<subrange<reverse_iterator<_Iter>, reverse_iterator<_Iter>, subrange_kind::sized>> = true;123 inline constexpr bool __is_sized_reverse_subrange<subrange<reverse_iterator<_Iter>, reverse_iterator<_Iter>, subrange_kind::sized>> = true;
124124
125 template<class _Tp>125 template<class _Tp>
126 constexpr bool __is_unsized_reverse_subrange = false;126 inline constexpr bool __is_unsized_reverse_subrange = false;
127127
128 template<class _Iter, subrange_kind _Kind>128 template<class _Iter, subrange_kind _Kind>
129 constexpr bool __is_unsized_reverse_subrange<subrange<reverse_iterator<_Iter>, reverse_iterator<_Iter>, _Kind>> = _Kind == subrange_kind::unsized;129 inline constexpr bool __is_unsized_reverse_subrange<subrange<reverse_iterator<_Iter>, reverse_iterator<_Iter>, _Kind>> = _Kind == subrange_kind::unsized;
130130
131 template<class _Tp>131 template<class _Tp>
132 struct __unwrapped_reverse_subrange {132 struct __unwrapped_reverse_subrange {
...@@ -143,9 +143,9 @@ namespace ranges {...@@ -143,9 +143,9 @@ namespace ranges {
143 requires __is_reverse_view<remove_cvref_t<_Range>>143 requires __is_reverse_view<remove_cvref_t<_Range>>
144 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI144 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
145 constexpr auto operator()(_Range&& __range) const145 constexpr auto operator()(_Range&& __range) const
146 noexcept(noexcept(_VSTD::forward<_Range>(__range).base()))146 noexcept(noexcept(std::forward<_Range>(__range).base()))
147 -> decltype( _VSTD::forward<_Range>(__range).base())147 -> decltype( std::forward<_Range>(__range).base())
148 { return _VSTD::forward<_Range>(__range).base(); }148 { return std::forward<_Range>(__range).base(); }
149149
150 template<class _Range,150 template<class _Range,
151 class _UnwrappedSubrange = typename __unwrapped_reverse_subrange<remove_cvref_t<_Range>>::type>151 class _UnwrappedSubrange = typename __unwrapped_reverse_subrange<remove_cvref_t<_Range>>::type>
...@@ -171,9 +171,9 @@ namespace ranges {...@@ -171,9 +171,9 @@ namespace ranges {
171 !__is_unsized_reverse_subrange<remove_cvref_t<_Range>>)171 !__is_unsized_reverse_subrange<remove_cvref_t<_Range>>)
172 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI172 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
173 constexpr auto operator()(_Range&& __range) const173 constexpr auto operator()(_Range&& __range) const
174 noexcept(noexcept(reverse_view{_VSTD::forward<_Range>(__range)}))174 noexcept(noexcept(reverse_view{std::forward<_Range>(__range)}))
175 -> decltype( reverse_view{_VSTD::forward<_Range>(__range)})175 -> decltype( reverse_view{std::forward<_Range>(__range)})
176 { return reverse_view{_VSTD::forward<_Range>(__range)}; }176 { return reverse_view{std::forward<_Range>(__range)}; }
177 };177 };
178 } // namespace __reverse178 } // namespace __reverse
179179
...@@ -183,7 +183,7 @@ namespace ranges {...@@ -183,7 +183,7 @@ namespace ranges {
183 } // namespace views183 } // namespace views
184} // namespace ranges184} // namespace ranges
185185
186#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)186#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
187187
188_LIBCPP_END_NAMESPACE_STD188_LIBCPP_END_NAMESPACE_STD
189189
lib/libcxx/include/__ranges/single_view.h+27-7
...@@ -11,6 +11,7 @@...@@ -11,6 +11,7 @@
1111
12#include <__config>12#include <__config>
13#include <__ranges/copyable_box.h>13#include <__ranges/copyable_box.h>
14#include <__ranges/range_adaptor.h>
14#include <__ranges/view_interface.h>15#include <__ranges/view_interface.h>
15#include <__utility/forward.h>16#include <__utility/forward.h>
16#include <__utility/in_place.h>17#include <__utility/in_place.h>
...@@ -19,12 +20,12 @@...@@ -19,12 +20,12 @@
19#include <type_traits>20#include <type_traits>
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
25_LIBCPP_BEGIN_NAMESPACE_STD26_LIBCPP_BEGIN_NAMESPACE_STD
2627
27#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)28#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
2829
29namespace ranges {30namespace ranges {
30 template<copy_constructible _Tp>31 template<copy_constructible _Tp>
...@@ -40,13 +41,13 @@ namespace ranges {...@@ -40,13 +41,13 @@ namespace ranges {
40 constexpr explicit single_view(const _Tp& __t) : __value_(in_place, __t) {}41 constexpr explicit single_view(const _Tp& __t) : __value_(in_place, __t) {}
4142
42 _LIBCPP_HIDE_FROM_ABI43 _LIBCPP_HIDE_FROM_ABI
43 constexpr explicit single_view(_Tp&& __t) : __value_(in_place, _VSTD::move(__t)) {}44 constexpr explicit single_view(_Tp&& __t) : __value_(in_place, std::move(__t)) {}
4445
45 template<class... _Args>46 template<class... _Args>
46 requires constructible_from<_Tp, _Args...>47 requires constructible_from<_Tp, _Args...>
47 _LIBCPP_HIDE_FROM_ABI48 _LIBCPP_HIDE_FROM_ABI
48 constexpr explicit single_view(in_place_t, _Args&&... __args)49 constexpr explicit single_view(in_place_t, _Args&&... __args)
49 : __value_{in_place, _VSTD::forward<_Args>(__args)...} {}50 : __value_{in_place, std::forward<_Args>(__args)...} {}
5051
51 _LIBCPP_HIDE_FROM_ABI52 _LIBCPP_HIDE_FROM_ABI
52 constexpr _Tp* begin() noexcept { return data(); }53 constexpr _Tp* begin() noexcept { return data(); }
...@@ -70,11 +71,30 @@ namespace ranges {...@@ -70,11 +71,30 @@ namespace ranges {
70 constexpr const _Tp* data() const noexcept { return __value_.operator->(); }71 constexpr const _Tp* data() const noexcept { return __value_.operator->(); }
71 };72 };
7273
73 template<class _Tp>74template<class _Tp>
74 single_view(_Tp) -> single_view<_Tp>;75single_view(_Tp) -> single_view<_Tp>;
76
77namespace views {
78namespace __single_view {
79
80struct __fn : __range_adaptor_closure<__fn> {
81 template<class _Range>
82 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
83 constexpr auto operator()(_Range&& __range) const
84 noexcept(noexcept(single_view<decay_t<_Range&&>>(std::forward<_Range>(__range))))
85 -> decltype( single_view<decay_t<_Range&&>>(std::forward<_Range>(__range)))
86 { return single_view<decay_t<_Range&&>>(std::forward<_Range>(__range)); }
87};
88} // namespace __single_view
89
90inline namespace __cpo {
91 inline constexpr auto single = __single_view::__fn{};
92} // namespace __cpo
93
94} // namespace views
75} // namespace ranges95} // namespace ranges
7696
77#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)97#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
7898
79_LIBCPP_END_NAMESPACE_STD99_LIBCPP_END_NAMESPACE_STD
80100
lib/libcxx/include/__ranges/size.h+84-77
...@@ -19,12 +19,12 @@...@@ -19,12 +19,12 @@
19#include <type_traits>19#include <type_traits>
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
23#endif23#endif
2424
25_LIBCPP_BEGIN_NAMESPACE_STD25_LIBCPP_BEGIN_NAMESPACE_STD
2626
27#if !defined(_LIBCPP_HAS_NO_CONCEPTS)27#if _LIBCPP_STD_VER > 17
2828
29namespace ranges {29namespace ranges {
30 template<class>30 template<class>
...@@ -35,68 +35,76 @@ namespace ranges {...@@ -35,68 +35,76 @@ namespace ranges {
3535
36namespace ranges {36namespace ranges {
37namespace __size {37namespace __size {
38 void size(auto&) = delete;38void size(auto&) = delete;
39 void size(const auto&) = delete;39void size(const auto&) = delete;
4040
41 template <class _Tp>41template <class _Tp>
42 concept __size_enabled = !disable_sized_range<remove_cvref_t<_Tp>>;42concept __size_enabled = !disable_sized_range<remove_cvref_t<_Tp>>;
4343
44 template <class _Tp>44template <class _Tp>
45 concept __member_size =45concept __member_size =
46 __size_enabled<_Tp> &&46 __size_enabled<_Tp> &&
47 __workaround_52970<_Tp> &&47 __workaround_52970<_Tp> &&
48 requires(_Tp&& __t) {48 requires(_Tp&& __t) {
49 { _LIBCPP_AUTO_CAST(__t.size()) } -> __integer_like;49 { _LIBCPP_AUTO_CAST(__t.size()) } -> __integer_like;
50 };
51
52 template <class _Tp>
53 concept __unqualified_size =
54 __size_enabled<_Tp> &&
55 !__member_size<_Tp> &&
56 __class_or_enum<remove_cvref_t<_Tp>> &&
57 requires(_Tp&& __t) {
58 { _LIBCPP_AUTO_CAST(size(__t)) } -> __integer_like;
59 };
60
61 template <class _Tp>
62 concept __difference =
63 !__member_size<_Tp> &&
64 !__unqualified_size<_Tp> &&
65 __class_or_enum<remove_cvref_t<_Tp>> &&
66 requires(_Tp&& __t) {
67 { ranges::begin(__t) } -> forward_iterator;
68 { ranges::end(__t) } -> sized_sentinel_for<decltype(ranges::begin(declval<_Tp>()))>;
69 };
70
71 struct __fn {
72 template <class _Tp, size_t _Sz>
73 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr size_t operator()(_Tp (&&)[_Sz]) const noexcept {
74 return _Sz;
75 }
76
77 template <class _Tp, size_t _Sz>
78 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr size_t operator()(_Tp (&)[_Sz]) const noexcept {
79 return _Sz;
80 }
81
82 template <__member_size _Tp>
83 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __integer_like auto operator()(_Tp&& __t) const
84 noexcept(noexcept(_LIBCPP_AUTO_CAST(__t.size()))) {
85 return _LIBCPP_AUTO_CAST(__t.size());
86 }
87
88 template <__unqualified_size _Tp>
89 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __integer_like auto operator()(_Tp&& __t) const
90 noexcept(noexcept(_LIBCPP_AUTO_CAST(size(__t)))) {
91 return _LIBCPP_AUTO_CAST(size(__t));
92 }
93
94 template<__difference _Tp>
95 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __integer_like auto operator()(_Tp&& __t) const
96 noexcept(noexcept(ranges::end(__t) - ranges::begin(__t))) {
97 return _VSTD::__to_unsigned_like(ranges::end(__t) - ranges::begin(__t));
98 }
99 };50 };
51
52template <class _Tp>
53concept __unqualified_size =
54 __size_enabled<_Tp> &&
55 !__member_size<_Tp> &&
56 __class_or_enum<remove_cvref_t<_Tp>> &&
57 requires(_Tp&& __t) {
58 { _LIBCPP_AUTO_CAST(size(__t)) } -> __integer_like;
59 };
60
61template <class _Tp>
62concept __difference =
63 !__member_size<_Tp> &&
64 !__unqualified_size<_Tp> &&
65 __class_or_enum<remove_cvref_t<_Tp>> &&
66 requires(_Tp&& __t) {
67 { ranges::begin(__t) } -> forward_iterator;
68 { ranges::end(__t) } -> sized_sentinel_for<decltype(ranges::begin(declval<_Tp>()))>;
69 };
70
71struct __fn {
72
73 // `[range.prim.size]`: the array case (for rvalues).
74 template <class _Tp, size_t _Sz>
75 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr size_t operator()(_Tp (&&)[_Sz]) const noexcept {
76 return _Sz;
77 }
78
79 // `[range.prim.size]`: the array case (for lvalues).
80 template <class _Tp, size_t _Sz>
81 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr size_t operator()(_Tp (&)[_Sz]) const noexcept {
82 return _Sz;
83 }
84
85 // `[range.prim.size]`: `auto(t.size())` is a valid expression.
86 template <__member_size _Tp>
87 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __integer_like auto operator()(_Tp&& __t) const
88 noexcept(noexcept(_LIBCPP_AUTO_CAST(__t.size()))) {
89 return _LIBCPP_AUTO_CAST(__t.size());
90 }
91
92 // `[range.prim.size]`: `auto(size(t))` is a valid expression.
93 template <__unqualified_size _Tp>
94 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __integer_like auto operator()(_Tp&& __t) const
95 noexcept(noexcept(_LIBCPP_AUTO_CAST(size(__t)))) {
96 return _LIBCPP_AUTO_CAST(size(__t));
97 }
98
99 // [range.prim.size]: the `to-unsigned-like` case.
100 template <__difference _Tp>
101 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
102 noexcept(noexcept(std::__to_unsigned_like(ranges::end(__t) - ranges::begin(__t))))
103 -> decltype( std::__to_unsigned_like(ranges::end(__t) - ranges::begin(__t)))
104 { return std::__to_unsigned_like(ranges::end(__t) - ranges::begin(__t));
105 }
106};
107
100} // namespace __size108} // namespace __size
101109
102inline namespace __cpo {110inline namespace __cpo {
...@@ -108,19 +116,18 @@ inline namespace __cpo {...@@ -108,19 +116,18 @@ inline namespace __cpo {
108116
109namespace ranges {117namespace ranges {
110namespace __ssize {118namespace __ssize {
111 struct __fn {119struct __fn {
112 template<class _Tp>120 template<class _Tp>
113 requires requires (_Tp&& __t) { ranges::size(__t); }121 requires requires (_Tp&& __t) { ranges::size(__t); }
114 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr integral auto operator()(_Tp&& __t) const122 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr integral auto operator()(_Tp&& __t) const
115 noexcept(noexcept(ranges::size(__t)))123 noexcept(noexcept(ranges::size(__t))) {
116 {124 using _Signed = make_signed_t<decltype(ranges::size(__t))>;
117 using _Signed = make_signed_t<decltype(ranges::size(__t))>;125 if constexpr (sizeof(ptrdiff_t) > sizeof(_Signed))
118 if constexpr (sizeof(ptrdiff_t) > sizeof(_Signed))126 return static_cast<ptrdiff_t>(ranges::size(__t));
119 return static_cast<ptrdiff_t>(ranges::size(__t));127 else
120 else128 return static_cast<_Signed>(ranges::size(__t));
121 return static_cast<_Signed>(ranges::size(__t));129 }
122 }130};
123 };
124} // namespace __ssize131} // namespace __ssize
125132
126inline namespace __cpo {133inline namespace __cpo {
...@@ -128,7 +135,7 @@ inline namespace __cpo {...@@ -128,7 +135,7 @@ inline namespace __cpo {
128} // namespace __cpo135} // namespace __cpo
129} // namespace ranges136} // namespace ranges
130137
131#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)138#endif // _LIBCPP_STD_VER > 17
132139
133_LIBCPP_END_NAMESPACE_STD140_LIBCPP_END_NAMESPACE_STD
134141
lib/libcxx/include/__ranges/subrange.h+20-17
...@@ -9,13 +9,13 @@...@@ -9,13 +9,13 @@
9#ifndef _LIBCPP___RANGES_SUBRANGE_H9#ifndef _LIBCPP___RANGES_SUBRANGE_H
10#define _LIBCPP___RANGES_SUBRANGE_H10#define _LIBCPP___RANGES_SUBRANGE_H
1111
12#include <__assert>
12#include <__concepts/constructible.h>13#include <__concepts/constructible.h>
13#include <__concepts/convertible_to.h>14#include <__concepts/convertible_to.h>
14#include <__concepts/copyable.h>15#include <__concepts/copyable.h>
15#include <__concepts/derived_from.h>16#include <__concepts/derived_from.h>
16#include <__concepts/different_from.h>17#include <__concepts/different_from.h>
17#include <__config>18#include <__config>
18#include <__debug>
19#include <__iterator/advance.h>19#include <__iterator/advance.h>
20#include <__iterator/concepts.h>20#include <__iterator/concepts.h>
21#include <__iterator/incrementable_traits.h>21#include <__iterator/incrementable_traits.h>
...@@ -31,12 +31,12 @@...@@ -31,12 +31,12 @@
31#include <type_traits>31#include <type_traits>
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
35#endif35#endif
3636
37_LIBCPP_BEGIN_NAMESPACE_STD37_LIBCPP_BEGIN_NAMESPACE_STD
3838
39#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)39#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
4040
41namespace ranges {41namespace ranges {
42 template<class _From, class _To>42 template<class _From, class _To>
...@@ -56,8 +56,8 @@ namespace ranges {...@@ -56,8 +56,8 @@ namespace ranges {
56 requires derived_from<tuple_size<_Tp>, integral_constant<size_t, 2>>;56 requires derived_from<tuple_size<_Tp>, integral_constant<size_t, 2>>;
57 typename tuple_element_t<0, remove_const_t<_Tp>>;57 typename tuple_element_t<0, remove_const_t<_Tp>>;
58 typename tuple_element_t<1, remove_const_t<_Tp>>;58 typename tuple_element_t<1, remove_const_t<_Tp>>;
59 { _VSTD::get<0>(__t) } -> convertible_to<const tuple_element_t<0, _Tp>&>;59 { std::get<0>(__t) } -> convertible_to<const tuple_element_t<0, _Tp>&>;
60 { _VSTD::get<1>(__t) } -> convertible_to<const tuple_element_t<1, _Tp>&>;60 { std::get<1>(__t) } -> convertible_to<const tuple_element_t<1, _Tp>&>;
61 };61 };
6262
63 template<class _Pair, class _Iter, class _Sent>63 template<class _Pair, class _Iter, class _Sent>
...@@ -77,14 +77,17 @@ namespace ranges {...@@ -77,14 +77,17 @@ namespace ranges {
77 class _LIBCPP_TEMPLATE_VIS subrange77 class _LIBCPP_TEMPLATE_VIS subrange
78 : public view_interface<subrange<_Iter, _Sent, _Kind>>78 : public view_interface<subrange<_Iter, _Sent, _Kind>>
79 {79 {
80 private:80 public:
81 // Note: this is an internal implementation detail that is public only for internal usage.
81 static constexpr bool _StoreSize = (_Kind == subrange_kind::sized && !sized_sentinel_for<_Sent, _Iter>);82 static constexpr bool _StoreSize = (_Kind == subrange_kind::sized && !sized_sentinel_for<_Sent, _Iter>);
83
84 private:
82 static constexpr bool _MustProvideSizeAtConstruction = !_StoreSize; // just to improve compiler diagnostics85 static constexpr bool _MustProvideSizeAtConstruction = !_StoreSize; // just to improve compiler diagnostics
83 struct _Empty { constexpr _Empty(auto) noexcept { } };86 struct _Empty { constexpr _Empty(auto) noexcept { } };
84 using _Size = conditional_t<_StoreSize, make_unsigned_t<iter_difference_t<_Iter>>, _Empty>;87 using _Size = conditional_t<_StoreSize, make_unsigned_t<iter_difference_t<_Iter>>, _Empty>;
85 [[no_unique_address]] _Iter __begin_ = _Iter();88 _LIBCPP_NO_UNIQUE_ADDRESS _Iter __begin_ = _Iter();
86 [[no_unique_address]] _Sent __end_ = _Sent();89 _LIBCPP_NO_UNIQUE_ADDRESS _Sent __end_ = _Sent();
87 [[no_unique_address]] _Size __size_ = 0;90 _LIBCPP_NO_UNIQUE_ADDRESS _Size __size_ = 0;
8891
89 public:92 public:
90 _LIBCPP_HIDE_FROM_ABI93 _LIBCPP_HIDE_FROM_ABI
...@@ -93,14 +96,14 @@ namespace ranges {...@@ -93,14 +96,14 @@ namespace ranges {
93 _LIBCPP_HIDE_FROM_ABI96 _LIBCPP_HIDE_FROM_ABI
94 constexpr subrange(__convertible_to_non_slicing<_Iter> auto __iter, _Sent __sent)97 constexpr subrange(__convertible_to_non_slicing<_Iter> auto __iter, _Sent __sent)
95 requires _MustProvideSizeAtConstruction98 requires _MustProvideSizeAtConstruction
96 : __begin_(_VSTD::move(__iter)), __end_(_VSTD::move(__sent))99 : __begin_(std::move(__iter)), __end_(std::move(__sent))
97 { }100 { }
98101
99 _LIBCPP_HIDE_FROM_ABI102 _LIBCPP_HIDE_FROM_ABI
100 constexpr subrange(__convertible_to_non_slicing<_Iter> auto __iter, _Sent __sent,103 constexpr subrange(__convertible_to_non_slicing<_Iter> auto __iter, _Sent __sent,
101 make_unsigned_t<iter_difference_t<_Iter>> __n)104 make_unsigned_t<iter_difference_t<_Iter>> __n)
102 requires (_Kind == subrange_kind::sized)105 requires (_Kind == subrange_kind::sized)
103 : __begin_(_VSTD::move(__iter)), __end_(_VSTD::move(__sent)), __size_(__n)106 : __begin_(std::move(__iter)), __end_(std::move(__sent)), __size_(__n)
104 {107 {
105 if constexpr (sized_sentinel_for<_Sent, _Iter>)108 if constexpr (sized_sentinel_for<_Sent, _Iter>)
106 _LIBCPP_ASSERT((__end_ - __begin_) == static_cast<iter_difference_t<_Iter>>(__n),109 _LIBCPP_ASSERT((__end_ - __begin_) == static_cast<iter_difference_t<_Iter>>(__n),
...@@ -149,7 +152,7 @@ namespace ranges {...@@ -149,7 +152,7 @@ namespace ranges {
149 }152 }
150153
151 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Iter begin() requires (!copyable<_Iter>) {154 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Iter begin() requires (!copyable<_Iter>) {
152 return _VSTD::move(__begin_);155 return std::move(__begin_);
153 }156 }
154157
155 _LIBCPP_HIDE_FROM_ABI158 _LIBCPP_HIDE_FROM_ABI
...@@ -168,7 +171,7 @@ namespace ranges {...@@ -168,7 +171,7 @@ namespace ranges {
168 if constexpr (_StoreSize)171 if constexpr (_StoreSize)
169 return __size_;172 return __size_;
170 else173 else
171 return _VSTD::__to_unsigned_like(__end_ - __begin_);174 return std::__to_unsigned_like(__end_ - __begin_);
172 }175 }
173176
174 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr subrange next(iter_difference_t<_Iter> __n = 1) const&177 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr subrange next(iter_difference_t<_Iter> __n = 1) const&
...@@ -181,7 +184,7 @@ namespace ranges {...@@ -181,7 +184,7 @@ namespace ranges {
181184
182 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr subrange next(iter_difference_t<_Iter> __n = 1) && {185 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr subrange next(iter_difference_t<_Iter> __n = 1) && {
183 advance(__n);186 advance(__n);
184 return _VSTD::move(*this);187 return std::move(*this);
185 }188 }
186189
187 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr subrange prev(iter_difference_t<_Iter> __n = 1) const190 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr subrange prev(iter_difference_t<_Iter> __n = 1) const
...@@ -198,14 +201,14 @@ namespace ranges {...@@ -198,14 +201,14 @@ namespace ranges {
198 if (__n < 0) {201 if (__n < 0) {
199 ranges::advance(__begin_, __n);202 ranges::advance(__begin_, __n);
200 if constexpr (_StoreSize)203 if constexpr (_StoreSize)
201 __size_ += _VSTD::__to_unsigned_like(-__n);204 __size_ += std::__to_unsigned_like(-__n);
202 return *this;205 return *this;
203 }206 }
204 }207 }
205208
206 auto __d = __n - ranges::advance(__begin_, __n, __end_);209 auto __d = __n - ranges::advance(__begin_, __n, __end_);
207 if constexpr (_StoreSize)210 if constexpr (_StoreSize)
208 __size_ -= _VSTD::__to_unsigned_like(__d);211 __size_ -= std::__to_unsigned_like(__d);
209 return *this;212 return *this;
210 }213 }
211 };214 };
...@@ -282,7 +285,7 @@ struct tuple_element<1, const ranges::subrange<_Ip, _Sp, _Kp>> {...@@ -282,7 +285,7 @@ struct tuple_element<1, const ranges::subrange<_Ip, _Sp, _Kp>> {
282 using type = _Sp;285 using type = _Sp;
283};286};
284287
285#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)288#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
286289
287_LIBCPP_END_NAMESPACE_STD290_LIBCPP_END_NAMESPACE_STD
288291
lib/libcxx/include/__ranges/take_view.h+274-122
...@@ -10,23 +10,34 @@...@@ -10,23 +10,34 @@
10#define _LIBCPP___RANGES_TAKE_VIEW_H10#define _LIBCPP___RANGES_TAKE_VIEW_H
1111
12#include <__algorithm/min.h>12#include <__algorithm/min.h>
13#include <__algorithm/ranges_min.h>
13#include <__config>14#include <__config>
15#include <__functional/bind_back.h>
16#include <__fwd/span.h>
17#include <__fwd/string_view.h>
14#include <__iterator/concepts.h>18#include <__iterator/concepts.h>
15#include <__iterator/counted_iterator.h>19#include <__iterator/counted_iterator.h>
16#include <__iterator/default_sentinel.h>20#include <__iterator/default_sentinel.h>
21#include <__iterator/distance.h>
17#include <__iterator/iterator_traits.h>22#include <__iterator/iterator_traits.h>
18#include <__ranges/access.h>23#include <__ranges/access.h>
19#include <__ranges/all.h>24#include <__ranges/all.h>
20#include <__ranges/concepts.h>25#include <__ranges/concepts.h>
26#include <__ranges/empty_view.h>
21#include <__ranges/enable_borrowed_range.h>27#include <__ranges/enable_borrowed_range.h>
28#include <__ranges/iota_view.h>
29#include <__ranges/range_adaptor.h>
22#include <__ranges/size.h>30#include <__ranges/size.h>
31#include <__ranges/subrange.h>
23#include <__ranges/view_interface.h>32#include <__ranges/view_interface.h>
33#include <__utility/auto_cast.h>
34#include <__utility/forward.h>
24#include <__utility/move.h>35#include <__utility/move.h>
25#include <concepts>36#include <concepts>
26#include <type_traits>37#include <type_traits>
2738
28#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)39#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
29#pragma GCC system_header40# pragma GCC system_header
30#endif41#endif
3142
32_LIBCPP_PUSH_MACROS43_LIBCPP_PUSH_MACROS
...@@ -34,149 +45,290 @@ _LIBCPP_PUSH_MACROS...@@ -34,149 +45,290 @@ _LIBCPP_PUSH_MACROS
3445
35_LIBCPP_BEGIN_NAMESPACE_STD46_LIBCPP_BEGIN_NAMESPACE_STD
3647
37#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)48#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
3849
39namespace ranges {50namespace ranges {
40 template<view _View>51
41 class take_view : public view_interface<take_view<_View>> {52template<view _View>
42 [[no_unique_address]] _View __base_ = _View();53class take_view : public view_interface<take_view<_View>> {
43 range_difference_t<_View> __count_ = 0;54 _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View();
4455 range_difference_t<_View> __count_ = 0;
45 template<bool> class __sentinel;56
4657 template<bool> class __sentinel;
47 public:58
48 _LIBCPP_HIDE_FROM_ABI59public:
49 take_view() requires default_initializable<_View> = default;60 _LIBCPP_HIDE_FROM_ABI
5061 take_view() requires default_initializable<_View> = default;
51 _LIBCPP_HIDE_FROM_ABI62
52 constexpr take_view(_View __base, range_difference_t<_View> __count)63 _LIBCPP_HIDE_FROM_ABI
53 : __base_(_VSTD::move(__base)), __count_(__count) {}64 constexpr take_view(_View __base, range_difference_t<_View> __count)
5465 : __base_(std::move(__base)), __count_(__count) {}
55 _LIBCPP_HIDE_FROM_ABI66
56 constexpr _View base() const& requires copy_constructible<_View> { return __base_; }67 _LIBCPP_HIDE_FROM_ABI
5768 constexpr _View base() const& requires copy_constructible<_View> { return __base_; }
58 _LIBCPP_HIDE_FROM_ABI69
59 constexpr _View base() && { return _VSTD::move(__base_); }70 _LIBCPP_HIDE_FROM_ABI
6071 constexpr _View base() && { return std::move(__base_); }
61 _LIBCPP_HIDE_FROM_ABI72
62 constexpr auto begin() requires (!__simple_view<_View>) {73 _LIBCPP_HIDE_FROM_ABI
63 if constexpr (sized_range<_View>) {74 constexpr auto begin() requires (!__simple_view<_View>) {
64 if constexpr (random_access_range<_View>) {75 if constexpr (sized_range<_View>) {
65 return ranges::begin(__base_);76 if constexpr (random_access_range<_View>) {
66 } else {77 return ranges::begin(__base_);
67 using _DifferenceT = range_difference_t<_View>;
68 auto __size = size();
69 return counted_iterator(ranges::begin(__base_), static_cast<_DifferenceT>(__size));
70 }
71 } else {78 } else {
72 return counted_iterator(ranges::begin(__base_), __count_);79 using _DifferenceT = range_difference_t<_View>;
80 auto __size = size();
81 return counted_iterator(ranges::begin(__base_), static_cast<_DifferenceT>(__size));
73 }82 }
83 } else {
84 return counted_iterator(ranges::begin(__base_), __count_);
74 }85 }
86 }
7587
76 _LIBCPP_HIDE_FROM_ABI88 _LIBCPP_HIDE_FROM_ABI
77 constexpr auto begin() const requires range<const _View> {89 constexpr auto begin() const requires range<const _View> {
78 if constexpr (sized_range<const _View>) {90 if constexpr (sized_range<const _View>) {
79 if constexpr (random_access_range<const _View>) {91 if constexpr (random_access_range<const _View>) {
80 return ranges::begin(__base_);92 return ranges::begin(__base_);
81 } else {
82 using _DifferenceT = range_difference_t<const _View>;
83 auto __size = size();
84 return counted_iterator(ranges::begin(__base_), static_cast<_DifferenceT>(__size));
85 }
86 } else {93 } else {
87 return counted_iterator(ranges::begin(__base_), __count_);94 using _DifferenceT = range_difference_t<const _View>;
95 auto __size = size();
96 return counted_iterator(ranges::begin(__base_), static_cast<_DifferenceT>(__size));
88 }97 }
98 } else {
99 return counted_iterator(ranges::begin(__base_), __count_);
89 }100 }
101 }
90102
91 _LIBCPP_HIDE_FROM_ABI103 _LIBCPP_HIDE_FROM_ABI
92 constexpr auto end() requires (!__simple_view<_View>) {104 constexpr auto end() requires (!__simple_view<_View>) {
93 if constexpr (sized_range<_View>) {105 if constexpr (sized_range<_View>) {
94 if constexpr (random_access_range<_View>) {106 if constexpr (random_access_range<_View>) {
95 return ranges::begin(__base_) + size();107 return ranges::begin(__base_) + size();
96 } else {
97 return default_sentinel;
98 }
99 } else {108 } else {
100 return __sentinel<false>{ranges::end(__base_)};109 return default_sentinel;
101 }110 }
111 } else {
112 return __sentinel<false>{ranges::end(__base_)};
102 }113 }
114 }
103115
104 _LIBCPP_HIDE_FROM_ABI116 _LIBCPP_HIDE_FROM_ABI
105 constexpr auto end() const requires range<const _View> {117 constexpr auto end() const requires range<const _View> {
106 if constexpr (sized_range<const _View>) {118 if constexpr (sized_range<const _View>) {
107 if constexpr (random_access_range<const _View>) {119 if constexpr (random_access_range<const _View>) {
108 return ranges::begin(__base_) + size();120 return ranges::begin(__base_) + size();
109 } else {
110 return default_sentinel;
111 }
112 } else {121 } else {
113 return __sentinel<true>{ranges::end(__base_)};122 return default_sentinel;
114 }123 }
124 } else {
125 return __sentinel<true>{ranges::end(__base_)};
115 }126 }
116127 }
117128
118 _LIBCPP_HIDE_FROM_ABI129 _LIBCPP_HIDE_FROM_ABI
119 constexpr auto size() requires sized_range<_View> {130 constexpr auto size() requires sized_range<_View> {
120 auto __n = ranges::size(__base_);131 auto __n = ranges::size(__base_);
121 // TODO: use ranges::min here.132 return ranges::min(__n, static_cast<decltype(__n)>(__count_));
122 return _VSTD::min(__n, static_cast<decltype(__n)>(__count_));133 }
123 }134
124135 _LIBCPP_HIDE_FROM_ABI
125 _LIBCPP_HIDE_FROM_ABI136 constexpr auto size() const requires sized_range<const _View> {
126 constexpr auto size() const requires sized_range<const _View> {137 auto __n = ranges::size(__base_);
127 auto __n = ranges::size(__base_);138 return ranges::min(__n, static_cast<decltype(__n)>(__count_));
128 // TODO: use ranges::min here.139 }
129 return _VSTD::min(__n, static_cast<decltype(__n)>(__count_));140};
130 }141
131 };142template<view _View>
132143template<bool _Const>
133 template<view _View>144class take_view<_View>::__sentinel {
134 template<bool _Const>145 using _Base = __maybe_const<_Const, _View>;
135 class take_view<_View>::__sentinel {146 template<bool _OtherConst>
136 using _Base = __maybe_const<_Const, _View>;147 using _Iter = counted_iterator<iterator_t<__maybe_const<_OtherConst, _View>>>;
137 template<bool _OtherConst>148 _LIBCPP_NO_UNIQUE_ADDRESS sentinel_t<_Base> __end_ = sentinel_t<_Base>();
138 using _Iter = counted_iterator<iterator_t<__maybe_const<_OtherConst, _View>>>;149
139 [[no_unique_address]] sentinel_t<_Base> __end_ = sentinel_t<_Base>();150 template<bool>
140151 friend class take_view<_View>::__sentinel;
141 template<bool>
142 friend class take_view<_View>::__sentinel;
143152
144public:153public:
145 _LIBCPP_HIDE_FROM_ABI154 _LIBCPP_HIDE_FROM_ABI
146 __sentinel() = default;155 __sentinel() = default;
147156
148 _LIBCPP_HIDE_FROM_ABI157 _LIBCPP_HIDE_FROM_ABI
149 constexpr explicit __sentinel(sentinel_t<_Base> __end) : __end_(_VSTD::move(__end)) {}158 constexpr explicit __sentinel(sentinel_t<_Base> __end) : __end_(std::move(__end)) {}
150159
151 _LIBCPP_HIDE_FROM_ABI160 _LIBCPP_HIDE_FROM_ABI
152 constexpr __sentinel(__sentinel<!_Const> __s)161 constexpr __sentinel(__sentinel<!_Const> __s)
153 requires _Const && convertible_to<sentinel_t<_View>, sentinel_t<_Base>>162 requires _Const && convertible_to<sentinel_t<_View>, sentinel_t<_Base>>
154 : __end_(_VSTD::move(__s.__end_)) {}163 : __end_(std::move(__s.__end_)) {}
155164
156 _LIBCPP_HIDE_FROM_ABI165 _LIBCPP_HIDE_FROM_ABI
157 constexpr sentinel_t<_Base> base() const { return __end_; }166 constexpr sentinel_t<_Base> base() const { return __end_; }
158167
159 _LIBCPP_HIDE_FROM_ABI168 _LIBCPP_HIDE_FROM_ABI
160 friend constexpr bool operator==(const _Iter<_Const>& __lhs, const __sentinel& __rhs) {169 friend constexpr bool operator==(const _Iter<_Const>& __lhs, const __sentinel& __rhs) {
161 return __lhs.count() == 0 || __lhs.base() == __rhs.__end_;170 return __lhs.count() == 0 || __lhs.base() == __rhs.__end_;
162 }171 }
163172
164 template<bool _OtherConst = !_Const>173 template<bool _OtherConst = !_Const>
165 requires sentinel_for<sentinel_t<_Base>, iterator_t<__maybe_const<_OtherConst, _View>>>174 requires sentinel_for<sentinel_t<_Base>, iterator_t<__maybe_const<_OtherConst, _View>>>
166 _LIBCPP_HIDE_FROM_ABI175 _LIBCPP_HIDE_FROM_ABI
167 friend constexpr bool operator==(const _Iter<_Const>& __lhs, const __sentinel& __rhs) {176 friend constexpr bool operator==(const _Iter<_Const>& __lhs, const __sentinel& __rhs) {
168 return __lhs.count() == 0 || __lhs.base() == __rhs.__end_;177 return __lhs.count() == 0 || __lhs.base() == __rhs.__end_;
169 }178 }
170 };179};
171180
172 template<class _Range>181template<class _Range>
173 take_view(_Range&&, range_difference_t<_Range>) -> take_view<views::all_t<_Range>>;182take_view(_Range&&, range_difference_t<_Range>) -> take_view<views::all_t<_Range>>;
183
184template<class _Tp>
185inline constexpr bool enable_borrowed_range<take_view<_Tp>> = enable_borrowed_range<_Tp>;
186
187namespace views {
188namespace __take {
189
190template <class _Tp>
191inline constexpr bool __is_empty_view = false;
192
193template <class _Tp>
194inline constexpr bool __is_empty_view<empty_view<_Tp>> = true;
195
196template <class _Tp>
197inline constexpr bool __is_passthrough_specialization = false;
198
199template <class _Tp, size_t _Extent>
200inline constexpr bool __is_passthrough_specialization<span<_Tp, _Extent>> = true;
201
202template <class _CharT, class _Traits>
203inline constexpr bool __is_passthrough_specialization<basic_string_view<_CharT, _Traits>> = true;
204
205template <class _Iter, class _Sent, subrange_kind _Kind>
206inline constexpr bool __is_passthrough_specialization<subrange<_Iter, _Sent, _Kind>> = true;
207
208template <class _Tp>
209inline constexpr bool __is_iota_specialization = false;
210
211template <class _Np, class _Bound>
212inline constexpr bool __is_iota_specialization<iota_view<_Np, _Bound>> = true;
213
214template <class _Tp>
215struct __passthrough_type;
216
217template <class _Tp, size_t _Extent>
218struct __passthrough_type<span<_Tp, _Extent>> {
219 using type = span<_Tp>;
220};
221
222template <class _CharT, class _Traits>
223struct __passthrough_type<basic_string_view<_CharT, _Traits>> {
224 using type = basic_string_view<_CharT, _Traits>;
225};
226
227template <class _Iter, class _Sent, subrange_kind _Kind>
228struct __passthrough_type<subrange<_Iter, _Sent, _Kind>> {
229 using type = subrange<_Iter>;
230};
231
232template <class _Tp>
233using __passthrough_type_t = typename __passthrough_type<_Tp>::type;
234
235struct __fn {
236 // [range.take.overview]: the `empty_view` case.
237 template <class _Range, convertible_to<range_difference_t<_Range>> _Np>
238 requires __is_empty_view<remove_cvref_t<_Range>>
239 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
240 constexpr auto operator()(_Range&& __range, _Np&&) const
241 noexcept(noexcept(_LIBCPP_AUTO_CAST(std::forward<_Range>(__range))))
242 -> decltype( _LIBCPP_AUTO_CAST(std::forward<_Range>(__range)))
243 { return _LIBCPP_AUTO_CAST(std::forward<_Range>(__range)); }
244
245 // [range.take.overview]: the `span | basic_string_view | subrange` case.
246 template <class _Range,
247 convertible_to<range_difference_t<_Range>> _Np,
248 class _RawRange = remove_cvref_t<_Range>,
249 class _Dist = range_difference_t<_Range>>
250 requires (!__is_empty_view<_RawRange> &&
251 random_access_range<_RawRange> &&
252 sized_range<_RawRange> &&
253 __is_passthrough_specialization<_RawRange>)
254 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
255 constexpr auto operator()(_Range&& __rng, _Np&& __n) const
256 noexcept(noexcept(__passthrough_type_t<_RawRange>(
257 ranges::begin(__rng),
258 ranges::begin(__rng) + std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n))
259 )))
260 -> decltype( __passthrough_type_t<_RawRange>(
261 // Note: deliberately not forwarding `__rng` to guard against double moves.
262 ranges::begin(__rng),
263 ranges::begin(__rng) + std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n))
264 ))
265 { return __passthrough_type_t<_RawRange>(
266 ranges::begin(__rng),
267 ranges::begin(__rng) + std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n))
268 ); }
269
270 // [range.take.overview]: the `iota_view` case.
271 template <class _Range,
272 convertible_to<range_difference_t<_Range>> _Np,
273 class _RawRange = remove_cvref_t<_Range>,
274 class _Dist = range_difference_t<_Range>>
275 requires (!__is_empty_view<_RawRange> &&
276 random_access_range<_RawRange> &&
277 sized_range<_RawRange> &&
278 __is_iota_specialization<_RawRange>)
279 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
280 constexpr auto operator()(_Range&& __rng, _Np&& __n) const
281 noexcept(noexcept(ranges::iota_view(
282 *ranges::begin(__rng),
283 *ranges::begin(__rng) + std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n))
284 )))
285 -> decltype( ranges::iota_view(
286 // Note: deliberately not forwarding `__rng` to guard against double moves.
287 *ranges::begin(__rng),
288 *ranges::begin(__rng) + std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n))
289 ))
290 { return ranges::iota_view(
291 *ranges::begin(__rng),
292 *ranges::begin(__rng) + std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n))
293 ); }
294
295 // [range.take.overview]: the "otherwise" case.
296 template <class _Range, convertible_to<range_difference_t<_Range>> _Np,
297 class _RawRange = remove_cvref_t<_Range>>
298 // Note: without specifically excluding the other cases, GCC sees this overload as ambiguous with the other
299 // overloads.
300 requires (!(__is_empty_view<_RawRange> ||
301 (__is_iota_specialization<_RawRange> &&
302 sized_range<_RawRange> &&
303 random_access_range<_RawRange>) ||
304 (__is_passthrough_specialization<_RawRange> &&
305 sized_range<_RawRange> &&
306 random_access_range<_RawRange>)
307 ))
308 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
309 constexpr auto operator()(_Range&& __range, _Np&& __n) const
310 noexcept(noexcept(take_view(std::forward<_Range>(__range), std::forward<_Np>(__n))))
311 -> decltype( take_view(std::forward<_Range>(__range), std::forward<_Np>(__n)))
312 { return take_view(std::forward<_Range>(__range), std::forward<_Np>(__n)); }
313
314 template <class _Np>
315 requires constructible_from<decay_t<_Np>, _Np>
316 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
317 constexpr auto operator()(_Np&& __n) const
318 noexcept(is_nothrow_constructible_v<decay_t<_Np>, _Np>)
319 { return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Np>(__n))); }
320};
321
322} // namespace __take
323
324inline namespace __cpo {
325 inline constexpr auto take = __take::__fn{};
326} // namespace __cpo
327} // namespace views
174328
175 template<class _Tp>
176 inline constexpr bool enable_borrowed_range<take_view<_Tp>> = enable_borrowed_range<_Tp>;
177} // namespace ranges329} // namespace ranges
178330
179#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)331#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
180332
181_LIBCPP_END_NAMESPACE_STD333_LIBCPP_END_NAMESPACE_STD
182334
lib/libcxx/include/__ranges/transform_view.h+21-21
...@@ -36,12 +36,12 @@...@@ -36,12 +36,12 @@
36#include <type_traits>36#include <type_traits>
3737
38#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)38#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
39#pragma GCC system_header39# pragma GCC system_header
40#endif40#endif
4141
42_LIBCPP_BEGIN_NAMESPACE_STD42_LIBCPP_BEGIN_NAMESPACE_STD
4343
44#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)44#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
4545
46namespace ranges {46namespace ranges {
4747
...@@ -53,7 +53,7 @@ template<class _View, class _Fn>...@@ -53,7 +53,7 @@ template<class _View, class _Fn>
53concept __transform_view_constraints =53concept __transform_view_constraints =
54 view<_View> && is_object_v<_Fn> &&54 view<_View> && is_object_v<_Fn> &&
55 regular_invocable<_Fn&, range_reference_t<_View>> &&55 regular_invocable<_Fn&, range_reference_t<_View>> &&
56 __referenceable<invoke_result_t<_Fn&, range_reference_t<_View>>>;56 __can_reference<invoke_result_t<_Fn&, range_reference_t<_View>>>;
5757
58template<input_range _View, copy_constructible _Fn>58template<input_range _View, copy_constructible _Fn>
59 requires __transform_view_constraints<_View, _Fn>59 requires __transform_view_constraints<_View, _Fn>
...@@ -61,8 +61,8 @@ class transform_view : public view_interface<transform_view<_View, _Fn>> {...@@ -61,8 +61,8 @@ class transform_view : public view_interface<transform_view<_View, _Fn>> {
61 template<bool> class __iterator;61 template<bool> class __iterator;
62 template<bool> class __sentinel;62 template<bool> class __sentinel;
6363
64 [[no_unique_address]] __copyable_box<_Fn> __func_;64 _LIBCPP_NO_UNIQUE_ADDRESS __copyable_box<_Fn> __func_;
65 [[no_unique_address]] _View __base_ = _View();65 _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View();
6666
67public:67public:
68 _LIBCPP_HIDE_FROM_ABI68 _LIBCPP_HIDE_FROM_ABI
...@@ -71,12 +71,12 @@ public:...@@ -71,12 +71,12 @@ public:
7171
72 _LIBCPP_HIDE_FROM_ABI72 _LIBCPP_HIDE_FROM_ABI
73 constexpr transform_view(_View __base, _Fn __func)73 constexpr transform_view(_View __base, _Fn __func)
74 : __func_(_VSTD::in_place, _VSTD::move(__func)), __base_(_VSTD::move(__base)) {}74 : __func_(std::in_place, std::move(__func)), __base_(std::move(__base)) {}
7575
76 _LIBCPP_HIDE_FROM_ABI76 _LIBCPP_HIDE_FROM_ABI
77 constexpr _View base() const& requires copy_constructible<_View> { return __base_; }77 constexpr _View base() const& requires copy_constructible<_View> { return __base_; }
78 _LIBCPP_HIDE_FROM_ABI78 _LIBCPP_HIDE_FROM_ABI
79 constexpr _View base() && { return _VSTD::move(__base_); }79 constexpr _View base() && { return std::move(__base_); }
8080
81 _LIBCPP_HIDE_FROM_ABI81 _LIBCPP_HIDE_FROM_ABI
82 constexpr __iterator<false> begin() {82 constexpr __iterator<false> begin() {
...@@ -183,7 +183,7 @@ public:...@@ -183,7 +183,7 @@ public:
183183
184 _LIBCPP_HIDE_FROM_ABI184 _LIBCPP_HIDE_FROM_ABI
185 constexpr __iterator(_Parent& __parent, iterator_t<_Base> __current)185 constexpr __iterator(_Parent& __parent, iterator_t<_Base> __current)
186 : __parent_(_VSTD::addressof(__parent)), __current_(_VSTD::move(__current)) {}186 : __parent_(std::addressof(__parent)), __current_(std::move(__current)) {}
187187
188 // Note: `__i` should always be `__iterator<false>`, but directly using188 // Note: `__i` should always be `__iterator<false>`, but directly using
189 // `__iterator<false>` is ill-formed when `_Const` is false189 // `__iterator<false>` is ill-formed when `_Const` is false
...@@ -191,7 +191,7 @@ public:...@@ -191,7 +191,7 @@ public:
191 _LIBCPP_HIDE_FROM_ABI191 _LIBCPP_HIDE_FROM_ABI
192 constexpr __iterator(__iterator<!_Const> __i)192 constexpr __iterator(__iterator<!_Const> __i)
193 requires _Const && convertible_to<iterator_t<_View>, iterator_t<_Base>>193 requires _Const && convertible_to<iterator_t<_View>, iterator_t<_Base>>
194 : __parent_(__i.__parent_), __current_(_VSTD::move(__i.__current_)) {}194 : __parent_(__i.__parent_), __current_(std::move(__i.__current_)) {}
195195
196 _LIBCPP_HIDE_FROM_ABI196 _LIBCPP_HIDE_FROM_ABI
197 constexpr const iterator_t<_Base>& base() const& noexcept {197 constexpr const iterator_t<_Base>& base() const& noexcept {
...@@ -200,14 +200,14 @@ public:...@@ -200,14 +200,14 @@ public:
200200
201 _LIBCPP_HIDE_FROM_ABI201 _LIBCPP_HIDE_FROM_ABI
202 constexpr iterator_t<_Base> base() && {202 constexpr iterator_t<_Base> base() && {
203 return _VSTD::move(__current_);203 return std::move(__current_);
204 }204 }
205205
206 _LIBCPP_HIDE_FROM_ABI206 _LIBCPP_HIDE_FROM_ABI
207 constexpr decltype(auto) operator*() const207 constexpr decltype(auto) operator*() const
208 noexcept(noexcept(_VSTD::invoke(*__parent_->__func_, *__current_)))208 noexcept(noexcept(std::invoke(*__parent_->__func_, *__current_)))
209 {209 {
210 return _VSTD::invoke(*__parent_->__func_, *__current_);210 return std::invoke(*__parent_->__func_, *__current_);
211 }211 }
212212
213 _LIBCPP_HIDE_FROM_ABI213 _LIBCPP_HIDE_FROM_ABI
...@@ -263,10 +263,10 @@ public:...@@ -263,10 +263,10 @@ public:
263263
264 _LIBCPP_HIDE_FROM_ABI264 _LIBCPP_HIDE_FROM_ABI
265 constexpr decltype(auto) operator[](difference_type __n) const265 constexpr decltype(auto) operator[](difference_type __n) const
266 noexcept(noexcept(_VSTD::invoke(*__parent_->__func_, __current_[__n])))266 noexcept(noexcept(std::invoke(*__parent_->__func_, __current_[__n])))
267 requires random_access_range<_Base>267 requires random_access_range<_Base>
268 {268 {
269 return _VSTD::invoke(*__parent_->__func_, __current_[__n]);269 return std::invoke(*__parent_->__func_, __current_[__n]);
270 }270 }
271271
272 _LIBCPP_HIDE_FROM_ABI272 _LIBCPP_HIDE_FROM_ABI
...@@ -344,7 +344,7 @@ public:...@@ -344,7 +344,7 @@ public:
344 noexcept(noexcept(*__i))344 noexcept(noexcept(*__i))
345 {345 {
346 if constexpr (is_lvalue_reference_v<decltype(*__i)>)346 if constexpr (is_lvalue_reference_v<decltype(*__i)>)
347 return _VSTD::move(*__i);347 return std::move(*__i);
348 else348 else
349 return *__i;349 return *__i;
350 }350 }
...@@ -378,7 +378,7 @@ public:...@@ -378,7 +378,7 @@ public:
378 _LIBCPP_HIDE_FROM_ABI378 _LIBCPP_HIDE_FROM_ABI
379 constexpr __sentinel(__sentinel<!_Const> __i)379 constexpr __sentinel(__sentinel<!_Const> __i)
380 requires _Const && convertible_to<sentinel_t<_View>, sentinel_t<_Base>>380 requires _Const && convertible_to<sentinel_t<_View>, sentinel_t<_Base>>
381 : __end_(_VSTD::move(__i.__end_)) {}381 : __end_(std::move(__i.__end_)) {}
382382
383 _LIBCPP_HIDE_FROM_ABI383 _LIBCPP_HIDE_FROM_ABI
384 constexpr sentinel_t<_Base> base() const { return __end_; }384 constexpr sentinel_t<_Base> base() const { return __end_; }
...@@ -413,16 +413,16 @@ namespace __transform {...@@ -413,16 +413,16 @@ namespace __transform {
413 template<class _Range, class _Fn>413 template<class _Range, class _Fn>
414 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI414 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
415 constexpr auto operator()(_Range&& __range, _Fn&& __f) const415 constexpr auto operator()(_Range&& __range, _Fn&& __f) const
416 noexcept(noexcept(transform_view(_VSTD::forward<_Range>(__range), _VSTD::forward<_Fn>(__f))))416 noexcept(noexcept(transform_view(std::forward<_Range>(__range), std::forward<_Fn>(__f))))
417 -> decltype( transform_view(_VSTD::forward<_Range>(__range), _VSTD::forward<_Fn>(__f)))417 -> decltype( transform_view(std::forward<_Range>(__range), std::forward<_Fn>(__f)))
418 { return transform_view(_VSTD::forward<_Range>(__range), _VSTD::forward<_Fn>(__f)); }418 { return transform_view(std::forward<_Range>(__range), std::forward<_Fn>(__f)); }
419419
420 template<class _Fn>420 template<class _Fn>
421 requires constructible_from<decay_t<_Fn>, _Fn>421 requires constructible_from<decay_t<_Fn>, _Fn>
422 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI422 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
423 constexpr auto operator()(_Fn&& __f) const423 constexpr auto operator()(_Fn&& __f) const
424 noexcept(is_nothrow_constructible_v<decay_t<_Fn>, _Fn>)424 noexcept(is_nothrow_constructible_v<decay_t<_Fn>, _Fn>)
425 { return __range_adaptor_closure_t(_VSTD::__bind_back(*this, _VSTD::forward<_Fn>(__f))); }425 { return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Fn>(__f))); }
426 };426 };
427} // namespace __transform427} // namespace __transform
428428
...@@ -433,7 +433,7 @@ inline namespace __cpo {...@@ -433,7 +433,7 @@ inline namespace __cpo {
433433
434} // namespace ranges434} // namespace ranges
435435
436#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)436#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
437437
438_LIBCPP_END_NAMESPACE_STD438_LIBCPP_END_NAMESPACE_STD
439439
lib/libcxx/include/__ranges/view_interface.h+12-33
...@@ -9,8 +9,10 @@...@@ -9,8 +9,10 @@
9#ifndef _LIBCPP___RANGES_VIEW_INTERFACE_H9#ifndef _LIBCPP___RANGES_VIEW_INTERFACE_H
10#define _LIBCPP___RANGES_VIEW_INTERFACE_H10#define _LIBCPP___RANGES_VIEW_INTERFACE_H
1111
12#include <__assert>
13#include <__concepts/derived_from.h>
14#include <__concepts/same_as.h>
12#include <__config>15#include <__config>
13#include <__debug>
14#include <__iterator/concepts.h>16#include <__iterator/concepts.h>
15#include <__iterator/iterator_traits.h>17#include <__iterator/iterator_traits.h>
16#include <__iterator/prev.h>18#include <__iterator/prev.h>
...@@ -18,25 +20,18 @@...@@ -18,25 +20,18 @@
18#include <__ranges/access.h>20#include <__ranges/access.h>
19#include <__ranges/concepts.h>21#include <__ranges/concepts.h>
20#include <__ranges/empty.h>22#include <__ranges/empty.h>
21#include <concepts>
22#include <type_traits>23#include <type_traits>
2324
24#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)25#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
25#pragma GCC system_header26# pragma GCC system_header
26#endif27#endif
2728
28_LIBCPP_BEGIN_NAMESPACE_STD29_LIBCPP_BEGIN_NAMESPACE_STD
2930
30#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)31#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
3132
32namespace ranges {33namespace ranges {
3334
34template<class _Tp>
35concept __can_empty = requires(_Tp __t) { ranges::empty(__t); };
36
37template<class _Tp>
38void __implicitly_convert_to(type_identity_t<_Tp>) noexcept;
39
40template<class _Derived>35template<class _Derived>
41 requires is_class_v<_Derived> && same_as<_Derived, remove_cv_t<_Derived>>36 requires is_class_v<_Derived> && same_as<_Derived, remove_cv_t<_Derived>>
42class view_interface {37class view_interface {
...@@ -55,7 +50,6 @@ class view_interface {...@@ -55,7 +50,6 @@ class view_interface {
55public:50public:
56 template<class _D2 = _Derived>51 template<class _D2 = _Derived>
57 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool empty()52 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool empty()
58 noexcept(noexcept(__implicitly_convert_to<bool>(ranges::begin(__derived()) == ranges::end(__derived()))))
59 requires forward_range<_D2>53 requires forward_range<_D2>
60 {54 {
61 return ranges::begin(__derived()) == ranges::end(__derived());55 return ranges::begin(__derived()) == ranges::end(__derived());
...@@ -63,7 +57,6 @@ public:...@@ -63,7 +57,6 @@ public:
6357
64 template<class _D2 = _Derived>58 template<class _D2 = _Derived>
65 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool empty() const59 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool empty() const
66 noexcept(noexcept(__implicitly_convert_to<bool>(ranges::begin(__derived()) == ranges::end(__derived()))))
67 requires forward_range<const _D2>60 requires forward_range<const _D2>
68 {61 {
69 return ranges::begin(__derived()) == ranges::end(__derived());62 return ranges::begin(__derived()) == ranges::end(__derived());
...@@ -72,8 +65,7 @@ public:...@@ -72,8 +65,7 @@ public:
72 template<class _D2 = _Derived>65 template<class _D2 = _Derived>
73 _LIBCPP_HIDE_FROM_ABI66 _LIBCPP_HIDE_FROM_ABI
74 constexpr explicit operator bool()67 constexpr explicit operator bool()
75 noexcept(noexcept(ranges::empty(declval<_D2>())))68 requires requires (_D2& __t) { ranges::empty(__t); }
76 requires __can_empty<_D2>
77 {69 {
78 return !ranges::empty(__derived());70 return !ranges::empty(__derived());
79 }71 }
...@@ -81,8 +73,7 @@ public:...@@ -81,8 +73,7 @@ public:
81 template<class _D2 = _Derived>73 template<class _D2 = _Derived>
82 _LIBCPP_HIDE_FROM_ABI74 _LIBCPP_HIDE_FROM_ABI
83 constexpr explicit operator bool() const75 constexpr explicit operator bool() const
84 noexcept(noexcept(ranges::empty(declval<const _D2>())))76 requires requires (const _D2& __t) { ranges::empty(__t); }
85 requires __can_empty<const _D2>
86 {77 {
87 return !ranges::empty(__derived());78 return !ranges::empty(__derived());
88 }79 }
...@@ -90,27 +81,23 @@ public:...@@ -90,27 +81,23 @@ public:
90 template<class _D2 = _Derived>81 template<class _D2 = _Derived>
91 _LIBCPP_HIDE_FROM_ABI82 _LIBCPP_HIDE_FROM_ABI
92 constexpr auto data()83 constexpr auto data()
93 noexcept(noexcept(_VSTD::to_address(ranges::begin(__derived()))))
94 requires contiguous_iterator<iterator_t<_D2>>84 requires contiguous_iterator<iterator_t<_D2>>
95 {85 {
96 return _VSTD::to_address(ranges::begin(__derived()));86 return std::to_address(ranges::begin(__derived()));
97 }87 }
9888
99 template<class _D2 = _Derived>89 template<class _D2 = _Derived>
100 _LIBCPP_HIDE_FROM_ABI90 _LIBCPP_HIDE_FROM_ABI
101 constexpr auto data() const91 constexpr auto data() const
102 noexcept(noexcept(_VSTD::to_address(ranges::begin(__derived()))))
103 requires range<const _D2> && contiguous_iterator<iterator_t<const _D2>>92 requires range<const _D2> && contiguous_iterator<iterator_t<const _D2>>
104 {93 {
105 return _VSTD::to_address(ranges::begin(__derived()));94 return std::to_address(ranges::begin(__derived()));
106 }95 }
10796
108 template<class _D2 = _Derived>97 template<class _D2 = _Derived>
109 _LIBCPP_HIDE_FROM_ABI98 _LIBCPP_HIDE_FROM_ABI
110 constexpr auto size()99 constexpr auto size()
111 noexcept(noexcept(ranges::end(__derived()) - ranges::begin(__derived())))100 requires forward_range<_D2> && sized_sentinel_for<sentinel_t<_D2>, iterator_t<_D2>>
112 requires forward_range<_D2>
113 && sized_sentinel_for<sentinel_t<_D2>, iterator_t<_D2>>
114 {101 {
115 return ranges::end(__derived()) - ranges::begin(__derived());102 return ranges::end(__derived()) - ranges::begin(__derived());
116 }103 }
...@@ -118,9 +105,7 @@ public:...@@ -118,9 +105,7 @@ public:
118 template<class _D2 = _Derived>105 template<class _D2 = _Derived>
119 _LIBCPP_HIDE_FROM_ABI106 _LIBCPP_HIDE_FROM_ABI
120 constexpr auto size() const107 constexpr auto size() const
121 noexcept(noexcept(ranges::end(__derived()) - ranges::begin(__derived())))108 requires forward_range<const _D2> && sized_sentinel_for<sentinel_t<const _D2>, iterator_t<const _D2>>
122 requires forward_range<const _D2>
123 && sized_sentinel_for<sentinel_t<const _D2>, iterator_t<const _D2>>
124 {109 {
125 return ranges::end(__derived()) - ranges::begin(__derived());110 return ranges::end(__derived()) - ranges::begin(__derived());
126 }111 }
...@@ -128,7 +113,6 @@ public:...@@ -128,7 +113,6 @@ public:
128 template<class _D2 = _Derived>113 template<class _D2 = _Derived>
129 _LIBCPP_HIDE_FROM_ABI114 _LIBCPP_HIDE_FROM_ABI
130 constexpr decltype(auto) front()115 constexpr decltype(auto) front()
131 noexcept(noexcept(*ranges::begin(__derived())))
132 requires forward_range<_D2>116 requires forward_range<_D2>
133 {117 {
134 _LIBCPP_ASSERT(!empty(),118 _LIBCPP_ASSERT(!empty(),
...@@ -139,7 +123,6 @@ public:...@@ -139,7 +123,6 @@ public:
139 template<class _D2 = _Derived>123 template<class _D2 = _Derived>
140 _LIBCPP_HIDE_FROM_ABI124 _LIBCPP_HIDE_FROM_ABI
141 constexpr decltype(auto) front() const125 constexpr decltype(auto) front() const
142 noexcept(noexcept(*ranges::begin(__derived())))
143 requires forward_range<const _D2>126 requires forward_range<const _D2>
144 {127 {
145 _LIBCPP_ASSERT(!empty(),128 _LIBCPP_ASSERT(!empty(),
...@@ -150,7 +133,6 @@ public:...@@ -150,7 +133,6 @@ public:
150 template<class _D2 = _Derived>133 template<class _D2 = _Derived>
151 _LIBCPP_HIDE_FROM_ABI134 _LIBCPP_HIDE_FROM_ABI
152 constexpr decltype(auto) back()135 constexpr decltype(auto) back()
153 noexcept(noexcept(*ranges::prev(ranges::end(__derived()))))
154 requires bidirectional_range<_D2> && common_range<_D2>136 requires bidirectional_range<_D2> && common_range<_D2>
155 {137 {
156 _LIBCPP_ASSERT(!empty(),138 _LIBCPP_ASSERT(!empty(),
...@@ -161,7 +143,6 @@ public:...@@ -161,7 +143,6 @@ public:
161 template<class _D2 = _Derived>143 template<class _D2 = _Derived>
162 _LIBCPP_HIDE_FROM_ABI144 _LIBCPP_HIDE_FROM_ABI
163 constexpr decltype(auto) back() const145 constexpr decltype(auto) back() const
164 noexcept(noexcept(*ranges::prev(ranges::end(__derived()))))
165 requires bidirectional_range<const _D2> && common_range<const _D2>146 requires bidirectional_range<const _D2> && common_range<const _D2>
166 {147 {
167 _LIBCPP_ASSERT(!empty(),148 _LIBCPP_ASSERT(!empty(),
...@@ -172,7 +153,6 @@ public:...@@ -172,7 +153,6 @@ public:
172 template<random_access_range _RARange = _Derived>153 template<random_access_range _RARange = _Derived>
173 _LIBCPP_HIDE_FROM_ABI154 _LIBCPP_HIDE_FROM_ABI
174 constexpr decltype(auto) operator[](range_difference_t<_RARange> __index)155 constexpr decltype(auto) operator[](range_difference_t<_RARange> __index)
175 noexcept(noexcept(ranges::begin(__derived())[__index]))
176 {156 {
177 return ranges::begin(__derived())[__index];157 return ranges::begin(__derived())[__index];
178 }158 }
...@@ -180,7 +160,6 @@ public:...@@ -180,7 +160,6 @@ public:
180 template<random_access_range _RARange = const _Derived>160 template<random_access_range _RARange = const _Derived>
181 _LIBCPP_HIDE_FROM_ABI161 _LIBCPP_HIDE_FROM_ABI
182 constexpr decltype(auto) operator[](range_difference_t<_RARange> __index) const162 constexpr decltype(auto) operator[](range_difference_t<_RARange> __index) const
183 noexcept(noexcept(ranges::begin(__derived())[__index]))
184 {163 {
185 return ranges::begin(__derived())[__index];164 return ranges::begin(__derived())[__index];
186 }165 }
...@@ -188,7 +167,7 @@ public:...@@ -188,7 +167,7 @@ public:
188167
189} // namespace ranges168} // namespace ranges
190169
191#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)170#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
192171
193_LIBCPP_END_NAMESPACE_STD172_LIBCPP_END_NAMESPACE_STD
194173
lib/libcxx/include/__ranges/zip_view.h created+511
...@@ -0,0 +1,511 @@
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___RANGES_ZIP_VIEW_H
10#define _LIBCPP___RANGES_ZIP_VIEW_H
11
12#include <__config>
13
14#include <__algorithm/ranges_min.h>
15#include <__compare/three_way_comparable.h>
16#include <__concepts/convertible_to.h>
17#include <__concepts/equality_comparable.h>
18#include <__functional/invoke.h>
19#include <__functional/operations.h>
20#include <__iterator/concepts.h>
21#include <__iterator/incrementable_traits.h>
22#include <__iterator/iter_move.h>
23#include <__iterator/iter_swap.h>
24#include <__iterator/iterator_traits.h>
25#include <__ranges/access.h>
26#include <__ranges/all.h>
27#include <__ranges/concepts.h>
28#include <__ranges/empty_view.h>
29#include <__ranges/enable_borrowed_range.h>
30#include <__ranges/size.h>
31#include <__ranges/view_interface.h>
32#include <__utility/forward.h>
33#include <__utility/integer_sequence.h>
34#include <__utility/move.h>
35#include <tuple>
36#include <type_traits>
37
38#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
39# pragma GCC system_header
40#endif
41
42_LIBCPP_PUSH_MACROS
43#include <__undef_macros>
44
45_LIBCPP_BEGIN_NAMESPACE_STD
46
47#if _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
48
49namespace ranges {
50
51template <class... _Ranges>
52concept __zip_is_common = (sizeof...(_Ranges) == 1 && (common_range<_Ranges> && ...)) ||
53 (!(bidirectional_range<_Ranges> && ...) && (common_range<_Ranges> && ...)) ||
54 ((random_access_range<_Ranges> && ...) && (sized_range<_Ranges> && ...));
55
56template <typename _Tp, typename _Up>
57auto __tuple_or_pair_test() -> pair<_Tp, _Up>;
58
59template <typename... _Types>
60 requires(sizeof...(_Types) != 2)
61auto __tuple_or_pair_test() -> tuple<_Types...>;
62
63template <class... _Types>
64using __tuple_or_pair = decltype(__tuple_or_pair_test<_Types...>());
65
66template <class _Fun, class _Tuple>
67_LIBCPP_HIDE_FROM_ABI constexpr auto __tuple_transform(_Fun&& __f, _Tuple&& __tuple) {
68 return std::apply(
69 [&]<class... _Types>(_Types&&... __elements) {
70 return __tuple_or_pair<invoke_result_t<_Fun&, _Types>...>(
71 std::invoke(__f, std::forward<_Types>(__elements))...);
72 },
73 std::forward<_Tuple>(__tuple));
74}
75
76template <class _Fun, class _Tuple>
77_LIBCPP_HIDE_FROM_ABI constexpr void __tuple_for_each(_Fun&& __f, _Tuple&& __tuple) {
78 std::apply(
79 [&]<class... _Types>(_Types&&... __elements) { (std::invoke(__f, std::forward<_Types>(__elements)), ...); },
80 std::forward<_Tuple>(__tuple));
81}
82
83template <class _Fun, class _Tuple1, class _Tuple2, size_t... _Indices>
84_LIBCPP_HIDE_FROM_ABI constexpr __tuple_or_pair<
85 invoke_result_t<_Fun&, typename tuple_element<_Indices, remove_cvref_t<_Tuple1>>::type,
86 typename tuple_element<_Indices, remove_cvref_t<_Tuple2>>::type>...>
87__tuple_zip_transform(_Fun&& __f, _Tuple1&& __tuple1, _Tuple2&& __tuple2, index_sequence<_Indices...>) {
88 return {std::invoke(__f, std::get<_Indices>(std::forward<_Tuple1>(__tuple1)),
89 std::get<_Indices>(std::forward<_Tuple2>(__tuple2)))...};
90}
91
92template <class _Fun, class _Tuple1, class _Tuple2>
93_LIBCPP_HIDE_FROM_ABI constexpr auto __tuple_zip_transform(_Fun&& __f, _Tuple1&& __tuple1, _Tuple2&& __tuple2) {
94 return ranges::__tuple_zip_transform(__f, std::forward<_Tuple1>(__tuple1), std::forward<_Tuple2>(__tuple2),
95 std::make_index_sequence<tuple_size<remove_cvref_t<_Tuple1>>::value>());
96}
97
98template <class _Fun, class _Tuple1, class _Tuple2, size_t... _Indices>
99_LIBCPP_HIDE_FROM_ABI constexpr void __tuple_zip_for_each(_Fun&& __f, _Tuple1&& __tuple1, _Tuple2&& __tuple2,
100 index_sequence<_Indices...>) {
101 (std::invoke(__f, std::get<_Indices>(std::forward<_Tuple1>(__tuple1)),
102 std::get<_Indices>(std::forward<_Tuple2>(__tuple2))),
103 ...);
104}
105
106template <class _Fun, class _Tuple1, class _Tuple2>
107_LIBCPP_HIDE_FROM_ABI constexpr auto __tuple_zip_for_each(_Fun&& __f, _Tuple1&& __tuple1, _Tuple2&& __tuple2) {
108 return ranges::__tuple_zip_for_each(__f, std::forward<_Tuple1>(__tuple1), std::forward<_Tuple2>(__tuple2),
109 std::make_index_sequence<tuple_size<remove_cvref_t<_Tuple1>>::value>());
110}
111
112template <class _Tuple1, class _Tuple2>
113_LIBCPP_HIDE_FROM_ABI constexpr bool __tuple_any_equals(const _Tuple1& __tuple1, const _Tuple2& __tuple2) {
114 const auto __equals = ranges::__tuple_zip_transform(std::equal_to<>(), __tuple1, __tuple2);
115 return std::apply([](auto... __bools) { return (__bools || ...); }, __equals);
116}
117
118// abs in cstdlib is not constexpr
119// TODO : remove __abs once P0533R9 is implemented.
120template <class _Tp>
121_LIBCPP_HIDE_FROM_ABI constexpr _Tp __abs(_Tp __t) {
122 return __t < 0 ? -__t : __t;
123}
124
125template <input_range... _Views>
126 requires(view<_Views> && ...) && (sizeof...(_Views) > 0)
127class zip_view : public view_interface<zip_view<_Views...>> {
128
129 _LIBCPP_NO_UNIQUE_ADDRESS tuple<_Views...> __views_;
130
131 template <bool>
132 class __iterator;
133
134 template <bool>
135 class __sentinel;
136
137public:
138 _LIBCPP_HIDE_FROM_ABI
139 zip_view() = default;
140
141 _LIBCPP_HIDE_FROM_ABI
142 constexpr explicit zip_view(_Views... __views) : __views_(std::move(__views)...) {}
143
144 _LIBCPP_HIDE_FROM_ABI
145 constexpr auto begin()
146 requires(!(__simple_view<_Views> && ...)) {
147 return __iterator<false>(ranges::__tuple_transform(ranges::begin, __views_));
148 }
149
150 _LIBCPP_HIDE_FROM_ABI
151 constexpr auto begin() const
152 requires(range<const _Views> && ...) {
153 return __iterator<true>(ranges::__tuple_transform(ranges::begin, __views_));
154 }
155
156 _LIBCPP_HIDE_FROM_ABI
157 constexpr auto end()
158 requires(!(__simple_view<_Views> && ...)) {
159 if constexpr (!__zip_is_common<_Views...>) {
160 return __sentinel<false>(ranges::__tuple_transform(ranges::end, __views_));
161 } else if constexpr ((random_access_range<_Views> && ...)) {
162 return begin() + iter_difference_t<__iterator<false>>(size());
163 } else {
164 return __iterator<false>(ranges::__tuple_transform(ranges::end, __views_));
165 }
166 }
167
168 _LIBCPP_HIDE_FROM_ABI
169 constexpr auto end() const
170 requires(range<const _Views> && ...) {
171 if constexpr (!__zip_is_common<const _Views...>) {
172 return __sentinel<true>(ranges::__tuple_transform(ranges::end, __views_));
173 } else if constexpr ((random_access_range<const _Views> && ...)) {
174 return begin() + iter_difference_t<__iterator<true>>(size());
175 } else {
176 return __iterator<true>(ranges::__tuple_transform(ranges::end, __views_));
177 }
178 }
179
180 _LIBCPP_HIDE_FROM_ABI
181 constexpr auto size()
182 requires(sized_range<_Views> && ...) {
183 return std::apply(
184 [](auto... __sizes) {
185 using _CT = make_unsigned_t<common_type_t<decltype(__sizes)...>>;
186 return ranges::min({_CT(__sizes)...});
187 },
188 ranges::__tuple_transform(ranges::size, __views_));
189 }
190
191 _LIBCPP_HIDE_FROM_ABI
192 constexpr auto size() const
193 requires(sized_range<const _Views> && ...) {
194 return std::apply(
195 [](auto... __sizes) {
196 using _CT = make_unsigned_t<common_type_t<decltype(__sizes)...>>;
197 return ranges::min({_CT(__sizes)...});
198 },
199 ranges::__tuple_transform(ranges::size, __views_));
200 }
201};
202
203template <class... _Ranges>
204zip_view(_Ranges&&...) -> zip_view<views::all_t<_Ranges>...>;
205
206template <bool _Const, class... _Views>
207concept __zip_all_random_access = (random_access_range<__maybe_const<_Const, _Views>> && ...);
208
209template <bool _Const, class... _Views>
210concept __zip_all_bidirectional = (bidirectional_range<__maybe_const<_Const, _Views>> && ...);
211
212template <bool _Const, class... _Views>
213concept __zip_all_forward = (forward_range<__maybe_const<_Const, _Views>> && ...);
214
215template <bool _Const, class... _Views>
216consteval auto __get_zip_view_iterator_tag() {
217 if constexpr (__zip_all_random_access<_Const, _Views...>) {
218 return random_access_iterator_tag();
219 } else if constexpr (__zip_all_bidirectional<_Const, _Views...>) {
220 return bidirectional_iterator_tag();
221 } else if constexpr (__zip_all_forward<_Const, _Views...>) {
222 return forward_iterator_tag();
223 } else {
224 return input_iterator_tag();
225 }
226}
227
228template <bool _Const, class... _Views>
229struct __zip_view_iterator_category_base {};
230
231template <bool _Const, class... _Views>
232 requires __zip_all_forward<_Const, _Views...>
233struct __zip_view_iterator_category_base<_Const, _Views...> {
234 using iterator_category = input_iterator_tag;
235};
236
237template <input_range... _Views>
238 requires(view<_Views> && ...) && (sizeof...(_Views) > 0)
239template <bool _Const>
240class zip_view<_Views...>::__iterator : public __zip_view_iterator_category_base<_Const, _Views...> {
241
242 __tuple_or_pair<iterator_t<__maybe_const<_Const, _Views>>...> __current_;
243
244 _LIBCPP_HIDE_FROM_ABI
245 constexpr explicit __iterator(__tuple_or_pair<iterator_t<__maybe_const<_Const, _Views>>...> __current)
246 : __current_(std::move(__current)) {}
247
248 template <bool>
249 friend class zip_view<_Views...>::__iterator;
250
251 template <bool>
252 friend class zip_view<_Views...>::__sentinel;
253
254 friend class zip_view<_Views...>;
255
256public:
257 using iterator_concept = decltype(__get_zip_view_iterator_tag<_Const, _Views...>());
258 using value_type = __tuple_or_pair<range_value_t<__maybe_const<_Const, _Views>>...>;
259 using difference_type = common_type_t<range_difference_t<__maybe_const<_Const, _Views>>...>;
260
261 _LIBCPP_HIDE_FROM_ABI
262 __iterator() = default;
263
264 _LIBCPP_HIDE_FROM_ABI
265 constexpr __iterator(__iterator<!_Const> __i)
266 requires _Const && (convertible_to<iterator_t<_Views>, iterator_t<__maybe_const<_Const, _Views>>> && ...)
267 : __current_(std::move(__i.__current_)) {}
268
269 _LIBCPP_HIDE_FROM_ABI
270 constexpr auto operator*() const {
271 return ranges::__tuple_transform([](auto& __i) -> decltype(auto) { return *__i; }, __current_);
272 }
273
274 _LIBCPP_HIDE_FROM_ABI
275 constexpr __iterator& operator++() {
276 ranges::__tuple_for_each([](auto& __i) { ++__i; }, __current_);
277 return *this;
278 }
279
280 _LIBCPP_HIDE_FROM_ABI
281 constexpr void operator++(int) { ++*this; }
282
283 _LIBCPP_HIDE_FROM_ABI
284 constexpr __iterator operator++(int)
285 requires __zip_all_forward<_Const, _Views...> {
286 auto __tmp = *this;
287 ++*this;
288 return __tmp;
289 }
290
291 _LIBCPP_HIDE_FROM_ABI
292 constexpr __iterator& operator--()
293 requires __zip_all_bidirectional<_Const, _Views...> {
294 ranges::__tuple_for_each([](auto& __i) { --__i; }, __current_);
295 return *this;
296 }
297
298 _LIBCPP_HIDE_FROM_ABI
299 constexpr __iterator operator--(int)
300 requires __zip_all_bidirectional<_Const, _Views...> {
301 auto __tmp = *this;
302 --*this;
303 return __tmp;
304 }
305
306 _LIBCPP_HIDE_FROM_ABI
307 constexpr __iterator& operator+=(difference_type __x)
308 requires __zip_all_random_access<_Const, _Views...> {
309 ranges::__tuple_for_each([&]<class _Iter>(_Iter& __i) { __i += iter_difference_t<_Iter>(__x); }, __current_);
310 return *this;
311 }
312
313 _LIBCPP_HIDE_FROM_ABI
314 constexpr __iterator& operator-=(difference_type __x)
315 requires __zip_all_random_access<_Const, _Views...> {
316 ranges::__tuple_for_each([&]<class _Iter>(_Iter& __i) { __i -= iter_difference_t<_Iter>(__x); }, __current_);
317 return *this;
318 }
319
320 _LIBCPP_HIDE_FROM_ABI
321 constexpr auto operator[](difference_type __n) const
322 requires __zip_all_random_access<_Const, _Views...> {
323 return ranges::__tuple_transform(
324 [&]<class _Iter>(_Iter& __i) -> decltype(auto) { return __i[iter_difference_t<_Iter>(__n)]; }, __current_);
325 }
326
327 _LIBCPP_HIDE_FROM_ABI
328 friend constexpr bool operator==(const __iterator& __x, const __iterator& __y)
329 requires(equality_comparable<iterator_t<__maybe_const<_Const, _Views>>> && ...) {
330 if constexpr (__zip_all_bidirectional<_Const, _Views...>) {
331 return __x.__current_ == __y.__current_;
332 } else {
333 return ranges::__tuple_any_equals(__x.__current_, __y.__current_);
334 }
335 }
336
337 _LIBCPP_HIDE_FROM_ABI
338 friend constexpr bool operator<(const __iterator& __x, const __iterator& __y)
339 requires __zip_all_random_access<_Const, _Views...> {
340 return __x.__current_ < __y.__current_;
341 }
342
343 _LIBCPP_HIDE_FROM_ABI
344 friend constexpr bool operator>(const __iterator& __x, const __iterator& __y)
345 requires __zip_all_random_access<_Const, _Views...> {
346 return __y < __x;
347 }
348
349 _LIBCPP_HIDE_FROM_ABI
350 friend constexpr bool operator<=(const __iterator& __x, const __iterator& __y)
351 requires __zip_all_random_access<_Const, _Views...> {
352 return !(__y < __x);
353 }
354
355 _LIBCPP_HIDE_FROM_ABI
356 friend constexpr bool operator>=(const __iterator& __x, const __iterator& __y)
357 requires __zip_all_random_access<_Const, _Views...> {
358 return !(__x < __y);
359 }
360
361 _LIBCPP_HIDE_FROM_ABI
362 friend constexpr auto operator<=>(const __iterator& __x, const __iterator& __y)
363 requires __zip_all_random_access<_Const, _Views...> &&
364 (three_way_comparable<iterator_t<__maybe_const<_Const, _Views>>> && ...) {
365 return __x.__current_ <=> __y.__current_;
366 }
367
368 _LIBCPP_HIDE_FROM_ABI
369 friend constexpr __iterator operator+(const __iterator& __i, difference_type __n)
370 requires __zip_all_random_access<_Const, _Views...> {
371 auto __r = __i;
372 __r += __n;
373 return __r;
374 }
375
376 _LIBCPP_HIDE_FROM_ABI
377 friend constexpr __iterator operator+(difference_type __n, const __iterator& __i)
378 requires __zip_all_random_access<_Const, _Views...> {
379 return __i + __n;
380 }
381
382 _LIBCPP_HIDE_FROM_ABI
383 friend constexpr __iterator operator-(const __iterator& __i, difference_type __n)
384 requires __zip_all_random_access<_Const, _Views...> {
385 auto __r = __i;
386 __r -= __n;
387 return __r;
388 }
389
390 _LIBCPP_HIDE_FROM_ABI
391 friend constexpr difference_type operator-(const __iterator& __x, const __iterator& __y)
392 requires(sized_sentinel_for<iterator_t<__maybe_const<_Const, _Views>>, iterator_t<__maybe_const<_Const, _Views>>> &&
393 ...) {
394 const auto __diffs = ranges::__tuple_zip_transform(minus<>(), __x.__current_, __y.__current_);
395 return std::apply(
396 [](auto... __ds) {
397 return ranges::min({difference_type(__ds)...},
398 [](auto __a, auto __b) { return ranges::__abs(__a) < ranges::__abs(__b); });
399 },
400 __diffs);
401 }
402
403 _LIBCPP_HIDE_FROM_ABI
404 friend constexpr auto iter_move(const __iterator& __i) noexcept(
405 (noexcept(ranges::iter_move(declval<const iterator_t<__maybe_const<_Const, _Views>>&>())) && ...) &&
406 (is_nothrow_move_constructible_v<range_rvalue_reference_t<__maybe_const<_Const, _Views>>> && ...)) {
407 return ranges::__tuple_transform(ranges::iter_move, __i.__current_);
408 }
409
410 _LIBCPP_HIDE_FROM_ABI
411 friend constexpr void iter_swap(const __iterator& __l, const __iterator& __r) noexcept(
412 (noexcept(ranges::iter_swap(declval<const iterator_t<__maybe_const<_Const, _Views>>&>(),
413 declval<const iterator_t<__maybe_const<_Const, _Views>>&>())) &&
414 ...))
415 requires(indirectly_swappable<iterator_t<__maybe_const<_Const, _Views>>> && ...) {
416 ranges::__tuple_zip_for_each(ranges::iter_swap, __l.__current_, __r.__current_);
417 }
418};
419
420template <input_range... _Views>
421 requires(view<_Views> && ...) && (sizeof...(_Views) > 0)
422template <bool _Const>
423class zip_view<_Views...>::__sentinel {
424
425 __tuple_or_pair<sentinel_t<__maybe_const<_Const, _Views>>...> __end_;
426
427 _LIBCPP_HIDE_FROM_ABI
428 constexpr explicit __sentinel(__tuple_or_pair<sentinel_t<__maybe_const<_Const, _Views>>...> __end) : __end_(__end) {}
429
430 friend class zip_view<_Views...>;
431
432 // hidden friend cannot access private member of iterator because they are friends of friends
433 template <bool _OtherConst>
434 _LIBCPP_HIDE_FROM_ABI static constexpr decltype(auto)
435 __iter_current(zip_view<_Views...>::__iterator<_OtherConst> const& __it) {
436 return (__it.__current_);
437 }
438
439public:
440 _LIBCPP_HIDE_FROM_ABI
441 __sentinel() = default;
442
443 _LIBCPP_HIDE_FROM_ABI
444 constexpr __sentinel(__sentinel<!_Const> __i)
445 requires _Const && (convertible_to<sentinel_t<_Views>, sentinel_t<__maybe_const<_Const, _Views>>> && ...)
446 : __end_(std::move(__i.__end_)) {}
447
448 template <bool _OtherConst>
449 requires(sentinel_for<sentinel_t<__maybe_const<_Const, _Views>>, iterator_t<__maybe_const<_OtherConst, _Views>>> &&
450 ...)
451 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const __iterator<_OtherConst>& __x, const __sentinel& __y) {
452 return ranges::__tuple_any_equals(__iter_current(__x), __y.__end_);
453 }
454
455 template <bool _OtherConst>
456 requires(
457 sized_sentinel_for<sentinel_t<__maybe_const<_Const, _Views>>, iterator_t<__maybe_const<_OtherConst, _Views>>> &&
458 ...)
459 _LIBCPP_HIDE_FROM_ABI friend constexpr common_type_t<range_difference_t<__maybe_const<_OtherConst, _Views>>...>
460 operator-(const __iterator<_OtherConst>& __x, const __sentinel& __y) {
461 const auto __diffs = ranges::__tuple_zip_transform(minus<>(), __iter_current(__x), __y.__end_);
462 return std::apply(
463 [](auto... __ds) {
464 using _Diff = common_type_t<range_difference_t<__maybe_const<_OtherConst, _Views>>...>;
465 return ranges::min({_Diff(__ds)...},
466 [](auto __a, auto __b) { return ranges::__abs(__a) < ranges::__abs(__b); });
467 },
468 __diffs);
469 }
470
471 template <bool _OtherConst>
472 requires(
473 sized_sentinel_for<sentinel_t<__maybe_const<_Const, _Views>>, iterator_t<__maybe_const<_OtherConst, _Views>>> &&
474 ...)
475 _LIBCPP_HIDE_FROM_ABI friend constexpr common_type_t<range_difference_t<__maybe_const<_OtherConst, _Views>>...>
476 operator-(const __sentinel& __y, const __iterator<_OtherConst>& __x) {
477 return -(__x - __y);
478 }
479};
480
481template <class... _Views>
482inline constexpr bool enable_borrowed_range<zip_view<_Views...>> = (enable_borrowed_range<_Views> && ...);
483
484namespace views {
485namespace __zip {
486
487struct __fn {
488 _LIBCPP_HIDE_FROM_ABI constexpr auto operator()() const noexcept { return empty_view<tuple<>>{}; }
489
490 template <class... _Ranges>
491 _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Ranges&&... __rs) const
492 noexcept(noexcept(zip_view<all_t<_Ranges&&>...>(std::forward<_Ranges>(__rs)...)))
493 -> decltype(zip_view<all_t<_Ranges&&>...>(std::forward<_Ranges>(__rs)...)) {
494 return zip_view<all_t<_Ranges>...>(std::forward<_Ranges>(__rs)...);
495 }
496};
497
498} // namespace __zip
499inline namespace __cpo {
500 inline constexpr auto zip = __zip::__fn{};
501} // namespace __cpo
502} // namespace views
503} // namespace ranges
504
505#endif // _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
506
507_LIBCPP_END_NAMESPACE_STD
508
509_LIBCPP_POP_MACROS
510
511#endif // _LIBCPP___RANGES_ZIP_VIEW_H
lib/libcxx/include/__split_buffer+112-83
...@@ -1,14 +1,31 @@...@@ -1,14 +1,31 @@
1// -*- C++ -*-1// -*- C++ -*-
2#ifndef _LIBCPP_SPLIT_BUFFER2//===----------------------------------------------------------------------===//
3#define _LIBCPP_SPLIT_BUFFER3//
44// 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___SPLIT_BUFFER
11#define _LIBCPP___SPLIT_BUFFER
12
13#include <__algorithm/max.h>
14#include <__algorithm/move.h>
15#include <__algorithm/move_backward.h>
5#include <__config>16#include <__config>
17#include <__iterator/distance.h>
18#include <__iterator/iterator_traits.h>
19#include <__iterator/move_iterator.h>
20#include <__memory/allocator.h>
21#include <__memory/compressed_pair.h>
22#include <__memory/swap_allocator.h>
6#include <__utility/forward.h>23#include <__utility/forward.h>
7#include <algorithm>24#include <memory>
8#include <type_traits>25#include <type_traits>
926
10#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)27#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
11#pragma GCC system_header28# pragma GCC system_header
12#endif29#endif
1330
14_LIBCPP_PUSH_MACROS31_LIBCPP_PUSH_MACROS
...@@ -45,116 +62,107 @@ public:...@@ -45,116 +62,107 @@ public:
45 typedef typename add_lvalue_reference<allocator_type>::type __alloc_ref;62 typedef typename add_lvalue_reference<allocator_type>::type __alloc_ref;
46 typedef typename add_lvalue_reference<allocator_type>::type __alloc_const_ref;63 typedef typename add_lvalue_reference<allocator_type>::type __alloc_const_ref;
4764
48 _LIBCPP_INLINE_VISIBILITY __alloc_rr& __alloc() _NOEXCEPT {return __end_cap_.second();}65 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY __alloc_rr& __alloc() _NOEXCEPT {return __end_cap_.second();}
49 _LIBCPP_INLINE_VISIBILITY const __alloc_rr& __alloc() const _NOEXCEPT {return __end_cap_.second();}66 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const __alloc_rr& __alloc() const _NOEXCEPT {return __end_cap_.second();}
50 _LIBCPP_INLINE_VISIBILITY pointer& __end_cap() _NOEXCEPT {return __end_cap_.first();}67 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY pointer& __end_cap() _NOEXCEPT {return __end_cap_.first();}
51 _LIBCPP_INLINE_VISIBILITY const pointer& __end_cap() const _NOEXCEPT {return __end_cap_.first();}68 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const pointer& __end_cap() const _NOEXCEPT {return __end_cap_.first();}
5269
53 _LIBCPP_INLINE_VISIBILITY70 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
54 __split_buffer()71 __split_buffer()
55 _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);72 _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);
56 _LIBCPP_INLINE_VISIBILITY73 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
57 explicit __split_buffer(__alloc_rr& __a);74 explicit __split_buffer(__alloc_rr& __a);
58 _LIBCPP_INLINE_VISIBILITY75 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
59 explicit __split_buffer(const __alloc_rr& __a);76 explicit __split_buffer(const __alloc_rr& __a);
60 __split_buffer(size_type __cap, size_type __start, __alloc_rr& __a);77 _LIBCPP_CONSTEXPR_AFTER_CXX17 __split_buffer(size_type __cap, size_type __start, __alloc_rr& __a);
61 ~__split_buffer();78 _LIBCPP_CONSTEXPR_AFTER_CXX17 ~__split_buffer();
6279
63 __split_buffer(__split_buffer&& __c)80 _LIBCPP_CONSTEXPR_AFTER_CXX17 __split_buffer(__split_buffer&& __c)
64 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);81 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
65 __split_buffer(__split_buffer&& __c, const __alloc_rr& __a);82 _LIBCPP_CONSTEXPR_AFTER_CXX17 __split_buffer(__split_buffer&& __c, const __alloc_rr& __a);
66 __split_buffer& operator=(__split_buffer&& __c)83 _LIBCPP_CONSTEXPR_AFTER_CXX17 __split_buffer& operator=(__split_buffer&& __c)
67 _NOEXCEPT_((__alloc_traits::propagate_on_container_move_assignment::value &&84 _NOEXCEPT_((__alloc_traits::propagate_on_container_move_assignment::value &&
68 is_nothrow_move_assignable<allocator_type>::value) ||85 is_nothrow_move_assignable<allocator_type>::value) ||
69 !__alloc_traits::propagate_on_container_move_assignment::value);86 !__alloc_traits::propagate_on_container_move_assignment::value);
7087
71 _LIBCPP_INLINE_VISIBILITY iterator begin() _NOEXCEPT {return __begin_;}88 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY iterator begin() _NOEXCEPT {return __begin_;}
72 _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT {return __begin_;}89 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT {return __begin_;}
73 _LIBCPP_INLINE_VISIBILITY iterator end() _NOEXCEPT {return __end_;}90 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY iterator end() _NOEXCEPT {return __end_;}
74 _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT {return __end_;}91 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT {return __end_;}
7592
76 _LIBCPP_INLINE_VISIBILITY93 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
77 void clear() _NOEXCEPT94 void clear() _NOEXCEPT
78 {__destruct_at_end(__begin_);}95 {__destruct_at_end(__begin_);}
79 _LIBCPP_INLINE_VISIBILITY size_type size() const {return static_cast<size_type>(__end_ - __begin_);}96 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY size_type size() const {return static_cast<size_type>(__end_ - __begin_);}
80 _LIBCPP_INLINE_VISIBILITY bool empty() const {return __end_ == __begin_;}97 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY bool empty() const {return __end_ == __begin_;}
81 _LIBCPP_INLINE_VISIBILITY size_type capacity() const {return static_cast<size_type>(__end_cap() - __first_);}98 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY size_type capacity() const {return static_cast<size_type>(__end_cap() - __first_);}
82 _LIBCPP_INLINE_VISIBILITY size_type __front_spare() const {return static_cast<size_type>(__begin_ - __first_);}99 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY size_type __front_spare() const {return static_cast<size_type>(__begin_ - __first_);}
83 _LIBCPP_INLINE_VISIBILITY size_type __back_spare() const {return static_cast<size_type>(__end_cap() - __end_);}100 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY size_type __back_spare() const {return static_cast<size_type>(__end_cap() - __end_);}
84101
85 _LIBCPP_INLINE_VISIBILITY reference front() {return *__begin_;}102 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY reference front() {return *__begin_;}
86 _LIBCPP_INLINE_VISIBILITY const_reference front() const {return *__begin_;}103 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_reference front() const {return *__begin_;}
87 _LIBCPP_INLINE_VISIBILITY reference back() {return *(__end_ - 1);}104 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY reference back() {return *(__end_ - 1);}
88 _LIBCPP_INLINE_VISIBILITY const_reference back() const {return *(__end_ - 1);}105 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_reference back() const {return *(__end_ - 1);}
89106
90 void reserve(size_type __n);107 _LIBCPP_CONSTEXPR_AFTER_CXX17 void reserve(size_type __n);
91 void shrink_to_fit() _NOEXCEPT;108 _LIBCPP_CONSTEXPR_AFTER_CXX17 void shrink_to_fit() _NOEXCEPT;
92 void push_front(const_reference __x);109 _LIBCPP_CONSTEXPR_AFTER_CXX17 void push_front(const_reference __x);
93 _LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x);110 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x);
94 void push_front(value_type&& __x);111 _LIBCPP_CONSTEXPR_AFTER_CXX17 void push_front(value_type&& __x);
95 void push_back(value_type&& __x);112 _LIBCPP_CONSTEXPR_AFTER_CXX17 void push_back(value_type&& __x);
96 template <class... _Args>113 template <class... _Args>
97 void emplace_back(_Args&&... __args);114 _LIBCPP_CONSTEXPR_AFTER_CXX17 void emplace_back(_Args&&... __args);
98115
99 _LIBCPP_INLINE_VISIBILITY void pop_front() {__destruct_at_begin(__begin_+1);}116 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void pop_front() {__destruct_at_begin(__begin_+1);}
100 _LIBCPP_INLINE_VISIBILITY void pop_back() {__destruct_at_end(__end_-1);}117 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void pop_back() {__destruct_at_end(__end_-1);}
101118
102 void __construct_at_end(size_type __n);119 _LIBCPP_CONSTEXPR_AFTER_CXX17 void __construct_at_end(size_type __n);
103 void __construct_at_end(size_type __n, const_reference __x);120 _LIBCPP_CONSTEXPR_AFTER_CXX17 void __construct_at_end(size_type __n, const_reference __x);
104 template <class _InputIter>121 template <class _InputIter>
105 typename enable_if122 _LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIter>::value>
106 <
107 __is_cpp17_input_iterator<_InputIter>::value &&
108 !__is_cpp17_forward_iterator<_InputIter>::value,
109 void
110 >::type
111 __construct_at_end(_InputIter __first, _InputIter __last);123 __construct_at_end(_InputIter __first, _InputIter __last);
112 template <class _ForwardIterator>124 template <class _ForwardIterator>
113 typename enable_if125 _LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value>
114 <
115 __is_cpp17_forward_iterator<_ForwardIterator>::value,
116 void
117 >::type
118 __construct_at_end(_ForwardIterator __first, _ForwardIterator __last);126 __construct_at_end(_ForwardIterator __first, _ForwardIterator __last);
119127
120 _LIBCPP_INLINE_VISIBILITY void __destruct_at_begin(pointer __new_begin)128 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void __destruct_at_begin(pointer __new_begin)
121 {__destruct_at_begin(__new_begin, is_trivially_destructible<value_type>());}129 {__destruct_at_begin(__new_begin, is_trivially_destructible<value_type>());}
122 _LIBCPP_INLINE_VISIBILITY130 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
123 void __destruct_at_begin(pointer __new_begin, false_type);131 void __destruct_at_begin(pointer __new_begin, false_type);
124 _LIBCPP_INLINE_VISIBILITY132 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
125 void __destruct_at_begin(pointer __new_begin, true_type);133 void __destruct_at_begin(pointer __new_begin, true_type);
126134
127 _LIBCPP_INLINE_VISIBILITY135 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
128 void __destruct_at_end(pointer __new_last) _NOEXCEPT136 void __destruct_at_end(pointer __new_last) _NOEXCEPT
129 {__destruct_at_end(__new_last, false_type());}137 {__destruct_at_end(__new_last, false_type());}
130 _LIBCPP_INLINE_VISIBILITY138 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
131 void __destruct_at_end(pointer __new_last, false_type) _NOEXCEPT;139 void __destruct_at_end(pointer __new_last, false_type) _NOEXCEPT;
132 _LIBCPP_INLINE_VISIBILITY140 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
133 void __destruct_at_end(pointer __new_last, true_type) _NOEXCEPT;141 void __destruct_at_end(pointer __new_last, true_type) _NOEXCEPT;
134142
135 void swap(__split_buffer& __x)143 _LIBCPP_CONSTEXPR_AFTER_CXX17 void swap(__split_buffer& __x)
136 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value||144 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value||
137 __is_nothrow_swappable<__alloc_rr>::value);145 __is_nothrow_swappable<__alloc_rr>::value);
138146
139 bool __invariants() const;147 _LIBCPP_CONSTEXPR_AFTER_CXX17 bool __invariants() const;
140148
141private:149private:
142 _LIBCPP_INLINE_VISIBILITY150 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
143 void __move_assign_alloc(__split_buffer& __c, true_type)151 void __move_assign_alloc(__split_buffer& __c, true_type)
144 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)152 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
145 {153 {
146 __alloc() = _VSTD::move(__c.__alloc());154 __alloc() = _VSTD::move(__c.__alloc());
147 }155 }
148156
149 _LIBCPP_INLINE_VISIBILITY157 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
150 void __move_assign_alloc(__split_buffer&, false_type) _NOEXCEPT158 void __move_assign_alloc(__split_buffer&, false_type) _NOEXCEPT
151 {}159 {}
152160
153 struct _ConstructTransaction {161 struct _ConstructTransaction {
154 explicit _ConstructTransaction(pointer* __p, size_type __n) _NOEXCEPT162 _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit _ConstructTransaction(pointer* __p, size_type __n) _NOEXCEPT
155 : __pos_(*__p), __end_(*__p + __n), __dest_(__p) {163 : __pos_(*__p), __end_(*__p + __n), __dest_(__p) {
156 }164 }
157 ~_ConstructTransaction() {165 _LIBCPP_CONSTEXPR_AFTER_CXX17 ~_ConstructTransaction() {
158 *__dest_ = __pos_;166 *__dest_ = __pos_;
159 }167 }
160 pointer __pos_;168 pointer __pos_;
...@@ -165,6 +173,7 @@ private:...@@ -165,6 +173,7 @@ private:
165};173};
166174
167template <class _Tp, class _Allocator>175template <class _Tp, class _Allocator>
176_LIBCPP_CONSTEXPR_AFTER_CXX17
168bool177bool
169__split_buffer<_Tp, _Allocator>::__invariants() const178__split_buffer<_Tp, _Allocator>::__invariants() const
170{179{
...@@ -195,6 +204,7 @@ __split_buffer<_Tp, _Allocator>::__invariants() const...@@ -195,6 +204,7 @@ __split_buffer<_Tp, _Allocator>::__invariants() const
195// Precondition: size() + __n <= capacity()204// Precondition: size() + __n <= capacity()
196// Postcondition: size() == size() + __n205// Postcondition: size() == size() + __n
197template <class _Tp, class _Allocator>206template <class _Tp, class _Allocator>
207_LIBCPP_CONSTEXPR_AFTER_CXX17
198void208void
199__split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n)209__split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n)
200{210{
...@@ -211,6 +221,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n)...@@ -211,6 +221,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n)
211// Postcondition: size() == old size() + __n221// Postcondition: size() == old size() + __n
212// Postcondition: [i] == __x for all i in [size() - __n, __n)222// Postcondition: [i] == __x for all i in [size() - __n, __n)
213template <class _Tp, class _Allocator>223template <class _Tp, class _Allocator>
224_LIBCPP_CONSTEXPR_AFTER_CXX17
214void225void
215__split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x)226__split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x)
216{227{
...@@ -223,12 +234,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n, const_referen...@@ -223,12 +234,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n, const_referen
223234
224template <class _Tp, class _Allocator>235template <class _Tp, class _Allocator>
225template <class _InputIter>236template <class _InputIter>
226typename enable_if237_LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIter>::value>
227<
228 __is_cpp17_input_iterator<_InputIter>::value &&
229 !__is_cpp17_forward_iterator<_InputIter>::value,
230 void
231>::type
232__split_buffer<_Tp, _Allocator>::__construct_at_end(_InputIter __first, _InputIter __last)238__split_buffer<_Tp, _Allocator>::__construct_at_end(_InputIter __first, _InputIter __last)
233{239{
234 __alloc_rr& __a = this->__alloc();240 __alloc_rr& __a = this->__alloc();
...@@ -251,11 +257,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(_InputIter __first, _InputIt...@@ -251,11 +257,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(_InputIter __first, _InputIt
251257
252template <class _Tp, class _Allocator>258template <class _Tp, class _Allocator>
253template <class _ForwardIterator>259template <class _ForwardIterator>
254typename enable_if260_LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value>
255<
256 __is_cpp17_forward_iterator<_ForwardIterator>::value,
257 void
258>::type
259__split_buffer<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last)261__split_buffer<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last)
260{262{
261 _ConstructTransaction __tx(&this->__end_, _VSTD::distance(__first, __last));263 _ConstructTransaction __tx(&this->__end_, _VSTD::distance(__first, __last));
...@@ -266,6 +268,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _F...@@ -266,6 +268,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _F
266}268}
267269
268template <class _Tp, class _Allocator>270template <class _Tp, class _Allocator>
271_LIBCPP_CONSTEXPR_AFTER_CXX17
269inline272inline
270void273void
271__split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_type)274__split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_type)
...@@ -275,6 +278,7 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_...@@ -275,6 +278,7 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_
275}278}
276279
277template <class _Tp, class _Allocator>280template <class _Tp, class _Allocator>
281_LIBCPP_CONSTEXPR_AFTER_CXX17
278inline282inline
279void283void
280__split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, true_type)284__split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, true_type)
...@@ -283,6 +287,7 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, true_t...@@ -283,6 +287,7 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, true_t
283}287}
284288
285template <class _Tp, class _Allocator>289template <class _Tp, class _Allocator>
290_LIBCPP_CONSTEXPR_AFTER_CXX17
286inline _LIBCPP_INLINE_VISIBILITY291inline _LIBCPP_INLINE_VISIBILITY
287void292void
288__split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_type) _NOEXCEPT293__split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_type) _NOEXCEPT
...@@ -292,6 +297,7 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_typ...@@ -292,6 +297,7 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_typ
292}297}
293298
294template <class _Tp, class _Allocator>299template <class _Tp, class _Allocator>
300_LIBCPP_CONSTEXPR_AFTER_CXX17
295inline _LIBCPP_INLINE_VISIBILITY301inline _LIBCPP_INLINE_VISIBILITY
296void302void
297__split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, true_type) _NOEXCEPT303__split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, true_type) _NOEXCEPT
...@@ -300,15 +306,23 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, true_type...@@ -300,15 +306,23 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, true_type
300}306}
301307
302template <class _Tp, class _Allocator>308template <class _Tp, class _Allocator>
309_LIBCPP_CONSTEXPR_AFTER_CXX17
303__split_buffer<_Tp, _Allocator>::__split_buffer(size_type __cap, size_type __start, __alloc_rr& __a)310__split_buffer<_Tp, _Allocator>::__split_buffer(size_type __cap, size_type __start, __alloc_rr& __a)
304 : __end_cap_(nullptr, __a)311 : __end_cap_(nullptr, __a)
305{312{
306 __first_ = __cap != 0 ? __alloc_traits::allocate(__alloc(), __cap) : nullptr;313 if (__cap == 0) {
314 __first_ = nullptr;
315 } else {
316 auto __allocation = std::__allocate_at_least(__alloc(), __cap);
317 __first_ = __allocation.ptr;
318 __cap = __allocation.count;
319 }
307 __begin_ = __end_ = __first_ + __start;320 __begin_ = __end_ = __first_ + __start;
308 __end_cap() = __first_ + __cap;321 __end_cap() = __first_ + __cap;
309}322}
310323
311template <class _Tp, class _Allocator>324template <class _Tp, class _Allocator>
325_LIBCPP_CONSTEXPR_AFTER_CXX17
312inline326inline
313__split_buffer<_Tp, _Allocator>::__split_buffer()327__split_buffer<_Tp, _Allocator>::__split_buffer()
314 _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)328 _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
...@@ -317,6 +331,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer()...@@ -317,6 +331,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer()
317}331}
318332
319template <class _Tp, class _Allocator>333template <class _Tp, class _Allocator>
334_LIBCPP_CONSTEXPR_AFTER_CXX17
320inline335inline
321__split_buffer<_Tp, _Allocator>::__split_buffer(__alloc_rr& __a)336__split_buffer<_Tp, _Allocator>::__split_buffer(__alloc_rr& __a)
322 : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a)337 : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a)
...@@ -324,6 +339,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(__alloc_rr& __a)...@@ -324,6 +339,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(__alloc_rr& __a)
324}339}
325340
326template <class _Tp, class _Allocator>341template <class _Tp, class _Allocator>
342_LIBCPP_CONSTEXPR_AFTER_CXX17
327inline343inline
328__split_buffer<_Tp, _Allocator>::__split_buffer(const __alloc_rr& __a)344__split_buffer<_Tp, _Allocator>::__split_buffer(const __alloc_rr& __a)
329 : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a)345 : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a)
...@@ -331,6 +347,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(const __alloc_rr& __a)...@@ -331,6 +347,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(const __alloc_rr& __a)
331}347}
332348
333template <class _Tp, class _Allocator>349template <class _Tp, class _Allocator>
350_LIBCPP_CONSTEXPR_AFTER_CXX17
334__split_buffer<_Tp, _Allocator>::~__split_buffer()351__split_buffer<_Tp, _Allocator>::~__split_buffer()
335{352{
336 clear();353 clear();
...@@ -339,6 +356,7 @@ __split_buffer<_Tp, _Allocator>::~__split_buffer()...@@ -339,6 +356,7 @@ __split_buffer<_Tp, _Allocator>::~__split_buffer()
339}356}
340357
341template <class _Tp, class _Allocator>358template <class _Tp, class _Allocator>
359_LIBCPP_CONSTEXPR_AFTER_CXX17
342__split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c)360__split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c)
343 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)361 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
344 : __first_(_VSTD::move(__c.__first_)),362 : __first_(_VSTD::move(__c.__first_)),
...@@ -353,6 +371,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c)...@@ -353,6 +371,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c)
353}371}
354372
355template <class _Tp, class _Allocator>373template <class _Tp, class _Allocator>
374_LIBCPP_CONSTEXPR_AFTER_CXX17
356__split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c, const __alloc_rr& __a)375__split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c, const __alloc_rr& __a)
357 : __end_cap_(nullptr, __a)376 : __end_cap_(nullptr, __a)
358{377{
...@@ -369,16 +388,17 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c, const __al...@@ -369,16 +388,17 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c, const __al
369 }388 }
370 else389 else
371 {390 {
372 size_type __cap = __c.size();391 auto __allocation = std::__allocate_at_least(__alloc(), __c.size());
373 __first_ = __alloc_traits::allocate(__alloc(), __cap);392 __first_ = __allocation.ptr;
374 __begin_ = __end_ = __first_;393 __begin_ = __end_ = __first_;
375 __end_cap() = __first_ + __cap;394 __end_cap() = __first_ + __allocation.count;
376 typedef move_iterator<iterator> _Ip;395 typedef move_iterator<iterator> _Ip;
377 __construct_at_end(_Ip(__c.begin()), _Ip(__c.end()));396 __construct_at_end(_Ip(__c.begin()), _Ip(__c.end()));
378 }397 }
379}398}
380399
381template <class _Tp, class _Allocator>400template <class _Tp, class _Allocator>
401_LIBCPP_CONSTEXPR_AFTER_CXX17
382__split_buffer<_Tp, _Allocator>&402__split_buffer<_Tp, _Allocator>&
383__split_buffer<_Tp, _Allocator>::operator=(__split_buffer&& __c)403__split_buffer<_Tp, _Allocator>::operator=(__split_buffer&& __c)
384 _NOEXCEPT_((__alloc_traits::propagate_on_container_move_assignment::value &&404 _NOEXCEPT_((__alloc_traits::propagate_on_container_move_assignment::value &&
...@@ -399,6 +419,7 @@ __split_buffer<_Tp, _Allocator>::operator=(__split_buffer&& __c)...@@ -399,6 +419,7 @@ __split_buffer<_Tp, _Allocator>::operator=(__split_buffer&& __c)
399}419}
400420
401template <class _Tp, class _Allocator>421template <class _Tp, class _Allocator>
422_LIBCPP_CONSTEXPR_AFTER_CXX17
402void423void
403__split_buffer<_Tp, _Allocator>::swap(__split_buffer& __x)424__split_buffer<_Tp, _Allocator>::swap(__split_buffer& __x)
404 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value||425 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value||
...@@ -412,6 +433,7 @@ __split_buffer<_Tp, _Allocator>::swap(__split_buffer& __x)...@@ -412,6 +433,7 @@ __split_buffer<_Tp, _Allocator>::swap(__split_buffer& __x)
412}433}
413434
414template <class _Tp, class _Allocator>435template <class _Tp, class _Allocator>
436_LIBCPP_CONSTEXPR_AFTER_CXX17
415void437void
416__split_buffer<_Tp, _Allocator>::reserve(size_type __n)438__split_buffer<_Tp, _Allocator>::reserve(size_type __n)
417{439{
...@@ -428,6 +450,7 @@ __split_buffer<_Tp, _Allocator>::reserve(size_type __n)...@@ -428,6 +450,7 @@ __split_buffer<_Tp, _Allocator>::reserve(size_type __n)
428}450}
429451
430template <class _Tp, class _Allocator>452template <class _Tp, class _Allocator>
453_LIBCPP_CONSTEXPR_AFTER_CXX17
431void454void
432__split_buffer<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT455__split_buffer<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT
433{456{
...@@ -455,6 +478,7 @@ __split_buffer<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT...@@ -455,6 +478,7 @@ __split_buffer<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT
455}478}
456479
457template <class _Tp, class _Allocator>480template <class _Tp, class _Allocator>
481_LIBCPP_CONSTEXPR_AFTER_CXX17
458void482void
459__split_buffer<_Tp, _Allocator>::push_front(const_reference __x)483__split_buffer<_Tp, _Allocator>::push_front(const_reference __x)
460{484{
...@@ -484,6 +508,7 @@ __split_buffer<_Tp, _Allocator>::push_front(const_reference __x)...@@ -484,6 +508,7 @@ __split_buffer<_Tp, _Allocator>::push_front(const_reference __x)
484}508}
485509
486template <class _Tp, class _Allocator>510template <class _Tp, class _Allocator>
511_LIBCPP_CONSTEXPR_AFTER_CXX17
487void512void
488__split_buffer<_Tp, _Allocator>::push_front(value_type&& __x)513__split_buffer<_Tp, _Allocator>::push_front(value_type&& __x)
489{514{
...@@ -514,6 +539,7 @@ __split_buffer<_Tp, _Allocator>::push_front(value_type&& __x)...@@ -514,6 +539,7 @@ __split_buffer<_Tp, _Allocator>::push_front(value_type&& __x)
514}539}
515540
516template <class _Tp, class _Allocator>541template <class _Tp, class _Allocator>
542_LIBCPP_CONSTEXPR_AFTER_CXX17
517inline _LIBCPP_INLINE_VISIBILITY543inline _LIBCPP_INLINE_VISIBILITY
518void544void
519__split_buffer<_Tp, _Allocator>::push_back(const_reference __x)545__split_buffer<_Tp, _Allocator>::push_back(const_reference __x)
...@@ -544,6 +570,7 @@ __split_buffer<_Tp, _Allocator>::push_back(const_reference __x)...@@ -544,6 +570,7 @@ __split_buffer<_Tp, _Allocator>::push_back(const_reference __x)
544}570}
545571
546template <class _Tp, class _Allocator>572template <class _Tp, class _Allocator>
573_LIBCPP_CONSTEXPR_AFTER_CXX17
547void574void
548__split_buffer<_Tp, _Allocator>::push_back(value_type&& __x)575__split_buffer<_Tp, _Allocator>::push_back(value_type&& __x)
549{576{
...@@ -575,6 +602,7 @@ __split_buffer<_Tp, _Allocator>::push_back(value_type&& __x)...@@ -575,6 +602,7 @@ __split_buffer<_Tp, _Allocator>::push_back(value_type&& __x)
575602
576template <class _Tp, class _Allocator>603template <class _Tp, class _Allocator>
577template <class... _Args>604template <class... _Args>
605_LIBCPP_CONSTEXPR_AFTER_CXX17
578void606void
579__split_buffer<_Tp, _Allocator>::emplace_back(_Args&&... __args)607__split_buffer<_Tp, _Allocator>::emplace_back(_Args&&... __args)
580{608{
...@@ -605,6 +633,7 @@ __split_buffer<_Tp, _Allocator>::emplace_back(_Args&&... __args)...@@ -605,6 +633,7 @@ __split_buffer<_Tp, _Allocator>::emplace_back(_Args&&... __args)
605}633}
606634
607template <class _Tp, class _Allocator>635template <class _Tp, class _Allocator>
636_LIBCPP_CONSTEXPR_AFTER_CXX17
608inline _LIBCPP_INLINE_VISIBILITY637inline _LIBCPP_INLINE_VISIBILITY
609void638void
610swap(__split_buffer<_Tp, _Allocator>& __x, __split_buffer<_Tp, _Allocator>& __y)639swap(__split_buffer<_Tp, _Allocator>& __x, __split_buffer<_Tp, _Allocator>& __y)
...@@ -617,4 +646,4 @@ _LIBCPP_END_NAMESPACE_STD...@@ -617,4 +646,4 @@ _LIBCPP_END_NAMESPACE_STD
617646
618_LIBCPP_POP_MACROS647_LIBCPP_POP_MACROS
619648
620#endif // _LIBCPP_SPLIT_BUFFER649#endif // _LIBCPP___SPLIT_BUFFER
lib/libcxx/include/__std_stream+1-1
...@@ -17,7 +17,7 @@...@@ -17,7 +17,7 @@
17#include <ostream>17#include <ostream>
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
21#endif21#endif
2222
23_LIBCPP_PUSH_MACROS23_LIBCPP_PUSH_MACROS
lib/libcxx/include/__string deleted-1175
...@@ -1,1175 +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___STRING
11#define _LIBCPP___STRING
12
13#include <__algorithm/copy.h>
14#include <__algorithm/copy_backward.h>
15#include <__algorithm/copy_n.h>
16#include <__algorithm/fill_n.h>
17#include <__algorithm/find_end.h>
18#include <__algorithm/find_first_of.h>
19#include <__algorithm/min.h>
20#include <__config>
21#include <__functional/hash.h> // for __murmur2_or_cityhash
22#include <__iterator/iterator_traits.h>
23#include <cstdint> // for uint_least16_t
24#include <cstdio> // for EOF
25#include <cstring> // for memcpy
26#include <iosfwd> // for streampos & friends
27#include <type_traits> // for __libcpp_is_constant_evaluated
28
29#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
30# include <cwchar> // for wmemcpy
31#endif
32
33#include <__debug>
34
35#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
36#pragma GCC system_header
37#endif
38
39_LIBCPP_PUSH_MACROS
40#include <__undef_macros>
41
42
43_LIBCPP_BEGIN_NAMESPACE_STD
44
45// The extern template ABI lists are kept outside of <string> to improve the
46// readability of that header. We maintain 2 ABI lists:
47// - _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST
48// - _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST
49// As the name implies, the ABI lists define the V1 (Stable) and unstable ABI.
50//
51// For unstable, we may explicitly remove function that are external in V1,
52// and add (new) external functions to better control inlining and compiler
53// optimization opportunities.
54//
55// For stable, the ABI list should rarely change, except for adding new
56// functions supporting new c++ version / API changes. Typically entries
57// must never be removed from the stable list.
58#define _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_Func, _CharType) \
59 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, value_type const*, size_type)) \
60 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::rfind(value_type const*, size_type, size_type) const) \
61 _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(value_type const*, size_type, size_type)) \
62 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&)) \
63 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, value_type const*)) \
64 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&, allocator<_CharType> const&)) \
65 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_last_not_of(value_type const*, size_type, size_type) const) \
66 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::~basic_string()) \
67 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_first_not_of(value_type const*, size_type, size_type) const) \
68 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, size_type, value_type)) \
69 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::operator=(value_type)) \
70 _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(value_type const*, size_type)) \
71 _Func(_LIBCPP_FUNC_VIS const _CharType& basic_string<_CharType>::at(size_type) const) \
72 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, value_type const*, size_type)) \
73 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_first_of(value_type const*, size_type, size_type) const) \
74 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, size_type, value_type)) \
75 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(value_type const*, size_type)) \
76 _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::reserve(size_type)) \
77 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(value_type const*, size_type)) \
78 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(basic_string const&, size_type, size_type)) \
79 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::copy(value_type*, size_type, size_type) const) \
80 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&, size_type, size_type, allocator<_CharType> const&)) \
81 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find(value_type, size_type) const) \
82 _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(size_type, value_type)) \
83 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, value_type const*)) \
84 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_last_of(value_type const*, size_type, size_type) const) \
85 _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__grow_by(size_type, size_type, size_type, size_type, size_type, size_type)) \
86 _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__grow_by_and_replace(size_type, size_type, size_type, size_type, size_type, size_type, value_type const*)) \
87 _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::push_back(value_type)) \
88 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(size_type, value_type)) \
89 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::rfind(value_type, size_type) const) \
90 _Func(_LIBCPP_FUNC_VIS const basic_string<_CharType>::size_type basic_string<_CharType>::npos) \
91 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(size_type, value_type)) \
92 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::erase(size_type, size_type)) \
93 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(basic_string const&, size_type, size_type)) \
94 _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(value_type const*) const) \
95 _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, value_type const*) const) \
96 _Func(_LIBCPP_FUNC_VIS _CharType& basic_string<_CharType>::at(size_type)) \
97 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(value_type const*)) \
98 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find(value_type const*, size_type, size_type) const) \
99 _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, basic_string const&, size_type, size_type) const) \
100 _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, value_type const*, size_type) const) \
101 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::operator=(basic_string const&)) \
102 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(value_type const*)) \
103 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, basic_string const&, size_type, size_type)) \
104 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::iterator basic_string<_CharType>::insert(basic_string::const_iterator, value_type)) \
105 _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::resize(size_type, value_type)) \
106 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, basic_string const&, size_type, size_type))
107
108#define _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_Func, _CharType) \
109 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, value_type const*, size_type)) \
110 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::rfind(value_type const*, size_type, size_type) const) \
111 _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(value_type const*, size_type, size_type)) \
112 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, value_type const*)) \
113 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_last_not_of(value_type const*, size_type, size_type) const) \
114 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::~basic_string()) \
115 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_first_not_of(value_type const*, size_type, size_type) const) \
116 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, size_type, value_type)) \
117 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::operator=(value_type)) \
118 _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(value_type const*, size_type)) \
119 _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init_copy_ctor_external(value_type const*, size_type)) \
120 _Func(_LIBCPP_FUNC_VIS const _CharType& basic_string<_CharType>::at(size_type) const) \
121 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, value_type const*, size_type)) \
122 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_first_of(value_type const*, size_type, size_type) const) \
123 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, size_type, value_type)) \
124 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::__assign_external(value_type const*, size_type)) \
125 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::__assign_external(value_type const*)) \
126 _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::reserve(size_type)) \
127 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(value_type const*, size_type)) \
128 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(basic_string const&, size_type, size_type)) \
129 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::copy(value_type*, size_type, size_type) const) \
130 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&, size_type, size_type, allocator<_CharType> const&)) \
131 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find(value_type, size_type) const) \
132 _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(size_type, value_type)) \
133 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, value_type const*)) \
134 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_last_of(value_type const*, size_type, size_type) const) \
135 _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__grow_by(size_type, size_type, size_type, size_type, size_type, size_type)) \
136 _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__grow_by_and_replace(size_type, size_type, size_type, size_type, size_type, size_type, value_type const*)) \
137 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::__assign_no_alias<false>(value_type const*, size_type)) \
138 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::__assign_no_alias<true>(value_type const*, size_type)) \
139 _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::push_back(value_type)) \
140 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(size_type, value_type)) \
141 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::rfind(value_type, size_type) const) \
142 _Func(_LIBCPP_FUNC_VIS const basic_string<_CharType>::size_type basic_string<_CharType>::npos) \
143 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(size_type, value_type)) \
144 _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__erase_external_with_move(size_type, size_type)) \
145 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(basic_string const&, size_type, size_type)) \
146 _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(value_type const*) const) \
147 _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, value_type const*) const) \
148 _Func(_LIBCPP_FUNC_VIS _CharType& basic_string<_CharType>::at(size_type)) \
149 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find(value_type const*, size_type, size_type) const) \
150 _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, basic_string const&, size_type, size_type) const) \
151 _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, value_type const*, size_type) const) \
152 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(value_type const*)) \
153 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, basic_string const&, size_type, size_type)) \
154 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::iterator basic_string<_CharType>::insert(basic_string::const_iterator, value_type)) \
155 _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::resize(size_type, value_type)) \
156 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, basic_string const&, size_type, size_type))
157
158
159// char_traits
160
161template <class _CharT>
162struct _LIBCPP_TEMPLATE_VIS char_traits
163{
164 typedef _CharT char_type;
165 typedef int int_type;
166 typedef streamoff off_type;
167 typedef streampos pos_type;
168 typedef mbstate_t state_type;
169
170 static inline void _LIBCPP_CONSTEXPR_AFTER_CXX14
171 assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;}
172 static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
173 {return __c1 == __c2;}
174 static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
175 {return __c1 < __c2;}
176
177 static _LIBCPP_CONSTEXPR_AFTER_CXX14
178 int compare(const char_type* __s1, const char_type* __s2, size_t __n);
179 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14
180 size_t length(const char_type* __s);
181 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14
182 const char_type* find(const char_type* __s, size_t __n, const char_type& __a);
183 static _LIBCPP_CONSTEXPR_AFTER_CXX17
184 char_type* move(char_type* __s1, const char_type* __s2, size_t __n);
185 _LIBCPP_INLINE_VISIBILITY
186 static _LIBCPP_CONSTEXPR_AFTER_CXX17
187 char_type* copy(char_type* __s1, const char_type* __s2, size_t __n);
188 _LIBCPP_INLINE_VISIBILITY
189 static _LIBCPP_CONSTEXPR_AFTER_CXX17
190 char_type* assign(char_type* __s, size_t __n, char_type __a);
191
192 static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
193 {return eq_int_type(__c, eof()) ? ~eof() : __c;}
194 static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
195 {return char_type(__c);}
196 static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
197 {return int_type(__c);}
198 static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
199 {return __c1 == __c2;}
200 static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
201 {return int_type(EOF);}
202};
203
204template <class _CharT>
205_LIBCPP_CONSTEXPR_AFTER_CXX14 int
206char_traits<_CharT>::compare(const char_type* __s1, const char_type* __s2, size_t __n)
207{
208 for (; __n; --__n, ++__s1, ++__s2)
209 {
210 if (lt(*__s1, *__s2))
211 return -1;
212 if (lt(*__s2, *__s1))
213 return 1;
214 }
215 return 0;
216}
217
218template <class _CharT>
219inline
220_LIBCPP_CONSTEXPR_AFTER_CXX14 size_t
221char_traits<_CharT>::length(const char_type* __s)
222{
223 size_t __len = 0;
224 for (; !eq(*__s, char_type(0)); ++__s)
225 ++__len;
226 return __len;
227}
228
229template <class _CharT>
230inline
231_LIBCPP_CONSTEXPR_AFTER_CXX14 const _CharT*
232char_traits<_CharT>::find(const char_type* __s, size_t __n, const char_type& __a)
233{
234 for (; __n; --__n)
235 {
236 if (eq(*__s, __a))
237 return __s;
238 ++__s;
239 }
240 return nullptr;
241}
242
243template <class _CharT>
244_LIBCPP_CONSTEXPR_AFTER_CXX17 _CharT*
245char_traits<_CharT>::move(char_type* __s1, const char_type* __s2, size_t __n)
246{
247 if (__n == 0) return __s1;
248 char_type* __r = __s1;
249 if (__s1 < __s2)
250 {
251 for (; __n; --__n, ++__s1, ++__s2)
252 assign(*__s1, *__s2);
253 }
254 else if (__s2 < __s1)
255 {
256 __s1 += __n;
257 __s2 += __n;
258 for (; __n; --__n)
259 assign(*--__s1, *--__s2);
260 }
261 return __r;
262}
263
264template <class _CharT>
265inline _LIBCPP_CONSTEXPR_AFTER_CXX17
266_CharT*
267char_traits<_CharT>::copy(char_type* __s1, const char_type* __s2, size_t __n)
268{
269 if (!__libcpp_is_constant_evaluated()) {
270 _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
271 }
272 char_type* __r = __s1;
273 for (; __n; --__n, ++__s1, ++__s2)
274 assign(*__s1, *__s2);
275 return __r;
276}
277
278template <class _CharT>
279inline _LIBCPP_CONSTEXPR_AFTER_CXX17
280_CharT*
281char_traits<_CharT>::assign(char_type* __s, size_t __n, char_type __a)
282{
283 char_type* __r = __s;
284 for (; __n; --__n, ++__s)
285 assign(*__s, __a);
286 return __r;
287}
288
289// constexpr versions of move/copy/assign.
290
291template <class _CharT>
292static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
293_CharT* __copy_constexpr(_CharT* __dest, const _CharT* __source, size_t __n) _NOEXCEPT
294{
295 _LIBCPP_ASSERT(__libcpp_is_constant_evaluated(), "__copy_constexpr() should always be constant evaluated");
296 _VSTD::copy_n(__source, __n, __dest);
297 return __dest;
298}
299
300template <class _CharT>
301static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
302_CharT* __move_constexpr(_CharT* __dest, const _CharT* __source, size_t __n) _NOEXCEPT
303{
304 _LIBCPP_ASSERT(__libcpp_is_constant_evaluated(), "__move_constexpr() should always be constant evaluated");
305 if (__n == 0)
306 return __dest;
307 _CharT* __allocation = new _CharT[__n];
308 _VSTD::__copy_constexpr(__allocation, __source, __n);
309 _VSTD::__copy_constexpr(__dest, static_cast<const _CharT*>(__allocation), __n);
310 delete[] __allocation;
311 return __dest;
312}
313
314template <class _CharT>
315static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
316_CharT* __assign_constexpr(_CharT* __s, size_t __n, _CharT __a) _NOEXCEPT
317{
318 _LIBCPP_ASSERT(__libcpp_is_constant_evaluated(), "__assign_constexpr() should always be constant evaluated");
319 _VSTD::fill_n(__s, __n, __a);
320 return __s;
321}
322
323// char_traits<char>
324
325template <>
326struct _LIBCPP_TEMPLATE_VIS char_traits<char>
327{
328 typedef char char_type;
329 typedef int int_type;
330 typedef streamoff off_type;
331 typedef streampos pos_type;
332 typedef mbstate_t state_type;
333
334 static inline _LIBCPP_CONSTEXPR_AFTER_CXX14
335 void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;}
336 static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
337 {return __c1 == __c2;}
338 static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
339 {return (unsigned char)__c1 < (unsigned char)__c2;}
340
341 static _LIBCPP_CONSTEXPR_AFTER_CXX14
342 int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
343
344 static inline size_t _LIBCPP_CONSTEXPR_AFTER_CXX14 length(const char_type* __s) _NOEXCEPT {
345 // GCC currently does not support __builtin_strlen during constant evaluation.
346 // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70816
347#ifdef _LIBCPP_COMPILER_GCC
348 if (__libcpp_is_constant_evaluated()) {
349 size_t __i = 0;
350 for (; __s[__i] != char_type('\0'); ++__i)
351 ;
352 return __i;
353 }
354#endif
355 return __builtin_strlen(__s);
356 }
357
358 static _LIBCPP_CONSTEXPR_AFTER_CXX14
359 const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;
360 static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
361 char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
362 {
363 return __libcpp_is_constant_evaluated()
364 ? _VSTD::__move_constexpr(__s1, __s2, __n)
365 : __n == 0 ? __s1 : (char_type*)_VSTD::memmove(__s1, __s2, __n);
366 }
367 static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
368 char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
369 {
370 if (!__libcpp_is_constant_evaluated()) {
371 _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
372 }
373 return __libcpp_is_constant_evaluated()
374 ? _VSTD::__copy_constexpr(__s1, __s2, __n)
375 : __n == 0 ? __s1 : (char_type*)_VSTD::memcpy(__s1, __s2, __n);
376 }
377 static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
378 char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT
379 {
380 return __libcpp_is_constant_evaluated()
381 ? _VSTD::__assign_constexpr(__s, __n, __a)
382 : __n == 0 ? __s : (char_type*)_VSTD::memset(__s, to_int_type(__a), __n);
383 }
384
385 static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
386 {return eq_int_type(__c, eof()) ? ~eof() : __c;}
387 static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
388 {return char_type(__c);}
389 static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
390 {return int_type((unsigned char)__c);}
391 static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
392 {return __c1 == __c2;}
393 static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
394 {return int_type(EOF);}
395};
396
397inline _LIBCPP_CONSTEXPR_AFTER_CXX14
398int
399char_traits<char>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
400{
401 if (__n == 0)
402 return 0;
403#if __has_feature(cxx_constexpr_string_builtins)
404 return __builtin_memcmp(__s1, __s2, __n);
405#elif _LIBCPP_STD_VER <= 14
406 return _VSTD::memcmp(__s1, __s2, __n);
407#else
408 for (; __n; --__n, ++__s1, ++__s2)
409 {
410 if (lt(*__s1, *__s2))
411 return -1;
412 if (lt(*__s2, *__s1))
413 return 1;
414 }
415 return 0;
416#endif
417}
418
419inline _LIBCPP_CONSTEXPR_AFTER_CXX14
420const char*
421char_traits<char>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT
422{
423 if (__n == 0)
424 return nullptr;
425#if __has_feature(cxx_constexpr_string_builtins)
426 return __builtin_char_memchr(__s, to_int_type(__a), __n);
427#elif _LIBCPP_STD_VER <= 14
428 return (const char_type*) _VSTD::memchr(__s, to_int_type(__a), __n);
429#else
430 for (; __n; --__n)
431 {
432 if (eq(*__s, __a))
433 return __s;
434 ++__s;
435 }
436 return nullptr;
437#endif
438}
439
440
441// char_traits<wchar_t>
442
443#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
444template <>
445struct _LIBCPP_TEMPLATE_VIS char_traits<wchar_t>
446{
447 typedef wchar_t char_type;
448 typedef wint_t int_type;
449 typedef streamoff off_type;
450 typedef streampos pos_type;
451 typedef mbstate_t state_type;
452
453 static inline _LIBCPP_CONSTEXPR_AFTER_CXX14
454 void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;}
455 static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
456 {return __c1 == __c2;}
457 static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
458 {return __c1 < __c2;}
459
460 static _LIBCPP_CONSTEXPR_AFTER_CXX14
461 int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
462 static _LIBCPP_CONSTEXPR_AFTER_CXX14
463 size_t length(const char_type* __s) _NOEXCEPT;
464 static _LIBCPP_CONSTEXPR_AFTER_CXX14
465 const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;
466 static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
467 char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
468 {
469 return __libcpp_is_constant_evaluated()
470 ? _VSTD::__move_constexpr(__s1, __s2, __n)
471 : __n == 0 ? __s1 : _VSTD::wmemmove(__s1, __s2, __n);
472 }
473 static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
474 char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
475 {
476 if (!__libcpp_is_constant_evaluated()) {
477 _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
478 }
479 return __libcpp_is_constant_evaluated()
480 ? _VSTD::__copy_constexpr(__s1, __s2, __n)
481 : __n == 0 ? __s1 : _VSTD::wmemcpy(__s1, __s2, __n);
482 }
483 static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
484 char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT
485 {
486 return __libcpp_is_constant_evaluated()
487 ? _VSTD::__assign_constexpr(__s, __n, __a)
488 : __n == 0 ? __s : _VSTD::wmemset(__s, __a, __n);
489 }
490 static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
491 {return eq_int_type(__c, eof()) ? ~eof() : __c;}
492 static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
493 {return char_type(__c);}
494 static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
495 {return int_type(__c);}
496 static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
497 {return __c1 == __c2;}
498 static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
499 {return int_type(WEOF);}
500};
501
502inline _LIBCPP_CONSTEXPR_AFTER_CXX14
503int
504char_traits<wchar_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
505{
506 if (__n == 0)
507 return 0;
508#if __has_feature(cxx_constexpr_string_builtins)
509 return __builtin_wmemcmp(__s1, __s2, __n);
510#elif _LIBCPP_STD_VER <= 14
511 return _VSTD::wmemcmp(__s1, __s2, __n);
512#else
513 for (; __n; --__n, ++__s1, ++__s2)
514 {
515 if (lt(*__s1, *__s2))
516 return -1;
517 if (lt(*__s2, *__s1))
518 return 1;
519 }
520 return 0;
521#endif
522}
523
524inline _LIBCPP_CONSTEXPR_AFTER_CXX14
525size_t
526char_traits<wchar_t>::length(const char_type* __s) _NOEXCEPT
527{
528#if __has_feature(cxx_constexpr_string_builtins)
529 return __builtin_wcslen(__s);
530#elif _LIBCPP_STD_VER <= 14
531 return _VSTD::wcslen(__s);
532#else
533 size_t __len = 0;
534 for (; !eq(*__s, char_type(0)); ++__s)
535 ++__len;
536 return __len;
537#endif
538}
539
540inline _LIBCPP_CONSTEXPR_AFTER_CXX14
541const wchar_t*
542char_traits<wchar_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT
543{
544 if (__n == 0)
545 return nullptr;
546#if __has_feature(cxx_constexpr_string_builtins)
547 return __builtin_wmemchr(__s, __a, __n);
548#elif _LIBCPP_STD_VER <= 14
549 return _VSTD::wmemchr(__s, __a, __n);
550#else
551 for (; __n; --__n)
552 {
553 if (eq(*__s, __a))
554 return __s;
555 ++__s;
556 }
557 return nullptr;
558#endif
559}
560#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
561
562template <class _Traits>
563_LIBCPP_INLINE_VISIBILITY
564_LIBCPP_CONSTEXPR
565inline size_t __char_traits_length_checked(const typename _Traits::char_type* __s) _NOEXCEPT {
566#if _LIBCPP_DEBUG_LEVEL >= 1
567 return __s ? _Traits::length(__s) : (_VSTD::__libcpp_debug_function(_VSTD::__libcpp_debug_info(__FILE__, __LINE__, "p == nullptr", "null pointer pass to non-null argument of char_traits<...>::length")), 0);
568#else
569 return _Traits::length(__s);
570#endif
571}
572
573#ifndef _LIBCPP_HAS_NO_CHAR8_T
574
575template <>
576struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t>
577{
578 typedef char8_t char_type;
579 typedef unsigned int int_type;
580 typedef streamoff off_type;
581 typedef u8streampos pos_type;
582 typedef mbstate_t state_type;
583
584 static inline constexpr void assign(char_type& __c1, const char_type& __c2) noexcept
585 {__c1 = __c2;}
586 static inline constexpr bool eq(char_type __c1, char_type __c2) noexcept
587 {return __c1 == __c2;}
588 static inline constexpr bool lt(char_type __c1, char_type __c2) noexcept
589 {return __c1 < __c2;}
590
591 static constexpr
592 int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
593
594 static constexpr
595 size_t length(const char_type* __s) _NOEXCEPT;
596
597 _LIBCPP_INLINE_VISIBILITY static constexpr
598 const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;
599
600 static _LIBCPP_CONSTEXPR_AFTER_CXX17
601 char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
602 {
603 return __libcpp_is_constant_evaluated()
604 ? _VSTD::__move_constexpr(__s1, __s2, __n)
605 : __n == 0 ? __s1 : (char_type*)_VSTD::memmove(__s1, __s2, __n);
606 }
607
608 static _LIBCPP_CONSTEXPR_AFTER_CXX17
609 char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
610 {
611 if (!__libcpp_is_constant_evaluated()) {
612 _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
613 }
614 return __libcpp_is_constant_evaluated()
615 ? _VSTD::__copy_constexpr(__s1, __s2, __n)
616 : __n == 0 ? __s1 : (char_type*)_VSTD::memcpy(__s1, __s2, __n);
617 }
618
619 static _LIBCPP_CONSTEXPR_AFTER_CXX17
620 char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT
621 {
622 return __libcpp_is_constant_evaluated()
623 ? _VSTD::__assign_constexpr(__s, __n, __a)
624 : __n == 0 ? __s : (char_type*)_VSTD::memset(__s, to_int_type(__a), __n);
625 }
626
627 static inline constexpr int_type not_eof(int_type __c) noexcept
628 {return eq_int_type(__c, eof()) ? ~eof() : __c;}
629 static inline constexpr char_type to_char_type(int_type __c) noexcept
630 {return char_type(__c);}
631 static inline constexpr int_type to_int_type(char_type __c) noexcept
632 {return int_type(__c);}
633 static inline constexpr bool eq_int_type(int_type __c1, int_type __c2) noexcept
634 {return __c1 == __c2;}
635 static inline constexpr int_type eof() noexcept
636 {return int_type(EOF);}
637};
638
639// TODO use '__builtin_strlen' if it ever supports char8_t ??
640inline constexpr
641size_t
642char_traits<char8_t>::length(const char_type* __s) _NOEXCEPT
643{
644 size_t __len = 0;
645 for (; !eq(*__s, char_type(0)); ++__s)
646 ++__len;
647 return __len;
648}
649
650inline constexpr
651int
652char_traits<char8_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
653{
654#if __has_feature(cxx_constexpr_string_builtins)
655 return __builtin_memcmp(__s1, __s2, __n);
656#else
657 for (; __n; --__n, ++__s1, ++__s2)
658 {
659 if (lt(*__s1, *__s2))
660 return -1;
661 if (lt(*__s2, *__s1))
662 return 1;
663 }
664 return 0;
665#endif
666}
667
668// TODO use '__builtin_char_memchr' if it ever supports char8_t ??
669inline constexpr
670const char8_t*
671char_traits<char8_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT
672{
673 for (; __n; --__n)
674 {
675 if (eq(*__s, __a))
676 return __s;
677 ++__s;
678 }
679 return nullptr;
680}
681
682#endif // #_LIBCPP_HAS_NO_CHAR8_T
683
684#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
685
686template <>
687struct _LIBCPP_TEMPLATE_VIS char_traits<char16_t>
688{
689 typedef char16_t char_type;
690 typedef uint_least16_t int_type;
691 typedef streamoff off_type;
692 typedef u16streampos pos_type;
693 typedef mbstate_t state_type;
694
695 static inline _LIBCPP_CONSTEXPR_AFTER_CXX14
696 void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;}
697 static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
698 {return __c1 == __c2;}
699 static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
700 {return __c1 < __c2;}
701
702 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14
703 int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
704 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14
705 size_t length(const char_type* __s) _NOEXCEPT;
706 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14
707 const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;
708 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
709 static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
710 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
711 static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
712 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
713 static char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT;
714
715 static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
716 {return eq_int_type(__c, eof()) ? ~eof() : __c;}
717 static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
718 {return char_type(__c);}
719 static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
720 {return int_type(__c);}
721 static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
722 {return __c1 == __c2;}
723 static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
724 {return int_type(0xFFFF);}
725};
726
727inline _LIBCPP_CONSTEXPR_AFTER_CXX14
728int
729char_traits<char16_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
730{
731 for (; __n; --__n, ++__s1, ++__s2)
732 {
733 if (lt(*__s1, *__s2))
734 return -1;
735 if (lt(*__s2, *__s1))
736 return 1;
737 }
738 return 0;
739}
740
741inline _LIBCPP_CONSTEXPR_AFTER_CXX14
742size_t
743char_traits<char16_t>::length(const char_type* __s) _NOEXCEPT
744{
745 size_t __len = 0;
746 for (; !eq(*__s, char_type(0)); ++__s)
747 ++__len;
748 return __len;
749}
750
751inline _LIBCPP_CONSTEXPR_AFTER_CXX14
752const char16_t*
753char_traits<char16_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT
754{
755 for (; __n; --__n)
756 {
757 if (eq(*__s, __a))
758 return __s;
759 ++__s;
760 }
761 return nullptr;
762}
763
764inline _LIBCPP_CONSTEXPR_AFTER_CXX17
765char16_t*
766char_traits<char16_t>::move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
767{
768 if (__n == 0) return __s1;
769 char_type* __r = __s1;
770 if (__s1 < __s2)
771 {
772 for (; __n; --__n, ++__s1, ++__s2)
773 assign(*__s1, *__s2);
774 }
775 else if (__s2 < __s1)
776 {
777 __s1 += __n;
778 __s2 += __n;
779 for (; __n; --__n)
780 assign(*--__s1, *--__s2);
781 }
782 return __r;
783}
784
785inline _LIBCPP_CONSTEXPR_AFTER_CXX17
786char16_t*
787char_traits<char16_t>::copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
788{
789 if (!__libcpp_is_constant_evaluated()) {
790 _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
791 }
792 char_type* __r = __s1;
793 for (; __n; --__n, ++__s1, ++__s2)
794 assign(*__s1, *__s2);
795 return __r;
796}
797
798inline _LIBCPP_CONSTEXPR_AFTER_CXX17
799char16_t*
800char_traits<char16_t>::assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT
801{
802 char_type* __r = __s;
803 for (; __n; --__n, ++__s)
804 assign(*__s, __a);
805 return __r;
806}
807
808template <>
809struct _LIBCPP_TEMPLATE_VIS char_traits<char32_t>
810{
811 typedef char32_t char_type;
812 typedef uint_least32_t int_type;
813 typedef streamoff off_type;
814 typedef u32streampos pos_type;
815 typedef mbstate_t state_type;
816
817 static inline _LIBCPP_CONSTEXPR_AFTER_CXX14
818 void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;}
819 static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
820 {return __c1 == __c2;}
821 static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
822 {return __c1 < __c2;}
823
824 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14
825 int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
826 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14
827 size_t length(const char_type* __s) _NOEXCEPT;
828 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14
829 const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;
830 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
831 static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
832 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
833 static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
834 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
835 static char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT;
836
837 static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
838 {return eq_int_type(__c, eof()) ? ~eof() : __c;}
839 static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
840 {return char_type(__c);}
841 static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
842 {return int_type(__c);}
843 static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
844 {return __c1 == __c2;}
845 static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
846 {return int_type(0xFFFFFFFF);}
847};
848
849inline _LIBCPP_CONSTEXPR_AFTER_CXX14
850int
851char_traits<char32_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
852{
853 for (; __n; --__n, ++__s1, ++__s2)
854 {
855 if (lt(*__s1, *__s2))
856 return -1;
857 if (lt(*__s2, *__s1))
858 return 1;
859 }
860 return 0;
861}
862
863inline _LIBCPP_CONSTEXPR_AFTER_CXX14
864size_t
865char_traits<char32_t>::length(const char_type* __s) _NOEXCEPT
866{
867 size_t __len = 0;
868 for (; !eq(*__s, char_type(0)); ++__s)
869 ++__len;
870 return __len;
871}
872
873inline _LIBCPP_CONSTEXPR_AFTER_CXX14
874const char32_t*
875char_traits<char32_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT
876{
877 for (; __n; --__n)
878 {
879 if (eq(*__s, __a))
880 return __s;
881 ++__s;
882 }
883 return nullptr;
884}
885
886inline _LIBCPP_CONSTEXPR_AFTER_CXX17
887char32_t*
888char_traits<char32_t>::move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
889{
890 if (__n == 0) return __s1;
891 char_type* __r = __s1;
892 if (__s1 < __s2)
893 {
894 for (; __n; --__n, ++__s1, ++__s2)
895 assign(*__s1, *__s2);
896 }
897 else if (__s2 < __s1)
898 {
899 __s1 += __n;
900 __s2 += __n;
901 for (; __n; --__n)
902 assign(*--__s1, *--__s2);
903 }
904 return __r;
905}
906
907inline _LIBCPP_CONSTEXPR_AFTER_CXX17
908char32_t*
909char_traits<char32_t>::copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
910{
911 if (!__libcpp_is_constant_evaluated()) {
912 _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
913 }
914 char_type* __r = __s1;
915 for (; __n; --__n, ++__s1, ++__s2)
916 assign(*__s1, *__s2);
917 return __r;
918}
919
920inline _LIBCPP_CONSTEXPR_AFTER_CXX17
921char32_t*
922char_traits<char32_t>::assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT
923{
924 char_type* __r = __s;
925 for (; __n; --__n, ++__s)
926 assign(*__s, __a);
927 return __r;
928}
929
930#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
931
932// helper fns for basic_string and string_view
933
934// __str_find
935template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
936inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
937__str_find(const _CharT *__p, _SizeT __sz,
938 _CharT __c, _SizeT __pos) _NOEXCEPT
939{
940 if (__pos >= __sz)
941 return __npos;
942 const _CharT* __r = _Traits::find(__p + __pos, __sz - __pos, __c);
943 if (__r == nullptr)
944 return __npos;
945 return static_cast<_SizeT>(__r - __p);
946}
947
948template <class _CharT, class _Traits>
949inline _LIBCPP_CONSTEXPR_AFTER_CXX11 const _CharT *
950__search_substring(const _CharT *__first1, const _CharT *__last1,
951 const _CharT *__first2, const _CharT *__last2) _NOEXCEPT {
952 // Take advantage of knowing source and pattern lengths.
953 // Stop short when source is smaller than pattern.
954 const ptrdiff_t __len2 = __last2 - __first2;
955 if (__len2 == 0)
956 return __first1;
957
958 ptrdiff_t __len1 = __last1 - __first1;
959 if (__len1 < __len2)
960 return __last1;
961
962 // First element of __first2 is loop invariant.
963 _CharT __f2 = *__first2;
964 while (true) {
965 __len1 = __last1 - __first1;
966 // Check whether __first1 still has at least __len2 bytes.
967 if (__len1 < __len2)
968 return __last1;
969
970 // Find __f2 the first byte matching in __first1.
971 __first1 = _Traits::find(__first1, __len1 - __len2 + 1, __f2);
972 if (__first1 == nullptr)
973 return __last1;
974
975 // It is faster to compare from the first byte of __first1 even if we
976 // already know that it matches the first byte of __first2: this is because
977 // __first2 is most likely aligned, as it is user's "pattern" string, and
978 // __first1 + 1 is most likely not aligned, as the match is in the middle of
979 // the string.
980 if (_Traits::compare(__first1, __first2, __len2) == 0)
981 return __first1;
982
983 ++__first1;
984 }
985}
986
987template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
988inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
989__str_find(const _CharT *__p, _SizeT __sz,
990 const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
991{
992 if (__pos > __sz)
993 return __npos;
994
995 if (__n == 0) // There is nothing to search, just return __pos.
996 return __pos;
997
998 const _CharT *__r = __search_substring<_CharT, _Traits>(
999 __p + __pos, __p + __sz, __s, __s + __n);
1000
1001 if (__r == __p + __sz)
1002 return __npos;
1003 return static_cast<_SizeT>(__r - __p);
1004}
1005
1006
1007// __str_rfind
1008
1009template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
1010inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
1011__str_rfind(const _CharT *__p, _SizeT __sz,
1012 _CharT __c, _SizeT __pos) _NOEXCEPT
1013{
1014 if (__sz < 1)
1015 return __npos;
1016 if (__pos < __sz)
1017 ++__pos;
1018 else
1019 __pos = __sz;
1020 for (const _CharT* __ps = __p + __pos; __ps != __p;)
1021 {
1022 if (_Traits::eq(*--__ps, __c))
1023 return static_cast<_SizeT>(__ps - __p);
1024 }
1025 return __npos;
1026}
1027
1028template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
1029inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
1030__str_rfind(const _CharT *__p, _SizeT __sz,
1031 const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
1032{
1033 __pos = _VSTD::min(__pos, __sz);
1034 if (__n < __sz - __pos)
1035 __pos += __n;
1036 else
1037 __pos = __sz;
1038 const _CharT* __r = _VSTD::__find_end(
1039 __p, __p + __pos, __s, __s + __n, _Traits::eq,
1040 random_access_iterator_tag(), random_access_iterator_tag());
1041 if (__n > 0 && __r == __p + __pos)
1042 return __npos;
1043 return static_cast<_SizeT>(__r - __p);
1044}
1045
1046// __str_find_first_of
1047template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
1048inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
1049__str_find_first_of(const _CharT *__p, _SizeT __sz,
1050 const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
1051{
1052 if (__pos >= __sz || __n == 0)
1053 return __npos;
1054 const _CharT* __r = _VSTD::__find_first_of_ce
1055 (__p + __pos, __p + __sz, __s, __s + __n, _Traits::eq );
1056 if (__r == __p + __sz)
1057 return __npos;
1058 return static_cast<_SizeT>(__r - __p);
1059}
1060
1061
1062// __str_find_last_of
1063template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
1064inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
1065__str_find_last_of(const _CharT *__p, _SizeT __sz,
1066 const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
1067 {
1068 if (__n != 0)
1069 {
1070 if (__pos < __sz)
1071 ++__pos;
1072 else
1073 __pos = __sz;
1074 for (const _CharT* __ps = __p + __pos; __ps != __p;)
1075 {
1076 const _CharT* __r = _Traits::find(__s, __n, *--__ps);
1077 if (__r)
1078 return static_cast<_SizeT>(__ps - __p);
1079 }
1080 }
1081 return __npos;
1082}
1083
1084
1085// __str_find_first_not_of
1086template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
1087inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
1088__str_find_first_not_of(const _CharT *__p, _SizeT __sz,
1089 const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
1090{
1091 if (__pos < __sz)
1092 {
1093 const _CharT* __pe = __p + __sz;
1094 for (const _CharT* __ps = __p + __pos; __ps != __pe; ++__ps)
1095 if (_Traits::find(__s, __n, *__ps) == nullptr)
1096 return static_cast<_SizeT>(__ps - __p);
1097 }
1098 return __npos;
1099}
1100
1101
1102template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
1103inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
1104__str_find_first_not_of(const _CharT *__p, _SizeT __sz,
1105 _CharT __c, _SizeT __pos) _NOEXCEPT
1106{
1107 if (__pos < __sz)
1108 {
1109 const _CharT* __pe = __p + __sz;
1110 for (const _CharT* __ps = __p + __pos; __ps != __pe; ++__ps)
1111 if (!_Traits::eq(*__ps, __c))
1112 return static_cast<_SizeT>(__ps - __p);
1113 }
1114 return __npos;
1115}
1116
1117
1118// __str_find_last_not_of
1119template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
1120inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
1121__str_find_last_not_of(const _CharT *__p, _SizeT __sz,
1122 const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
1123{
1124 if (__pos < __sz)
1125 ++__pos;
1126 else
1127 __pos = __sz;
1128 for (const _CharT* __ps = __p + __pos; __ps != __p;)
1129 if (_Traits::find(__s, __n, *--__ps) == nullptr)
1130 return static_cast<_SizeT>(__ps - __p);
1131 return __npos;
1132}
1133
1134
1135template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
1136inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
1137__str_find_last_not_of(const _CharT *__p, _SizeT __sz,
1138 _CharT __c, _SizeT __pos) _NOEXCEPT
1139{
1140 if (__pos < __sz)
1141 ++__pos;
1142 else
1143 __pos = __sz;
1144 for (const _CharT* __ps = __p + __pos; __ps != __p;)
1145 if (!_Traits::eq(*--__ps, __c))
1146 return static_cast<_SizeT>(__ps - __p);
1147 return __npos;
1148}
1149
1150template<class _Ptr>
1151inline _LIBCPP_INLINE_VISIBILITY
1152size_t __do_string_hash(_Ptr __p, _Ptr __e)
1153{
1154 typedef typename iterator_traits<_Ptr>::value_type value_type;
1155 return __murmur2_or_cityhash<size_t>()(__p, (__e-__p)*sizeof(value_type));
1156}
1157
1158template <class _CharT, class _Iter, class _Traits=char_traits<_CharT> >
1159struct __quoted_output_proxy
1160{
1161 _Iter __first;
1162 _Iter __last;
1163 _CharT __delim;
1164 _CharT __escape;
1165
1166 __quoted_output_proxy(_Iter __f, _Iter __l, _CharT __d, _CharT __e)
1167 : __first(__f), __last(__l), __delim(__d), __escape(__e) {}
1168 // This would be a nice place for a string_ref
1169};
1170
1171_LIBCPP_END_NAMESPACE_STD
1172
1173_LIBCPP_POP_MACROS
1174
1175#endif // _LIBCPP___STRING
lib/libcxx/include/__string/char_traits.h created+927
...@@ -0,0 +1,927 @@
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___STRING_CHAR_TRAITS_H
10#define _LIBCPP___STRING_CHAR_TRAITS_H
11
12#include <__algorithm/copy_n.h>
13#include <__algorithm/fill_n.h>
14#include <__algorithm/find_end.h>
15#include <__algorithm/find_first_of.h>
16#include <__algorithm/min.h>
17#include <__config>
18#include <__functional/hash.h>
19#include <__iterator/iterator_traits.h>
20#include <cstdint>
21#include <cstdio>
22#include <cstring>
23#include <iosfwd>
24#include <type_traits>
25
26#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
27# include <cwchar> // for wmemcpy
28#endif
29
30#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
31# pragma GCC system_header
32#endif
33
34_LIBCPP_PUSH_MACROS
35#include <__undef_macros>
36
37_LIBCPP_BEGIN_NAMESPACE_STD
38
39template <class _CharT>
40struct _LIBCPP_TEMPLATE_VIS char_traits
41{
42 typedef _CharT char_type;
43 typedef int int_type;
44 typedef streamoff off_type;
45 typedef streampos pos_type;
46 typedef mbstate_t state_type;
47
48 static inline void _LIBCPP_CONSTEXPR_AFTER_CXX14
49 assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;}
50 static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
51 {return __c1 == __c2;}
52 static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
53 {return __c1 < __c2;}
54
55 static _LIBCPP_CONSTEXPR_AFTER_CXX14
56 int compare(const char_type* __s1, const char_type* __s2, size_t __n);
57 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14
58 size_t length(const char_type* __s);
59 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14
60 const char_type* find(const char_type* __s, size_t __n, const char_type& __a);
61 static _LIBCPP_CONSTEXPR_AFTER_CXX17
62 char_type* move(char_type* __s1, const char_type* __s2, size_t __n);
63 _LIBCPP_INLINE_VISIBILITY
64 static _LIBCPP_CONSTEXPR_AFTER_CXX17
65 char_type* copy(char_type* __s1, const char_type* __s2, size_t __n);
66 _LIBCPP_INLINE_VISIBILITY
67 static _LIBCPP_CONSTEXPR_AFTER_CXX17
68 char_type* assign(char_type* __s, size_t __n, char_type __a);
69
70 static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
71 {return eq_int_type(__c, eof()) ? ~eof() : __c;}
72 static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
73 {return char_type(__c);}
74 static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
75 {return int_type(__c);}
76 static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
77 {return __c1 == __c2;}
78 static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
79 {return int_type(EOF);}
80};
81
82template <class _CharT>
83_LIBCPP_CONSTEXPR_AFTER_CXX14 int
84char_traits<_CharT>::compare(const char_type* __s1, const char_type* __s2, size_t __n)
85{
86 for (; __n; --__n, ++__s1, ++__s2)
87 {
88 if (lt(*__s1, *__s2))
89 return -1;
90 if (lt(*__s2, *__s1))
91 return 1;
92 }
93 return 0;
94}
95
96template <class _CharT>
97inline
98_LIBCPP_CONSTEXPR_AFTER_CXX14 size_t
99char_traits<_CharT>::length(const char_type* __s)
100{
101 size_t __len = 0;
102 for (; !eq(*__s, char_type(0)); ++__s)
103 ++__len;
104 return __len;
105}
106
107template <class _CharT>
108inline
109_LIBCPP_CONSTEXPR_AFTER_CXX14 const _CharT*
110char_traits<_CharT>::find(const char_type* __s, size_t __n, const char_type& __a)
111{
112 for (; __n; --__n)
113 {
114 if (eq(*__s, __a))
115 return __s;
116 ++__s;
117 }
118 return nullptr;
119}
120
121template <class _CharT>
122_LIBCPP_CONSTEXPR_AFTER_CXX17 _CharT*
123char_traits<_CharT>::move(char_type* __s1, const char_type* __s2, size_t __n)
124{
125 if (__n == 0) return __s1;
126 char_type* __r = __s1;
127 if (__s1 < __s2)
128 {
129 for (; __n; --__n, ++__s1, ++__s2)
130 assign(*__s1, *__s2);
131 }
132 else if (__s2 < __s1)
133 {
134 __s1 += __n;
135 __s2 += __n;
136 for (; __n; --__n)
137 assign(*--__s1, *--__s2);
138 }
139 return __r;
140}
141
142template <class _CharT>
143inline _LIBCPP_CONSTEXPR_AFTER_CXX17
144_CharT*
145char_traits<_CharT>::copy(char_type* __s1, const char_type* __s2, size_t __n)
146{
147 if (!__libcpp_is_constant_evaluated()) {
148 _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
149 }
150 char_type* __r = __s1;
151 for (; __n; --__n, ++__s1, ++__s2)
152 assign(*__s1, *__s2);
153 return __r;
154}
155
156template <class _CharT>
157inline _LIBCPP_CONSTEXPR_AFTER_CXX17
158_CharT*
159char_traits<_CharT>::assign(char_type* __s, size_t __n, char_type __a)
160{
161 char_type* __r = __s;
162 for (; __n; --__n, ++__s)
163 assign(*__s, __a);
164 return __r;
165}
166
167template <class _CharT>
168static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
169_CharT* __char_traits_move(_CharT* __dest, const _CharT* __source, size_t __n) _NOEXCEPT
170{
171#ifdef _LIBCPP_COMPILER_GCC
172 if (__libcpp_is_constant_evaluated()) {
173 if (__n == 0)
174 return __dest;
175 _CharT* __allocation = new _CharT[__n];
176 std::copy_n(__source, __n, __allocation);
177 std::copy_n(static_cast<const _CharT*>(__allocation), __n, __dest);
178 delete[] __allocation;
179 return __dest;
180 }
181#endif
182 ::__builtin_memmove(__dest, __source, __n * sizeof(_CharT));
183 return __dest;
184}
185
186// char_traits<char>
187
188template <>
189struct _LIBCPP_TEMPLATE_VIS char_traits<char>
190{
191 typedef char char_type;
192 typedef int int_type;
193 typedef streamoff off_type;
194 typedef streampos pos_type;
195 typedef mbstate_t state_type;
196
197 static inline _LIBCPP_CONSTEXPR_AFTER_CXX14
198 void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;}
199 static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
200 {return __c1 == __c2;}
201 static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
202 {return (unsigned char)__c1 < (unsigned char)__c2;}
203
204 static _LIBCPP_CONSTEXPR_AFTER_CXX14
205 int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
206
207 static inline size_t _LIBCPP_CONSTEXPR_AFTER_CXX14 length(const char_type* __s) _NOEXCEPT {
208 // GCC currently does not support __builtin_strlen during constant evaluation.
209 // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70816
210#ifdef _LIBCPP_COMPILER_GCC
211 if (__libcpp_is_constant_evaluated()) {
212 size_t __i = 0;
213 for (; __s[__i] != char_type('\0'); ++__i)
214 ;
215 return __i;
216 }
217#endif
218 return __builtin_strlen(__s);
219 }
220
221 static _LIBCPP_CONSTEXPR_AFTER_CXX14
222 const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;
223
224 static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
225 char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
226 return std::__char_traits_move(__s1, __s2, __n);
227 }
228
229 static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
230 char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
231 if (!__libcpp_is_constant_evaluated())
232 _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
233 std::copy_n(__s2, __n, __s1);
234 return __s1;
235 }
236
237 static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
238 char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT {
239 std::fill_n(__s, __n, __a);
240 return __s;
241 }
242
243 static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
244 {return eq_int_type(__c, eof()) ? ~eof() : __c;}
245 static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
246 {return char_type(__c);}
247 static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
248 {return int_type((unsigned char)__c);}
249 static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
250 {return __c1 == __c2;}
251 static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
252 {return int_type(EOF);}
253};
254
255inline _LIBCPP_CONSTEXPR_AFTER_CXX14
256int
257char_traits<char>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
258{
259 if (__n == 0)
260 return 0;
261#if __has_feature(cxx_constexpr_string_builtins)
262 return __builtin_memcmp(__s1, __s2, __n);
263#elif _LIBCPP_STD_VER <= 14
264 return _VSTD::memcmp(__s1, __s2, __n);
265#else
266 for (; __n; --__n, ++__s1, ++__s2)
267 {
268 if (lt(*__s1, *__s2))
269 return -1;
270 if (lt(*__s2, *__s1))
271 return 1;
272 }
273 return 0;
274#endif
275}
276
277inline _LIBCPP_CONSTEXPR_AFTER_CXX14
278const char*
279char_traits<char>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT
280{
281 if (__n == 0)
282 return nullptr;
283#if __has_feature(cxx_constexpr_string_builtins)
284 return __builtin_char_memchr(__s, to_int_type(__a), __n);
285#elif _LIBCPP_STD_VER <= 14
286 return (const char_type*) _VSTD::memchr(__s, to_int_type(__a), __n);
287#else
288 for (; __n; --__n)
289 {
290 if (eq(*__s, __a))
291 return __s;
292 ++__s;
293 }
294 return nullptr;
295#endif
296}
297
298
299// char_traits<wchar_t>
300
301#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
302template <>
303struct _LIBCPP_TEMPLATE_VIS char_traits<wchar_t>
304{
305 typedef wchar_t char_type;
306 typedef wint_t int_type;
307 typedef streamoff off_type;
308 typedef streampos pos_type;
309 typedef mbstate_t state_type;
310
311 static inline _LIBCPP_CONSTEXPR_AFTER_CXX14
312 void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;}
313 static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
314 {return __c1 == __c2;}
315 static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
316 {return __c1 < __c2;}
317
318 static _LIBCPP_CONSTEXPR_AFTER_CXX14
319 int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
320 static _LIBCPP_CONSTEXPR_AFTER_CXX14
321 size_t length(const char_type* __s) _NOEXCEPT;
322 static _LIBCPP_CONSTEXPR_AFTER_CXX14
323 const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;
324
325 static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
326 char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
327 return std::__char_traits_move(__s1, __s2, __n);
328 }
329
330 static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
331 char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
332 if (!__libcpp_is_constant_evaluated())
333 _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
334 std::copy_n(__s2, __n, __s1);
335 return __s1;
336 }
337
338 static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
339 char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT {
340 std::fill_n(__s, __n, __a);
341 return __s;
342 }
343
344 static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
345 {return eq_int_type(__c, eof()) ? ~eof() : __c;}
346 static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
347 {return char_type(__c);}
348 static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
349 {return int_type(__c);}
350 static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
351 {return __c1 == __c2;}
352 static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
353 {return int_type(WEOF);}
354};
355
356inline _LIBCPP_CONSTEXPR_AFTER_CXX14
357int
358char_traits<wchar_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
359{
360 if (__n == 0)
361 return 0;
362#if __has_feature(cxx_constexpr_string_builtins)
363 return __builtin_wmemcmp(__s1, __s2, __n);
364#elif _LIBCPP_STD_VER <= 14
365 return _VSTD::wmemcmp(__s1, __s2, __n);
366#else
367 for (; __n; --__n, ++__s1, ++__s2)
368 {
369 if (lt(*__s1, *__s2))
370 return -1;
371 if (lt(*__s2, *__s1))
372 return 1;
373 }
374 return 0;
375#endif
376}
377
378inline _LIBCPP_CONSTEXPR_AFTER_CXX14
379size_t
380char_traits<wchar_t>::length(const char_type* __s) _NOEXCEPT
381{
382#if __has_feature(cxx_constexpr_string_builtins)
383 return __builtin_wcslen(__s);
384#elif _LIBCPP_STD_VER <= 14
385 return _VSTD::wcslen(__s);
386#else
387 size_t __len = 0;
388 for (; !eq(*__s, char_type(0)); ++__s)
389 ++__len;
390 return __len;
391#endif
392}
393
394inline _LIBCPP_CONSTEXPR_AFTER_CXX14
395const wchar_t*
396char_traits<wchar_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT
397{
398 if (__n == 0)
399 return nullptr;
400#if __has_feature(cxx_constexpr_string_builtins)
401 return __builtin_wmemchr(__s, __a, __n);
402#elif _LIBCPP_STD_VER <= 14
403 return _VSTD::wmemchr(__s, __a, __n);
404#else
405 for (; __n; --__n)
406 {
407 if (eq(*__s, __a))
408 return __s;
409 ++__s;
410 }
411 return nullptr;
412#endif
413}
414#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
415
416#ifndef _LIBCPP_HAS_NO_CHAR8_T
417
418template <>
419struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t>
420{
421 typedef char8_t char_type;
422 typedef unsigned int int_type;
423 typedef streamoff off_type;
424 typedef u8streampos pos_type;
425 typedef mbstate_t state_type;
426
427 static inline constexpr void assign(char_type& __c1, const char_type& __c2) noexcept
428 {__c1 = __c2;}
429 static inline constexpr bool eq(char_type __c1, char_type __c2) noexcept
430 {return __c1 == __c2;}
431 static inline constexpr bool lt(char_type __c1, char_type __c2) noexcept
432 {return __c1 < __c2;}
433
434 static constexpr
435 int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
436
437 static constexpr
438 size_t length(const char_type* __s) _NOEXCEPT;
439
440 _LIBCPP_INLINE_VISIBILITY static constexpr
441 const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;
442
443 static _LIBCPP_CONSTEXPR_AFTER_CXX17
444 char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
445 return std::__char_traits_move(__s1, __s2, __n);
446 }
447
448 static _LIBCPP_CONSTEXPR_AFTER_CXX17
449 char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
450 if (!__libcpp_is_constant_evaluated())
451 _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
452 std::copy_n(__s2, __n, __s1);
453 return __s1;
454 }
455
456 static _LIBCPP_CONSTEXPR_AFTER_CXX17
457 char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT {
458 std::fill_n(__s, __n, __a);
459 return __s;
460 }
461
462 static inline constexpr int_type not_eof(int_type __c) noexcept
463 {return eq_int_type(__c, eof()) ? ~eof() : __c;}
464 static inline constexpr char_type to_char_type(int_type __c) noexcept
465 {return char_type(__c);}
466 static inline constexpr int_type to_int_type(char_type __c) noexcept
467 {return int_type(__c);}
468 static inline constexpr bool eq_int_type(int_type __c1, int_type __c2) noexcept
469 {return __c1 == __c2;}
470 static inline constexpr int_type eof() noexcept
471 {return int_type(EOF);}
472};
473
474// TODO use '__builtin_strlen' if it ever supports char8_t ??
475inline constexpr
476size_t
477char_traits<char8_t>::length(const char_type* __s) _NOEXCEPT
478{
479 size_t __len = 0;
480 for (; !eq(*__s, char_type(0)); ++__s)
481 ++__len;
482 return __len;
483}
484
485inline constexpr
486int
487char_traits<char8_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
488{
489#if __has_feature(cxx_constexpr_string_builtins)
490 return __builtin_memcmp(__s1, __s2, __n);
491#else
492 for (; __n; --__n, ++__s1, ++__s2)
493 {
494 if (lt(*__s1, *__s2))
495 return -1;
496 if (lt(*__s2, *__s1))
497 return 1;
498 }
499 return 0;
500#endif
501}
502
503// TODO use '__builtin_char_memchr' if it ever supports char8_t ??
504inline constexpr
505const char8_t*
506char_traits<char8_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT
507{
508 for (; __n; --__n)
509 {
510 if (eq(*__s, __a))
511 return __s;
512 ++__s;
513 }
514 return nullptr;
515}
516
517#endif // _LIBCPP_HAS_NO_CHAR8_T
518
519template <>
520struct _LIBCPP_TEMPLATE_VIS char_traits<char16_t>
521{
522 typedef char16_t char_type;
523 typedef uint_least16_t int_type;
524 typedef streamoff off_type;
525 typedef u16streampos pos_type;
526 typedef mbstate_t state_type;
527
528 static inline _LIBCPP_CONSTEXPR_AFTER_CXX14
529 void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;}
530 static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
531 {return __c1 == __c2;}
532 static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
533 {return __c1 < __c2;}
534
535 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14
536 int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
537 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14
538 size_t length(const char_type* __s) _NOEXCEPT;
539 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14
540 const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;
541
542 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
543 static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
544 return std::__char_traits_move(__s1, __s2, __n);
545 }
546
547 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
548 static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
549 if (!__libcpp_is_constant_evaluated())
550 _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
551 std::copy_n(__s2, __n, __s1);
552 return __s1;
553 }
554
555 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
556 static char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT {
557 std::fill_n(__s, __n, __a);
558 return __s;
559 }
560
561 static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
562 {return eq_int_type(__c, eof()) ? ~eof() : __c;}
563 static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
564 {return char_type(__c);}
565 static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
566 {return int_type(__c);}
567 static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
568 {return __c1 == __c2;}
569 static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
570 {return int_type(0xFFFF);}
571};
572
573inline _LIBCPP_CONSTEXPR_AFTER_CXX14
574int
575char_traits<char16_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
576{
577 for (; __n; --__n, ++__s1, ++__s2)
578 {
579 if (lt(*__s1, *__s2))
580 return -1;
581 if (lt(*__s2, *__s1))
582 return 1;
583 }
584 return 0;
585}
586
587inline _LIBCPP_CONSTEXPR_AFTER_CXX14
588size_t
589char_traits<char16_t>::length(const char_type* __s) _NOEXCEPT
590{
591 size_t __len = 0;
592 for (; !eq(*__s, char_type(0)); ++__s)
593 ++__len;
594 return __len;
595}
596
597inline _LIBCPP_CONSTEXPR_AFTER_CXX14
598const char16_t*
599char_traits<char16_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT
600{
601 for (; __n; --__n)
602 {
603 if (eq(*__s, __a))
604 return __s;
605 ++__s;
606 }
607 return nullptr;
608}
609
610template <>
611struct _LIBCPP_TEMPLATE_VIS char_traits<char32_t>
612{
613 typedef char32_t char_type;
614 typedef uint_least32_t int_type;
615 typedef streamoff off_type;
616 typedef u32streampos pos_type;
617 typedef mbstate_t state_type;
618
619 static inline _LIBCPP_CONSTEXPR_AFTER_CXX14
620 void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;}
621 static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
622 {return __c1 == __c2;}
623 static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
624 {return __c1 < __c2;}
625
626 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14
627 int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
628 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14
629 size_t length(const char_type* __s) _NOEXCEPT;
630 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14
631 const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;
632
633 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
634 static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
635 return std::__char_traits_move(__s1, __s2, __n);
636 }
637
638 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
639 static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
640 std::copy_n(__s2, __n, __s1);
641 return __s1;
642 }
643
644 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
645 static char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT {
646 std::fill_n(__s, __n, __a);
647 return __s;
648 }
649
650 static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
651 {return eq_int_type(__c, eof()) ? ~eof() : __c;}
652 static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
653 {return char_type(__c);}
654 static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
655 {return int_type(__c);}
656 static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
657 {return __c1 == __c2;}
658 static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
659 {return int_type(0xFFFFFFFF);}
660};
661
662inline _LIBCPP_CONSTEXPR_AFTER_CXX14
663int
664char_traits<char32_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
665{
666 for (; __n; --__n, ++__s1, ++__s2)
667 {
668 if (lt(*__s1, *__s2))
669 return -1;
670 if (lt(*__s2, *__s1))
671 return 1;
672 }
673 return 0;
674}
675
676inline _LIBCPP_CONSTEXPR_AFTER_CXX14
677size_t
678char_traits<char32_t>::length(const char_type* __s) _NOEXCEPT
679{
680 size_t __len = 0;
681 for (; !eq(*__s, char_type(0)); ++__s)
682 ++__len;
683 return __len;
684}
685
686inline _LIBCPP_CONSTEXPR_AFTER_CXX14
687const char32_t*
688char_traits<char32_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT
689{
690 for (; __n; --__n)
691 {
692 if (eq(*__s, __a))
693 return __s;
694 ++__s;
695 }
696 return nullptr;
697}
698
699// helper fns for basic_string and string_view
700
701// __str_find
702template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
703inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
704__str_find(const _CharT *__p, _SizeT __sz,
705 _CharT __c, _SizeT __pos) _NOEXCEPT
706{
707 if (__pos >= __sz)
708 return __npos;
709 const _CharT* __r = _Traits::find(__p + __pos, __sz - __pos, __c);
710 if (__r == nullptr)
711 return __npos;
712 return static_cast<_SizeT>(__r - __p);
713}
714
715template <class _CharT, class _Traits>
716inline _LIBCPP_CONSTEXPR_AFTER_CXX11 const _CharT *
717__search_substring(const _CharT *__first1, const _CharT *__last1,
718 const _CharT *__first2, const _CharT *__last2) _NOEXCEPT {
719 // Take advantage of knowing source and pattern lengths.
720 // Stop short when source is smaller than pattern.
721 const ptrdiff_t __len2 = __last2 - __first2;
722 if (__len2 == 0)
723 return __first1;
724
725 ptrdiff_t __len1 = __last1 - __first1;
726 if (__len1 < __len2)
727 return __last1;
728
729 // First element of __first2 is loop invariant.
730 _CharT __f2 = *__first2;
731 while (true) {
732 __len1 = __last1 - __first1;
733 // Check whether __first1 still has at least __len2 bytes.
734 if (__len1 < __len2)
735 return __last1;
736
737 // Find __f2 the first byte matching in __first1.
738 __first1 = _Traits::find(__first1, __len1 - __len2 + 1, __f2);
739 if (__first1 == nullptr)
740 return __last1;
741
742 // It is faster to compare from the first byte of __first1 even if we
743 // already know that it matches the first byte of __first2: this is because
744 // __first2 is most likely aligned, as it is user's "pattern" string, and
745 // __first1 + 1 is most likely not aligned, as the match is in the middle of
746 // the string.
747 if (_Traits::compare(__first1, __first2, __len2) == 0)
748 return __first1;
749
750 ++__first1;
751 }
752}
753
754template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
755inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
756__str_find(const _CharT *__p, _SizeT __sz,
757 const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
758{
759 if (__pos > __sz)
760 return __npos;
761
762 if (__n == 0) // There is nothing to search, just return __pos.
763 return __pos;
764
765 const _CharT *__r = __search_substring<_CharT, _Traits>(
766 __p + __pos, __p + __sz, __s, __s + __n);
767
768 if (__r == __p + __sz)
769 return __npos;
770 return static_cast<_SizeT>(__r - __p);
771}
772
773
774// __str_rfind
775
776template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
777inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
778__str_rfind(const _CharT *__p, _SizeT __sz,
779 _CharT __c, _SizeT __pos) _NOEXCEPT
780{
781 if (__sz < 1)
782 return __npos;
783 if (__pos < __sz)
784 ++__pos;
785 else
786 __pos = __sz;
787 for (const _CharT* __ps = __p + __pos; __ps != __p;)
788 {
789 if (_Traits::eq(*--__ps, __c))
790 return static_cast<_SizeT>(__ps - __p);
791 }
792 return __npos;
793}
794
795template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
796inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
797__str_rfind(const _CharT *__p, _SizeT __sz,
798 const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
799{
800 __pos = _VSTD::min(__pos, __sz);
801 if (__n < __sz - __pos)
802 __pos += __n;
803 else
804 __pos = __sz;
805 const _CharT* __r = std::__find_end_classic(__p, __p + __pos, __s, __s + __n, _Traits::eq);
806 if (__n > 0 && __r == __p + __pos)
807 return __npos;
808 return static_cast<_SizeT>(__r - __p);
809}
810
811// __str_find_first_of
812template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
813inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
814__str_find_first_of(const _CharT *__p, _SizeT __sz,
815 const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
816{
817 if (__pos >= __sz || __n == 0)
818 return __npos;
819 const _CharT* __r = _VSTD::__find_first_of_ce
820 (__p + __pos, __p + __sz, __s, __s + __n, _Traits::eq );
821 if (__r == __p + __sz)
822 return __npos;
823 return static_cast<_SizeT>(__r - __p);
824}
825
826
827// __str_find_last_of
828template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
829inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
830__str_find_last_of(const _CharT *__p, _SizeT __sz,
831 const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
832 {
833 if (__n != 0)
834 {
835 if (__pos < __sz)
836 ++__pos;
837 else
838 __pos = __sz;
839 for (const _CharT* __ps = __p + __pos; __ps != __p;)
840 {
841 const _CharT* __r = _Traits::find(__s, __n, *--__ps);
842 if (__r)
843 return static_cast<_SizeT>(__ps - __p);
844 }
845 }
846 return __npos;
847}
848
849
850// __str_find_first_not_of
851template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
852inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
853__str_find_first_not_of(const _CharT *__p, _SizeT __sz,
854 const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
855{
856 if (__pos < __sz)
857 {
858 const _CharT* __pe = __p + __sz;
859 for (const _CharT* __ps = __p + __pos; __ps != __pe; ++__ps)
860 if (_Traits::find(__s, __n, *__ps) == nullptr)
861 return static_cast<_SizeT>(__ps - __p);
862 }
863 return __npos;
864}
865
866
867template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
868inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
869__str_find_first_not_of(const _CharT *__p, _SizeT __sz,
870 _CharT __c, _SizeT __pos) _NOEXCEPT
871{
872 if (__pos < __sz)
873 {
874 const _CharT* __pe = __p + __sz;
875 for (const _CharT* __ps = __p + __pos; __ps != __pe; ++__ps)
876 if (!_Traits::eq(*__ps, __c))
877 return static_cast<_SizeT>(__ps - __p);
878 }
879 return __npos;
880}
881
882
883// __str_find_last_not_of
884template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
885inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
886__str_find_last_not_of(const _CharT *__p, _SizeT __sz,
887 const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
888{
889 if (__pos < __sz)
890 ++__pos;
891 else
892 __pos = __sz;
893 for (const _CharT* __ps = __p + __pos; __ps != __p;)
894 if (_Traits::find(__s, __n, *--__ps) == nullptr)
895 return static_cast<_SizeT>(__ps - __p);
896 return __npos;
897}
898
899
900template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
901inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
902__str_find_last_not_of(const _CharT *__p, _SizeT __sz,
903 _CharT __c, _SizeT __pos) _NOEXCEPT
904{
905 if (__pos < __sz)
906 ++__pos;
907 else
908 __pos = __sz;
909 for (const _CharT* __ps = __p + __pos; __ps != __p;)
910 if (!_Traits::eq(*--__ps, __c))
911 return static_cast<_SizeT>(__ps - __p);
912 return __npos;
913}
914
915template<class _Ptr>
916inline _LIBCPP_INLINE_VISIBILITY
917size_t __do_string_hash(_Ptr __p, _Ptr __e)
918{
919 typedef typename iterator_traits<_Ptr>::value_type value_type;
920 return __murmur2_or_cityhash<size_t>()(__p, (__e-__p)*sizeof(value_type));
921}
922
923_LIBCPP_END_NAMESPACE_STD
924
925_LIBCPP_POP_MACROS
926
927#endif // _LIBCPP___STRING_CHAR_TRAITS_H
lib/libcxx/include/__string/extern_template_lists.h created+131
...@@ -0,0 +1,131 @@
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___STRING_EXTERN_TEMPLATE_LISTS_H
10#define _LIBCPP___STRING_EXTERN_TEMPLATE_LISTS_H
11
12#include <__config>
13
14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
15# pragma GCC system_header
16#endif
17
18// We maintain 2 ABI lists:
19// - _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST
20// - _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST
21// As the name implies, the ABI lists define the V1 (Stable) and unstable ABI.
22//
23// For unstable, we may explicitly remove function that are external in V1,
24// and add (new) external functions to better control inlining and compiler
25// optimization opportunities.
26//
27// For stable, the ABI list should rarely change, except for adding new
28// functions supporting new c++ version / API changes. Typically entries
29// must never be removed from the stable list.
30#define _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_Func, _CharType) \
31 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, value_type const*, size_type)) \
32 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::rfind(value_type const*, size_type, size_type) const) \
33 _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(value_type const*, size_type, size_type)) \
34 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&)) \
35 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, value_type const*)) \
36 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&, allocator<_CharType> const&)) \
37 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_last_not_of(value_type const*, size_type, size_type) const) \
38 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::~basic_string()) \
39 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_first_not_of(value_type const*, size_type, size_type) const) \
40 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, size_type, value_type)) \
41 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::operator=(value_type)) \
42 _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(value_type const*, size_type)) \
43 _Func(_LIBCPP_FUNC_VIS const _CharType& basic_string<_CharType>::at(size_type) const) \
44 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, value_type const*, size_type)) \
45 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_first_of(value_type const*, size_type, size_type) const) \
46 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, size_type, value_type)) \
47 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(value_type const*, size_type)) \
48 _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::reserve(size_type)) \
49 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(value_type const*, size_type)) \
50 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(basic_string const&, size_type, size_type)) \
51 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::copy(value_type*, size_type, size_type) const) \
52 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&, size_type, size_type, allocator<_CharType> const&)) \
53 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find(value_type, size_type) const) \
54 _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(size_type, value_type)) \
55 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, value_type const*)) \
56 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_last_of(value_type const*, size_type, size_type) const) \
57 _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__grow_by(size_type, size_type, size_type, size_type, size_type, size_type)) \
58 _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__grow_by_and_replace(size_type, size_type, size_type, size_type, size_type, size_type, value_type const*)) \
59 _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::push_back(value_type)) \
60 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(size_type, value_type)) \
61 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::rfind(value_type, size_type) const) \
62 _Func(_LIBCPP_FUNC_VIS const basic_string<_CharType>::size_type basic_string<_CharType>::npos) \
63 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(size_type, value_type)) \
64 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::erase(size_type, size_type)) \
65 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(basic_string const&, size_type, size_type)) \
66 _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(value_type const*) const) \
67 _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, value_type const*) const) \
68 _Func(_LIBCPP_FUNC_VIS _CharType& basic_string<_CharType>::at(size_type)) \
69 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(value_type const*)) \
70 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find(value_type const*, size_type, size_type) const) \
71 _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, basic_string const&, size_type, size_type) const) \
72 _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, value_type const*, size_type) const) \
73 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::operator=(basic_string const&)) \
74 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(value_type const*)) \
75 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, basic_string const&, size_type, size_type)) \
76 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::iterator basic_string<_CharType>::insert(basic_string::const_iterator, value_type)) \
77 _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::resize(size_type, value_type)) \
78 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, basic_string const&, size_type, size_type))
79
80#define _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_Func, _CharType) \
81 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, value_type const*, size_type)) \
82 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::rfind(value_type const*, size_type, size_type) const) \
83 _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(value_type const*, size_type, size_type)) \
84 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, value_type const*)) \
85 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_last_not_of(value_type const*, size_type, size_type) const) \
86 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::~basic_string()) \
87 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_first_not_of(value_type const*, size_type, size_type) const) \
88 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, size_type, value_type)) \
89 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::operator=(value_type)) \
90 _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(value_type const*, size_type)) \
91 _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init_copy_ctor_external(value_type const*, size_type)) \
92 _Func(_LIBCPP_FUNC_VIS const _CharType& basic_string<_CharType>::at(size_type) const) \
93 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, value_type const*, size_type)) \
94 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_first_of(value_type const*, size_type, size_type) const) \
95 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, size_type, value_type)) \
96 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::__assign_external(value_type const*, size_type)) \
97 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::__assign_external(value_type const*)) \
98 _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::reserve(size_type)) \
99 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(value_type const*, size_type)) \
100 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(basic_string const&, size_type, size_type)) \
101 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::copy(value_type*, size_type, size_type) const) \
102 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&, size_type, size_type, allocator<_CharType> const&)) \
103 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find(value_type, size_type) const) \
104 _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(size_type, value_type)) \
105 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, value_type const*)) \
106 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_last_of(value_type const*, size_type, size_type) const) \
107 _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__grow_by(size_type, size_type, size_type, size_type, size_type, size_type)) \
108 _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__grow_by_and_replace(size_type, size_type, size_type, size_type, size_type, size_type, value_type const*)) \
109 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::__assign_no_alias<false>(value_type const*, size_type)) \
110 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::__assign_no_alias<true>(value_type const*, size_type)) \
111 _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::push_back(value_type)) \
112 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(size_type, value_type)) \
113 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::rfind(value_type, size_type) const) \
114 _Func(_LIBCPP_FUNC_VIS const basic_string<_CharType>::size_type basic_string<_CharType>::npos) \
115 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(size_type, value_type)) \
116 _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__erase_external_with_move(size_type, size_type)) \
117 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(basic_string const&, size_type, size_type)) \
118 _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(value_type const*) const) \
119 _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, value_type const*) const) \
120 _Func(_LIBCPP_FUNC_VIS _CharType& basic_string<_CharType>::at(size_type)) \
121 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find(value_type const*, size_type, size_type) const) \
122 _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, basic_string const&, size_type, size_type) const) \
123 _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, value_type const*, size_type) const) \
124 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(value_type const*)) \
125 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, basic_string const&, size_type, size_type)) \
126 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::iterator basic_string<_CharType>::insert(basic_string::const_iterator, value_type)) \
127 _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::resize(size_type, value_type)) \
128 _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, basic_string const&, size_type, size_type))
129
130
131#endif // _LIBCPP___STRING_EXTERN_TEMPLATE_LISTS_H
lib/libcxx/include/__support/android/locale_bionic.h+13-7
...@@ -26,10 +26,15 @@ extern "C" {...@@ -26,10 +26,15 @@ extern "C" {
26#if defined(__ANDROID__)26#if defined(__ANDROID__)
2727
28#include <android/api-level.h>28#include <android/api-level.h>
29#include <android/ndk-version.h>
30#if __ANDROID_API__ < 2129#if __ANDROID_API__ < 21
31#include <__support/xlocale/__posix_l_fallback.h>30#include <__support/xlocale/__posix_l_fallback.h>
32#endif31#endif
32
33// If we do not have this header, we are in a platform build rather than an NDK
34// build, which will always be at least as new as the ToT NDK, in which case we
35// don't need any of the inlines below since libc provides them.
36#if __has_include(<android/ndk-version.h>)
37#include <android/ndk-version.h>
33// In NDK versions later than 16, locale-aware functions are provided by38// In NDK versions later than 16, locale-aware functions are provided by
34// legacy_stdlib_inlines.h39// legacy_stdlib_inlines.h
35#if __NDK_MAJOR__ <= 1640#if __NDK_MAJOR__ <= 16
...@@ -41,18 +46,18 @@ extern "C" {...@@ -41,18 +46,18 @@ extern "C" {
41extern "C" {46extern "C" {
42#endif47#endif
4348
44inline _LIBCPP_INLINE_VISIBILITY float strtof_l(const char* __nptr, char** __endptr,49inline _LIBCPP_HIDE_FROM_ABI float
45 locale_t) {50strtof_l(const char* __nptr, char** __endptr, locale_t) {
46 return ::strtof(__nptr, __endptr);51 return ::strtof(__nptr, __endptr);
47}52}
4853
49inline _LIBCPP_INLINE_VISIBILITY double strtod_l(const char* __nptr,54inline _LIBCPP_HIDE_FROM_ABI double
50 char** __endptr, locale_t) {55strtod_l(const char* __nptr, char** __endptr, locale_t) {
51 return ::strtod(__nptr, __endptr);56 return ::strtod(__nptr, __endptr);
52}57}
5358
54inline _LIBCPP_INLINE_VISIBILITY long strtol_l(const char* __nptr, char** __endptr,59inline _LIBCPP_HIDE_FROM_ABI long
55 int __base, locale_t) {60strtol_l(const char* __nptr, char** __endptr, int __base, locale_t) {
56 return ::strtol(__nptr, __endptr, __base);61 return ::strtol(__nptr, __endptr, __base);
57}62}
5863
...@@ -63,6 +68,7 @@ inline _LIBCPP_INLINE_VISIBILITY long strtol_l(const char* __nptr, char** __endp...@@ -63,6 +68,7 @@ inline _LIBCPP_INLINE_VISIBILITY long strtol_l(const char* __nptr, char** __endp
63#endif // __ANDROID_API__ < 2668#endif // __ANDROID_API__ < 26
6469
65#endif // __NDK_MAJOR__ <= 1670#endif // __NDK_MAJOR__ <= 16
71#endif // __has_include(<android/ndk-version.h>)
66#endif // defined(__ANDROID__)72#endif // defined(__ANDROID__)
6773
68#endif // defined(__BIONIC__)74#endif // defined(__BIONIC__)
lib/libcxx/include/__support/ibm/gettod_zos.h+2-1
...@@ -12,7 +12,8 @@...@@ -12,7 +12,8 @@
1212
13#include <time.h>13#include <time.h>
1414
15static inline int gettimeofdayMonotonic(struct timespec64* Output) {15inline _LIBCPP_HIDE_FROM_ABI int
16gettimeofdayMonotonic(struct timespec64* Output) {
1617
17 // The POSIX gettimeofday() function is not available on z/OS. Therefore,18 // The POSIX gettimeofday() function is not available on z/OS. Therefore,
18 // we will call stcke and other hardware instructions in implement equivalent.19 // we will call stcke and other hardware instructions in implement equivalent.
lib/libcxx/include/__support/ibm/limits.h deleted-98
...@@ -1,98 +0,0 @@
1// -*- C++ -*-
2//===-----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP_SUPPORT_IBM_LIMITS_H
11#define _LIBCPP_SUPPORT_IBM_LIMITS_H
12
13#if !defined(_AIX) // Linux
14#include <math.h> // for HUGE_VAL, HUGE_VALF, HUGE_VALL, and NAN
15
16static const unsigned int _QNAN_F = 0x7fc00000;
17#define NANF (*((float *)(&_QNAN_F)))
18static const unsigned int _QNAN_LDBL128[4] = {0x7ff80000, 0x0, 0x0, 0x0};
19#define NANL (*((long double *)(&_QNAN_LDBL128)))
20static const unsigned int _SNAN_F= 0x7f855555;
21#define NANSF (*((float *)(&_SNAN_F)))
22static const unsigned int _SNAN_D[2] = {0x7ff55555, 0x55555555};
23#define NANS (*((double *)(&_SNAN_D)))
24static const unsigned int _SNAN_LDBL128[4] = {0x7ff55555, 0x55555555, 0x0, 0x0};
25#define NANSL (*((long double *)(&_SNAN_LDBL128)))
26
27#define __builtin_huge_val() HUGE_VAL
28#define __builtin_huge_valf() HUGE_VALF
29#define __builtin_huge_vall() HUGE_VALL
30#define __builtin_nan(__dummy) NAN
31#define __builtin_nanf(__dummy) NANF
32#define __builtin_nanl(__dummy) NANL
33#define __builtin_nans(__dummy) NANS
34#define __builtin_nansf(__dummy) NANSF
35#define __builtin_nansl(__dummy) NANSL
36
37#else
38
39#include <math.h>
40#include <float.h> // limit constants
41
42#define __builtin_huge_val() HUGE_VAL //0x7ff0000000000000
43#define __builtin_huge_valf() HUGE_VALF //0x7f800000
44#define __builtin_huge_vall() HUGE_VALL //0x7ff0000000000000
45#define __builtin_nan(__dummy) nan(__dummy) //0x7ff8000000000000
46#define __builtin_nanf(__dummy) nanf(__dummy) // 0x7ff80000
47#define __builtin_nanl(__dummy) nanl(__dummy) //0x7ff8000000000000
48#define __builtin_nans(__dummy) DBL_SNAN //0x7ff5555555555555
49#define __builtin_nansf(__dummy) FLT_SNAN //0x7f855555
50#define __builtin_nansl(__dummy) DBL_SNAN //0x7ff5555555555555
51
52#define __FLT_MANT_DIG__ FLT_MANT_DIG
53#define __FLT_DIG__ FLT_DIG
54#define __FLT_RADIX__ FLT_RADIX
55#define __FLT_MIN_EXP__ FLT_MIN_EXP
56#define __FLT_MIN_10_EXP__ FLT_MIN_10_EXP
57#define __FLT_MAX_EXP__ FLT_MAX_EXP
58#define __FLT_MAX_10_EXP__ FLT_MAX_10_EXP
59#define __FLT_MIN__ FLT_MIN
60#define __FLT_MAX__ FLT_MAX
61#define __FLT_EPSILON__ FLT_EPSILON
62// predefined by XLC on LoP
63#define __FLT_DENORM_MIN__ 1.40129846e-45F
64
65#define __DBL_MANT_DIG__ DBL_MANT_DIG
66#define __DBL_DIG__ DBL_DIG
67#define __DBL_MIN_EXP__ DBL_MIN_EXP
68#define __DBL_MIN_10_EXP__ DBL_MIN_10_EXP
69#define __DBL_MAX_EXP__ DBL_MAX_EXP
70#define __DBL_MAX_10_EXP__ DBL_MAX_10_EXP
71#define __DBL_MIN__ DBL_MIN
72#define __DBL_MAX__ DBL_MAX
73#define __DBL_EPSILON__ DBL_EPSILON
74// predefined by XLC on LoP
75#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
76
77#define __LDBL_MANT_DIG__ LDBL_MANT_DIG
78#define __LDBL_DIG__ LDBL_DIG
79#define __LDBL_MIN_EXP__ LDBL_MIN_EXP
80#define __LDBL_MIN_10_EXP__ LDBL_MIN_10_EXP
81#define __LDBL_MAX_EXP__ LDBL_MAX_EXP
82#define __LDBL_MAX_10_EXP__ LDBL_MAX_10_EXP
83#define __LDBL_MIN__ LDBL_MIN
84#define __LDBL_MAX__ LDBL_MAX
85#define __LDBL_EPSILON__ LDBL_EPSILON
86// predefined by XLC on LoP
87#if __LONGDOUBLE128
88#define __LDBL_DENORM_MIN__ 4.94065645841246544176568792868221e-324L
89#else
90#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324L
91#endif
92
93// predefined by XLC on LoP
94#define __CHAR_BIT__ 8
95
96#endif // _AIX
97
98#endif // _LIBCPP_SUPPORT_IBM_LIMITS_H
lib/libcxx/include/__support/ibm/support.h deleted-53
...@@ -1,53 +0,0 @@
1// -*- C++ -*-
2//===-----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP_SUPPORT_IBM_SUPPORT_H
11#define _LIBCPP_SUPPORT_IBM_SUPPORT_H
12
13extern "builtin" int __popcnt4(unsigned int);
14extern "builtin" int __popcnt8(unsigned long long);
15extern "builtin" unsigned int __cnttz4(unsigned int);
16extern "builtin" unsigned int __cnttz8(unsigned long long);
17extern "builtin" unsigned int __cntlz4(unsigned int);
18extern "builtin" unsigned int __cntlz8(unsigned long long);
19
20// Builtin functions for counting population
21#define __builtin_popcount(x) __popcnt4(x)
22#define __builtin_popcountll(x) __popcnt8(x)
23#if defined(__64BIT__)
24#define __builtin_popcountl(x) __builtin_popcountll(x)
25#else
26#define __builtin_popcountl(x) __builtin_popcount(x)
27#endif
28
29// Builtin functions for counting trailing zeros
30#define __builtin_ctz(x) __cnttz4(x)
31#define __builtin_ctzll(x) __cnttz8(x)
32#if defined(__64BIT__)
33#define __builtin_ctzl(x) __builtin_ctzll(x)
34#else
35#define __builtin_ctzl(x) __builtin_ctz(x)
36#endif
37
38// Builtin functions for counting leading zeros
39#define __builtin_clz(x) __cntlz4(x)
40#define __builtin_clzll(x) __cntlz8(x)
41#if defined(__64BIT__)
42#define __builtin_clzl(x) __builtin_clzll(x)
43#else
44#define __builtin_clzl(x) __builtin_clz(x)
45#endif
46
47#if defined(__64BIT__)
48#define __SIZE_WIDTH__ 64
49#else
50#define __SIZE_WIDTH__ 32
51#endif
52
53#endif // _LIBCPP_SUPPORT_IBM_SUPPORT_H
lib/libcxx/include/__support/ibm/xlocale.h+26-30
...@@ -10,7 +10,10 @@...@@ -10,7 +10,10 @@
10#ifndef _LIBCPP_SUPPORT_IBM_XLOCALE_H10#ifndef _LIBCPP_SUPPORT_IBM_XLOCALE_H
11#define _LIBCPP_SUPPORT_IBM_XLOCALE_H11#define _LIBCPP_SUPPORT_IBM_XLOCALE_H
1212
13#if defined(__MVS__)
13#include <__support/ibm/locale_mgmt_zos.h>14#include <__support/ibm/locale_mgmt_zos.h>
15#endif // defined(__MVS__)
16
14#include <stdarg.h>17#include <stdarg.h>
1518
16#include "cstdlib"19#include "cstdlib"
...@@ -52,57 +55,50 @@ private:...@@ -52,57 +55,50 @@ private:
5255
53// The following are not POSIX routines. These are quick-and-dirty hacks56// The following are not POSIX routines. These are quick-and-dirty hacks
54// to make things pretend to work57// to make things pretend to work
55static inline58inline _LIBCPP_HIDE_FROM_ABI long long
56long long strtoll_l(const char *__nptr, char **__endptr,59strtoll_l(const char *__nptr, char **__endptr, int __base, locale_t locale) {
57 int __base, locale_t locale) {
58 __setAndRestore __newloc(locale);60 __setAndRestore __newloc(locale);
59 return strtoll(__nptr, __endptr, __base);61 return ::strtoll(__nptr, __endptr, __base);
60}62}
6163
62static inline64inline _LIBCPP_HIDE_FROM_ABI long
63long strtol_l(const char *__nptr, char **__endptr,65strtol_l(const char *__nptr, char **__endptr, int __base, locale_t locale) {
64 int __base, locale_t locale) {
65 __setAndRestore __newloc(locale);66 __setAndRestore __newloc(locale);
66 return strtol(__nptr, __endptr, __base);67 return ::strtol(__nptr, __endptr, __base);
67}68}
6869
69static inline70inline _LIBCPP_HIDE_FROM_ABI double
70double strtod_l(const char *__nptr, char **__endptr,71strtod_l(const char *__nptr, char **__endptr, locale_t locale) {
71 locale_t locale) {
72 __setAndRestore __newloc(locale);72 __setAndRestore __newloc(locale);
73 return strtod(__nptr, __endptr);73 return ::strtod(__nptr, __endptr);
74}74}
7575
76static inline76inline _LIBCPP_HIDE_FROM_ABI float
77float strtof_l(const char *__nptr, char **__endptr,77strtof_l(const char *__nptr, char **__endptr, locale_t locale) {
78 locale_t locale) {
79 __setAndRestore __newloc(locale);78 __setAndRestore __newloc(locale);
80 return strtof(__nptr, __endptr);79 return ::strtof(__nptr, __endptr);
81}80}
8281
83static inline82inline _LIBCPP_HIDE_FROM_ABI long double
84long double strtold_l(const char *__nptr, char **__endptr,83strtold_l(const char *__nptr, char **__endptr, locale_t locale) {
85 locale_t locale) {
86 __setAndRestore __newloc(locale);84 __setAndRestore __newloc(locale);
87 return strtold(__nptr, __endptr);85 return ::strtold(__nptr, __endptr);
88}86}
8987
90static inline88inline _LIBCPP_HIDE_FROM_ABI unsigned long long
91unsigned long long strtoull_l(const char *__nptr, char **__endptr,89strtoull_l(const char *__nptr, char **__endptr, int __base, locale_t locale) {
92 int __base, locale_t locale) {
93 __setAndRestore __newloc(locale);90 __setAndRestore __newloc(locale);
94 return strtoull(__nptr, __endptr, __base);91 return ::strtoull(__nptr, __endptr, __base);
95}92}
9693
97static inline94inline _LIBCPP_HIDE_FROM_ABI unsigned long
98unsigned long strtoul_l(const char *__nptr, char **__endptr,95strtoul_l(const char *__nptr, char **__endptr, int __base, locale_t locale) {
99 int __base, locale_t locale) {
100 __setAndRestore __newloc(locale);96 __setAndRestore __newloc(locale);
101 return strtoul(__nptr, __endptr, __base);97 return ::strtoul(__nptr, __endptr, __base);
102}98}
10399
104static inline100inline _LIBCPP_HIDE_FROM_ABI int
105int vasprintf(char **strp, const char *fmt, va_list ap) {101vasprintf(char **strp, const char *fmt, va_list ap) {
106 const size_t buff_size = 256;102 const size_t buff_size = 256;
107 if ((*strp = (char *)malloc(buff_size)) == NULL) {103 if ((*strp = (char *)malloc(buff_size)) == NULL) {
108 return -1;104 return -1;
lib/libcxx/include/__support/musl/xlocale.h+15-16
...@@ -24,30 +24,29 @@...@@ -24,30 +24,29 @@
24extern "C" {24extern "C" {
25#endif25#endif
2626
27static inline long long strtoll_l(const char *nptr, char **endptr, int base,27inline _LIBCPP_HIDE_FROM_ABI long long
28 locale_t) {28strtoll_l(const char *__nptr, char **__endptr, int __base, locale_t) {
29 return strtoll(nptr, endptr, base);29 return ::strtoll(__nptr, __endptr, __base);
30}30}
3131
32static inline unsigned long long strtoull_l(const char *nptr, char **endptr,32inline _LIBCPP_HIDE_FROM_ABI unsigned long long
33 int base, locale_t) {33strtoull_l(const char *__nptr, char **__endptr, int __base, locale_t) {
34 return strtoull(nptr, endptr, base);34 return ::strtoull(__nptr, __endptr, __base);
35}35}
3636
37static inline long long wcstoll_l(const wchar_t *nptr, wchar_t **endptr,37inline _LIBCPP_HIDE_FROM_ABI long long
38 int base, locale_t) {38wcstoll_l(const wchar_t *__nptr, wchar_t **__endptr, int __base, locale_t) {
39 return wcstoll(nptr, endptr, base);39 return ::wcstoll(__nptr, __endptr, __base);
40}40}
4141
42static inline unsigned long long wcstoull_l(const wchar_t *nptr,42inline _LIBCPP_HIDE_FROM_ABI long long
43 wchar_t **endptr, int base,43wcstoull_l(const wchar_t *__nptr, wchar_t **__endptr, int __base, locale_t) {
44 locale_t) {44 return ::wcstoull(__nptr, __endptr, __base);
45 return wcstoull(nptr, endptr, base);
46}45}
4746
48static inline long double wcstold_l(const wchar_t *nptr, wchar_t **endptr,47inline _LIBCPP_HIDE_FROM_ABI long double
49 locale_t) {48wcstold_l(const wchar_t *__nptr, wchar_t **__endptr, locale_t) {
50 return wcstold(nptr, endptr);49 return ::wcstold(__nptr, __endptr);
51}50}
5251
53#ifdef __cplusplus52#ifdef __cplusplus
lib/libcxx/include/__support/openbsd/xlocale.h+4-4
...@@ -22,13 +22,13 @@ extern "C" {...@@ -22,13 +22,13 @@ extern "C" {
2222
2323
24inline _LIBCPP_HIDE_FROM_ABI long24inline _LIBCPP_HIDE_FROM_ABI long
25strtol_l(const char *nptr, char **endptr, int base, locale_t) {25strtol_l(const char *__nptr, char **__endptr, int __base, locale_t) {
26 return ::strtol(nptr, endptr, base);26 return ::strtol(__nptr, __endptr, __base);
27}27}
2828
29inline _LIBCPP_HIDE_FROM_ABI unsigned long29inline _LIBCPP_HIDE_FROM_ABI unsigned long
30strtoul_l(const char *nptr, char **endptr, int base, locale_t) {30strtoul_l(const char *__nptr, char **__endptr, int __base, locale_t) {
31 return ::strtoul(nptr, endptr, base);31 return ::strtoul(__nptr, __endptr, __base);
32}32}
3333
3434
lib/libcxx/include/__support/solaris/xlocale.h+27-28
...@@ -32,40 +32,39 @@ struct lconv *localeconv(void);...@@ -32,40 +32,39 @@ struct lconv *localeconv(void);
32struct lconv *localeconv_l(locale_t __l);32struct lconv *localeconv_l(locale_t __l);
3333
34// FIXME: These are quick-and-dirty hacks to make things pretend to work34// FIXME: These are quick-and-dirty hacks to make things pretend to work
35static inline35inline _LIBCPP_HIDE_FROM_ABI long long
36long long strtoll_l(const char *__nptr, char **__endptr,36strtoll_l(const char *__nptr, char **__endptr, int __base, locale_t __loc) {
37 int __base, locale_t __loc) {37 return ::strtoll(__nptr, __endptr, __base);
38 return strtoll(__nptr, __endptr, __base);
39}38}
40static inline39
41long strtol_l(const char *__nptr, char **__endptr,40inline _LIBCPP_HIDE_FROM_ABI long
42 int __base, locale_t __loc) {41strtol_l(const char *__nptr, char **__endptr, int __base, locale_t __loc) {
43 return strtol(__nptr, __endptr, __base);42 return ::strtol(__nptr, __endptr, __base);
44}43}
45static inline44
46unsigned long long strtoull_l(const char *__nptr, char **__endptr,45inline _LIBCPP_HIDE_FROM_ABI unsigned long long
47 int __base, locale_t __loc) {46strtoull_l(const char *__nptr, char **__endptr, int __base, locale_t __loc)
48 return strtoull(__nptr, __endptr, __base);47 return ::strtoull(__nptr, __endptr, __base);
49}48}
50static inline49
51unsigned long strtoul_l(const char *__nptr, char **__endptr,50inline _LIBCPP_HIDE_FROM_ABI unsigned long
52 int __base, locale_t __loc) {51strtoul_l(const char *__nptr, char **__endptr, int __base, locale_t __loc) {
53 return strtoul(__nptr, __endptr, __base);52 return ::strtoul(__nptr, __endptr, __base);
54}53}
55static inline54
56float strtof_l(const char *__nptr, char **__endptr,55inline _LIBCPP_HIDE_FROM_ABI float
57 locale_t __loc) {56strtof_l(const char *__nptr, char **__endptr, locale_t __loc) {
58 return strtof(__nptr, __endptr);57 return ::strtof(__nptr, __endptr);
59}58}
60static inline59
61double strtod_l(const char *__nptr, char **__endptr,60inline _LIBCPP_HIDE_FROM_ABI double
62 locale_t __loc) {61strtod_l(const char *__nptr, char **__endptr, locale_t __loc) {
63 return strtod(__nptr, __endptr);62 return ::strtod(__nptr, __endptr);
64}63}
65static inline64
66long double strtold_l(const char *__nptr, char **__endptr,65inline _LIBCPP_HIDE_FROM_ABI long double
67 locale_t __loc) {66strtold_l(const char *__nptr, char **__endptr, locale_t __loc) {
68 return strtold(__nptr, __endptr);67 return ::strtold(__nptr, __endptr);
69}68}
7069
7170
lib/libcxx/include/__support/win32/locale_win32.h+30-32
...@@ -11,7 +11,7 @@...@@ -11,7 +11,7 @@
11#define _LIBCPP_SUPPORT_WIN32_LOCALE_WIN32_H11#define _LIBCPP_SUPPORT_WIN32_LOCALE_WIN32_H
1212
13#include <__config>13#include <__config>
14#include <__nullptr>14#include <cstddef>
15#include <locale.h> // _locale_t15#include <locale.h> // _locale_t
16#include <stdio.h>16#include <stdio.h>
1717
...@@ -186,28 +186,28 @@ private:...@@ -186,28 +186,28 @@ private:
186// Locale management functions186// Locale management functions
187#define freelocale _free_locale187#define freelocale _free_locale
188// FIXME: base currently unused. Needs manual work to construct the new locale188// FIXME: base currently unused. Needs manual work to construct the new locale
189locale_t newlocale( int mask, const char * locale, locale_t base );189locale_t newlocale( int __mask, const char * __locale, locale_t __base );
190// uselocale can't be implemented on Windows because Windows allows partial modification190// uselocale can't be implemented on Windows because Windows allows partial modification
191// of thread-local locale and so _get_current_locale() returns a copy while uselocale does191// of thread-local locale and so _get_current_locale() returns a copy while uselocale does
192// not create any copies.192// not create any copies.
193// We can still implement raii even without uselocale though.193// We can still implement raii even without uselocale though.
194194
195195
196lconv *localeconv_l( locale_t &loc );196lconv *localeconv_l( locale_t & __loc );
197size_t mbrlen_l( const char *__restrict s, size_t n,197size_t mbrlen_l( const char *__restrict __s, size_t __n,
198 mbstate_t *__restrict ps, locale_t loc);198 mbstate_t *__restrict __ps, locale_t __loc);
199size_t mbsrtowcs_l( wchar_t *__restrict dst, const char **__restrict src,199size_t mbsrtowcs_l( wchar_t *__restrict __dst, const char **__restrict __src,
200 size_t len, mbstate_t *__restrict ps, locale_t loc );200 size_t __len, mbstate_t *__restrict __ps, locale_t __loc );
201size_t wcrtomb_l( char *__restrict s, wchar_t wc, mbstate_t *__restrict ps,201size_t wcrtomb_l( char *__restrict __s, wchar_t __wc, mbstate_t *__restrict __ps,
202 locale_t loc);202 locale_t __loc);
203size_t mbrtowc_l( wchar_t *__restrict pwc, const char *__restrict s,203size_t mbrtowc_l( wchar_t *__restrict __pwc, const char *__restrict __s,
204 size_t n, mbstate_t *__restrict ps, locale_t loc);204 size_t __n, mbstate_t *__restrict __ps, locale_t __loc);
205size_t mbsnrtowcs_l( wchar_t *__restrict dst, const char **__restrict src,205size_t mbsnrtowcs_l( wchar_t *__restrict __dst, const char **__restrict __src,
206 size_t nms, size_t len, mbstate_t *__restrict ps, locale_t loc);206 size_t __nms, size_t __len, mbstate_t *__restrict __ps, locale_t __loc);
207size_t wcsnrtombs_l( char *__restrict dst, const wchar_t **__restrict src,207size_t wcsnrtombs_l( char *__restrict __dst, const wchar_t **__restrict __src,
208 size_t nwc, size_t len, mbstate_t *__restrict ps, locale_t loc);208 size_t __nwc, size_t __len, mbstate_t *__restrict __ps, locale_t __loc);
209wint_t btowc_l( int c, locale_t loc );209wint_t btowc_l( int __c, locale_t __loc );
210int wctob_l( wint_t c, locale_t loc );210int wctob_l( wint_t __c, locale_t __loc );
211211
212decltype(MB_CUR_MAX) MB_CUR_MAX_L( locale_t __l );212decltype(MB_CUR_MAX) MB_CUR_MAX_L( locale_t __l );
213213
...@@ -223,18 +223,16 @@ decltype(MB_CUR_MAX) MB_CUR_MAX_L( locale_t __l );...@@ -223,18 +223,16 @@ decltype(MB_CUR_MAX) MB_CUR_MAX_L( locale_t __l );
223_LIBCPP_FUNC_VIS float strtof_l(const char*, char**, locale_t);223_LIBCPP_FUNC_VIS float strtof_l(const char*, char**, locale_t);
224_LIBCPP_FUNC_VIS long double strtold_l(const char*, char**, locale_t);224_LIBCPP_FUNC_VIS long double strtold_l(const char*, char**, locale_t);
225#endif225#endif
226inline _LIBCPP_INLINE_VISIBILITY226inline _LIBCPP_HIDE_FROM_ABI int
227int227islower_l(int __c, _locale_t __loc)
228islower_l(int c, _locale_t loc)
229{228{
230 return _islower_l((int)c, loc);229 return _islower_l((int)__c, __loc);
231}230}
232231
233inline _LIBCPP_INLINE_VISIBILITY232inline _LIBCPP_HIDE_FROM_ABI int
234int233isupper_l(int __c, _locale_t __loc)
235isupper_l(int c, _locale_t loc)
236{234{
237 return _isupper_l((int)c, loc);235 return _isupper_l((int)__c, __loc);
238}236}
239237
240#define isdigit_l _isdigit_l238#define isdigit_l _isdigit_l
...@@ -266,18 +264,18 @@ _LIBCPP_FUNC_VIS size_t strftime_l(char *ret, size_t n, const char *format,...@@ -266,18 +264,18 @@ _LIBCPP_FUNC_VIS size_t strftime_l(char *ret, size_t n, const char *format,
266#define sprintf_l( __s, __l, __f, ... ) _sprintf_l( __s, __f, __l, __VA_ARGS__ )264#define sprintf_l( __s, __l, __f, ... ) _sprintf_l( __s, __f, __l, __VA_ARGS__ )
267#define vsprintf_l( __s, __l, __f, ... ) _vsprintf_l( __s, __f, __l, __VA_ARGS__ )265#define vsprintf_l( __s, __l, __f, ... ) _vsprintf_l( __s, __f, __l, __VA_ARGS__ )
268#define vsnprintf_l( __s, __n, __l, __f, ... ) _vsnprintf_l( __s, __n, __f, __l, __VA_ARGS__ )266#define vsnprintf_l( __s, __n, __l, __f, ... ) _vsnprintf_l( __s, __n, __f, __l, __VA_ARGS__ )
269_LIBCPP_FUNC_VIS int snprintf_l(char *ret, size_t n, locale_t loc, const char *format, ...);267_LIBCPP_FUNC_VIS int snprintf_l(char *__ret, size_t __n, locale_t __loc, const char *__format, ...);
270_LIBCPP_FUNC_VIS int asprintf_l( char **ret, locale_t loc, const char *format, ... );268_LIBCPP_FUNC_VIS int asprintf_l( char **__ret, locale_t __loc, const char *__format, ... );
271_LIBCPP_FUNC_VIS int vasprintf_l( char **ret, locale_t loc, const char *format, va_list ap );269_LIBCPP_FUNC_VIS int vasprintf_l( char **__ret, locale_t __loc, const char *__format, va_list __ap );
272270
273// not-so-pressing FIXME: use locale to determine blank characters271// not-so-pressing FIXME: use locale to determine blank characters
274inline int isblank_l( int c, locale_t /*loc*/ )272inline int isblank_l( int __c, locale_t /*loc*/ )
275{273{
276 return ( c == ' ' || c == '\t' );274 return ( __c == ' ' || __c == '\t' );
277}275}
278inline int iswblank_l( wint_t c, locale_t /*loc*/ )276inline int iswblank_l( wint_t __c, locale_t /*loc*/ )
279{277{
280 return ( c == L' ' || c == L'\t' );278 return ( __c == L' ' || __c == L'\t' );
281}279}
282280
283#endif // _LIBCPP_SUPPORT_WIN32_LOCALE_WIN32_H281#endif // _LIBCPP_SUPPORT_WIN32_LOCALE_WIN32_H
lib/libcxx/include/__support/xlocale/__nop_locale_mgmt.h+9-4
...@@ -16,18 +16,23 @@ extern "C" {...@@ -16,18 +16,23 @@ extern "C" {
1616
17// Patch over lack of extended locale support17// Patch over lack of extended locale support
18typedef void *locale_t;18typedef void *locale_t;
19static inline locale_t duplocale(locale_t) {19
20inline _LIBCPP_HIDE_FROM_ABI locale_t
21duplocale(locale_t) {
20 return NULL;22 return NULL;
21}23}
2224
23static inline void freelocale(locale_t) {25inline _LIBCPP_HIDE_FROM_ABI void
26freelocale(locale_t) {
24}27}
2528
26static inline locale_t newlocale(int, const char *, locale_t) {29inline _LIBCPP_HIDE_FROM_ABI locale_t
30newlocale(int, const char *, locale_t) {
27 return NULL;31 return NULL;
28}32}
2933
30static inline locale_t uselocale(locale_t) {34inline _LIBCPP_HIDE_FROM_ABI locale_t
35uselocale(locale_t) {
31 return NULL;36 return NULL;
32}37}
3338
lib/libcxx/include/__support/xlocale/__posix_l_fallback.h+72-72
...@@ -19,142 +19,142 @@...@@ -19,142 +19,142 @@
19extern "C" {19extern "C" {
20#endif20#endif
2121
22inline _LIBCPP_INLINE_VISIBILITY int isalnum_l(int c, locale_t) {22inline _LIBCPP_HIDE_FROM_ABI int isalnum_l(int __c, locale_t) {
23 return ::isalnum(c);23 return ::isalnum(__c);
24}24}
2525
26inline _LIBCPP_INLINE_VISIBILITY int isalpha_l(int c, locale_t) {26inline _LIBCPP_HIDE_FROM_ABI int isalpha_l(int __c, locale_t) {
27 return ::isalpha(c);27 return ::isalpha(__c);
28}28}
2929
30inline _LIBCPP_INLINE_VISIBILITY int isblank_l(int c, locale_t) {30inline _LIBCPP_HIDE_FROM_ABI int isblank_l(int __c, locale_t) {
31 return ::isblank(c);31 return ::isblank(__c);
32}32}
3333
34inline _LIBCPP_INLINE_VISIBILITY int iscntrl_l(int c, locale_t) {34inline _LIBCPP_HIDE_FROM_ABI int iscntrl_l(int __c, locale_t) {
35 return ::iscntrl(c);35 return ::iscntrl(__c);
36}36}
3737
38inline _LIBCPP_INLINE_VISIBILITY int isdigit_l(int c, locale_t) {38inline _LIBCPP_HIDE_FROM_ABI int isdigit_l(int __c, locale_t) {
39 return ::isdigit(c);39 return ::isdigit(__c);
40}40}
4141
42inline _LIBCPP_INLINE_VISIBILITY int isgraph_l(int c, locale_t) {42inline _LIBCPP_HIDE_FROM_ABI int isgraph_l(int __c, locale_t) {
43 return ::isgraph(c);43 return ::isgraph(__c);
44}44}
4545
46inline _LIBCPP_INLINE_VISIBILITY int islower_l(int c, locale_t) {46inline _LIBCPP_HIDE_FROM_ABI int islower_l(int __c, locale_t) {
47 return ::islower(c);47 return ::islower(__c);
48}48}
4949
50inline _LIBCPP_INLINE_VISIBILITY int isprint_l(int c, locale_t) {50inline _LIBCPP_HIDE_FROM_ABI int isprint_l(int __c, locale_t) {
51 return ::isprint(c);51 return ::isprint(__c);
52}52}
5353
54inline _LIBCPP_INLINE_VISIBILITY int ispunct_l(int c, locale_t) {54inline _LIBCPP_HIDE_FROM_ABI int ispunct_l(int __c, locale_t) {
55 return ::ispunct(c);55 return ::ispunct(__c);
56}56}
5757
58inline _LIBCPP_INLINE_VISIBILITY int isspace_l(int c, locale_t) {58inline _LIBCPP_HIDE_FROM_ABI int isspace_l(int __c, locale_t) {
59 return ::isspace(c);59 return ::isspace(__c);
60}60}
6161
62inline _LIBCPP_INLINE_VISIBILITY int isupper_l(int c, locale_t) {62inline _LIBCPP_HIDE_FROM_ABI int isupper_l(int __c, locale_t) {
63 return ::isupper(c);63 return ::isupper(__c);
64}64}
6565
66inline _LIBCPP_INLINE_VISIBILITY int isxdigit_l(int c, locale_t) {66inline _LIBCPP_HIDE_FROM_ABI int isxdigit_l(int __c, locale_t) {
67 return ::isxdigit(c);67 return ::isxdigit(__c);
68}68}
6969
70inline _LIBCPP_INLINE_VISIBILITY int iswalnum_l(wint_t c, locale_t) {70inline _LIBCPP_HIDE_FROM_ABI int iswalnum_l(wint_t __c, locale_t) {
71 return ::iswalnum(c);71 return ::iswalnum(__c);
72}72}
7373
74inline _LIBCPP_INLINE_VISIBILITY int iswalpha_l(wint_t c, locale_t) {74inline _LIBCPP_HIDE_FROM_ABI int iswalpha_l(wint_t __c, locale_t) {
75 return ::iswalpha(c);75 return ::iswalpha(__c);
76}76}
7777
78inline _LIBCPP_INLINE_VISIBILITY int iswblank_l(wint_t c, locale_t) {78inline _LIBCPP_HIDE_FROM_ABI int iswblank_l(wint_t __c, locale_t) {
79 return ::iswblank(c);79 return ::iswblank(__c);
80}80}
8181
82inline _LIBCPP_INLINE_VISIBILITY int iswcntrl_l(wint_t c, locale_t) {82inline _LIBCPP_HIDE_FROM_ABI int iswcntrl_l(wint_t __c, locale_t) {
83 return ::iswcntrl(c);83 return ::iswcntrl(__c);
84}84}
8585
86inline _LIBCPP_INLINE_VISIBILITY int iswdigit_l(wint_t c, locale_t) {86inline _LIBCPP_HIDE_FROM_ABI int iswdigit_l(wint_t __c, locale_t) {
87 return ::iswdigit(c);87 return ::iswdigit(__c);
88}88}
8989
90inline _LIBCPP_INLINE_VISIBILITY int iswgraph_l(wint_t c, locale_t) {90inline _LIBCPP_HIDE_FROM_ABI int iswgraph_l(wint_t __c, locale_t) {
91 return ::iswgraph(c);91 return ::iswgraph(__c);
92}92}
9393
94inline _LIBCPP_INLINE_VISIBILITY int iswlower_l(wint_t c, locale_t) {94inline _LIBCPP_HIDE_FROM_ABI int iswlower_l(wint_t __c, locale_t) {
95 return ::iswlower(c);95 return ::iswlower(__c);
96}96}
9797
98inline _LIBCPP_INLINE_VISIBILITY int iswprint_l(wint_t c, locale_t) {98inline _LIBCPP_HIDE_FROM_ABI int iswprint_l(wint_t __c, locale_t) {
99 return ::iswprint(c);99 return ::iswprint(__c);
100}100}
101101
102inline _LIBCPP_INLINE_VISIBILITY int iswpunct_l(wint_t c, locale_t) {102inline _LIBCPP_HIDE_FROM_ABI int iswpunct_l(wint_t __c, locale_t) {
103 return ::iswpunct(c);103 return ::iswpunct(__c);
104}104}
105105
106inline _LIBCPP_INLINE_VISIBILITY int iswspace_l(wint_t c, locale_t) {106inline _LIBCPP_HIDE_FROM_ABI int iswspace_l(wint_t __c, locale_t) {
107 return ::iswspace(c);107 return ::iswspace(__c);
108}108}
109109
110inline _LIBCPP_INLINE_VISIBILITY int iswupper_l(wint_t c, locale_t) {110inline _LIBCPP_HIDE_FROM_ABI int iswupper_l(wint_t __c, locale_t) {
111 return ::iswupper(c);111 return ::iswupper(__c);
112}112}
113113
114inline _LIBCPP_INLINE_VISIBILITY int iswxdigit_l(wint_t c, locale_t) {114inline _LIBCPP_HIDE_FROM_ABI int iswxdigit_l(wint_t __c, locale_t) {
115 return ::iswxdigit(c);115 return ::iswxdigit(__c);
116}116}
117117
118inline _LIBCPP_INLINE_VISIBILITY int toupper_l(int c, locale_t) {118inline _LIBCPP_HIDE_FROM_ABI int toupper_l(int __c, locale_t) {
119 return ::toupper(c);119 return ::toupper(__c);
120}120}
121121
122inline _LIBCPP_INLINE_VISIBILITY int tolower_l(int c, locale_t) {122inline _LIBCPP_HIDE_FROM_ABI int tolower_l(int __c, locale_t) {
123 return ::tolower(c);123 return ::tolower(__c);
124}124}
125125
126inline _LIBCPP_INLINE_VISIBILITY wint_t towupper_l(wint_t c, locale_t) {126inline _LIBCPP_HIDE_FROM_ABI wint_t towupper_l(wint_t __c, locale_t) {
127 return ::towupper(c);127 return ::towupper(__c);
128}128}
129129
130inline _LIBCPP_INLINE_VISIBILITY wint_t towlower_l(wint_t c, locale_t) {130inline _LIBCPP_HIDE_FROM_ABI wint_t towlower_l(wint_t __c, locale_t) {
131 return ::towlower(c);131 return ::towlower(__c);
132}132}
133133
134inline _LIBCPP_INLINE_VISIBILITY int strcoll_l(const char *s1, const char *s2,134inline _LIBCPP_HIDE_FROM_ABI int
135 locale_t) {135strcoll_l(const char *__s1, const char *__s2, locale_t) {
136 return ::strcoll(s1, s2);136 return ::strcoll(__s1, __s2);
137}137}
138138
139inline _LIBCPP_INLINE_VISIBILITY size_t strxfrm_l(char *dest, const char *src,139inline _LIBCPP_HIDE_FROM_ABI size_t
140 size_t n, locale_t) {140strxfrm_l(char *__dest, const char *__src, size_t __n, locale_t) {
141 return ::strxfrm(dest, src, n);141 return ::strxfrm(__dest, __src, __n);
142}142}
143143
144inline _LIBCPP_INLINE_VISIBILITY size_t strftime_l(char *s, size_t max,144inline _LIBCPP_HIDE_FROM_ABI size_t
145 const char *format,145strftime_l(char *__s, size_t __max, const char *__format, const struct tm *__tm,
146 const struct tm *tm, locale_t) {146 locale_t) {
147 return ::strftime(s, max, format, tm);147 return ::strftime(__s, __max, __format, __tm);
148}148}
149149
150inline _LIBCPP_INLINE_VISIBILITY int wcscoll_l(const wchar_t *ws1,150inline _LIBCPP_HIDE_FROM_ABI int
151 const wchar_t *ws2, locale_t) {151wcscoll_l(const wchar_t *__ws1, const wchar_t *__ws2, locale_t) {
152 return ::wcscoll(ws1, ws2);152 return ::wcscoll(__ws1, __ws2);
153}153}
154154
155inline _LIBCPP_INLINE_VISIBILITY size_t wcsxfrm_l(wchar_t *dest, const wchar_t *src,155inline _LIBCPP_HIDE_FROM_ABI size_t
156 size_t n, locale_t) {156wcsxfrm_l(wchar_t *__dest, const wchar_t *__src, size_t __n, locale_t) {
157 return ::wcsxfrm(dest, src, n);157 return ::wcsxfrm(__dest, __src, __n);
158}158}
159159
160#ifdef __cplusplus160#ifdef __cplusplus
lib/libcxx/include/__support/xlocale/__strtonum_fallback.h+24-24
...@@ -19,44 +19,44 @@...@@ -19,44 +19,44 @@
19extern "C" {19extern "C" {
20#endif20#endif
2121
22inline _LIBCPP_INLINE_VISIBILITY float strtof_l(const char *nptr,22inline _LIBCPP_HIDE_FROM_ABI float
23 char **endptr, locale_t) {23strtof_l(const char *__nptr, char **__endptr, locale_t) {
24 return ::strtof(nptr, endptr);24 return ::strtof(__nptr, __endptr);
25}25}
2626
27inline _LIBCPP_INLINE_VISIBILITY double strtod_l(const char *nptr,27inline _LIBCPP_HIDE_FROM_ABI double
28 char **endptr, locale_t) {28strtod_l(const char *__nptr, char **__endptr, locale_t) {
29 return ::strtod(nptr, endptr);29 return ::strtod(__nptr, __endptr);
30}30}
3131
32inline _LIBCPP_INLINE_VISIBILITY long double strtold_l(const char *nptr,32inline _LIBCPP_HIDE_FROM_ABI long double
33 char **endptr, locale_t) {33strtold_l(const char *__nptr, char **__endptr, locale_t) {
34 return ::strtold(nptr, endptr);34 return ::strtold(__nptr, __endptr);
35}35}
3636
37inline _LIBCPP_INLINE_VISIBILITY long long37inline _LIBCPP_HIDE_FROM_ABI long long
38strtoll_l(const char *nptr, char **endptr, int base, locale_t) {38strtoll_l(const char *__nptr, char **__endptr, int __base, locale_t) {
39 return ::strtoll(nptr, endptr, base);39 return ::strtoll(__nptr, __endptr, __base);
40}40}
4141
42inline _LIBCPP_INLINE_VISIBILITY unsigned long long42inline _LIBCPP_HIDE_FROM_ABI unsigned long long
43strtoull_l(const char *nptr, char **endptr, int base, locale_t) {43strtoull_l(const char *__nptr, char **__endptr, int __base, locale_t) {
44 return ::strtoull(nptr, endptr, base);44 return ::strtoull(__nptr, __endptr, __base);
45}45}
4646
47inline _LIBCPP_INLINE_VISIBILITY long long47inline _LIBCPP_HIDE_FROM_ABI long long
48wcstoll_l(const wchar_t *nptr, wchar_t **endptr, int base, locale_t) {48wcstoll_l(const wchar_t *__nptr, wchar_t **__endptr, int __base, locale_t) {
49 return ::wcstoll(nptr, endptr, base);49 return ::wcstoll(__nptr, __endptr, __base);
50}50}
5151
52inline _LIBCPP_INLINE_VISIBILITY unsigned long long52inline _LIBCPP_HIDE_FROM_ABI unsigned long long
53wcstoull_l(const wchar_t *nptr, wchar_t **endptr, int base, locale_t) {53wcstoull_l(const wchar_t *__nptr, wchar_t **__endptr, int __base, locale_t) {
54 return ::wcstoull(nptr, endptr, base);54 return ::wcstoull(__nptr, __endptr, __base);
55}55}
5656
57inline _LIBCPP_INLINE_VISIBILITY long double wcstold_l(const wchar_t *nptr,57inline _LIBCPP_HIDE_FROM_ABI long double
58 wchar_t **endptr, locale_t) {58wcstold_l(const wchar_t *__nptr, wchar_t **__endptr, locale_t) {
59 return ::wcstold(nptr, endptr);59 return ::wcstold(__nptr, __endptr);
60}60}
6161
62#ifdef __cplusplus62#ifdef __cplusplus
lib/libcxx/include/__thread/poll_with_backoff.h+6-2
...@@ -10,11 +10,15 @@...@@ -10,11 +10,15 @@
10#define _LIBCPP___THREAD_POLL_WITH_BACKOFF_H10#define _LIBCPP___THREAD_POLL_WITH_BACKOFF_H
1111
12#include <__availability>12#include <__availability>
13#include <__chrono/duration.h>
14#include <__chrono/high_resolution_clock.h>
15#include <__chrono/steady_clock.h>
16#include <__chrono/time_point.h>
13#include <__config>17#include <__config>
14#include <chrono>18#include <__filesystem/file_time_type.h>
1519
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17#pragma GCC system_header21# pragma GCC system_header
18#endif22#endif
1923
20_LIBCPP_BEGIN_NAMESPACE_STD24_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__thread/timed_backoff_policy.h+3-3
...@@ -13,11 +13,11 @@...@@ -13,11 +13,11 @@
1313
14#ifndef _LIBCPP_HAS_NO_THREADS14#ifndef _LIBCPP_HAS_NO_THREADS
1515
16#include <__threading_support>16# include <__chrono/duration.h>
17#include <chrono>17# include <__threading_support>
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
21#endif21#endif
2222
23_LIBCPP_BEGIN_NAMESPACE_STD23_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__threading_support+17-16
...@@ -7,13 +7,14 @@...@@ -7,13 +7,14 @@
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
99
10#ifndef _LIBCPP_THREADING_SUPPORT10#ifndef _LIBCPP___THREADING_SUPPORT
11#define _LIBCPP_THREADING_SUPPORT11#define _LIBCPP___THREADING_SUPPORT
1212
13#include <__availability>13#include <__availability>
14#include <__chrono/convert_to_timespec.h>
15#include <__chrono/duration.h>
14#include <__config>16#include <__config>
15#include <__thread/poll_with_backoff.h>17#include <__thread/poll_with_backoff.h>
16#include <chrono>
17#include <errno.h>18#include <errno.h>
18#include <iosfwd>19#include <iosfwd>
19#include <limits>20#include <limits>
...@@ -23,7 +24,7 @@...@@ -23,7 +24,7 @@
23#endif24#endif
2425
25#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER26#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
26#pragma GCC system_header27# pragma GCC system_header
27#endif28#endif
2829
29#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)30#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
...@@ -200,15 +201,15 @@ int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv);...@@ -200,15 +201,15 @@ int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv);
200201
201// Execute once202// Execute once
202_LIBCPP_THREAD_ABI_VISIBILITY203_LIBCPP_THREAD_ABI_VISIBILITY
203int __libcpp_execute_once(__libcpp_exec_once_flag *flag,204int __libcpp_execute_once(__libcpp_exec_once_flag *__flag,
204 void (*init_routine)());205 void (*__init_routine)());
205206
206// Thread id207// Thread id
207_LIBCPP_THREAD_ABI_VISIBILITY208_LIBCPP_THREAD_ABI_VISIBILITY
208bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2);209bool __libcpp_thread_id_equal(__libcpp_thread_id __t1, __libcpp_thread_id __t2);
209210
210_LIBCPP_THREAD_ABI_VISIBILITY211_LIBCPP_THREAD_ABI_VISIBILITY
211bool __libcpp_thread_id_less(__libcpp_thread_id t1, __libcpp_thread_id t2);212bool __libcpp_thread_id_less(__libcpp_thread_id __t1, __libcpp_thread_id __t2);
212213
213// Thread214// Thread
214_LIBCPP_THREAD_ABI_VISIBILITY215_LIBCPP_THREAD_ABI_VISIBILITY
...@@ -346,22 +347,22 @@ int __libcpp_condvar_destroy(__libcpp_condvar_t *__cv)...@@ -346,22 +347,22 @@ int __libcpp_condvar_destroy(__libcpp_condvar_t *__cv)
346}347}
347348
348// Execute once349// Execute once
349int __libcpp_execute_once(__libcpp_exec_once_flag *flag,350int __libcpp_execute_once(__libcpp_exec_once_flag *__flag,
350 void (*init_routine)()) {351 void (*__init_routine)()) {
351 return pthread_once(flag, init_routine);352 return pthread_once(__flag, __init_routine);
352}353}
353354
354// Thread id355// Thread id
355// Returns non-zero if the thread ids are equal, otherwise 0356// Returns non-zero if the thread ids are equal, otherwise 0
356bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2)357bool __libcpp_thread_id_equal(__libcpp_thread_id __t1, __libcpp_thread_id __t2)
357{358{
358 return t1 == t2;359 return __t1 == __t2;
359}360}
360361
361// Returns non-zero if t1 < t2, otherwise 0362// Returns non-zero if t1 < t2, otherwise 0
362bool __libcpp_thread_id_less(__libcpp_thread_id t1, __libcpp_thread_id t2)363bool __libcpp_thread_id_less(__libcpp_thread_id __t1, __libcpp_thread_id __t2)
363{364{
364 return t1 < t2;365 return __t1 < __t2;
365}366}
366367
367// Thread368// Thread
...@@ -673,4 +674,4 @@ get_id() _NOEXCEPT...@@ -673,4 +674,4 @@ get_id() _NOEXCEPT
673674
674_LIBCPP_END_NAMESPACE_STD675_LIBCPP_END_NAMESPACE_STD
675676
676#endif // _LIBCPP_THREADING_SUPPORT677#endif // _LIBCPP___THREADING_SUPPORT
lib/libcxx/include/__tree+37-40
...@@ -10,16 +10,22 @@...@@ -10,16 +10,22 @@
10#ifndef _LIBCPP___TREE10#ifndef _LIBCPP___TREE
11#define _LIBCPP___TREE11#define _LIBCPP___TREE
1212
13#include <__algorithm/min.h>
14#include <__assert>
13#include <__config>15#include <__config>
16#include <__debug>
17#include <__iterator/distance.h>
18#include <__iterator/iterator_traits.h>
19#include <__iterator/next.h>
20#include <__memory/swap_allocator.h>
14#include <__utility/forward.h>21#include <__utility/forward.h>
15#include <algorithm>22#include <__utility/swap.h>
16#include <iterator>
17#include <limits>23#include <limits>
18#include <memory>24#include <memory>
19#include <stdexcept>25#include <stdexcept>
2026
21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)27#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
22#pragma GCC system_header28# pragma GCC system_header
23#endif29#endif
2430
25_LIBCPP_PUSH_MACROS31_LIBCPP_PUSH_MACROS
...@@ -28,12 +34,10 @@ _LIBCPP_PUSH_MACROS...@@ -28,12 +34,10 @@ _LIBCPP_PUSH_MACROS
2834
29_LIBCPP_BEGIN_NAMESPACE_STD35_LIBCPP_BEGIN_NAMESPACE_STD
3036
31#if defined(__GNUC__) && !defined(__clang__) // gcc.gnu.org/PR37804
32template <class, class, class, class> class _LIBCPP_TEMPLATE_VIS map;37template <class, class, class, class> class _LIBCPP_TEMPLATE_VIS map;
33template <class, class, class, class> class _LIBCPP_TEMPLATE_VIS multimap;38template <class, class, class, class> class _LIBCPP_TEMPLATE_VIS multimap;
34template <class, class, class> class _LIBCPP_TEMPLATE_VIS set;39template <class, class, class> class _LIBCPP_TEMPLATE_VIS set;
35template <class, class, class> class _LIBCPP_TEMPLATE_VIS multiset;40template <class, class, class> class _LIBCPP_TEMPLATE_VIS multiset;
36#endif
3741
38template <class _Tp, class _Compare, class _Allocator> class __tree;42template <class _Tp, class _Compare, class _Allocator> class __tree;
39template <class _Tp, class _NodePtr, class _DiffType>43template <class _Tp, class _NodePtr, class _DiffType>
...@@ -140,35 +144,35 @@ __tree_invariant(_NodePtr __root)...@@ -140,35 +144,35 @@ __tree_invariant(_NodePtr __root)
140}144}
141145
142// Returns: pointer to the left-most node under __x.146// Returns: pointer to the left-most node under __x.
143// Precondition: __x != nullptr.
144template <class _NodePtr>147template <class _NodePtr>
145inline _LIBCPP_INLINE_VISIBILITY148inline _LIBCPP_INLINE_VISIBILITY
146_NodePtr149_NodePtr
147__tree_min(_NodePtr __x) _NOEXCEPT150__tree_min(_NodePtr __x) _NOEXCEPT
148{151{
152 _LIBCPP_ASSERT(__x != nullptr, "Root node shouldn't be null");
149 while (__x->__left_ != nullptr)153 while (__x->__left_ != nullptr)
150 __x = __x->__left_;154 __x = __x->__left_;
151 return __x;155 return __x;
152}156}
153157
154// Returns: pointer to the right-most node under __x.158// Returns: pointer to the right-most node under __x.
155// Precondition: __x != nullptr.
156template <class _NodePtr>159template <class _NodePtr>
157inline _LIBCPP_INLINE_VISIBILITY160inline _LIBCPP_INLINE_VISIBILITY
158_NodePtr161_NodePtr
159__tree_max(_NodePtr __x) _NOEXCEPT162__tree_max(_NodePtr __x) _NOEXCEPT
160{163{
164 _LIBCPP_ASSERT(__x != nullptr, "Root node shouldn't be null");
161 while (__x->__right_ != nullptr)165 while (__x->__right_ != nullptr)
162 __x = __x->__right_;166 __x = __x->__right_;
163 return __x;167 return __x;
164}168}
165169
166// Returns: pointer to the next in-order node after __x.170// Returns: pointer to the next in-order node after __x.
167// Precondition: __x != nullptr.
168template <class _NodePtr>171template <class _NodePtr>
169_NodePtr172_NodePtr
170__tree_next(_NodePtr __x) _NOEXCEPT173__tree_next(_NodePtr __x) _NOEXCEPT
171{174{
175 _LIBCPP_ASSERT(__x != nullptr, "node shouldn't be null");
172 if (__x->__right_ != nullptr)176 if (__x->__right_ != nullptr)
173 return _VSTD::__tree_min(__x->__right_);177 return _VSTD::__tree_min(__x->__right_);
174 while (!_VSTD::__tree_is_left_child(__x))178 while (!_VSTD::__tree_is_left_child(__x))
...@@ -181,6 +185,7 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -181,6 +185,7 @@ inline _LIBCPP_INLINE_VISIBILITY
181_EndNodePtr185_EndNodePtr
182__tree_next_iter(_NodePtr __x) _NOEXCEPT186__tree_next_iter(_NodePtr __x) _NOEXCEPT
183{187{
188 _LIBCPP_ASSERT(__x != nullptr, "node shouldn't be null");
184 if (__x->__right_ != nullptr)189 if (__x->__right_ != nullptr)
185 return static_cast<_EndNodePtr>(_VSTD::__tree_min(__x->__right_));190 return static_cast<_EndNodePtr>(_VSTD::__tree_min(__x->__right_));
186 while (!_VSTD::__tree_is_left_child(__x))191 while (!_VSTD::__tree_is_left_child(__x))
...@@ -189,13 +194,13 @@ __tree_next_iter(_NodePtr __x) _NOEXCEPT...@@ -189,13 +194,13 @@ __tree_next_iter(_NodePtr __x) _NOEXCEPT
189}194}
190195
191// Returns: pointer to the previous in-order node before __x.196// Returns: pointer to the previous in-order node before __x.
192// Precondition: __x != nullptr.
193// Note: __x may be the end node.197// Note: __x may be the end node.
194template <class _NodePtr, class _EndNodePtr>198template <class _NodePtr, class _EndNodePtr>
195inline _LIBCPP_INLINE_VISIBILITY199inline _LIBCPP_INLINE_VISIBILITY
196_NodePtr200_NodePtr
197__tree_prev_iter(_EndNodePtr __x) _NOEXCEPT201__tree_prev_iter(_EndNodePtr __x) _NOEXCEPT
198{202{
203 _LIBCPP_ASSERT(__x != nullptr, "node shouldn't be null");
199 if (__x->__left_ != nullptr)204 if (__x->__left_ != nullptr)
200 return _VSTD::__tree_max(__x->__left_);205 return _VSTD::__tree_max(__x->__left_);
201 _NodePtr __xx = static_cast<_NodePtr>(__x);206 _NodePtr __xx = static_cast<_NodePtr>(__x);
...@@ -205,11 +210,11 @@ __tree_prev_iter(_EndNodePtr __x) _NOEXCEPT...@@ -205,11 +210,11 @@ __tree_prev_iter(_EndNodePtr __x) _NOEXCEPT
205}210}
206211
207// Returns: pointer to a node which has no children212// Returns: pointer to a node which has no children
208// Precondition: __x != nullptr.
209template <class _NodePtr>213template <class _NodePtr>
210_NodePtr214_NodePtr
211__tree_leaf(_NodePtr __x) _NOEXCEPT215__tree_leaf(_NodePtr __x) _NOEXCEPT
212{216{
217 _LIBCPP_ASSERT(__x != nullptr, "node shouldn't be null");
213 while (true)218 while (true)
214 {219 {
215 if (__x->__left_ != nullptr)220 if (__x->__left_ != nullptr)
...@@ -229,11 +234,12 @@ __tree_leaf(_NodePtr __x) _NOEXCEPT...@@ -229,11 +234,12 @@ __tree_leaf(_NodePtr __x) _NOEXCEPT
229234
230// Effects: Makes __x->__right_ the subtree root with __x as its left child235// Effects: Makes __x->__right_ the subtree root with __x as its left child
231// while preserving in-order order.236// while preserving in-order order.
232// Precondition: __x->__right_ != nullptr
233template <class _NodePtr>237template <class _NodePtr>
234void238void
235__tree_left_rotate(_NodePtr __x) _NOEXCEPT239__tree_left_rotate(_NodePtr __x) _NOEXCEPT
236{240{
241 _LIBCPP_ASSERT(__x != nullptr, "node shouldn't be null");
242 _LIBCPP_ASSERT(__x->__right_ != nullptr, "node should have a right child");
237 _NodePtr __y = __x->__right_;243 _NodePtr __y = __x->__right_;
238 __x->__right_ = __y->__left_;244 __x->__right_ = __y->__left_;
239 if (__x->__right_ != nullptr)245 if (__x->__right_ != nullptr)
...@@ -249,11 +255,12 @@ __tree_left_rotate(_NodePtr __x) _NOEXCEPT...@@ -249,11 +255,12 @@ __tree_left_rotate(_NodePtr __x) _NOEXCEPT
249255
250// Effects: Makes __x->__left_ the subtree root with __x as its right child256// Effects: Makes __x->__left_ the subtree root with __x as its right child
251// while preserving in-order order.257// while preserving in-order order.
252// Precondition: __x->__left_ != nullptr
253template <class _NodePtr>258template <class _NodePtr>
254void259void
255__tree_right_rotate(_NodePtr __x) _NOEXCEPT260__tree_right_rotate(_NodePtr __x) _NOEXCEPT
256{261{
262 _LIBCPP_ASSERT(__x != nullptr, "node shouldn't be null");
263 _LIBCPP_ASSERT(__x->__left_ != nullptr, "node should have a left child");
257 _NodePtr __y = __x->__left_;264 _NodePtr __y = __x->__left_;
258 __x->__left_ = __y->__right_;265 __x->__left_ = __y->__right_;
259 if (__x->__left_ != nullptr)266 if (__x->__left_ != nullptr)
...@@ -268,8 +275,7 @@ __tree_right_rotate(_NodePtr __x) _NOEXCEPT...@@ -268,8 +275,7 @@ __tree_right_rotate(_NodePtr __x) _NOEXCEPT
268}275}
269276
270// Effects: Rebalances __root after attaching __x to a leaf.277// Effects: Rebalances __root after attaching __x to a leaf.
271// Precondition: __root != nulptr && __x != nullptr.278// Precondition: __x has no children.
272// __x has no children.
273// __x == __root or == a direct or indirect child of __root.279// __x == __root or == a direct or indirect child of __root.
274// If __x were to be unlinked from __root (setting __root to280// If __x were to be unlinked from __root (setting __root to
275// nullptr if __root == __x), __tree_invariant(__root) == true.281// nullptr if __root == __x), __tree_invariant(__root) == true.
...@@ -279,6 +285,8 @@ template <class _NodePtr>...@@ -279,6 +285,8 @@ template <class _NodePtr>
279void285void
280__tree_balance_after_insert(_NodePtr __root, _NodePtr __x) _NOEXCEPT286__tree_balance_after_insert(_NodePtr __root, _NodePtr __x) _NOEXCEPT
281{287{
288 _LIBCPP_ASSERT(__root != nullptr, "Root of the tree shouldn't be null");
289 _LIBCPP_ASSERT(__x != nullptr, "Can't attach null node to a leaf");
282 __x->__is_black_ = __x == __root;290 __x->__is_black_ = __x == __root;
283 while (__x != __root && !__x->__parent_unsafe()->__is_black_)291 while (__x != __root && !__x->__parent_unsafe()->__is_black_)
284 {292 {
...@@ -338,9 +346,7 @@ __tree_balance_after_insert(_NodePtr __root, _NodePtr __x) _NOEXCEPT...@@ -338,9 +346,7 @@ __tree_balance_after_insert(_NodePtr __root, _NodePtr __x) _NOEXCEPT
338 }346 }
339}347}
340348
341// Precondition: __root != nullptr && __z != nullptr.349// Precondition: __z == __root or == a direct or indirect child of __root.
342// __tree_invariant(__root) == true.
343// __z == __root or == a direct or indirect child of __root.
344// Effects: unlinks __z from the tree rooted at __root, rebalancing as needed.350// Effects: unlinks __z from the tree rooted at __root, rebalancing as needed.
345// Postcondition: __tree_invariant(end_node->__left_) == true && end_node->__left_351// Postcondition: __tree_invariant(end_node->__left_) == true && end_node->__left_
346// nor any of its children refer to __z. end_node->__left_352// nor any of its children refer to __z. end_node->__left_
...@@ -349,6 +355,9 @@ template <class _NodePtr>...@@ -349,6 +355,9 @@ template <class _NodePtr>
349void355void
350__tree_remove(_NodePtr __root, _NodePtr __z) _NOEXCEPT356__tree_remove(_NodePtr __root, _NodePtr __z) _NOEXCEPT
351{357{
358 _LIBCPP_ASSERT(__root != nullptr, "Root node should not be null");
359 _LIBCPP_ASSERT(__z != nullptr, "The node to remove should not be null");
360 _LIBCPP_DEBUG_ASSERT(__tree_invariant(__root), "The tree invariants should hold");
352 // __z will be removed from the tree. Client still needs to destruct/deallocate it361 // __z will be removed from the tree. Client still needs to destruct/deallocate it
353 // __y is either __z, or if __z has two children, __tree_next(__z).362 // __y is either __z, or if __z has two children, __tree_next(__z).
354 // __y will have at most one child.363 // __y will have at most one child.
...@@ -545,7 +554,7 @@ template <class ..._Args>...@@ -545,7 +554,7 @@ template <class ..._Args>
545struct __is_tree_value_type : false_type {};554struct __is_tree_value_type : false_type {};
546555
547template <class _One>556template <class _One>
548struct __is_tree_value_type<_One> : __is_tree_value_type_imp<typename __uncvref<_One>::type> {};557struct __is_tree_value_type<_One> : __is_tree_value_type_imp<__uncvref_t<_One> > {};
549558
550template <class _Tp>559template <class _Tp>
551struct __tree_key_value_types {560struct __tree_key_value_types {
...@@ -589,8 +598,7 @@ struct __tree_key_value_types<__value_type<_Key, _Tp> > {...@@ -589,8 +598,7 @@ struct __tree_key_value_types<__value_type<_Key, _Tp> > {
589598
590 template <class _Up>599 template <class _Up>
591 _LIBCPP_INLINE_VISIBILITY600 _LIBCPP_INLINE_VISIBILITY
592 static typename enable_if<__is_same_uncvref<_Up, __container_value_type>::value,601 static __enable_if_t<__is_same_uncvref<_Up, __container_value_type>::value, key_type const&>
593 key_type const&>::type
594 __get_key(_Up& __t) {602 __get_key(_Up& __t) {
595 return __t.first;603 return __t.first;
596 }604 }
...@@ -603,8 +611,7 @@ struct __tree_key_value_types<__value_type<_Key, _Tp> > {...@@ -603,8 +611,7 @@ struct __tree_key_value_types<__value_type<_Key, _Tp> > {
603611
604 template <class _Up>612 template <class _Up>
605 _LIBCPP_INLINE_VISIBILITY613 _LIBCPP_INLINE_VISIBILITY
606 static typename enable_if<__is_same_uncvref<_Up, __container_value_type>::value,614 static __enable_if_t<__is_same_uncvref<_Up, __container_value_type>::value, __container_value_type const&>
607 __container_value_type const&>::type
608 __get_value(_Up& __t) {615 __get_value(_Up& __t) {
609 return __t;616 return __t;
610 }617 }
...@@ -1167,10 +1174,8 @@ public:...@@ -1167,10 +1174,8 @@ public:
11671174
1168 template <class _First, class _Second>1175 template <class _First, class _Second>
1169 _LIBCPP_INLINE_VISIBILITY1176 _LIBCPP_INLINE_VISIBILITY
1170 typename enable_if<1177 __enable_if_t<__can_extract_map_key<_First, key_type, __container_value_type>::value, pair<iterator, bool> >
1171 __can_extract_map_key<_First, key_type, __container_value_type>::value,1178 __emplace_unique(_First&& __f, _Second&& __s) {
1172 pair<iterator, bool>
1173 >::type __emplace_unique(_First&& __f, _Second&& __s) {
1174 return __emplace_unique_key_args(__f, _VSTD::forward<_First>(__f),1179 return __emplace_unique_key_args(__f, _VSTD::forward<_First>(__f),
1175 _VSTD::forward<_Second>(__s));1180 _VSTD::forward<_Second>(__s));
1176 }1181 }
...@@ -1211,10 +1216,8 @@ public:...@@ -1211,10 +1216,8 @@ public:
12111216
1212 template <class _First, class _Second>1217 template <class _First, class _Second>
1213 _LIBCPP_INLINE_VISIBILITY1218 _LIBCPP_INLINE_VISIBILITY
1214 typename enable_if<1219 __enable_if_t<__can_extract_map_key<_First, key_type, __container_value_type>::value, iterator>
1215 __can_extract_map_key<_First, key_type, __container_value_type>::value,1220 __emplace_hint_unique(const_iterator __p, _First&& __f, _Second&& __s) {
1216 iterator
1217 >::type __emplace_hint_unique(const_iterator __p, _First&& __f, _Second&& __s) {
1218 return __emplace_hint_unique_key_args(__p, __f,1221 return __emplace_hint_unique_key_args(__p, __f,
1219 _VSTD::forward<_First>(__f),1222 _VSTD::forward<_First>(__f),
1220 _VSTD::forward<_Second>(__s)).first;1223 _VSTD::forward<_Second>(__s)).first;
...@@ -1267,21 +1270,15 @@ public:...@@ -1267,21 +1270,15 @@ public:
1267 return __emplace_hint_unique_key_args(__p, _NodeTypes::__get_key(__v), _VSTD::move(__v)).first;1270 return __emplace_hint_unique_key_args(__p, _NodeTypes::__get_key(__v), _VSTD::move(__v)).first;
1268 }1271 }
12691272
1270 template <class _Vp, class = typename enable_if<1273 template <class _Vp,
1271 !is_same<typename __unconstref<_Vp>::type,1274 class = __enable_if_t<!is_same<typename __unconstref<_Vp>::type, __container_value_type>::value> >
1272 __container_value_type
1273 >::value
1274 >::type>
1275 _LIBCPP_INLINE_VISIBILITY1275 _LIBCPP_INLINE_VISIBILITY
1276 pair<iterator, bool> __insert_unique(_Vp&& __v) {1276 pair<iterator, bool> __insert_unique(_Vp&& __v) {
1277 return __emplace_unique(_VSTD::forward<_Vp>(__v));1277 return __emplace_unique(_VSTD::forward<_Vp>(__v));
1278 }1278 }
12791279
1280 template <class _Vp, class = typename enable_if<1280 template <class _Vp,
1281 !is_same<typename __unconstref<_Vp>::type,1281 class = __enable_if_t<!is_same<typename __unconstref<_Vp>::type, __container_value_type>::value> >
1282 __container_value_type
1283 >::value
1284 >::type>
1285 _LIBCPP_INLINE_VISIBILITY1282 _LIBCPP_INLINE_VISIBILITY
1286 iterator __insert_unique(const_iterator __p, _Vp&& __v) {1283 iterator __insert_unique(const_iterator __p, _Vp&& __v) {
1287 return __emplace_hint_unique(__p, _VSTD::forward<_Vp>(__v));1284 return __emplace_hint_unique(__p, _VSTD::forward<_Vp>(__v));
lib/libcxx/include/__tuple+6-7
...@@ -15,7 +15,7 @@...@@ -15,7 +15,7 @@
15#include <type_traits>15#include <type_traits>
1616
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header18# pragma GCC system_header
19#endif19#endif
2020
2121
...@@ -30,14 +30,14 @@ using __enable_if_tuple_size_imp = _Tp;...@@ -30,14 +30,14 @@ using __enable_if_tuple_size_imp = _Tp;
30template <class _Tp>30template <class _Tp>
31struct _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp<31struct _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp<
32 const _Tp,32 const _Tp,
33 typename enable_if<!is_volatile<_Tp>::value>::type,33 __enable_if_t<!is_volatile<_Tp>::value>,
34 integral_constant<size_t, sizeof(tuple_size<_Tp>)>>>34 integral_constant<size_t, sizeof(tuple_size<_Tp>)>>>
35 : public integral_constant<size_t, tuple_size<_Tp>::value> {};35 : public integral_constant<size_t, tuple_size<_Tp>::value> {};
3636
37template <class _Tp>37template <class _Tp>
38struct _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp<38struct _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp<
39 volatile _Tp,39 volatile _Tp,
40 typename enable_if<!is_const<_Tp>::value>::type,40 __enable_if_t<!is_const<_Tp>::value>,
41 integral_constant<size_t, sizeof(tuple_size<_Tp>)>>>41 integral_constant<size_t, sizeof(tuple_size<_Tp>)>>>
42 : public integral_constant<size_t, tuple_size<_Tp>::value> {};42 : public integral_constant<size_t, tuple_size<_Tp>::value> {};
4343
...@@ -278,7 +278,7 @@ using __type_pack_element _LIBCPP_NODEBUG = typename decltype(...@@ -278,7 +278,7 @@ using __type_pack_element _LIBCPP_NODEBUG = typename decltype(
278#endif278#endif
279279
280template <size_t _Ip, class ..._Types>280template <size_t _Ip, class ..._Types>
281struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, __tuple_types<_Types...>>281struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, __tuple_types<_Types...> >
282{282{
283 static_assert(_Ip < sizeof...(_Types), "tuple_element index out of range");283 static_assert(_Ip < sizeof...(_Types), "tuple_element index out of range");
284 typedef _LIBCPP_NODEBUG __type_pack_element<_Ip, _Types...> type;284 typedef _LIBCPP_NODEBUG __type_pack_element<_Ip, _Types...> type;
...@@ -393,7 +393,7 @@ struct __tuple_sfinae_base {...@@ -393,7 +393,7 @@ struct __tuple_sfinae_base {
393 template <template <class, class...> class _Trait,393 template <template <class, class...> class _Trait,
394 class ..._LArgs, class ..._RArgs>394 class ..._LArgs, class ..._RArgs>
395 static auto __do_test(__tuple_types<_LArgs...>, __tuple_types<_RArgs...>)395 static auto __do_test(__tuple_types<_LArgs...>, __tuple_types<_RArgs...>)
396 -> __all<typename enable_if<_Trait<_LArgs, _RArgs>::value, bool>::type{true}...>;396 -> __all<__enable_if_t<_Trait<_LArgs, _RArgs>::value, bool>{true}...>;
397 template <template <class...> class>397 template <template <class...> class>
398 static auto __do_test(...) -> false_type;398 static auto __do_test(...) -> false_type;
399399
...@@ -469,8 +469,7 @@ template <class _SizeTrait, size_t _Expected>...@@ -469,8 +469,7 @@ template <class _SizeTrait, size_t _Expected>
469struct __tuple_like_with_size_imp<true, _SizeTrait, _Expected>469struct __tuple_like_with_size_imp<true, _SizeTrait, _Expected>
470 : integral_constant<bool, _SizeTrait::value == _Expected> {};470 : integral_constant<bool, _SizeTrait::value == _Expected> {};
471471
472template <class _Tuple, size_t _ExpectedSize,472template <class _Tuple, size_t _ExpectedSize, class _RawTuple = __uncvref_t<_Tuple> >
473 class _RawTuple = typename __uncvref<_Tuple>::type>
474using __tuple_like_with_size _LIBCPP_NODEBUG = __tuple_like_with_size_imp<473using __tuple_like_with_size _LIBCPP_NODEBUG = __tuple_like_with_size_imp<
475 __tuple_like<_RawTuple>::value,474 __tuple_like<_RawTuple>::value,
476 tuple_size<_RawTuple>, _ExpectedSize475 tuple_size<_RawTuple>, _ExpectedSize
lib/libcxx/include/__type_traits/add_const.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___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> struct _LIBCPP_TEMPLATE_VIS add_const {
21 typedef _LIBCPP_NODEBUG const _Tp type;
22};
23
24#if _LIBCPP_STD_VER > 11
25template <class _Tp> using add_const_t = typename add_const<_Tp>::type;
26#endif
27
28_LIBCPP_END_NAMESPACE_STD
29
30#endif // _LIBCPP___TYPE_TRAITS_ADD_CONST_H
lib/libcxx/include/__type_traits/add_cv.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___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> struct _LIBCPP_TEMPLATE_VIS add_cv {
21 typedef _LIBCPP_NODEBUG const volatile _Tp type;
22};
23
24#if _LIBCPP_STD_VER > 11
25template <class _Tp> using add_cv_t = typename add_cv<_Tp>::type;
26#endif
27
28_LIBCPP_END_NAMESPACE_STD
29
30#endif // _LIBCPP___TYPE_TRAITS_ADD_CV_H
lib/libcxx/include/__type_traits/add_lvalue_reference.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___TYPE_TRAITS_ADD_LVALUE_REFERENCE_H
10#define _LIBCPP___TYPE_TRAITS_ADD_LVALUE_REFERENCE_H
11
12#include <__config>
13#include <__type_traits/is_referenceable.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, bool = __is_referenceable<_Tp>::value> struct __add_lvalue_reference_impl { typedef _LIBCPP_NODEBUG _Tp type; };
22template <class _Tp > struct __add_lvalue_reference_impl<_Tp, true> { typedef _LIBCPP_NODEBUG _Tp& type; };
23
24template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_lvalue_reference
25{typedef _LIBCPP_NODEBUG typename __add_lvalue_reference_impl<_Tp>::type type;};
26
27#if _LIBCPP_STD_VER > 11
28template <class _Tp> using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type;
29#endif
30
31_LIBCPP_END_NAMESPACE_STD
32
33#endif // _LIBCPP___TYPE_TRAITS_ADD_LVALUE_REFERENCE_H
lib/libcxx/include/__type_traits/add_pointer.h created+41
...@@ -0,0 +1,41 @@
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_POINTER_H
10#define _LIBCPP___TYPE_TRAITS_ADD_POINTER_H
11
12#include <__config>
13#include <__type_traits/is_referenceable.h>
14#include <__type_traits/is_same.h>
15#include <__type_traits/remove_cv.h>
16#include <__type_traits/remove_reference.h>
17
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header
20#endif
21
22_LIBCPP_BEGIN_NAMESPACE_STD
23
24template <class _Tp,
25 bool = __is_referenceable<_Tp>::value ||
26 _IsSame<typename remove_cv<_Tp>::type, void>::value>
27struct __add_pointer_impl
28 {typedef _LIBCPP_NODEBUG typename remove_reference<_Tp>::type* type;};
29template <class _Tp> struct __add_pointer_impl<_Tp, false>
30 {typedef _LIBCPP_NODEBUG _Tp type;};
31
32template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_pointer
33 {typedef _LIBCPP_NODEBUG typename __add_pointer_impl<_Tp>::type type;};
34
35#if _LIBCPP_STD_VER > 11
36template <class _Tp> using add_pointer_t = typename add_pointer<_Tp>::type;
37#endif
38
39_LIBCPP_END_NAMESPACE_STD
40
41#endif // _LIBCPP___TYPE_TRAITS_ADD_POINTER_H
lib/libcxx/include/__type_traits/add_rvalue_reference.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___TYPE_TRAITS_ADD_RVALUE_REFERENCE_H
10#define _LIBCPP___TYPE_TRAITS_ADD_RVALUE_REFERENCE_H
11
12#include <__config>
13#include <__type_traits/is_referenceable.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, bool = __is_referenceable<_Tp>::value> struct __add_rvalue_reference_impl { typedef _LIBCPP_NODEBUG _Tp type; };
22template <class _Tp > struct __add_rvalue_reference_impl<_Tp, true> { typedef _LIBCPP_NODEBUG _Tp&& type; };
23
24template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_rvalue_reference
25{typedef _LIBCPP_NODEBUG typename __add_rvalue_reference_impl<_Tp>::type type;};
26
27#if _LIBCPP_STD_VER > 11
28template <class _Tp> using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type;
29#endif
30
31_LIBCPP_END_NAMESPACE_STD
32
33#endif // _LIBCPP___TYPE_TRAITS_ADD_RVALUE_REFERENCE_H
lib/libcxx/include/__type_traits/add_volatile.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___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> struct _LIBCPP_TEMPLATE_VIS add_volatile {
21 typedef _LIBCPP_NODEBUG volatile _Tp type;
22};
23
24#if _LIBCPP_STD_VER > 11
25template <class _Tp> using add_volatile_t = typename add_volatile<_Tp>::type;
26#endif
27
28_LIBCPP_END_NAMESPACE_STD
29
30#endif // _LIBCPP___TYPE_TRAITS_ADD_VOLATILE_H
lib/libcxx/include/__type_traits/aligned_storage.h created+142
...@@ -0,0 +1,142 @@
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_ALIGNED_STORAGE_H
10#define _LIBCPP___TYPE_TRAITS_ALIGNED_STORAGE_H
11
12#include <__config>
13#include <__type_traits/conditional.h>
14#include <__type_traits/integral_constant.h>
15#include <__type_traits/nat.h>
16#include <__type_traits/type_list.h>
17#include <cstddef>
18
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20# pragma GCC system_header
21#endif
22
23_LIBCPP_BEGIN_NAMESPACE_STD
24
25template <class _Tp>
26struct __align_type
27{
28 static const size_t value = _LIBCPP_PREFERRED_ALIGNOF(_Tp);
29 typedef _Tp type;
30};
31
32struct __struct_double {long double __lx;};
33struct __struct_double4 {double __lx[4];};
34
35typedef
36 __type_list<__align_type<unsigned char>,
37 __type_list<__align_type<unsigned short>,
38 __type_list<__align_type<unsigned int>,
39 __type_list<__align_type<unsigned long>,
40 __type_list<__align_type<unsigned long long>,
41 __type_list<__align_type<double>,
42 __type_list<__align_type<long double>,
43 __type_list<__align_type<__struct_double>,
44 __type_list<__align_type<__struct_double4>,
45 __type_list<__align_type<int*>,
46 __nat
47 > > > > > > > > > > __all_types;
48
49template <size_t _Align>
50struct _ALIGNAS(_Align) __fallback_overaligned {};
51
52template <class _TL, size_t _Align> struct __find_pod;
53
54template <class _Hp, size_t _Align>
55struct __find_pod<__type_list<_Hp, __nat>, _Align>
56{
57 typedef typename conditional<
58 _Align == _Hp::value,
59 typename _Hp::type,
60 __fallback_overaligned<_Align>
61 >::type type;
62};
63
64template <class _Hp, class _Tp, size_t _Align>
65struct __find_pod<__type_list<_Hp, _Tp>, _Align>
66{
67 typedef typename conditional<
68 _Align == _Hp::value,
69 typename _Hp::type,
70 typename __find_pod<_Tp, _Align>::type
71 >::type type;
72};
73
74template <class _TL, size_t _Len> struct __find_max_align;
75
76template <class _Hp, size_t _Len>
77struct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant<size_t, _Hp::value> {};
78
79template <size_t _Len, size_t _A1, size_t _A2>
80struct __select_align
81{
82private:
83 static const size_t __min = _A2 < _A1 ? _A2 : _A1;
84 static const size_t __max = _A1 < _A2 ? _A2 : _A1;
85public:
86 static const size_t value = _Len < __max ? __min : __max;
87};
88
89template <class _Hp, class _Tp, size_t _Len>
90struct __find_max_align<__type_list<_Hp, _Tp>, _Len>
91 : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {};
92
93template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
94struct _LIBCPP_TEMPLATE_VIS aligned_storage
95{
96 typedef typename __find_pod<__all_types, _Align>::type _Aligner;
97 union type
98 {
99 _Aligner __align;
100 unsigned char __data[(_Len + _Align - 1)/_Align * _Align];
101 };
102};
103
104#if _LIBCPP_STD_VER > 11
105template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
106 using aligned_storage_t = typename aligned_storage<_Len, _Align>::type;
107#endif
108
109#define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \
110template <size_t _Len>\
111struct _LIBCPP_TEMPLATE_VIS aligned_storage<_Len, n>\
112{\
113 struct _ALIGNAS(n) type\
114 {\
115 unsigned char __lx[(_Len + n - 1)/n * n];\
116 };\
117}
118
119_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1);
120_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2);
121_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4);
122_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x8);
123_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x10);
124_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x20);
125_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x40);
126_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x80);
127_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x100);
128_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x200);
129_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x400);
130_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800);
131_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000);
132_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000);
133// PE/COFF does not support alignment beyond 8192 (=0x2000)
134#if !defined(_LIBCPP_OBJECT_FORMAT_COFF)
135_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000);
136#endif // !defined(_LIBCPP_OBJECT_FORMAT_COFF)
137
138#undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION
139
140_LIBCPP_END_NAMESPACE_STD
141
142#endif // _LIBCPP___TYPE_TRAITS_ALIGNED_STORAGE_H
lib/libcxx/include/__type_traits/aligned_union.h created+55
...@@ -0,0 +1,55 @@
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_ALIGNED_UNION_H
10#define _LIBCPP___TYPE_TRAITS_ALIGNED_UNION_H
11
12#include <__config>
13#include <__type_traits/aligned_storage.h>
14#include <__type_traits/integral_constant.h>
15#include <cstddef>
16
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header
19#endif
20
21_LIBCPP_BEGIN_NAMESPACE_STD
22
23template <size_t _I0, size_t ..._In>
24struct __static_max;
25
26template <size_t _I0>
27struct __static_max<_I0>
28{
29 static const size_t value = _I0;
30};
31
32template <size_t _I0, size_t _I1, size_t ..._In>
33struct __static_max<_I0, _I1, _In...>
34{
35 static const size_t value = _I0 >= _I1 ? __static_max<_I0, _In...>::value :
36 __static_max<_I1, _In...>::value;
37};
38
39template <size_t _Len, class _Type0, class ..._Types>
40struct aligned_union
41{
42 static const size_t alignment_value = __static_max<_LIBCPP_PREFERRED_ALIGNOF(_Type0),
43 _LIBCPP_PREFERRED_ALIGNOF(_Types)...>::value;
44 static const size_t __len = __static_max<_Len, sizeof(_Type0),
45 sizeof(_Types)...>::value;
46 typedef typename aligned_storage<__len, alignment_value>::type type;
47};
48
49#if _LIBCPP_STD_VER > 11
50template <size_t _Len, class ..._Types> using aligned_union_t = typename aligned_union<_Len, _Types...>::type;
51#endif
52
53_LIBCPP_END_NAMESPACE_STD
54
55#endif // _LIBCPP___TYPE_TRAITS_ALIGNED_UNION_H
lib/libcxx/include/__type_traits/alignment_of.h created+32
...@@ -0,0 +1,32 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_ALIGNMENT_OF_H
10#define _LIBCPP___TYPE_TRAITS_ALIGNMENT_OF_H
11
12#include <__config>
13#include <__type_traits/integral_constant.h>
14#include <cstddef>
15
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header
18#endif
19
20_LIBCPP_BEGIN_NAMESPACE_STD
21
22template <class _Tp> struct _LIBCPP_TEMPLATE_VIS alignment_of
23 : public integral_constant<size_t, _LIBCPP_ALIGNOF(_Tp)> {};
24
25#if _LIBCPP_STD_VER > 14
26template <class _Tp>
27inline constexpr size_t alignment_of_v = alignment_of<_Tp>::value;
28#endif
29
30_LIBCPP_END_NAMESPACE_STD
31
32#endif // _LIBCPP___TYPE_TRAITS_ALIGNMENT_OF_H
lib/libcxx/include/__type_traits/apply_cv.h created+76
...@@ -0,0 +1,76 @@
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_APPLY_CV_H
10#define _LIBCPP___TYPE_TRAITS_APPLY_CV_H
11
12#include <__config>
13#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_const.h>
15#include <__type_traits/is_volatile.h>
16#include <__type_traits/remove_reference.h>
17#include <cstddef>
18
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20# pragma GCC system_header
21#endif
22
23_LIBCPP_BEGIN_NAMESPACE_STD
24
25template <class _Tp, class _Up, bool = is_const<typename remove_reference<_Tp>::type>::value,
26 bool = is_volatile<typename remove_reference<_Tp>::type>::value>
27struct __apply_cv
28{
29 typedef _LIBCPP_NODEBUG _Up type;
30};
31
32template <class _Tp, class _Up>
33struct __apply_cv<_Tp, _Up, true, false>
34{
35 typedef _LIBCPP_NODEBUG const _Up type;
36};
37
38template <class _Tp, class _Up>
39struct __apply_cv<_Tp, _Up, false, true>
40{
41 typedef volatile _Up type;
42};
43
44template <class _Tp, class _Up>
45struct __apply_cv<_Tp, _Up, true, true>
46{
47 typedef const volatile _Up type;
48};
49
50template <class _Tp, class _Up>
51struct __apply_cv<_Tp&, _Up, false, false>
52{
53 typedef _Up& type;
54};
55
56template <class _Tp, class _Up>
57struct __apply_cv<_Tp&, _Up, true, false>
58{
59 typedef const _Up& type;
60};
61
62template <class _Tp, class _Up>
63struct __apply_cv<_Tp&, _Up, false, true>
64{
65 typedef volatile _Up& type;
66};
67
68template <class _Tp, class _Up>
69struct __apply_cv<_Tp&, _Up, true, true>
70{
71 typedef const volatile _Up& type;
72};
73
74_LIBCPP_END_NAMESPACE_STD
75
76#endif // _LIBCPP___TYPE_TRAITS_APPLY_CV_H
lib/libcxx/include/__type_traits/common_reference.h created+188
...@@ -0,0 +1,188 @@
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_COMMON_REFERENCE_H
10#define _LIBCPP___TYPE_TRAITS_COMMON_REFERENCE_H
11
12#include <__config>
13#include <__type_traits/common_type.h>
14#include <__type_traits/copy_cv.h>
15#include <__type_traits/copy_cvref.h>
16#include <__type_traits/is_convertible.h>
17#include <__type_traits/is_reference.h>
18#include <__type_traits/remove_cv.h>
19#include <__type_traits/remove_cvref.h>
20#include <__type_traits/remove_reference.h>
21#include <__utility/declval.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
29// common_reference
30#if _LIBCPP_STD_VER > 17
31// Let COND_RES(X, Y) be:
32template <class _Xp, class _Yp>
33using __cond_res =
34 decltype(false ? declval<_Xp(&)()>()() : declval<_Yp(&)()>()());
35
36// Let `XREF(A)` denote a unary alias template `T` such that `T<U>` denotes the same type as `U`
37// with the addition of `A`'s cv and reference qualifiers, for a non-reference cv-unqualified type
38// `U`.
39// [Note: `XREF(A)` is `__xref<A>::template __apply`]
40template <class _Tp>
41struct __xref {
42 template<class _Up>
43 using __apply = __copy_cvref_t<_Tp, _Up>;
44};
45
46// Given types A and B, let X be remove_reference_t<A>, let Y be remove_reference_t<B>,
47// and let COMMON-REF(A, B) be:
48template<class _Ap, class _Bp, class _Xp = remove_reference_t<_Ap>, class _Yp = remove_reference_t<_Bp>>
49struct __common_ref;
50
51template<class _Xp, class _Yp>
52using __common_ref_t = typename __common_ref<_Xp, _Yp>::__type;
53
54template<class _Xp, class _Yp>
55using __cv_cond_res = __cond_res<__copy_cv_t<_Xp, _Yp>&, __copy_cv_t<_Yp, _Xp>&>;
56
57
58// If A and B are both lvalue reference types, COMMON-REF(A, B) is
59// COND-RES(COPYCV(X, Y)&, COPYCV(Y, X)&) if that type exists and is a reference type.
60template<class _Ap, class _Bp, class _Xp, class _Yp>
61requires requires { typename __cv_cond_res<_Xp, _Yp>; } && is_reference_v<__cv_cond_res<_Xp, _Yp>>
62struct __common_ref<_Ap&, _Bp&, _Xp, _Yp>
63{
64 using __type = __cv_cond_res<_Xp, _Yp>;
65};
66
67// Otherwise, let C be remove_reference_t<COMMON-REF(X&, Y&)>&&. ...
68template <class _Xp, class _Yp>
69using __common_ref_C = remove_reference_t<__common_ref_t<_Xp&, _Yp&>>&&;
70
71
72// .... 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.
74template<class _Ap, class _Bp, class _Xp, class _Yp>
75requires
76 requires { typename __common_ref_C<_Xp, _Yp>; } &&
77 is_convertible_v<_Ap&&, __common_ref_C<_Xp, _Yp>> &&
78 is_convertible_v<_Bp&&, __common_ref_C<_Xp, _Yp>>
79struct __common_ref<_Ap&&, _Bp&&, _Xp, _Yp>
80{
81 using __type = __common_ref_C<_Xp, _Yp>;
82};
83
84// Otherwise, let D be COMMON-REF(const X&, Y&). ...
85template <class _Tp, class _Up>
86using __common_ref_D = __common_ref_t<const _Tp&, _Up&>;
87
88// ... If A is an rvalue reference and B is an lvalue reference and D is well-formed and
89// is_convertible_v<A, D> is true, then COMMON-REF(A, B) is D.
90template<class _Ap, class _Bp, class _Xp, class _Yp>
91requires requires { typename __common_ref_D<_Xp, _Yp>; } &&
92 is_convertible_v<_Ap&&, __common_ref_D<_Xp, _Yp>>
93struct __common_ref<_Ap&&, _Bp&, _Xp, _Yp>
94{
95 using __type = __common_ref_D<_Xp, _Yp>;
96};
97
98// Otherwise, if A is an lvalue reference and B is an rvalue reference, then
99// COMMON-REF(A, B) is COMMON-REF(B, A).
100template<class _Ap, class _Bp, class _Xp, class _Yp>
101struct __common_ref<_Ap&, _Bp&&, _Xp, _Yp> : __common_ref<_Bp&&, _Ap&> {};
102
103// Otherwise, COMMON-REF(A, B) is ill-formed.
104template<class _Ap, class _Bp, class _Xp, class _Yp>
105struct __common_ref {};
106
107// Note C: For the common_reference trait applied to a parameter pack [...]
108
109template <class...>
110struct common_reference;
111
112template <class... _Types>
113using common_reference_t = typename common_reference<_Types...>::type;
114
115// bullet 1 - sizeof...(T) == 0
116template<>
117struct common_reference<> {};
118
119// bullet 2 - sizeof...(T) == 1
120template <class _Tp>
121struct common_reference<_Tp>
122{
123 using type = _Tp;
124};
125
126// bullet 3 - sizeof...(T) == 2
127template <class _Tp, class _Up> struct __common_reference_sub_bullet3;
128template <class _Tp, class _Up> struct __common_reference_sub_bullet2 : __common_reference_sub_bullet3<_Tp, _Up> {};
129template <class _Tp, class _Up> struct __common_reference_sub_bullet1 : __common_reference_sub_bullet2<_Tp, _Up> {};
130
131// sub-bullet 1 - If T1 and T2 are reference types and COMMON-REF(T1, T2) is well-formed, then
132// the member typedef `type` denotes that type.
133template <class _Tp, class _Up> struct common_reference<_Tp, _Up> : __common_reference_sub_bullet1<_Tp, _Up> {};
134
135template <class _Tp, class _Up>
136requires is_reference_v<_Tp> && is_reference_v<_Up> && requires { typename __common_ref_t<_Tp, _Up>; }
137struct __common_reference_sub_bullet1<_Tp, _Up>
138{
139 using type = __common_ref_t<_Tp, _Up>;
140};
141
142// sub-bullet 2 - Otherwise, if basic_common_reference<remove_cvref_t<T1>, remove_cvref_t<T2>, XREF(T1), XREF(T2)>::type
143// is well-formed, then the member typedef `type` denotes that type.
144template <class, class, template <class> class, template <class> class> struct basic_common_reference {};
145
146template <class _Tp, class _Up>
147using __basic_common_reference_t = typename basic_common_reference<
148 remove_cvref_t<_Tp>, remove_cvref_t<_Up>,
149 __xref<_Tp>::template __apply, __xref<_Up>::template __apply>::type;
150
151template <class _Tp, class _Up>
152requires requires { typename __basic_common_reference_t<_Tp, _Up>; }
153struct __common_reference_sub_bullet2<_Tp, _Up>
154{
155 using type = __basic_common_reference_t<_Tp, _Up>;
156};
157
158// sub-bullet 3 - Otherwise, if COND-RES(T1, T2) is well-formed,
159// then the member typedef `type` denotes that type.
160template <class _Tp, class _Up>
161requires requires { typename __cond_res<_Tp, _Up>; }
162struct __common_reference_sub_bullet3<_Tp, _Up>
163{
164 using type = __cond_res<_Tp, _Up>;
165};
166
167
168// sub-bullet 4 & 5 - Otherwise, if common_type_t<T1, T2> is well-formed,
169// then the member typedef `type` denotes that type.
170// - Otherwise, there shall be no member `type`.
171template <class _Tp, class _Up> struct __common_reference_sub_bullet3 : common_type<_Tp, _Up> {};
172
173// bullet 4 - If there is such a type `C`, the member typedef type shall denote the same type, if
174// any, as `common_reference_t<C, Rest...>`.
175template <class _Tp, class _Up, class _Vp, class... _Rest>
176requires requires { typename common_reference_t<_Tp, _Up>; }
177struct common_reference<_Tp, _Up, _Vp, _Rest...>
178 : common_reference<common_reference_t<_Tp, _Up>, _Vp, _Rest...>
179{};
180
181// bullet 5 - Otherwise, there shall be no member `type`.
182template <class...> struct common_reference {};
183
184#endif // _LIBCPP_STD_VER > 17
185
186_LIBCPP_END_NAMESPACE_STD
187
188#endif // _LIBCPP___TYPE_TRAITS_COMMON_REFERENCE_H
lib/libcxx/include/__type_traits/common_type.h created+138
...@@ -0,0 +1,138 @@
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_COMMON_TYPE_H
10#define _LIBCPP___TYPE_TRAITS_COMMON_TYPE_H
11
12#include <__config>
13#include <__type_traits/conditional.h>
14#include <__type_traits/decay.h>
15#include <__type_traits/is_same.h>
16#include <__type_traits/remove_cvref.h>
17#include <__type_traits/void_t.h>
18#include <__utility/declval.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#if _LIBCPP_STD_VER > 17
27// Let COND_RES(X, Y) be:
28template <class _Tp, class _Up>
29using __cond_type = decltype(false ? declval<_Tp>() : declval<_Up>());
30
31template <class _Tp, class _Up, class = void>
32struct __common_type3 {};
33
34// sub-bullet 4 - "if COND_RES(CREF(D1), CREF(D2)) denotes a type..."
35template <class _Tp, class _Up>
36struct __common_type3<_Tp, _Up, void_t<__cond_type<const _Tp&, const _Up&>>>
37{
38 using type = remove_cvref_t<__cond_type<const _Tp&, const _Up&>>;
39};
40
41template <class _Tp, class _Up, class = void>
42struct __common_type2_imp : __common_type3<_Tp, _Up> {};
43#else
44template <class _Tp, class _Up, class = void>
45struct __common_type2_imp {};
46#endif
47
48// sub-bullet 3 - "if decay_t<decltype(false ? declval<D1>() : declval<D2>())> ..."
49template <class _Tp, class _Up>
50struct __common_type2_imp<_Tp, _Up,
51 typename __void_t<decltype(
52 true ? declval<_Tp>() : declval<_Up>()
53 )>::type>
54{
55 typedef _LIBCPP_NODEBUG typename decay<decltype(
56 true ? declval<_Tp>() : declval<_Up>()
57 )>::type type;
58};
59
60template <class, class = void>
61struct __common_type_impl {};
62
63// Clang provides variadic templates in C++03 as an extension.
64#if !defined(_LIBCPP_CXX03_LANG) || defined(__clang__)
65# define _LIBCPP_OPTIONAL_PACK(...) , __VA_ARGS__
66template <class... _Tp>
67struct __common_types;
68template <class... _Tp>
69struct _LIBCPP_TEMPLATE_VIS common_type;
70#else
71# define _LIBCPP_OPTIONAL_PACK(...)
72struct __no_arg;
73template <class _Tp, class _Up, class = __no_arg>
74struct __common_types;
75template <class _Tp = __no_arg, class _Up = __no_arg, class _Vp = __no_arg,
76 class _Unused = __no_arg>
77struct common_type {
78 static_assert(sizeof(_Unused) == 0,
79 "common_type accepts at most 3 arguments in C++03");
80};
81#endif // _LIBCPP_CXX03_LANG
82
83template <class _Tp, class _Up>
84struct __common_type_impl<
85 __common_types<_Tp, _Up>,
86 typename __void_t<typename common_type<_Tp, _Up>::type>::type>
87{
88 typedef typename common_type<_Tp, _Up>::type type;
89};
90
91template <class _Tp, class _Up, class _Vp _LIBCPP_OPTIONAL_PACK(class... _Rest)>
92struct __common_type_impl<
93 __common_types<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)>,
94 typename __void_t<typename common_type<_Tp, _Up>::type>::type>
95 : __common_type_impl<__common_types<typename common_type<_Tp, _Up>::type,
96 _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)> > {
97};
98
99// bullet 1 - sizeof...(Tp) == 0
100
101template <>
102struct _LIBCPP_TEMPLATE_VIS common_type<> {};
103
104// bullet 2 - sizeof...(Tp) == 1
105
106template <class _Tp>
107struct _LIBCPP_TEMPLATE_VIS common_type<_Tp>
108 : public common_type<_Tp, _Tp> {};
109
110// bullet 3 - sizeof...(Tp) == 2
111
112// sub-bullet 1 - "If is_same_v<T1, D1> is false or ..."
113template <class _Tp, class _Up>
114struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up>
115 : conditional<
116 _IsSame<_Tp, typename decay<_Tp>::type>::value && _IsSame<_Up, typename decay<_Up>::type>::value,
117 __common_type2_imp<_Tp, _Up>,
118 common_type<typename decay<_Tp>::type, typename decay<_Up>::type>
119 >::type
120{};
121
122// bullet 4 - sizeof...(Tp) > 2
123
124template <class _Tp, class _Up, class _Vp _LIBCPP_OPTIONAL_PACK(class... _Rest)>
125struct _LIBCPP_TEMPLATE_VIS
126 common_type<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)>
127 : __common_type_impl<
128 __common_types<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)> > {};
129
130#undef _LIBCPP_OPTIONAL_PACK
131
132#if _LIBCPP_STD_VER > 11
133template <class ..._Tp> using common_type_t = typename common_type<_Tp...>::type;
134#endif
135
136_LIBCPP_END_NAMESPACE_STD
137
138#endif // _LIBCPP___TYPE_TRAITS_COMMON_TYPE_H
lib/libcxx/include/__type_traits/conditional.h created+53
...@@ -0,0 +1,53 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_CONDITIONAL_H
10#define _LIBCPP___TYPE_TRAITS_CONDITIONAL_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 <bool>
21struct _IfImpl;
22
23template <>
24struct _IfImpl<true> {
25 template <class _IfRes, class _ElseRes>
26 using _Select _LIBCPP_NODEBUG = _IfRes;
27};
28
29template <>
30struct _IfImpl<false> {
31 template <class _IfRes, class _ElseRes>
32 using _Select _LIBCPP_NODEBUG = _ElseRes;
33};
34
35template <bool _Cond, class _IfRes, class _ElseRes>
36using _If _LIBCPP_NODEBUG = typename _IfImpl<_Cond>::template _Select<_IfRes, _ElseRes>;
37
38template <bool _Bp, class _If, class _Then>
39 struct _LIBCPP_TEMPLATE_VIS conditional {typedef _If type;};
40template <class _If, class _Then>
41 struct _LIBCPP_TEMPLATE_VIS conditional<false, _If, _Then> {typedef _Then type;};
42
43#if _LIBCPP_STD_VER > 11
44template <bool _Bp, class _IfRes, class _ElseRes>
45using conditional_t = typename conditional<_Bp, _IfRes, _ElseRes>::type;
46#endif
47
48// Helper so we can use "conditional_t" in all language versions.
49template <bool _Bp, class _If, class _Then> using __conditional_t = typename conditional<_Bp, _If, _Then>::type;
50
51_LIBCPP_END_NAMESPACE_STD
52
53#endif // _LIBCPP___TYPE_TRAITS_CONDITIONAL_H
lib/libcxx/include/__type_traits/conjunction.h created+57
...@@ -0,0 +1,57 @@
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_CONJUNCTION_H
10#define _LIBCPP___TYPE_TRAITS_CONJUNCTION_H
11
12#include <__config>
13#include <__type_traits/conditional.h>
14#include <__type_traits/enable_if.h>
15#include <__type_traits/integral_constant.h>
16
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header
19#endif
20
21_LIBCPP_BEGIN_NAMESPACE_STD
22
23#if _LIBCPP_STD_VER > 14
24
25template <class _Arg, class... _Args>
26struct __conjunction_impl {
27 using type = conditional_t<!bool(_Arg::value), _Arg, typename __conjunction_impl<_Args...>::type>;
28};
29
30template <class _Arg>
31struct __conjunction_impl<_Arg> {
32 using type = _Arg;
33};
34
35template <class... _Args>
36struct conjunction : __conjunction_impl<true_type, _Args...>::type {};
37
38template<class... _Args>
39inline constexpr bool conjunction_v = conjunction<_Args...>::value;
40
41#endif // _LIBCPP_STD_VER > 14
42
43template <class...>
44using __expand_to_true = true_type;
45
46template <class... _Pred>
47__expand_to_true<__enable_if_t<_Pred::value>...> __and_helper(int);
48
49template <class...>
50false_type __and_helper(...);
51
52template <class... _Pred>
53using _And _LIBCPP_NODEBUG = decltype(__and_helper<_Pred...>(0));
54
55_LIBCPP_END_NAMESPACE_STD
56
57#endif // _LIBCPP___TYPE_TRAITS_CONJUNCTION_H
lib/libcxx/include/__type_traits/copy_cv.h created+54
...@@ -0,0 +1,54 @@
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_COPY_CV_H
10#define _LIBCPP___TYPE_TRAITS_COPY_CV_H
11
12#include <__config>
13#include <__type_traits/add_const.h>
14#include <__type_traits/add_cv.h>
15#include <__type_traits/add_volatile.h>
16
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header
19#endif
20
21_LIBCPP_BEGIN_NAMESPACE_STD
22
23// Let COPYCV(FROM, TO) be an alias for type TO with the addition of FROM's
24// top-level cv-qualifiers.
25template <class _From, class _To>
26struct __copy_cv
27{
28 using type = _To;
29};
30
31template <class _From, class _To>
32struct __copy_cv<const _From, _To>
33{
34 using type = typename add_const<_To>::type;
35};
36
37template <class _From, class _To>
38struct __copy_cv<volatile _From, _To>
39{
40 using type = typename add_volatile<_To>::type;
41};
42
43template <class _From, class _To>
44struct __copy_cv<const volatile _From, _To>
45{
46 using type = typename add_cv<_To>::type;
47};
48
49template <class _From, class _To>
50using __copy_cv_t = typename __copy_cv<_From, _To>::type;
51
52_LIBCPP_END_NAMESPACE_STD
53
54#endif // _LIBCPP___TYPE_TRAITS_COPY_CV_H
lib/libcxx/include/__type_traits/copy_cvref.h created+46
...@@ -0,0 +1,46 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_COPY_CVREF_H
10#define _LIBCPP___TYPE_TRAITS_COPY_CVREF_H
11
12#include <__config>
13#include <__type_traits/add_lvalue_reference.h>
14#include <__type_traits/add_rvalue_reference.h>
15#include <__type_traits/copy_cv.h>
16
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header
19#endif
20
21_LIBCPP_BEGIN_NAMESPACE_STD
22
23template <class _From, class _To>
24struct __copy_cvref
25{
26 using type = __copy_cv_t<_From, _To>;
27};
28
29template <class _From, class _To>
30struct __copy_cvref<_From&, _To>
31{
32 using type = typename add_lvalue_reference<__copy_cv_t<_From, _To> >::type;
33};
34
35template <class _From, class _To>
36struct __copy_cvref<_From&&, _To>
37{
38 using type = typename add_rvalue_reference<__copy_cv_t<_From, _To> >::type;
39};
40
41template <class _From, class _To>
42using __copy_cvref_t = typename __copy_cvref<_From, _To>::type;
43
44_LIBCPP_END_NAMESPACE_STD
45
46#endif // _LIBCPP___TYPE_TRAITS_COPY_CVREF_H
lib/libcxx/include/__type_traits/decay.h created+65
...@@ -0,0 +1,65 @@
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_DECAY_H
10#define _LIBCPP___TYPE_TRAITS_DECAY_H
11
12#include <__config>
13#include <__type_traits/add_pointer.h>
14#include <__type_traits/conditional.h>
15#include <__type_traits/integral_constant.h>
16#include <__type_traits/is_array.h>
17#include <__type_traits/is_function.h>
18#include <__type_traits/is_referenceable.h>
19#include <__type_traits/remove_cv.h>
20#include <__type_traits/remove_extent.h>
21#include <__type_traits/remove_reference.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 _Up, bool>
30struct __decay {
31 typedef _LIBCPP_NODEBUG typename remove_cv<_Up>::type type;
32};
33
34template <class _Up>
35struct __decay<_Up, true> {
36public:
37 typedef _LIBCPP_NODEBUG typename conditional
38 <
39 is_array<_Up>::value,
40 typename remove_extent<_Up>::type*,
41 typename conditional
42 <
43 is_function<_Up>::value,
44 typename add_pointer<_Up>::type,
45 typename remove_cv<_Up>::type
46 >::type
47 >::type type;
48};
49
50template <class _Tp>
51struct _LIBCPP_TEMPLATE_VIS decay
52{
53private:
54 typedef _LIBCPP_NODEBUG typename remove_reference<_Tp>::type _Up;
55public:
56 typedef _LIBCPP_NODEBUG typename __decay<_Up, __is_referenceable<_Up>::value>::type type;
57};
58
59#if _LIBCPP_STD_VER > 11
60template <class _Tp> using decay_t = typename decay<_Tp>::type;
61#endif
62
63_LIBCPP_END_NAMESPACE_STD
64
65#endif // _LIBCPP___TYPE_TRAITS_DECAY_H
lib/libcxx/include/__type_traits/disjunction.h created+53
...@@ -0,0 +1,53 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_DISJUNCTION_H
10#define _LIBCPP___TYPE_TRAITS_DISJUNCTION_H
11
12#include <__config>
13#include <__type_traits/conditional.h>
14#include <__type_traits/integral_constant.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 <bool>
23struct _OrImpl;
24
25template <>
26struct _OrImpl<true> {
27 template <class _Res, class _First, class... _Rest>
28 using _Result _LIBCPP_NODEBUG =
29 typename _OrImpl<!bool(_First::value) && sizeof...(_Rest) != 0>::template _Result<_First, _Rest...>;
30};
31
32template <>
33struct _OrImpl<false> {
34 template <class _Res, class...>
35 using _Result = _Res;
36};
37
38template <class... _Args>
39using _Or _LIBCPP_NODEBUG = typename _OrImpl<sizeof...(_Args) != 0>::template _Result<false_type, _Args...>;
40
41#if _LIBCPP_STD_VER > 14
42
43template <class... _Args>
44struct disjunction : _Or<_Args...> {};
45
46template <class... _Args>
47inline constexpr bool disjunction_v = _Or<_Args...>::value;
48
49#endif // _LIBCPP_STD_VER > 14
50
51_LIBCPP_END_NAMESPACE_STD
52
53#endif // _LIBCPP___TYPE_TRAITS_DISJUNCTION_H
lib/libcxx/include/__type_traits/enable_if.h created+31
...@@ -0,0 +1,31 @@
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_ENABLE_IF_H
10#define _LIBCPP___TYPE_TRAITS_ENABLE_IF_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 <bool, class _Tp = void> struct _LIBCPP_TEMPLATE_VIS enable_if {};
21template <class _Tp> struct _LIBCPP_TEMPLATE_VIS enable_if<true, _Tp> {typedef _Tp type;};
22
23template <bool _Bp, class _Tp = void> using __enable_if_t _LIBCPP_NODEBUG = typename enable_if<_Bp, _Tp>::type;
24
25#if _LIBCPP_STD_VER > 11
26template <bool _Bp, class _Tp = void> using enable_if_t = typename enable_if<_Bp, _Tp>::type;
27#endif
28
29_LIBCPP_END_NAMESPACE_STD
30
31#endif // _LIBCPP___TYPE_TRAITS_ENABLE_IF_H
lib/libcxx/include/__type_traits/extent.h created+55
...@@ -0,0 +1,55 @@
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_EXTENT_H
10#define _LIBCPP___TYPE_TRAITS_EXTENT_H
11
12#include <__config>
13#include <__type_traits/integral_constant.h>
14#include <cstddef>
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 __has_builtin(__array_extent)
23
24template<class _Tp, size_t _Dim = 0>
25struct _LIBCPP_TEMPLATE_VIS extent
26 : integral_constant<size_t, __array_extent(_Tp, _Dim)> { };
27
28#if _LIBCPP_STD_VER > 14
29template <class _Tp, unsigned _Ip = 0>
30inline constexpr size_t extent_v = __array_extent(_Tp, _Ip);
31#endif
32
33#else // __has_builtin(__array_extent)
34
35template <class _Tp, unsigned _Ip = 0> struct _LIBCPP_TEMPLATE_VIS extent
36 : public integral_constant<size_t, 0> {};
37template <class _Tp> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], 0>
38 : public integral_constant<size_t, 0> {};
39template <class _Tp, unsigned _Ip> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], _Ip>
40 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
41template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], 0>
42 : public integral_constant<size_t, _Np> {};
43template <class _Tp, size_t _Np, unsigned _Ip> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], _Ip>
44 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
45
46#if _LIBCPP_STD_VER > 14
47template <class _Tp, unsigned _Ip = 0>
48inline constexpr size_t extent_v = extent<_Tp, _Ip>::value;
49#endif
50
51#endif // __has_builtin(__array_extent)
52
53_LIBCPP_END_NAMESPACE_STD
54
55#endif // _LIBCPP___TYPE_TRAITS_EXTENT_H
lib/libcxx/include/__type_traits/has_unique_object_representation.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_HAS_UNIQUE_OBJECT_REPRESENTATION_H
10#define _LIBCPP___TYPE_TRAITS_HAS_UNIQUE_OBJECT_REPRESENTATION_H
11
12#include <__config>
13#include <__type_traits/integral_constant.h>
14#include <__type_traits/remove_all_extents.h>
15#include <__type_traits/remove_cv.h>
16
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header
19#endif
20
21_LIBCPP_BEGIN_NAMESPACE_STD
22
23#if _LIBCPP_STD_VER > 14
24
25template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_unique_object_representations
26 : public integral_constant<bool,
27 __has_unique_object_representations(remove_cv_t<remove_all_extents_t<_Tp>>)> {};
28
29template <class _Tp>
30inline constexpr bool has_unique_object_representations_v = has_unique_object_representations<_Tp>::value;
31
32#endif
33
34_LIBCPP_END_NAMESPACE_STD
35
36#endif // _LIBCPP___TYPE_TRAITS_HAS_UNIQUE_OBJECT_REPRESENTATION_H
lib/libcxx/include/__type_traits/has_virtual_destructor.h created+40
...@@ -0,0 +1,40 @@
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_HAS_VIRTUAL_DESTRUCTOR_H
10#define _LIBCPP___TYPE_TRAITS_HAS_VIRTUAL_DESTRUCTOR_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 __has_builtin(__has_virtual_destructor)
22
23template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor
24 : public integral_constant<bool, __has_virtual_destructor(_Tp)> {};
25
26#else
27
28template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor
29 : public false_type {};
30
31#endif
32
33#if _LIBCPP_STD_VER > 14
34template <class _Tp>
35inline constexpr bool has_virtual_destructor_v = has_virtual_destructor<_Tp>::value;
36#endif
37
38_LIBCPP_END_NAMESPACE_STD
39
40#endif // _LIBCPP___TYPE_TRAITS_HAS_VIRTUAL_DESTRUCTOR_H
lib/libcxx/include/__type_traits/integral_constant.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___TYPE_TRAITS_INTEGRAL_CONSTANT_H
10#define _LIBCPP___TYPE_TRAITS_INTEGRAL_CONSTANT_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, _Tp __v>
21struct _LIBCPP_TEMPLATE_VIS integral_constant
22{
23 static _LIBCPP_CONSTEXPR const _Tp value = __v;
24 typedef _Tp value_type;
25 typedef integral_constant type;
26 _LIBCPP_INLINE_VISIBILITY
27 _LIBCPP_CONSTEXPR operator value_type() const _NOEXCEPT {return value;}
28#if _LIBCPP_STD_VER > 11
29 _LIBCPP_INLINE_VISIBILITY
30 constexpr value_type operator ()() const _NOEXCEPT {return value;}
31#endif
32};
33
34template <class _Tp, _Tp __v>
35_LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value;
36
37typedef integral_constant<bool, true> true_type;
38typedef integral_constant<bool, false> false_type;
39
40template <bool _Val>
41using _BoolConstant _LIBCPP_NODEBUG = integral_constant<bool, _Val>;
42
43#if _LIBCPP_STD_VER > 14
44template <bool __b>
45using bool_constant = integral_constant<bool, __b>;
46#endif
47
48_LIBCPP_END_NAMESPACE_STD
49
50#endif // _LIBCPP___TYPE_TRAITS_INTEGRAL_CONSTANT_H
lib/libcxx/include/__type_traits/is_abstract.h created+31
...@@ -0,0 +1,31 @@
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_ABSTRACT_H
10#define _LIBCPP___TYPE_TRAITS_IS_ABSTRACT_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
21template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_abstract
22 : public integral_constant<bool, __is_abstract(_Tp)> {};
23
24#if _LIBCPP_STD_VER > 14
25template <class _Tp>
26inline constexpr bool is_abstract_v = __is_abstract(_Tp);
27#endif
28
29_LIBCPP_END_NAMESPACE_STD
30
31#endif // _LIBCPP___TYPE_TRAITS_IS_ABSTRACT_H
lib/libcxx/include/__type_traits/is_aggregate.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___TYPE_TRAITS_IS_AGGREGATE_H
10#define _LIBCPP___TYPE_TRAITS_IS_AGGREGATE_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 > 14
22
23template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
24is_aggregate : public integral_constant<bool, __is_aggregate(_Tp)> {};
25
26template <class _Tp>
27inline constexpr bool is_aggregate_v = __is_aggregate(_Tp);
28
29#endif // _LIBCPP_STD_VER > 14
30
31_LIBCPP_END_NAMESPACE_STD
32
33#endif // _LIBCPP___TYPE_TRAITS_IS_AGGREGATE_H
lib/libcxx/include/__type_traits/is_arithmetic.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___TYPE_TRAITS_IS_ARITHMETIC_H
10#define _LIBCPP___TYPE_TRAITS_IS_ARITHMETIC_H
11
12#include <__config>
13#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_floating_point.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_LIBCPP_BEGIN_NAMESPACE_STD
22
23template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_arithmetic
24 : public integral_constant<bool, is_integral<_Tp>::value ||
25 is_floating_point<_Tp>::value> {};
26
27#if _LIBCPP_STD_VER > 14
28template <class _Tp>
29inline constexpr bool is_arithmetic_v = is_arithmetic<_Tp>::value;
30#endif
31
32_LIBCPP_END_NAMESPACE_STD
33
34#endif // _LIBCPP___TYPE_TRAITS_IS_ARITHMETIC_H
lib/libcxx/include/__type_traits/is_array.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_IS_ARRAY_H
10#define _LIBCPP___TYPE_TRAITS_IS_ARRAY_H
11
12#include <__config>
13#include <__type_traits/integral_constant.h>
14#include <cstddef>
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// TODO: Clang incorrectly reports that __is_array is true for T[0].
23// Re-enable the branch once https://llvm.org/PR54705 is fixed.
24#if __has_builtin(__is_array) && 0
25
26template <class _Tp>
27struct _LIBCPP_TEMPLATE_VIS is_array : _BoolConstant<__is_array(_Tp)> { };
28
29#if _LIBCPP_STD_VER > 14
30template <class _Tp>
31inline constexpr bool is_array_v = __is_array(_Tp);
32#endif
33
34#else
35
36template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array
37 : public false_type {};
38template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[]>
39 : public true_type {};
40template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[_Np]>
41 : public true_type {};
42
43#if _LIBCPP_STD_VER > 14
44template <class _Tp>
45inline constexpr bool is_array_v = is_array<_Tp>::value;
46#endif
47
48#endif // __has_builtin(__is_array)
49
50_LIBCPP_END_NAMESPACE_STD
51
52#endif // _LIBCPP___TYPE_TRAITS_IS_ARRAY_H
lib/libcxx/include/__type_traits/is_assignable.h created+66
...@@ -0,0 +1,66 @@
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_ASSIGNABLE_H
10#define _LIBCPP___TYPE_TRAITS_IS_ASSIGNABLE_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
21template<typename, typename _Tp> struct __select_2nd { typedef _LIBCPP_NODEBUG _Tp type; };
22
23#if __has_builtin(__is_assignable)
24
25template<class _Tp, class _Up>
26struct _LIBCPP_TEMPLATE_VIS is_assignable : _BoolConstant<__is_assignable(_Tp, _Up)> { };
27
28#if _LIBCPP_STD_VER > 14
29template <class _Tp, class _Arg>
30inline constexpr bool is_assignable_v = __is_assignable(_Tp, _Arg);
31#endif
32
33#else // __has_builtin(__is_assignable)
34
35template <class _Tp, class _Arg>
36typename __select_2nd<decltype((declval<_Tp>() = declval<_Arg>())), true_type>::type
37__is_assignable_test(int);
38
39template <class, class>
40false_type __is_assignable_test(...);
41
42
43template <class _Tp, class _Arg, bool = is_void<_Tp>::value || is_void<_Arg>::value>
44struct __is_assignable_imp
45 : public decltype((_VSTD::__is_assignable_test<_Tp, _Arg>(0))) {};
46
47template <class _Tp, class _Arg>
48struct __is_assignable_imp<_Tp, _Arg, true>
49 : public false_type
50{
51};
52
53template <class _Tp, class _Arg>
54struct is_assignable
55 : public __is_assignable_imp<_Tp, _Arg> {};
56
57#if _LIBCPP_STD_VER > 14
58template <class _Tp, class _Arg>
59inline constexpr bool is_assignable_v = is_assignable<_Tp, _Arg>::value;
60#endif
61
62#endif // __has_builtin(__is_assignable)
63
64_LIBCPP_END_NAMESPACE_STD
65
66#endif // _LIBCPP___TYPE_TRAITS_IS_ASSIGNABLE_H
lib/libcxx/include/__type_traits/is_base_of.h created+32
...@@ -0,0 +1,32 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_IS_BASE_OF_H
10#define _LIBCPP___TYPE_TRAITS_IS_BASE_OF_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
21template <class _Bp, class _Dp>
22struct _LIBCPP_TEMPLATE_VIS is_base_of
23 : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {};
24
25#if _LIBCPP_STD_VER > 14
26template <class _Bp, class _Dp>
27inline constexpr bool is_base_of_v = __is_base_of(_Bp, _Dp);
28#endif
29
30_LIBCPP_END_NAMESPACE_STD
31
32#endif // _LIBCPP___TYPE_TRAITS_IS_BASE_OF_H
lib/libcxx/include/__type_traits/is_bounded_array.h created+38
...@@ -0,0 +1,38 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_IS_BOUNDED_ARRAY_H
10#define _LIBCPP___TYPE_TRAITS_IS_BOUNDED_ARRAY_H
11
12#include <__config>
13#include <__type_traits/integral_constant.h>
14#include <cstddef>
15
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header
18#endif
19
20_LIBCPP_BEGIN_NAMESPACE_STD
21
22template <class> struct _LIBCPP_TEMPLATE_VIS __libcpp_is_bounded_array : false_type {};
23template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS __libcpp_is_bounded_array<_Tp[_Np]> : true_type {};
24
25#if _LIBCPP_STD_VER > 17
26
27template <class> struct _LIBCPP_TEMPLATE_VIS is_bounded_array : false_type {};
28template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS is_bounded_array<_Tp[_Np]> : true_type {};
29
30template <class _Tp>
31inline constexpr
32bool is_bounded_array_v = is_bounded_array<_Tp>::value;
33
34#endif
35
36_LIBCPP_END_NAMESPACE_STD
37
38#endif // _LIBCPP___TYPE_TRAITS_IS_BOUNDED_ARRAY_H
lib/libcxx/include/__type_traits/is_callable.h created+32
...@@ -0,0 +1,32 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_IS_CALLABLE_H
10#define _LIBCPP___TYPE_TRAITS_IS_CALLABLE_H
11
12#include <__config>
13#include <__type_traits/integral_constant.h>
14#include <__utility/declval.h>
15
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header
18#endif
19
20_LIBCPP_BEGIN_NAMESPACE_STD
21
22template<class _Func, class... _Args, class = decltype(std::declval<_Func>()(std::declval<_Args>()...))>
23true_type __is_callable_helper(int);
24template<class...>
25false_type __is_callable_helper(...);
26
27template<class _Func, class... _Args>
28struct __is_callable : decltype(__is_callable_helper<_Func, _Args...>(0)) {};
29
30_LIBCPP_END_NAMESPACE_STD
31
32#endif // _LIBCPP___TYPE_TRAITS_IS_CALLABLE_H
lib/libcxx/include/__type_traits/is_class.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___TYPE_TRAITS_IS_CLASS_H
10#define _LIBCPP___TYPE_TRAITS_IS_CLASS_H
11
12#include <__config>
13#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_union.h>
15#include <__type_traits/remove_cv.h>
16
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header
19#endif
20
21_LIBCPP_BEGIN_NAMESPACE_STD
22
23template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_class
24 : public integral_constant<bool, __is_class(_Tp)> {};
25
26#if _LIBCPP_STD_VER > 14
27template <class _Tp>
28inline constexpr bool is_class_v = __is_class(_Tp);
29#endif
30
31_LIBCPP_END_NAMESPACE_STD
32
33#endif // _LIBCPP___TYPE_TRAITS_IS_CLASS_H
lib/libcxx/include/__type_traits/is_compound.h created+46
...@@ -0,0 +1,46 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_IS_COMPOUND_H
10#define _LIBCPP___TYPE_TRAITS_IS_COMPOUND_H
11
12#include <__config>
13#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_fundamental.h>
15
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header
18#endif
19
20_LIBCPP_BEGIN_NAMESPACE_STD
21
22#if __has_builtin(__is_compound)
23
24template<class _Tp>
25struct _LIBCPP_TEMPLATE_VIS is_compound : _BoolConstant<__is_compound(_Tp)> { };
26
27#if _LIBCPP_STD_VER > 14
28template <class _Tp>
29inline constexpr bool is_compound_v = __is_compound(_Tp);
30#endif
31
32#else // __has_builtin(__is_compound)
33
34template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_compound
35 : public integral_constant<bool, !is_fundamental<_Tp>::value> {};
36
37#if _LIBCPP_STD_VER > 14
38template <class _Tp>
39inline constexpr bool is_compound_v = is_compound<_Tp>::value;
40#endif
41
42#endif // __has_builtin(__is_compound)
43
44_LIBCPP_END_NAMESPACE_STD
45
46#endif // _LIBCPP___TYPE_TRAITS_IS_COMPOUND_H
lib/libcxx/include/__type_traits/is_const.h created+45
...@@ -0,0 +1,45 @@
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_CONST_H
10#define _LIBCPP___TYPE_TRAITS_IS_CONST_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 __has_builtin(__is_const)
22
23template <class _Tp>
24struct _LIBCPP_TEMPLATE_VIS is_const : _BoolConstant<__is_const(_Tp)> { };
25
26#if _LIBCPP_STD_VER > 14
27template <class _Tp>
28inline constexpr bool is_const_v = __is_const(_Tp);
29#endif
30
31#else
32
33template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const : public false_type {};
34template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const<_Tp const> : public true_type {};
35
36#if _LIBCPP_STD_VER > 14
37template <class _Tp>
38inline constexpr bool is_const_v = is_const<_Tp>::value;
39#endif
40
41#endif // __has_builtin(__is_const)
42
43_LIBCPP_END_NAMESPACE_STD
44
45#endif // _LIBCPP___TYPE_TRAITS_IS_CONST_H
lib/libcxx/include/__type_traits/is_constant_evaluated.h created+32
...@@ -0,0 +1,32 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_IS_CONSTANT_EVALUATED_H
10#define _LIBCPP___TYPE_TRAITS_IS_CONSTANT_EVALUATED_H
11
12#include <__config>
13
14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
15# pragma GCC system_header
16#endif
17
18_LIBCPP_BEGIN_NAMESPACE_STD
19
20#if _LIBCPP_STD_VER > 17
21_LIBCPP_INLINE_VISIBILITY
22inline constexpr bool is_constant_evaluated() noexcept {
23 return __builtin_is_constant_evaluated();
24}
25#endif
26
27inline _LIBCPP_CONSTEXPR
28bool __libcpp_is_constant_evaluated() _NOEXCEPT { return __builtin_is_constant_evaluated(); }
29
30_LIBCPP_END_NAMESPACE_STD
31
32#endif // _LIBCPP___TYPE_TRAITS_IS_CONSTANT_EVALUATED_H
lib/libcxx/include/__type_traits/is_constructible.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___TYPE_IS_CONSTRUCTIBLE_H
10#define _LIBCPP___TYPE_IS_CONSTRUCTIBLE_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
21template <class _Tp, class ..._Args>
22struct _LIBCPP_TEMPLATE_VIS is_constructible
23 : public integral_constant<bool, __is_constructible(_Tp, _Args...)>
24{ };
25
26#if _LIBCPP_STD_VER > 14
27template <class _Tp, class ..._Args>
28inline constexpr bool is_constructible_v = is_constructible<_Tp, _Args...>::value;
29#endif
30
31_LIBCPP_END_NAMESPACE_STD
32
33#endif // _LIBCPP___TYPE_IS_CONSTRUCTIBLE_H
lib/libcxx/include/__type_traits/is_convertible.h created+108
...@@ -0,0 +1,108 @@
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_CONVERTIBLE_H
10#define _LIBCPP___TYPE_TRAITS_IS_CONVERTIBLE_H
11
12#include <__config>
13#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_array.h>
15#include <__type_traits/is_function.h>
16#include <__type_traits/is_void.h>
17#include <__type_traits/remove_reference.h>
18#include <__utility/declval.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 __has_builtin(__is_convertible_to) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK)
28
29template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS is_convertible
30 : public integral_constant<bool, __is_convertible_to(_T1, _T2)> {};
31
32#else // __has_builtin(__is_convertible_to) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK)
33
34namespace __is_convertible_imp
35{
36template <class _Tp> void __test_convert(_Tp);
37
38template <class _From, class _To, class = void>
39struct __is_convertible_test : public false_type {};
40
41template <class _From, class _To>
42struct __is_convertible_test<_From, _To,
43 decltype(__is_convertible_imp::__test_convert<_To>(declval<_From>()))> : public true_type
44{};
45
46template <class _Tp, bool _IsArray = is_array<_Tp>::value,
47 bool _IsFunction = is_function<_Tp>::value,
48 bool _IsVoid = is_void<_Tp>::value>
49 struct __is_array_function_or_void {enum {value = 0};};
50template <class _Tp> struct __is_array_function_or_void<_Tp, true, false, false> {enum {value = 1};};
51template <class _Tp> struct __is_array_function_or_void<_Tp, false, true, false> {enum {value = 2};};
52template <class _Tp> struct __is_array_function_or_void<_Tp, false, false, true> {enum {value = 3};};
53}
54
55template <class _Tp,
56 unsigned = __is_convertible_imp::__is_array_function_or_void<typename remove_reference<_Tp>::type>::value>
57struct __is_convertible_check
58{
59 static const size_t __v = 0;
60};
61
62template <class _Tp>
63struct __is_convertible_check<_Tp, 0>
64{
65 static const size_t __v = sizeof(_Tp);
66};
67
68template <class _T1, class _T2,
69 unsigned _T1_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T1>::value,
70 unsigned _T2_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T2>::value>
71struct __is_convertible
72 : public integral_constant<bool,
73 __is_convertible_imp::__is_convertible_test<_T1, _T2>::value
74 >
75{};
76
77template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 1> : public false_type {};
78template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 1> : public false_type {};
79template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 1> : public false_type {};
80template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 1> : public false_type {};
81
82template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 2> : public false_type {};
83template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 2> : public false_type {};
84template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 2> : public false_type {};
85template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 2> : public false_type {};
86
87template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 3> : public false_type {};
88template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 3> : public false_type {};
89template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 3> : public false_type {};
90template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 3> : public true_type {};
91
92template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS is_convertible
93 : public __is_convertible<_T1, _T2>
94{
95 static const size_t __complete_check1 = __is_convertible_check<_T1>::__v;
96 static const size_t __complete_check2 = __is_convertible_check<_T2>::__v;
97};
98
99#endif // __has_builtin(__is_convertible_to) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK)
100
101#if _LIBCPP_STD_VER > 14
102template <class _From, class _To>
103inline constexpr bool is_convertible_v = is_convertible<_From, _To>::value;
104#endif
105
106_LIBCPP_END_NAMESPACE_STD
107
108#endif // _LIBCPP___TYPE_TRAITS_IS_CONVERTIBLE_H
lib/libcxx/include/__type_traits/is_copy_assignable.h created+35
...@@ -0,0 +1,35 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_IS_COPY_ASSIGNABLE_H
10#define _LIBCPP___TYPE_TRAITS_IS_COPY_ASSIGNABLE_H
11
12#include <__config>
13#include <__type_traits/add_const.h>
14#include <__type_traits/add_lvalue_reference.h>
15#include <__type_traits/integral_constant.h>
16#include <__type_traits/is_assignable.h>
17
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header
20#endif
21
22_LIBCPP_BEGIN_NAMESPACE_STD
23
24template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_copy_assignable
25 : public is_assignable<typename add_lvalue_reference<_Tp>::type,
26 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
27
28#if _LIBCPP_STD_VER > 14
29template <class _Tp>
30inline constexpr bool is_copy_assignable_v = is_copy_assignable<_Tp>::value;
31#endif
32
33_LIBCPP_END_NAMESPACE_STD
34
35#endif // _LIBCPP___TYPE_TRAITS_IS_COPY_ASSIGNABLE_H
lib/libcxx/include/__type_traits/is_copy_constructible.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_COPY_CONSTRUCTIBLE_H
10#define _LIBCPP___TYPE_TRAITS_IS_COPY_CONSTRUCTIBLE_H
11
12#include <__config>
13#include <__type_traits/add_const.h>
14#include <__type_traits/add_lvalue_reference.h>
15#include <__type_traits/integral_constant.h>
16#include <__type_traits/is_constructible.h>
17
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header
20#endif
21
22_LIBCPP_BEGIN_NAMESPACE_STD
23
24template <class _Tp>
25struct _LIBCPP_TEMPLATE_VIS is_copy_constructible
26 : public is_constructible<_Tp,
27 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
28
29#if _LIBCPP_STD_VER > 14
30template <class _Tp>
31inline constexpr bool is_copy_constructible_v = is_copy_constructible<_Tp>::value;
32#endif
33
34_LIBCPP_END_NAMESPACE_STD
35
36#endif // _LIBCPP___TYPE_TRAITS_IS_COPY_CONSTRUCTIBLE_H
lib/libcxx/include/__type_traits/is_core_convertible.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_CORE_CONVERTIBLE_H
10#define _LIBCPP___TYPE_TRAITS_IS_CORE_CONVERTIBLE_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// [conv.general]/3 says "E is convertible to T" whenever "T t=E;" is well-formed.
22// We can't test for that, but we can test implicit convertibility by passing it
23// to a function. Notice that __is_core_convertible<void,void> is false,
24// and __is_core_convertible<immovable-type,immovable-type> is true in C++17 and later.
25
26template <class _Tp, class _Up, class = void>
27struct __is_core_convertible : public false_type {};
28
29template <class _Tp, class _Up>
30struct __is_core_convertible<_Tp, _Up, decltype(
31 static_cast<void(*)(_Up)>(0) ( static_cast<_Tp(*)()>(0)() )
32)> : public true_type {};
33
34_LIBCPP_END_NAMESPACE_STD
35
36#endif // _LIBCPP___TYPE_TRAITS_IS_CORE_CONVERTIBLE_H
lib/libcxx/include/__type_traits/is_default_constructible.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___TYPE_TRAITS_IS_DEFAULT_CONSTRUCTIBLE_H
10#define _LIBCPP___TYPE_TRAITS_IS_DEFAULT_CONSTRUCTIBLE_H
11
12#include <__config>
13#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_constructible.h>
15
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header
18#endif
19
20_LIBCPP_BEGIN_NAMESPACE_STD
21
22template <class _Tp>
23struct _LIBCPP_TEMPLATE_VIS is_default_constructible
24 : public is_constructible<_Tp>
25 {};
26
27#if _LIBCPP_STD_VER > 14
28template <class _Tp>
29inline constexpr bool is_default_constructible_v = is_default_constructible<_Tp>::value;
30#endif
31
32_LIBCPP_END_NAMESPACE_STD
33
34#endif // _LIBCPP___TYPE_TRAITS_IS_DEFAULT_CONSTRUCTIBLE_H
lib/libcxx/include/__type_traits/is_destructible.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___TYPE_TRAITS_IS_DESTRUCTIBLE_H
10#define _LIBCPP___TYPE_TRAITS_IS_DESTRUCTIBLE_H
11
12#include <__config>
13#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_function.h>
15#include <__type_traits/is_reference.h>
16#include <__type_traits/remove_all_extents.h>
17#include <__utility/declval.h>
18
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20# pragma GCC system_header
21#endif
22
23_LIBCPP_BEGIN_NAMESPACE_STD
24
25#if __has_builtin(__is_destructible)
26
27template<class _Tp>
28struct _LIBCPP_TEMPLATE_VIS is_destructible : _BoolConstant<__is_destructible(_Tp)> { };
29
30#if _LIBCPP_STD_VER > 14
31template <class _Tp>
32inline constexpr bool is_destructible_v = __is_destructible(_Tp);
33#endif
34
35#else // __has_builtin(__is_destructible)
36
37// if it's a reference, return true
38// if it's a function, return false
39// if it's void, return false
40// if it's an array of unknown bound, return false
41// Otherwise, return "declval<_Up&>().~_Up()" is well-formed
42// where _Up is remove_all_extents<_Tp>::type
43
44template <class>
45struct __is_destructible_apply { typedef int type; };
46
47template <typename _Tp>
48struct __is_destructor_wellformed {
49 template <typename _Tp1>
50 static true_type __test (
51 typename __is_destructible_apply<decltype(declval<_Tp1&>().~_Tp1())>::type
52 );
53
54 template <typename _Tp1>
55 static false_type __test (...);
56
57 static const bool value = decltype(__test<_Tp>(12))::value;
58};
59
60template <class _Tp, bool>
61struct __destructible_imp;
62
63template <class _Tp>
64struct __destructible_imp<_Tp, false>
65 : public integral_constant<bool,
66 __is_destructor_wellformed<typename remove_all_extents<_Tp>::type>::value> {};
67
68template <class _Tp>
69struct __destructible_imp<_Tp, true>
70 : public true_type {};
71
72template <class _Tp, bool>
73struct __destructible_false;
74
75template <class _Tp>
76struct __destructible_false<_Tp, false> : public __destructible_imp<_Tp, is_reference<_Tp>::value> {};
77
78template <class _Tp>
79struct __destructible_false<_Tp, true> : public false_type {};
80
81template <class _Tp>
82struct is_destructible
83 : public __destructible_false<_Tp, is_function<_Tp>::value> {};
84
85template <class _Tp>
86struct is_destructible<_Tp[]>
87 : public false_type {};
88
89template <>
90struct is_destructible<void>
91 : public false_type {};
92
93#if _LIBCPP_STD_VER > 14
94template <class _Tp>
95inline constexpr bool is_destructible_v = is_destructible<_Tp>::value;
96#endif
97
98#endif // __has_builtin(__is_destructible)
99
100_LIBCPP_END_NAMESPACE_STD
101
102#endif // _LIBCPP___TYPE_TRAITS_IS_DESTRUCTIBLE_H
lib/libcxx/include/__type_traits/is_empty.h created+32
...@@ -0,0 +1,32 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_IS_EMPTY_H
10#define _LIBCPP___TYPE_TRAITS_IS_EMPTY_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
21template <class _Tp>
22struct _LIBCPP_TEMPLATE_VIS is_empty
23 : public integral_constant<bool, __is_empty(_Tp)> {};
24
25#if _LIBCPP_STD_VER > 14
26template <class _Tp>
27inline constexpr bool is_empty_v = __is_empty(_Tp);
28#endif
29
30_LIBCPP_END_NAMESPACE_STD
31
32#endif // _LIBCPP___TYPE_TRAITS_IS_EMPTY_H
lib/libcxx/include/__type_traits/is_enum.h created+32
...@@ -0,0 +1,32 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_IS_ENUM_H
10#define _LIBCPP___TYPE_TRAITS_IS_ENUM_H
11
12#include <__config>
13#include <__type_traits/integral_constant.h>
14#include <__type_traits/remove_cv.h>
15
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header
18#endif
19
20_LIBCPP_BEGIN_NAMESPACE_STD
21
22template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum
23 : public integral_constant<bool, __is_enum(_Tp)> {};
24
25#if _LIBCPP_STD_VER > 14
26template <class _Tp>
27inline constexpr bool is_enum_v = __is_enum(_Tp);
28#endif
29
30_LIBCPP_END_NAMESPACE_STD
31
32#endif // _LIBCPP___TYPE_TRAITS_IS_ENUM_H
lib/libcxx/include/__type_traits/is_final.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_FINAL_H
10#define _LIBCPP___TYPE_TRAITS_IS_FINAL_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
21template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
22__libcpp_is_final : public integral_constant<bool, __is_final(_Tp)> {};
23
24#if _LIBCPP_STD_VER > 11
25template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
26is_final : public integral_constant<bool, __is_final(_Tp)> {};
27#endif
28
29#if _LIBCPP_STD_VER > 14
30template <class _Tp>
31inline constexpr bool is_final_v = __is_final(_Tp);
32#endif
33
34_LIBCPP_END_NAMESPACE_STD
35
36#endif // _LIBCPP___TYPE_TRAITS_IS_FINAL_H
lib/libcxx/include/__type_traits/is_floating_point.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___TYPE_TRAITS_IS_FLOATING_POINT_H
10#define _LIBCPP___TYPE_TRAITS_IS_FLOATING_POINT_H
11
12#include <__config>
13#include <__type_traits/integral_constant.h>
14#include <__type_traits/remove_cv.h>
15
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header
18#endif
19
20_LIBCPP_BEGIN_NAMESPACE_STD
21
22template <class _Tp> struct __libcpp_is_floating_point : public false_type {};
23template <> struct __libcpp_is_floating_point<float> : public true_type {};
24template <> struct __libcpp_is_floating_point<double> : public true_type {};
25template <> struct __libcpp_is_floating_point<long double> : public true_type {};
26
27template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_floating_point
28 : public __libcpp_is_floating_point<typename remove_cv<_Tp>::type> {};
29
30#if _LIBCPP_STD_VER > 14
31template <class _Tp>
32inline constexpr bool is_floating_point_v = is_floating_point<_Tp>::value;
33#endif
34
35_LIBCPP_END_NAMESPACE_STD
36
37#endif // _LIBCPP___TYPE_TRAITS_IS_FLOATING_POINT_H
lib/libcxx/include/__type_traits/is_function.h created+43
...@@ -0,0 +1,43 @@
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_FUNCTIONAL_H
10#define _LIBCPP___TYPE_TRAITS_IS_FUNCTIONAL_H
11
12#include <__config>
13#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_const.h>
15#include <__type_traits/is_reference.h>
16
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header
19#endif
20
21_LIBCPP_BEGIN_NAMESPACE_STD
22
23#if __has_builtin(__is_function)
24
25template <class _Tp>
26struct _LIBCPP_TEMPLATE_VIS is_function : integral_constant<bool, __is_function(_Tp)> {};
27
28#else
29
30template <class _Tp>
31struct _LIBCPP_TEMPLATE_VIS is_function
32 : public integral_constant<bool, !(is_reference<_Tp>::value || is_const<const _Tp>::value)> {};
33
34#endif // __has_builtin(__is_function)
35
36#if _LIBCPP_STD_VER > 14
37template <class _Tp>
38inline constexpr bool is_function_v = is_function<_Tp>::value;
39#endif
40
41_LIBCPP_END_NAMESPACE_STD
42
43#endif // _LIBCPP___TYPE_TRAITS_IS_FUNCTIONAL_H
lib/libcxx/include/__type_traits/is_fundamental.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___TYPE_TRAITS_IS_FUNDAMENTAL_H
10#define _LIBCPP___TYPE_TRAITS_IS_FUNDAMENTAL_H
11
12#include <__config>
13#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_null_pointer.h>
15#include <__type_traits/is_void.h>
16
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header
19#endif
20
21_LIBCPP_BEGIN_NAMESPACE_STD
22
23#if __has_builtin(__is_fundamental)
24
25template<class _Tp>
26struct _LIBCPP_TEMPLATE_VIS is_fundamental : _BoolConstant<__is_fundamental(_Tp)> { };
27
28#if _LIBCPP_STD_VER > 14
29template <class _Tp>
30inline constexpr bool is_fundamental_v = __is_fundamental(_Tp);
31#endif
32
33#else // __has_builtin(__is_fundamental)
34
35template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_fundamental
36 : public integral_constant<bool, is_void<_Tp>::value ||
37 __is_nullptr_t<_Tp>::value ||
38 is_arithmetic<_Tp>::value> {};
39
40#if _LIBCPP_STD_VER > 14
41template <class _Tp>
42inline constexpr bool is_fundamental_v = is_fundamental<_Tp>::value;
43#endif
44
45#endif // __has_builtin(__is_fundamental)
46
47_LIBCPP_END_NAMESPACE_STD
48
49#endif // _LIBCPP___TYPE_TRAITS_IS_FUNDAMENTAL_H
lib/libcxx/include/__type_traits/is_integral.h created+72
...@@ -0,0 +1,72 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_IS_INTEGRAL_H
10#define _LIBCPP___TYPE_TRAITS_IS_INTEGRAL_H
11
12#include <__config>
13#include <__type_traits/integral_constant.h>
14#include <__type_traits/remove_cv.h>
15
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header
18#endif
19
20_LIBCPP_BEGIN_NAMESPACE_STD
21
22template <class _Tp> struct __libcpp_is_integral { enum { value = 0 }; };
23template <> struct __libcpp_is_integral<bool> { enum { value = 1 }; };
24template <> struct __libcpp_is_integral<char> { enum { value = 1 }; };
25template <> struct __libcpp_is_integral<signed char> { enum { value = 1 }; };
26template <> struct __libcpp_is_integral<unsigned char> { enum { value = 1 }; };
27#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
28template <> struct __libcpp_is_integral<wchar_t> { enum { value = 1 }; };
29#endif
30#ifndef _LIBCPP_HAS_NO_CHAR8_T
31template <> struct __libcpp_is_integral<char8_t> { enum { value = 1 }; };
32#endif
33template <> struct __libcpp_is_integral<char16_t> { enum { value = 1 }; };
34template <> struct __libcpp_is_integral<char32_t> { enum { value = 1 }; };
35template <> struct __libcpp_is_integral<short> { enum { value = 1 }; };
36template <> struct __libcpp_is_integral<unsigned short> { enum { value = 1 }; };
37template <> struct __libcpp_is_integral<int> { enum { value = 1 }; };
38template <> struct __libcpp_is_integral<unsigned int> { enum { value = 1 }; };
39template <> struct __libcpp_is_integral<long> { enum { value = 1 }; };
40template <> struct __libcpp_is_integral<unsigned long> { enum { value = 1 }; };
41template <> struct __libcpp_is_integral<long long> { enum { value = 1 }; };
42template <> struct __libcpp_is_integral<unsigned long long> { enum { value = 1 }; };
43#ifndef _LIBCPP_HAS_NO_INT128
44template <> struct __libcpp_is_integral<__int128_t> { enum { value = 1 }; };
45template <> struct __libcpp_is_integral<__uint128_t> { enum { value = 1 }; };
46#endif
47
48#if __has_builtin(__is_integral)
49
50template <class _Tp>
51struct _LIBCPP_TEMPLATE_VIS is_integral : _BoolConstant<__is_integral(_Tp)> { };
52
53#if _LIBCPP_STD_VER > 14
54template <class _Tp>
55inline constexpr bool is_integral_v = __is_integral(_Tp);
56#endif
57
58#else
59
60template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_integral
61 : public _BoolConstant<__libcpp_is_integral<typename remove_cv<_Tp>::type>::value> {};
62
63#if _LIBCPP_STD_VER > 14
64template <class _Tp>
65inline constexpr bool is_integral_v = is_integral<_Tp>::value;
66#endif
67
68#endif // __has_builtin(__is_integral)
69
70_LIBCPP_END_NAMESPACE_STD
71
72#endif // _LIBCPP___TYPE_TRAITS_IS_INTEGRAL_H
lib/libcxx/include/__type_traits/is_literal_type.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___TYPE_TRAITS_IS_LITERAL_TYPE
10#define _LIBCPP___TYPE_TRAITS_IS_LITERAL_TYPE
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 <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)
22template <class _Tp> struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 is_literal_type
23 : public integral_constant<bool, __is_literal_type(_Tp)>
24 {};
25
26#if _LIBCPP_STD_VER > 14
27template <class _Tp>
28_LIBCPP_DEPRECATED_IN_CXX17 inline constexpr bool is_literal_type_v = is_literal_type<_Tp>::value;
29#endif // _LIBCPP_STD_VER > 14
30#endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)
31
32_LIBCPP_END_NAMESPACE_STD
33
34#endif // _LIBCPP___TYPE_TRAITS_IS_LITERAL_TYPE
lib/libcxx/include/__type_traits/is_member_function_pointer.h created+64
...@@ -0,0 +1,64 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_IS_MEMBER_FUNCTION_POINTER_H
10#define _LIBCPP___TYPE_TRAITS_IS_MEMBER_FUNCTION_POINTER_H
11
12#include <__config>
13#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_function.h>
15#include <__type_traits/remove_cv.h>
16#include <cstddef>
17
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header
20#endif
21
22_LIBCPP_BEGIN_NAMESPACE_STD
23
24template <class _Tp> struct __libcpp_is_member_pointer {
25 enum {
26 __is_member = false,
27 __is_func = false,
28 __is_obj = false
29 };
30};
31template <class _Tp, class _Up> struct __libcpp_is_member_pointer<_Tp _Up::*> {
32 enum {
33 __is_member = true,
34 __is_func = is_function<_Tp>::value,
35 __is_obj = !__is_func,
36 };
37};
38
39#if __has_builtin(__is_member_function_pointer)
40
41template<class _Tp>
42struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer
43 : _BoolConstant<__is_member_function_pointer(_Tp)> { };
44
45#if _LIBCPP_STD_VER > 14
46template <class _Tp>
47inline constexpr bool is_member_function_pointer_v = __is_member_function_pointer(_Tp);
48#endif
49
50#else // __has_builtin(__is_member_function_pointer)
51
52template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer
53 : public _BoolConstant< __libcpp_is_member_pointer<typename remove_cv<_Tp>::type>::__is_func > {};
54
55#if _LIBCPP_STD_VER > 14
56template <class _Tp>
57inline constexpr bool is_member_function_pointer_v = is_member_function_pointer<_Tp>::value;
58#endif
59
60#endif // __has_builtin(__is_member_function_pointer)
61
62_LIBCPP_END_NAMESPACE_STD
63
64#endif // _LIBCPP___TYPE_TRAITS_IS_MEMBER_FUNCTION_POINTER_H
lib/libcxx/include/__type_traits/is_member_object_pointer.h created+46
...@@ -0,0 +1,46 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_IS_MEMBER_OBJECT_POINTER_H
10#define _LIBCPP___TYPE_TRAITS_IS_MEMBER_OBJECT_POINTER_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 __has_builtin(__is_member_object_pointer)
22
23template<class _Tp>
24struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer
25 : _BoolConstant<__is_member_object_pointer(_Tp)> { };
26
27#if _LIBCPP_STD_VER > 14
28template <class _Tp>
29inline constexpr bool is_member_object_pointer_v = __is_member_object_pointer(_Tp);
30#endif
31
32#else // __has_builtin(__is_member_object_pointer)
33
34template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer
35 : public _BoolConstant< __libcpp_is_member_pointer<typename remove_cv<_Tp>::type>::__is_obj > {};
36
37#if _LIBCPP_STD_VER > 14
38template <class _Tp>
39inline constexpr bool is_member_object_pointer_v = is_member_object_pointer<_Tp>::value;
40#endif
41
42#endif // __has_builtin(__is_member_object_pointer)
43
44_LIBCPP_END_NAMESPACE_STD
45
46#endif // _LIBCPP___TYPE_TRAITS_IS_MEMBER_FUNCTION_POINTER_H
lib/libcxx/include/__type_traits/is_member_pointer.h created+45
...@@ -0,0 +1,45 @@
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_MEMBER_POINTER_H
10#define _LIBCPP___TYPE_TRAITS_IS_MEMBER_POINTER_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 __has_builtin(__is_member_pointer)
22
23template<class _Tp>
24struct _LIBCPP_TEMPLATE_VIS is_member_pointer : _BoolConstant<__is_member_pointer(_Tp)> { };
25
26#if _LIBCPP_STD_VER > 14
27template <class _Tp>
28inline constexpr bool is_member_pointer_v = __is_member_pointer(_Tp);
29#endif
30
31#else // __has_builtin(__is_member_pointer)
32
33template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_pointer
34 : public _BoolConstant< __libcpp_is_member_pointer<typename remove_cv<_Tp>::type>::__is_member > {};
35
36#if _LIBCPP_STD_VER > 14
37template <class _Tp>
38inline constexpr bool is_member_pointer_v = is_member_pointer<_Tp>::value;
39#endif
40
41#endif // __has_builtin(__is_member_pointer)
42
43_LIBCPP_END_NAMESPACE_STD
44
45#endif // _LIBCPP___TYPE_TRAITS_IS_MEMBER_POINTER_H
lib/libcxx/include/__type_traits/is_move_assignable.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_MOVE_ASSIGNABLE_H
10#define _LIBCPP___TYPE_TRAITS_IS_MOVE_ASSIGNABLE_H
11
12#include <__config>
13#include <__type_traits/add_const.h>
14#include <__type_traits/add_lvalue_reference.h>
15#include <__type_traits/add_rvalue_reference.h>
16#include <__type_traits/integral_constant.h>
17#include <__type_traits/is_assignable.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> struct _LIBCPP_TEMPLATE_VIS is_move_assignable
26 : public is_assignable<typename add_lvalue_reference<_Tp>::type,
27 typename add_rvalue_reference<_Tp>::type> {};
28
29#if _LIBCPP_STD_VER > 14
30template <class _Tp>
31inline constexpr bool is_move_assignable_v = is_move_assignable<_Tp>::value;
32#endif
33
34_LIBCPP_END_NAMESPACE_STD
35
36#endif // _LIBCPP___TYPE_TRAITS_IS_MOVE_ASSIGNABLE_H
lib/libcxx/include/__type_traits/is_move_constructible.h created+35
...@@ -0,0 +1,35 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_IS_MOVE_CONSTRUCTIBLE_H
10#define _LIBCPP___TYPE_TRAITS_IS_MOVE_CONSTRUCTIBLE_H
11
12#include <__config>
13#include <__type_traits/add_rvalue_reference.h>
14#include <__type_traits/integral_constant.h>
15#include <__type_traits/is_constructible.h>
16
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header
19#endif
20
21_LIBCPP_BEGIN_NAMESPACE_STD
22
23template <class _Tp>
24struct _LIBCPP_TEMPLATE_VIS is_move_constructible
25 : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
26 {};
27
28#if _LIBCPP_STD_VER > 14
29template <class _Tp>
30inline constexpr bool is_move_constructible_v = is_move_constructible<_Tp>::value;
31#endif
32
33_LIBCPP_END_NAMESPACE_STD
34
35#endif // _LIBCPP___TYPE_TRAITS_IS_MOVE_CONSTRUCTIBLE_H
lib/libcxx/include/__type_traits/is_nothrow_assignable.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___TYPE_TRAITS_IS_NOTHROW_ASSIGNABLE_H
10#define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_ASSIGNABLE_H
11
12#include <__config>
13#include <__type_traits/add_const.h>
14#include <__type_traits/integral_constant.h>
15
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header
18#endif
19
20_LIBCPP_BEGIN_NAMESPACE_STD
21
22#if __has_builtin(__is_nothrow_assignable)
23
24template <class _Tp, class _Arg>
25struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable
26 : public integral_constant<bool, __is_nothrow_assignable(_Tp, _Arg)> {};
27
28#else
29
30template <bool, class _Tp, class _Arg> struct __libcpp_is_nothrow_assignable;
31
32template <class _Tp, class _Arg>
33struct __libcpp_is_nothrow_assignable<false, _Tp, _Arg>
34 : public false_type
35{
36};
37
38template <class _Tp, class _Arg>
39struct __libcpp_is_nothrow_assignable<true, _Tp, _Arg>
40 : public integral_constant<bool, noexcept(declval<_Tp>() = declval<_Arg>()) >
41{
42};
43
44template <class _Tp, class _Arg>
45struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable
46 : public __libcpp_is_nothrow_assignable<is_assignable<_Tp, _Arg>::value, _Tp, _Arg>
47{
48};
49
50#endif // __has_builtin(__is_nothrow_assignable)
51
52#if _LIBCPP_STD_VER > 14
53template <class _Tp, class _Arg>
54inline constexpr bool is_nothrow_assignable_v = is_nothrow_assignable<_Tp, _Arg>::value;
55#endif
56
57_LIBCPP_END_NAMESPACE_STD
58
59#endif // _LIBCPP___TYPE_TRAITS_IS_NOTHROW_ASSIGNABLE_H
lib/libcxx/include/__type_traits/is_nothrow_constructible.h created+75
...@@ -0,0 +1,75 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_IS_NOTHROW_CONSTRUCTIBLE_H
10#define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_CONSTRUCTIBLE_H
11
12#include <__config>
13#include <__type_traits/integral_constant.h>
14#include <__utility/declval.h>
15
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header
18#endif
19
20_LIBCPP_BEGIN_NAMESPACE_STD
21
22#if __has_builtin(__is_nothrow_constructible)
23
24template <class _Tp, class... _Args>
25struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
26 : public integral_constant<bool, __is_nothrow_constructible(_Tp, _Args...)> {};
27
28#else
29
30template <bool, bool, class _Tp, class... _Args> struct __libcpp_is_nothrow_constructible;
31
32template <class _Tp, class... _Args>
33struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/false, _Tp, _Args...>
34 : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))>
35{
36};
37
38template <class _Tp>
39void __implicit_conversion_to(_Tp) noexcept { }
40
41template <class _Tp, class _Arg>
42struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/true, _Tp, _Arg>
43 : public integral_constant<bool, noexcept(_VSTD::__implicit_conversion_to<_Tp>(declval<_Arg>()))>
44{
45};
46
47template <class _Tp, bool _IsReference, class... _Args>
48struct __libcpp_is_nothrow_constructible</*is constructible*/false, _IsReference, _Tp, _Args...>
49 : public false_type
50{
51};
52
53template <class _Tp, class... _Args>
54struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
55 : __libcpp_is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, is_reference<_Tp>::value, _Tp, _Args...>
56{
57};
58
59template <class _Tp, size_t _Ns>
60struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp[_Ns]>
61 : __libcpp_is_nothrow_constructible<is_constructible<_Tp>::value, is_reference<_Tp>::value, _Tp>
62{
63};
64
65#endif // __has_builtin(__is_nothrow_constructible)
66
67
68#if _LIBCPP_STD_VER > 14
69template <class _Tp, class ..._Args>
70inline constexpr bool is_nothrow_constructible_v = is_nothrow_constructible<_Tp, _Args...>::value;
71#endif
72
73_LIBCPP_END_NAMESPACE_STD
74
75#endif // _LIBCPP___TYPE_TRAITS_IS_NOTHROW_CONSTRUCTIBLE_H
lib/libcxx/include/__type_traits/is_nothrow_convertible.h created+53
...@@ -0,0 +1,53 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_IS_NOTHROW_CONVERTIBLE_H
10#define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_CONVERTIBLE_H
11
12#include <__config>
13#include <__type_traits/conjunction.h>
14#include <__type_traits/disjunction.h>
15#include <__type_traits/integral_constant.h>
16#include <__type_traits/is_convertible.h>
17#include <__type_traits/is_void.h>
18#include <__type_traits/lazy.h>
19#include <__utility/declval.h>
20
21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
22# pragma GCC system_header
23#endif
24
25_LIBCPP_BEGIN_NAMESPACE_STD
26
27#if _LIBCPP_STD_VER > 17
28
29template <typename _Tp>
30static void __test_noexcept(_Tp) noexcept;
31
32template<typename _Fm, typename _To>
33static bool_constant<noexcept(_VSTD::__test_noexcept<_To>(declval<_Fm>()))>
34__is_nothrow_convertible_test();
35
36template <typename _Fm, typename _To>
37struct __is_nothrow_convertible_helper: decltype(__is_nothrow_convertible_test<_Fm, _To>())
38{ };
39
40template <typename _Fm, typename _To>
41struct is_nothrow_convertible : _Or<
42 _And<is_void<_To>, is_void<_Fm>>,
43 _Lazy<_And, is_convertible<_Fm, _To>, __is_nothrow_convertible_helper<_Fm, _To>>
44>::type { };
45
46template <typename _Fm, typename _To>
47inline constexpr bool is_nothrow_convertible_v = is_nothrow_convertible<_Fm, _To>::value;
48
49#endif // _LIBCPP_STD_VER > 17
50
51_LIBCPP_END_NAMESPACE_STD
52
53#endif // _LIBCPP___TYPE_TRAITS_IS_NOTHROW_CONVERTIBLE_H
lib/libcxx/include/__type_traits/is_nothrow_copy_assignable.h created+35
...@@ -0,0 +1,35 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_IS_NOTHROW_COPY_ASSIGNABLE_H
10#define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_COPY_ASSIGNABLE_H
11
12#include <__config>
13#include <__type_traits/add_const.h>
14#include <__type_traits/add_lvalue_reference.h>
15#include <__type_traits/integral_constant.h>
16#include <__type_traits/is_nothrow_assignable.h>
17
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header
20#endif
21
22_LIBCPP_BEGIN_NAMESPACE_STD
23
24template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_assignable
25 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
26 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
27
28#if _LIBCPP_STD_VER > 14
29template <class _Tp>
30inline constexpr bool is_nothrow_copy_assignable_v = is_nothrow_copy_assignable<_Tp>::value;
31#endif
32
33_LIBCPP_END_NAMESPACE_STD
34
35#endif // _LIBCPP___TYPE_TRAITS_IS_NOTHROW_COPY_ASSIGNABLE_H
lib/libcxx/include/__type_traits/is_nothrow_copy_constructible.h created+35
...@@ -0,0 +1,35 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_IS_NOTHROW_COPY_CONSTRUCTIBLE_H
10#define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_COPY_CONSTRUCTIBLE_H
11
12#include <__config>
13#include <__type_traits/add_const.h>
14#include <__type_traits/add_lvalue_reference.h>
15#include <__type_traits/integral_constant.h>
16#include <__type_traits/is_nothrow_constructible.h>
17
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header
20#endif
21
22_LIBCPP_BEGIN_NAMESPACE_STD
23
24template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_constructible
25 : public is_nothrow_constructible<_Tp,
26 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
27
28#if _LIBCPP_STD_VER > 14
29template <class _Tp>
30inline constexpr bool is_nothrow_copy_constructible_v = is_nothrow_copy_constructible<_Tp>::value;
31#endif
32
33_LIBCPP_END_NAMESPACE_STD
34
35#endif // _LIBCPP___TYPE_TRAITS_IS_NOTHROW_COPY_CONSTRUCTIBLE_H
lib/libcxx/include/__type_traits/is_nothrow_default_constructible.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___TYPE_TRAITS_IS_NOTHROW_DEFAULT_CONSTRUCTIBLE_H
10#define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_DEFAULT_CONSTRUCTIBLE_H
11
12#include <__config>
13#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_nothrow_constructible.h>
15
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header
18#endif
19
20_LIBCPP_BEGIN_NAMESPACE_STD
21
22template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_default_constructible
23 : public is_nothrow_constructible<_Tp>
24 {};
25
26#if _LIBCPP_STD_VER > 14
27template <class _Tp>
28inline constexpr bool is_nothrow_default_constructible_v = is_nothrow_default_constructible<_Tp>::value;
29#endif
30
31_LIBCPP_END_NAMESPACE_STD
32
33#endif // _LIBCPP___TYPE_TRAITS_IS_NOTHROW_DEFAULT_CONSTRUCTIBLE_H
lib/libcxx/include/__type_traits/is_nothrow_destructible.h created+90
...@@ -0,0 +1,90 @@
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_NOTHROW_DESTRUCTIBLE_H
10#define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_DESTRUCTIBLE_H
11
12#include <__config>
13#include <__type_traits/add_const.h>
14#include <__type_traits/integral_constant.h>
15#include <__type_traits/is_destructible.h>
16#include <__type_traits/is_reference.h>
17#include <__type_traits/is_scalar.h>
18#include <__type_traits/remove_all_extents.h>
19#include <__utility/declval.h>
20#include <cstddef>
21
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23# pragma GCC system_header
24#endif
25
26_LIBCPP_BEGIN_NAMESPACE_STD
27
28#if !defined(_LIBCPP_CXX03_LANG)
29
30template <bool, class _Tp> struct __libcpp_is_nothrow_destructible;
31
32template <class _Tp>
33struct __libcpp_is_nothrow_destructible<false, _Tp>
34 : public false_type
35{
36};
37
38template <class _Tp>
39struct __libcpp_is_nothrow_destructible<true, _Tp>
40 : public integral_constant<bool, noexcept(declval<_Tp>().~_Tp()) >
41{
42};
43
44template <class _Tp>
45struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible
46 : public __libcpp_is_nothrow_destructible<is_destructible<_Tp>::value, _Tp>
47{
48};
49
50template <class _Tp, size_t _Ns>
51struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[_Ns]>
52 : public is_nothrow_destructible<_Tp>
53{
54};
55
56template <class _Tp>
57struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&>
58 : public true_type
59{
60};
61
62template <class _Tp>
63struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&&>
64 : public true_type
65{
66};
67
68#else
69
70template <class _Tp> struct __libcpp_nothrow_destructor
71 : public integral_constant<bool, is_scalar<_Tp>::value ||
72 is_reference<_Tp>::value> {};
73
74template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible
75 : public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {};
76
77template <class _Tp>
78struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[]>
79 : public false_type {};
80
81#endif
82
83#if _LIBCPP_STD_VER > 14
84template <class _Tp>
85inline constexpr bool is_nothrow_destructible_v = is_nothrow_destructible<_Tp>::value;
86#endif
87
88_LIBCPP_END_NAMESPACE_STD
89
90#endif // _LIBCPP___TYPE_TRAITS_IS_NOTHROW_DESTRUCTIBLE_H
lib/libcxx/include/__type_traits/is_nothrow_move_assignable.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_NOTHROW_MOVE_ASSIGNABLE_H
10#define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_MOVE_ASSIGNABLE_H
11
12#include <__config>
13#include <__type_traits/add_lvalue_reference.h>
14#include <__type_traits/add_rvalue_reference.h>
15#include <__type_traits/integral_constant.h>
16#include <__type_traits/is_nothrow_assignable.h>
17
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header
20#endif
21
22_LIBCPP_BEGIN_NAMESPACE_STD
23
24template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_assignable
25 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
26 typename add_rvalue_reference<_Tp>::type>
27 {};
28
29#if _LIBCPP_STD_VER > 14
30template <class _Tp>
31inline constexpr bool is_nothrow_move_assignable_v = is_nothrow_move_assignable<_Tp>::value;
32#endif
33
34_LIBCPP_END_NAMESPACE_STD
35
36#endif // _LIBCPP___TYPE_TRAITS_IS_NOTHROW_MOVE_ASSIGNABLE_H
lib/libcxx/include/__type_traits/is_nothrow_move_constructible.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___TYPE_TRAITS_IS_NOTHROW_MOVE_CONSTRUCTIBLE_H
10#define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_MOVE_CONSTRUCTIBLE_H
11
12#include <__config>
13#include <__type_traits/add_rvalue_reference.h>
14#include <__type_traits/integral_constant.h>
15#include <__type_traits/is_nothrow_constructible.h>
16
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header
19#endif
20
21_LIBCPP_BEGIN_NAMESPACE_STD
22
23template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_constructible
24 : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
25 {};
26
27#if _LIBCPP_STD_VER > 14
28template <class _Tp>
29inline constexpr bool is_nothrow_move_constructible_v = is_nothrow_move_constructible<_Tp>::value;
30#endif
31
32_LIBCPP_END_NAMESPACE_STD
33
34#endif // _LIBCPP___TYPE_TRAITS_IS_NOTHROW_MOVE_CONSTRUCTIBLE_H
lib/libcxx/include/__type_traits/is_null_pointer.h created+41
...@@ -0,0 +1,41 @@
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_NULL_POINTER_H
10#define _LIBCPP___TYPE_TRAITS_IS_NULL_POINTER_H
11
12#include <__config>
13#include <__type_traits/integral_constant.h>
14#include <__type_traits/remove_cv.h>
15#include <cstddef>
16
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header
19#endif
20
21_LIBCPP_BEGIN_NAMESPACE_STD
22
23template <class _Tp> struct __is_nullptr_t_impl : public false_type {};
24template <> struct __is_nullptr_t_impl<nullptr_t> : public true_type {};
25
26template <class _Tp> struct _LIBCPP_TEMPLATE_VIS __is_nullptr_t
27 : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
28
29#if _LIBCPP_STD_VER > 11
30template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_null_pointer
31 : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
32
33#if _LIBCPP_STD_VER > 14
34template <class _Tp>
35inline constexpr bool is_null_pointer_v = is_null_pointer<_Tp>::value;
36#endif
37#endif // _LIBCPP_STD_VER > 11
38
39_LIBCPP_END_NAMESPACE_STD
40
41#endif // _LIBCPP___TYPE_TRAITS_IS_NULL_POINTER_H
lib/libcxx/include/__type_traits/is_object.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_IS_OBJECT_H
10#define _LIBCPP___TYPE_TRAITS_IS_OBJECT_H
11
12#include <__config>
13#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_array.h>
15#include <__type_traits/is_class.h>
16#include <__type_traits/is_scalar.h>
17#include <__type_traits/is_union.h>
18
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20# pragma GCC system_header
21#endif
22
23_LIBCPP_BEGIN_NAMESPACE_STD
24
25#if __has_builtin(__is_object)
26
27template<class _Tp>
28struct _LIBCPP_TEMPLATE_VIS is_object : _BoolConstant<__is_object(_Tp)> { };
29
30#if _LIBCPP_STD_VER > 14
31template <class _Tp>
32inline constexpr bool is_object_v = __is_object(_Tp);
33#endif
34
35#else // __has_builtin(__is_object)
36
37template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_object
38 : public integral_constant<bool, is_scalar<_Tp>::value ||
39 is_array<_Tp>::value ||
40 is_union<_Tp>::value ||
41 is_class<_Tp>::value > {};
42
43#if _LIBCPP_STD_VER > 14
44template <class _Tp>
45inline constexpr bool is_object_v = is_object<_Tp>::value;
46#endif
47
48#endif // __has_builtin(__is_object)
49
50_LIBCPP_END_NAMESPACE_STD
51
52#endif // _LIBCPP___TYPE_TRAITS_IS_OBJECT_H
lib/libcxx/include/__type_traits/is_pod.h created+43
...@@ -0,0 +1,43 @@
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_POD_H
10#define _LIBCPP___TYPE_TRAITS_IS_POD_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 __has_builtin(__is_pod)
22
23template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod
24 : public integral_constant<bool, __is_pod(_Tp)> {};
25
26#else
27
28template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod
29 : public integral_constant<bool, is_trivially_default_constructible<_Tp>::value &&
30 is_trivially_copy_constructible<_Tp>::value &&
31 is_trivially_copy_assignable<_Tp>::value &&
32 is_trivially_destructible<_Tp>::value> {};
33
34#endif // __has_builtin(__is_pod)
35
36#if _LIBCPP_STD_VER > 14
37template <class _Tp>
38inline constexpr bool is_pod_v = is_pod<_Tp>::value;
39#endif
40
41_LIBCPP_END_NAMESPACE_STD
42
43#endif // _LIBCPP___TYPE_TRAITS_IS_POD_H
lib/libcxx/include/__type_traits/is_pointer.h created+57
...@@ -0,0 +1,57 @@
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_POINTER_H
10#define _LIBCPP___TYPE_TRAITS_IS_POINTER_H
11
12#include <__config>
13#include <__type_traits/integral_constant.h>
14#include <__type_traits/remove_cv.h>
15
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header
18#endif
19
20_LIBCPP_BEGIN_NAMESPACE_STD
21
22#if __has_builtin(__is_pointer)
23
24template<class _Tp>
25struct _LIBCPP_TEMPLATE_VIS is_pointer : _BoolConstant<__is_pointer(_Tp)> { };
26
27#if _LIBCPP_STD_VER > 14
28template <class _Tp>
29inline constexpr bool is_pointer_v = __is_pointer(_Tp);
30#endif
31
32#else // __has_builtin(__is_pointer)
33
34template <class _Tp> struct __libcpp_is_pointer : public false_type {};
35template <class _Tp> struct __libcpp_is_pointer<_Tp*> : public true_type {};
36
37template <class _Tp> struct __libcpp_remove_objc_qualifiers { typedef _Tp type; };
38#if defined(_LIBCPP_HAS_OBJC_ARC)
39template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __strong> { typedef _Tp type; };
40template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __weak> { typedef _Tp type; };
41template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __autoreleasing> { typedef _Tp type; };
42template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __unsafe_unretained> { typedef _Tp type; };
43#endif
44
45template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pointer
46 : public __libcpp_is_pointer<typename __libcpp_remove_objc_qualifiers<typename remove_cv<_Tp>::type>::type> {};
47
48#if _LIBCPP_STD_VER > 14
49template <class _Tp>
50inline constexpr bool is_pointer_v = is_pointer<_Tp>::value;
51#endif
52
53#endif // __has_builtin(__is_pointer)
54
55_LIBCPP_END_NAMESPACE_STD
56
57#endif // _LIBCPP___TYPE_TRAITS_IS_POINTER_H
lib/libcxx/include/__type_traits/is_polymorphic.h created+32
...@@ -0,0 +1,32 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_IS_POLYMORPHIC_H
10#define _LIBCPP___TYPE_TRAITS_IS_POLYMORPHIC_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
21template <class _Tp>
22struct _LIBCPP_TEMPLATE_VIS is_polymorphic
23 : public integral_constant<bool, __is_polymorphic(_Tp)> {};
24
25#if _LIBCPP_STD_VER > 14
26template <class _Tp>
27inline constexpr bool is_polymorphic_v = __is_polymorphic(_Tp);
28#endif
29
30_LIBCPP_END_NAMESPACE_STD
31
32#endif // _LIBCPP___TYPE_TRAITS_IS_POLYMORPHIC_H
lib/libcxx/include/__type_traits/is_primary_template.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___TYPE_TRAITS_IS_PRIMARY_TEMPLATE_H
10#define _LIBCPP___TYPE_TRAITS_IS_PRIMARY_TEMPLATE_H
11
12#include <__config>
13#include <__type_traits/enable_if.h>
14#include <__type_traits/is_same.h>
15#include <__type_traits/is_valid_expansion.h>
16
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header
19#endif
20
21_LIBCPP_BEGIN_NAMESPACE_STD
22
23template <class _Tp>
24using __test_for_primary_template = __enable_if_t<
25 _IsSame<_Tp, typename _Tp::__primary_template>::value
26 >;
27template <class _Tp>
28using __is_primary_template = _IsValidExpansion<
29 __test_for_primary_template, _Tp
30 >;
31
32_LIBCPP_END_NAMESPACE_STD
33
34#endif // _LIBCPP___TYPE_TRAITS_IS_PRIMARY_TEMPLATE_H
lib/libcxx/include/__type_traits/is_reference.h created+70
...@@ -0,0 +1,70 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_IS_REFERENCE_H
10#define _LIBCPP___TYPE_TRAITS_IS_REFERENCE_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 __has_builtin(__is_lvalue_reference) && \
22 __has_builtin(__is_rvalue_reference) && \
23 __has_builtin(__is_reference)
24
25template<class _Tp>
26struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : _BoolConstant<__is_lvalue_reference(_Tp)> { };
27
28template<class _Tp>
29struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : _BoolConstant<__is_rvalue_reference(_Tp)> { };
30
31template<class _Tp>
32struct _LIBCPP_TEMPLATE_VIS is_reference : _BoolConstant<__is_reference(_Tp)> { };
33
34#if _LIBCPP_STD_VER > 14
35template <class _Tp>
36inline constexpr bool is_reference_v = __is_reference(_Tp);
37template <class _Tp>
38inline constexpr bool is_lvalue_reference_v = __is_lvalue_reference(_Tp);
39template <class _Tp>
40inline constexpr bool is_rvalue_reference_v = __is_rvalue_reference(_Tp);
41#endif
42
43#else // __has_builtin(__is_lvalue_reference) && etc...
44
45template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : public false_type {};
46template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference<_Tp&> : public true_type {};
47
48template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : public false_type {};
49template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference<_Tp&&> : public true_type {};
50
51template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference : public false_type {};
52template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&> : public true_type {};
53template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&&> : public true_type {};
54
55#if _LIBCPP_STD_VER > 14
56template <class _Tp>
57inline constexpr bool is_reference_v = is_reference<_Tp>::value;
58
59template <class _Tp>
60inline constexpr bool is_lvalue_reference_v = is_lvalue_reference<_Tp>::value;
61
62template <class _Tp>
63inline constexpr bool is_rvalue_reference_v = is_rvalue_reference<_Tp>::value;
64#endif
65
66#endif // __has_builtin(__is_lvalue_reference) && etc...
67
68_LIBCPP_END_NAMESPACE_STD
69
70#endif // _LIBCPP___TYPE_TRAITS_IS_REFERENCE_H
lib/libcxx/include/__type_traits/is_reference_wrapper.h created+31
...@@ -0,0 +1,31 @@
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_REFERENCE_WRAPPER_H
10#define _LIBCPP___TYPE_TRAITS_IS_REFERENCE_WRAPPER_H
11
12#include <__config>
13#include <__type_traits/integral_constant.h>
14#include <__type_traits/remove_cv.h>
15
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header
18#endif
19
20_LIBCPP_BEGIN_NAMESPACE_STD
21
22template <class _Tp> class _LIBCPP_TEMPLATE_VIS reference_wrapper;
23
24template <class _Tp> struct __is_reference_wrapper_impl : public false_type {};
25template <class _Tp> struct __is_reference_wrapper_impl<reference_wrapper<_Tp> > : public true_type {};
26template <class _Tp> struct __is_reference_wrapper
27 : public __is_reference_wrapper_impl<typename remove_cv<_Tp>::type> {};
28
29_LIBCPP_END_NAMESPACE_STD
30
31#endif // _LIBCPP___TYPE_TRAITS_ENABLE_IF_H
lib/libcxx/include/__type_traits/is_referenceable.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___TYPE_TRAITS_IS_REFERENCEABLE_H
10#define _LIBCPP___TYPE_TRAITS_IS_REFERENCEABLE_H
11
12#include <__config>
13#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_same.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
22struct __is_referenceable_impl {
23 template <class _Tp> static _Tp& __test(int);
24 template <class _Tp> static false_type __test(...);
25};
26
27template <class _Tp>
28struct __is_referenceable : integral_constant<bool,
29 _IsNotSame<decltype(__is_referenceable_impl::__test<_Tp>(0)), false_type>::value> {};
30
31_LIBCPP_END_NAMESPACE_STD
32
33#endif // _LIBCPP___TYPE_TRAITS_IS_REFERENCEABLE_H
lib/libcxx/include/__type_traits/is_same.h created+44
...@@ -0,0 +1,44 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_IS_SAME_H
10#define _LIBCPP___TYPE_TRAITS_IS_SAME_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
21template <class _Tp, class _Up>
22struct _LIBCPP_TEMPLATE_VIS is_same : _BoolConstant<__is_same(_Tp, _Up)> { };
23
24#if _LIBCPP_STD_VER > 14
25template <class _Tp, class _Up>
26inline constexpr bool is_same_v = __is_same(_Tp, _Up);
27#endif
28
29// _IsSame<T,U> has the same effect as is_same<T,U> but instantiates fewer types:
30// is_same<A,B> and is_same<C,D> are guaranteed to be different types, but
31// _IsSame<A,B> and _IsSame<C,D> are the same type (namely, false_type).
32// Neither GCC nor Clang can mangle the __is_same builtin, so _IsSame
33// mustn't be directly used anywhere that contributes to name-mangling
34// (such as in a dependent return type).
35
36template <class _Tp, class _Up>
37using _IsSame = _BoolConstant<__is_same(_Tp, _Up)>;
38
39template <class _Tp, class _Up>
40using _IsNotSame = _BoolConstant<!__is_same(_Tp, _Up)>;
41
42_LIBCPP_END_NAMESPACE_STD
43
44#endif // _LIBCPP___TYPE_TRAITS_IS_SAME_H
lib/libcxx/include/__type_traits/is_scalar.h created+61
...@@ -0,0 +1,61 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_IS_SCALAR_H
10#define _LIBCPP___TYPE_TRAITS_IS_SCALAR_H
11
12#include <__config>
13#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_arithmetic.h>
15#include <__type_traits/is_enum.h>
16#include <__type_traits/is_member_pointer.h>
17#include <__type_traits/is_pointer.h>
18
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20# pragma GCC system_header
21#endif
22
23_LIBCPP_BEGIN_NAMESPACE_STD
24
25#if __has_builtin(__is_scalar)
26
27template<class _Tp>
28struct _LIBCPP_TEMPLATE_VIS is_scalar : _BoolConstant<__is_scalar(_Tp)> { };
29
30#if _LIBCPP_STD_VER > 14
31template <class _Tp>
32inline constexpr bool is_scalar_v = __is_scalar(_Tp);
33#endif
34
35#else // __has_builtin(__is_scalar)
36
37template <class _Tp> struct __is_block : false_type {};
38#if defined(_LIBCPP_HAS_EXTENSION_BLOCKS)
39template <class _Rp, class ..._Args> struct __is_block<_Rp (^)(_Args...)> : true_type {};
40#endif
41
42template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_scalar
43 : public integral_constant<bool, is_arithmetic<_Tp>::value ||
44 is_member_pointer<_Tp>::value ||
45 is_pointer<_Tp>::value ||
46 __is_nullptr_t<_Tp>::value ||
47 __is_block<_Tp>::value ||
48 is_enum<_Tp>::value > {};
49
50template <> struct _LIBCPP_TEMPLATE_VIS is_scalar<nullptr_t> : public true_type {};
51
52#if _LIBCPP_STD_VER > 14
53template <class _Tp>
54inline constexpr bool is_scalar_v = is_scalar<_Tp>::value;
55#endif
56
57#endif // __has_builtin(__is_scalar)
58
59_LIBCPP_END_NAMESPACE_STD
60
61#endif // _LIBCPP___TYPE_TRAITS_IS_SCALAR_H
lib/libcxx/include/__type_traits/is_scoped_enum.h created+42
...@@ -0,0 +1,42 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_IS_SCOPED_ENUM_H
10#define _LIBCPP___TYPE_TRAITS_IS_SCOPED_ENUM_H
11
12#include <__config>
13#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_convertible.h>
15#include <__type_traits/is_enum.h>
16#include <__type_traits/underlying_type.h>
17
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header
20#endif
21
22_LIBCPP_BEGIN_NAMESPACE_STD
23
24#if _LIBCPP_STD_VER > 20
25template <class _Tp, bool = is_enum_v<_Tp> >
26struct __is_scoped_enum_helper : false_type {};
27
28template <class _Tp>
29struct __is_scoped_enum_helper<_Tp, true>
30 : public bool_constant<!is_convertible_v<_Tp, underlying_type_t<_Tp> > > {};
31
32template <class _Tp>
33struct _LIBCPP_TEMPLATE_VIS is_scoped_enum
34 : public __is_scoped_enum_helper<_Tp> {};
35
36template <class _Tp>
37inline constexpr bool is_scoped_enum_v = is_scoped_enum<_Tp>::value;
38#endif
39
40_LIBCPP_END_NAMESPACE_STD
41
42#endif // _LIBCPP___TYPE_TRAITS_IS_SCOPED_ENUM_H
lib/libcxx/include/__type_traits/is_signed.h created+55
...@@ -0,0 +1,55 @@
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_SIGNED_H
10#define _LIBCPP___TYPE_TRAITS_IS_SIGNED_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 __has_builtin(__is_signed)
22
23template<class _Tp>
24struct _LIBCPP_TEMPLATE_VIS is_signed : _BoolConstant<__is_signed(_Tp)> { };
25
26#if _LIBCPP_STD_VER > 14
27template <class _Tp>
28inline constexpr bool is_signed_v = __is_signed(_Tp);
29#endif
30
31#else // __has_builtin(__is_signed)
32
33template <class _Tp, bool = is_integral<_Tp>::value>
34struct __libcpp_is_signed_impl : public _BoolConstant<(_Tp(-1) < _Tp(0))> {};
35
36template <class _Tp>
37struct __libcpp_is_signed_impl<_Tp, false> : public true_type {}; // floating point
38
39template <class _Tp, bool = is_arithmetic<_Tp>::value>
40struct __libcpp_is_signed : public __libcpp_is_signed_impl<_Tp> {};
41
42template <class _Tp> struct __libcpp_is_signed<_Tp, false> : public false_type {};
43
44template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_signed : public __libcpp_is_signed<_Tp> {};
45
46#if _LIBCPP_STD_VER > 14
47template <class _Tp>
48inline constexpr bool is_signed_v = is_signed<_Tp>::value;
49#endif
50
51#endif // __has_builtin(__is_signed)
52
53_LIBCPP_END_NAMESPACE_STD
54
55#endif // _LIBCPP___TYPE_TRAITS_IS_SIGNED_H
lib/libcxx/include/__type_traits/is_signed_integer.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___TYPE_TRAITS_IS_SIGNED_INTEGER_H
10#define _LIBCPP___TYPE_TRAITS_IS_SIGNED_INTEGER_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
21template <class _Tp> struct __libcpp_is_signed_integer : public false_type {};
22template <> struct __libcpp_is_signed_integer<signed char> : public true_type {};
23template <> struct __libcpp_is_signed_integer<signed short> : public true_type {};
24template <> struct __libcpp_is_signed_integer<signed int> : public true_type {};
25template <> struct __libcpp_is_signed_integer<signed long> : public true_type {};
26template <> struct __libcpp_is_signed_integer<signed long long> : public true_type {};
27#ifndef _LIBCPP_HAS_NO_INT128
28template <> struct __libcpp_is_signed_integer<__int128_t> : public true_type {};
29#endif
30
31_LIBCPP_END_NAMESPACE_STD
32
33#endif // _LIBCPP___TYPE_TRAITS_IS_SIGNED_INTEGER_H
lib/libcxx/include/__type_traits/is_standard_layout.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_STANDARD_LAYOUT_H
10#define _LIBCPP___TYPE_TRAITS_IS_STANDARD_LAYOUT_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
21template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_standard_layout
22#if __has_builtin(__is_standard_layout)
23 : public integral_constant<bool, __is_standard_layout(_Tp)>
24#else
25 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
26#endif
27 {};
28
29#if _LIBCPP_STD_VER > 14
30template <class _Tp>
31inline constexpr bool is_standard_layout_v = is_standard_layout<_Tp>::value;
32#endif
33
34_LIBCPP_END_NAMESPACE_STD
35
36#endif // _LIBCPP___TYPE_TRAITS_IS_STANDARD_LAYOUT_H
lib/libcxx/include/__type_traits/is_trivial.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___TYPE_TRAITS_IS_TRIVIAL_H
10#define _LIBCPP___TYPE_TRAITS_IS_TRIVIAL_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
21template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivial
22#if __has_builtin(__is_trivial)
23 : public integral_constant<bool, __is_trivial(_Tp)>
24#else
25 : integral_constant<bool, is_trivially_copyable<_Tp>::value &&
26 is_trivially_default_constructible<_Tp>::value>
27#endif
28 {};
29
30#if _LIBCPP_STD_VER > 14
31template <class _Tp>
32inline constexpr bool is_trivial_v = is_trivial<_Tp>::value;
33#endif
34
35_LIBCPP_END_NAMESPACE_STD
36
37#endif // _LIBCPP___TYPE_TRAITS_IS_TRIVIAL_H
lib/libcxx/include/__type_traits/is_trivially_assignable.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___TYPE_TRAITS_IS_TRIVIALLY_ASSIGNABLE_H
10#define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_ASSIGNABLE_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
21template <class _Tp, class _Arg>
22struct is_trivially_assignable
23 : integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)>
24{ };
25
26#if _LIBCPP_STD_VER > 14
27template <class _Tp, class _Arg>
28inline constexpr bool is_trivially_assignable_v = is_trivially_assignable<_Tp, _Arg>::value;
29#endif
30
31_LIBCPP_END_NAMESPACE_STD
32
33#endif // _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_ASSIGNABLE_H
lib/libcxx/include/__type_traits/is_trivially_constructible.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___TYPE_TRAITS_IS_TRIVIALLY_CONSTRUCTIBLE_H
10#define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_CONSTRUCTIBLE_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
21template <class _Tp, class... _Args>
22struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible
23 : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)>
24{
25};
26
27#if _LIBCPP_STD_VER > 14
28template <class _Tp, class... _Args>
29inline constexpr bool is_trivially_constructible_v = is_trivially_constructible<_Tp, _Args...>::value;
30#endif
31
32_LIBCPP_END_NAMESPACE_STD
33
34#endif // _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_CONSTRUCTIBLE_H
lib/libcxx/include/__type_traits/is_trivially_copy_assignable.h created+35
...@@ -0,0 +1,35 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_COPY_ASSIGNABLE_H
10#define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_COPY_ASSIGNABLE_H
11
12#include <__config>
13#include <__type_traits/add_const.h>
14#include <__type_traits/add_lvalue_reference.h>
15#include <__type_traits/integral_constant.h>
16#include <__type_traits/is_trivially_assignable.h>
17
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header
20#endif
21
22_LIBCPP_BEGIN_NAMESPACE_STD
23
24template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_assignable
25 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
26 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
27
28#if _LIBCPP_STD_VER > 14
29template <class _Tp>
30inline constexpr bool is_trivially_copy_assignable_v = is_trivially_copy_assignable<_Tp>::value;
31#endif
32
33_LIBCPP_END_NAMESPACE_STD
34
35#endif // _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_COPY_ASSIGNABLE_H
lib/libcxx/include/__type_traits/is_trivially_copy_constructible.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___TYPE_TRAITS_IS_TRIVIALLY_COPY_CONSTRUCTIBLE_H
10#define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_COPY_CONSTRUCTIBLE_H
11
12#include <__config>
13#include <__type_traits/add_lvalue_reference.h>
14#include <__type_traits/integral_constant.h>
15#include <__type_traits/is_trivially_constructible.h>
16
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header
19#endif
20
21_LIBCPP_BEGIN_NAMESPACE_STD
22
23template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_constructible
24 : public is_trivially_constructible<_Tp, typename add_lvalue_reference<const _Tp>::type>
25 {};
26
27#if _LIBCPP_STD_VER > 14
28template <class _Tp>
29inline constexpr bool is_trivially_copy_constructible_v = is_trivially_copy_constructible<_Tp>::value;
30#endif
31
32_LIBCPP_END_NAMESPACE_STD
33
34#endif // _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_COPY_CONSTRUCTIBLE_H
lib/libcxx/include/__type_traits/is_trivially_copyable.h created+32
...@@ -0,0 +1,32 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_COPYABLE_H
10#define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_COPYABLE_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
21template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copyable
22 : public integral_constant<bool, __is_trivially_copyable(_Tp)>
23 {};
24
25#if _LIBCPP_STD_VER > 14
26template <class _Tp>
27inline constexpr bool is_trivially_copyable_v = is_trivially_copyable<_Tp>::value;
28#endif
29
30_LIBCPP_END_NAMESPACE_STD
31
32#endif // _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_COPYABLE_H
lib/libcxx/include/__type_traits/is_trivially_default_constructible.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___TYPE_TRAITS_IS_TRIVIALLY_DEFAULT_CONSTRUCTIBLE_H
10#define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_DEFAULT_CONSTRUCTIBLE_H
11
12#include <__config>
13#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_trivially_constructible.h>
15
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header
18#endif
19
20_LIBCPP_BEGIN_NAMESPACE_STD
21
22template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_default_constructible
23 : public is_trivially_constructible<_Tp>
24 {};
25
26#if _LIBCPP_STD_VER > 14
27template <class _Tp>
28inline constexpr bool is_trivially_default_constructible_v = is_trivially_default_constructible<_Tp>::value;
29#endif
30
31_LIBCPP_END_NAMESPACE_STD
32
33#endif // _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_DEFAULT_CONSTRUCTIBLE_H
lib/libcxx/include/__type_traits/is_trivially_destructible.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_IS_TRIVIALLY_DESTRUCTIBLE_H
10#define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_DESTRUCTIBLE_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 __has_builtin(__is_trivially_destructible)
22
23template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
24 : public integral_constant<bool, __is_trivially_destructible(_Tp)> {};
25
26#elif __has_builtin(__has_trivial_destructor)
27
28template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
29 : public integral_constant<bool, is_destructible<_Tp>::value && __has_trivial_destructor(_Tp)> {};
30
31#else
32
33template <class _Tp> struct __libcpp_trivial_destructor
34 : public integral_constant<bool, is_scalar<_Tp>::value ||
35 is_reference<_Tp>::value> {};
36
37template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
38 : public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {};
39
40template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible<_Tp[]>
41 : public false_type {};
42
43#endif // __has_builtin(__is_trivially_destructible)
44
45#if _LIBCPP_STD_VER > 14
46template <class _Tp>
47inline constexpr bool is_trivially_destructible_v = is_trivially_destructible<_Tp>::value;
48#endif
49
50_LIBCPP_END_NAMESPACE_STD
51
52#endif // _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_DESTRUCTIBLE_H
lib/libcxx/include/__type_traits/is_trivially_move_assignable.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_TRIVIALLY_MOVE_ASSIGNABLE_H
10#define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_MOVE_ASSIGNABLE_H
11
12#include <__config>
13#include <__type_traits/add_lvalue_reference.h>
14#include <__type_traits/add_rvalue_reference.h>
15#include <__type_traits/integral_constant.h>
16#include <__type_traits/is_trivially_assignable.h>
17
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header
20#endif
21
22_LIBCPP_BEGIN_NAMESPACE_STD
23
24template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_assignable
25 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
26 typename add_rvalue_reference<_Tp>::type>
27 {};
28
29#if _LIBCPP_STD_VER > 14
30template <class _Tp>
31inline constexpr bool is_trivially_move_assignable_v = is_trivially_move_assignable<_Tp>::value;
32#endif
33
34_LIBCPP_END_NAMESPACE_STD
35
36#endif // _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_MOVE_ASSIGNABLE_H
lib/libcxx/include/__type_traits/is_trivially_move_constructible.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___TYPE_TRAITS_IS_TRIVIALLY_MOVE_CONSTRUCTIBLE_H
10#define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_MOVE_CONSTRUCTIBLE_H
11
12#include <__config>
13#include <__type_traits/add_rvalue_reference.h>
14#include <__type_traits/integral_constant.h>
15#include <__type_traits/is_trivially_constructible.h>
16
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header
19#endif
20
21_LIBCPP_BEGIN_NAMESPACE_STD
22
23template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_constructible
24 : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
25 {};
26
27#if _LIBCPP_STD_VER > 14
28template <class _Tp>
29inline constexpr bool is_trivially_move_constructible_v = is_trivially_move_constructible<_Tp>::value;
30#endif
31
32_LIBCPP_END_NAMESPACE_STD
33
34#endif // _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_MOVE_CONSTRUCTIBLE_H
lib/libcxx/include/__type_traits/is_unbounded_array.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___TYPE_TRAITS_IS_UNBOUNDED_ARRAY_H
10#define _LIBCPP___TYPE_TRAITS_IS_UNBOUNDED_ARRAY_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
21template <class> struct _LIBCPP_TEMPLATE_VIS __libcpp_is_unbounded_array : false_type {};
22template <class _Tp> struct _LIBCPP_TEMPLATE_VIS __libcpp_is_unbounded_array<_Tp[]> : true_type {};
23
24#if _LIBCPP_STD_VER > 17
25
26template <class> struct _LIBCPP_TEMPLATE_VIS is_unbounded_array : false_type {};
27template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_unbounded_array<_Tp[]> : true_type {};
28
29template <class _Tp>
30inline constexpr
31bool is_unbounded_array_v = is_unbounded_array<_Tp>::value;
32
33#endif
34
35_LIBCPP_END_NAMESPACE_STD
36
37#endif // _LIBCPP___TYPE_TRAITS_IS_UNBOUNDED_ARRAY_H
lib/libcxx/include/__type_traits/is_union.h created+32
...@@ -0,0 +1,32 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_IS_UNION_H
10#define _LIBCPP___TYPE_TRAITS_IS_UNION_H
11
12#include <__config>
13#include <__type_traits/integral_constant.h>
14#include <__type_traits/remove_cv.h>
15
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header
18#endif
19
20_LIBCPP_BEGIN_NAMESPACE_STD
21
22template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_union
23 : public integral_constant<bool, __is_union(_Tp)> {};
24
25#if _LIBCPP_STD_VER > 14
26template <class _Tp>
27inline constexpr bool is_union_v = __is_union(_Tp);
28#endif
29
30_LIBCPP_END_NAMESPACE_STD
31
32#endif // _LIBCPP___TYPE_TRAITS_IS_UNION_H
lib/libcxx/include/__type_traits/is_unsigned.h created+58
...@@ -0,0 +1,58 @@
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_UNSIGNED_H
10#define _LIBCPP___TYPE_TRAITS_IS_UNSIGNED_H
11
12#include <__config>
13#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_arithmetic.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_LIBCPP_BEGIN_NAMESPACE_STD
22
23// Before AppleClang 14, __is_unsigned returned true for enums with signed underlying type.
24#if __has_builtin(__is_unsigned) && !(defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 1400)
25
26template<class _Tp>
27struct _LIBCPP_TEMPLATE_VIS is_unsigned : _BoolConstant<__is_unsigned(_Tp)> { };
28
29#if _LIBCPP_STD_VER > 14
30template <class _Tp>
31inline constexpr bool is_unsigned_v = __is_unsigned(_Tp);
32#endif
33
34#else // __has_builtin(__is_unsigned)
35
36template <class _Tp, bool = is_integral<_Tp>::value>
37struct __libcpp_is_unsigned_impl : public _BoolConstant<(_Tp(0) < _Tp(-1))> {};
38
39template <class _Tp>
40struct __libcpp_is_unsigned_impl<_Tp, false> : public false_type {}; // floating point
41
42template <class _Tp, bool = is_arithmetic<_Tp>::value>
43struct __libcpp_is_unsigned : public __libcpp_is_unsigned_impl<_Tp> {};
44
45template <class _Tp> struct __libcpp_is_unsigned<_Tp, false> : public false_type {};
46
47template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_unsigned : public __libcpp_is_unsigned<_Tp> {};
48
49#if _LIBCPP_STD_VER > 14
50template <class _Tp>
51inline constexpr bool is_unsigned_v = is_unsigned<_Tp>::value;
52#endif
53
54#endif // __has_builtin(__is_unsigned)
55
56_LIBCPP_END_NAMESPACE_STD
57
58#endif // _LIBCPP___TYPE_TRAITS_IS_UNSIGNED_H
lib/libcxx/include/__type_traits/is_unsigned_integer.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___TYPE_TRAITS_IS_UNSIGNED_INTEGER_H
10#define _LIBCPP___TYPE_TRAITS_IS_UNSIGNED_INTEGER_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
21template <class _Tp> struct __libcpp_is_unsigned_integer : public false_type {};
22template <> struct __libcpp_is_unsigned_integer<unsigned char> : public true_type {};
23template <> struct __libcpp_is_unsigned_integer<unsigned short> : public true_type {};
24template <> struct __libcpp_is_unsigned_integer<unsigned int> : public true_type {};
25template <> struct __libcpp_is_unsigned_integer<unsigned long> : public true_type {};
26template <> struct __libcpp_is_unsigned_integer<unsigned long long> : public true_type {};
27#ifndef _LIBCPP_HAS_NO_INT128
28template <> struct __libcpp_is_unsigned_integer<__uint128_t> : public true_type {};
29#endif
30
31_LIBCPP_END_NAMESPACE_STD
32
33#endif // _LIBCPP___TYPE_TRAITS_IS_UNSIGNED_INTEGER_H
lib/libcxx/include/__type_traits/is_valid_expansion.h created+31
...@@ -0,0 +1,31 @@
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_VALID_EXPANSION_H
10#define _LIBCPP___TYPE_TRAITS_IS_VALID_EXPANSION_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
21template <template <class...> class _Templ, class ..._Args, class = _Templ<_Args...> >
22true_type __sfinae_test_impl(int);
23template <template <class...> class, class ...>
24false_type __sfinae_test_impl(...);
25
26template <template <class ...> class _Templ, class ..._Args>
27using _IsValidExpansion _LIBCPP_NODEBUG = decltype(__sfinae_test_impl<_Templ, _Args...>(0));
28
29_LIBCPP_END_NAMESPACE_STD
30
31#endif // _LIBCPP___TYPE_TRAITS_IS_VALID_EXPANSION_H
lib/libcxx/include/__type_traits/is_void.h created+45
...@@ -0,0 +1,45 @@
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_VOID_H
10#define _LIBCPP___TYPE_TRAITS_IS_VOID_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 __has_builtin(__is_void)
22
23template <class _Tp>
24struct _LIBCPP_TEMPLATE_VIS is_void : _BoolConstant<__is_void(_Tp)> { };
25
26#if _LIBCPP_STD_VER > 14
27template <class _Tp>
28inline constexpr bool is_void_v = __is_void(_Tp);
29#endif
30
31#else
32
33template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_void
34 : public is_same<typename remove_cv<_Tp>::type, void> {};
35
36#if _LIBCPP_STD_VER > 14
37template <class _Tp>
38inline constexpr bool is_void_v = is_void<_Tp>::value;
39#endif
40
41#endif // __has_builtin(__is_void)
42
43_LIBCPP_END_NAMESPACE_STD
44
45#endif // _LIBCPP___TYPE_TRAITS_IS_VOID_H
lib/libcxx/include/__type_traits/is_volatile.h created+45
...@@ -0,0 +1,45 @@
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_VOLATILE_H
10#define _LIBCPP___TYPE_TRAITS_IS_VOLATILE_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 __has_builtin(__is_volatile)
22
23template <class _Tp>
24struct _LIBCPP_TEMPLATE_VIS is_volatile : _BoolConstant<__is_volatile(_Tp)> { };
25
26#if _LIBCPP_STD_VER > 14
27template <class _Tp>
28inline constexpr bool is_volatile_v = __is_volatile(_Tp);
29#endif
30
31#else
32
33template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile : public false_type {};
34template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile<_Tp volatile> : public true_type {};
35
36#if _LIBCPP_STD_VER > 14
37template <class _Tp>
38inline constexpr bool is_volatile_v = is_volatile<_Tp>::value;
39#endif
40
41#endif // __has_builtin(__is_volatile)
42
43_LIBCPP_END_NAMESPACE_STD
44
45#endif // _LIBCPP___TYPE_TRAITS_IS_VOLATILE_H
lib/libcxx/include/__type_traits/lazy.h created+25
...@@ -0,0 +1,25 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_LAZY_H
10#define _LIBCPP___TYPE_TRAITS_LAZY_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 <template <class...> class _Func, class ..._Args>
21struct _Lazy : _Func<_Args...> {};
22
23_LIBCPP_END_NAMESPACE_STD
24
25#endif // _LIBCPP___TYPE_TRAITS_LAZY_H
lib/libcxx/include/__type_traits/make_32_64_or_128_bit.h created+48
...@@ -0,0 +1,48 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_MAKE_32_64_OR_128_BIT_H
10#define _LIBCPP___TYPE_TRAITS_MAKE_32_64_OR_128_BIT_H
11
12#include <__config>
13#include <__type_traits/conditional.h>
14#include <__type_traits/is_same.h>
15#include <__type_traits/is_signed.h>
16#include <__type_traits/is_unsigned.h>
17#include <__type_traits/make_unsigned.h>
18#include <cstdint>
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/// Helper to promote an integral to smallest 32, 64, or 128 bit representation.
27///
28/// The restriction is the same as the integral version of to_char.
29template <class _Tp>
30#if _LIBCPP_STD_VER > 17
31 requires (is_signed_v<_Tp> || is_unsigned_v<_Tp> || is_same_v<_Tp, char>)
32#endif
33using __make_32_64_or_128_bit_t =
34 __copy_unsigned_t<_Tp,
35 __conditional_t<sizeof(_Tp) <= sizeof(int32_t), int32_t,
36 __conditional_t<sizeof(_Tp) <= sizeof(int64_t), int64_t,
37#ifndef _LIBCPP_HAS_NO_INT128
38 __conditional_t<sizeof(_Tp) <= sizeof(__int128_t), __int128_t,
39 /* else */ void>
40#else
41 /* else */ void
42#endif
43 > >
44 >;
45
46_LIBCPP_END_NAMESPACE_STD
47
48#endif // _LIBCPP___TYPE_TRAITS_MAKE_32_64_OR_128_BIT_H
lib/libcxx/include/__type_traits/make_signed.h created+76
...@@ -0,0 +1,76 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_MAKE_SIGNED_H
10#define _LIBCPP___TYPE_TRAITS_MAKE_SIGNED_H
11
12#include <__config>
13#include <__type_traits/apply_cv.h>
14#include <__type_traits/is_enum.h>
15#include <__type_traits/is_integral.h>
16#include <__type_traits/nat.h>
17#include <__type_traits/remove_cv.h>
18#include <__type_traits/type_list.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
26typedef
27 __type_list<signed char,
28 __type_list<signed short,
29 __type_list<signed int,
30 __type_list<signed long,
31 __type_list<signed long long,
32#ifndef _LIBCPP_HAS_NO_INT128
33 __type_list<__int128_t,
34#endif
35 __nat
36#ifndef _LIBCPP_HAS_NO_INT128
37 >
38#endif
39 > > > > > __signed_types;
40
41template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
42struct __make_signed {};
43
44template <class _Tp>
45struct __make_signed<_Tp, true>
46{
47 typedef typename __find_first<__signed_types, sizeof(_Tp)>::type type;
48};
49
50template <> struct __make_signed<bool, true> {};
51template <> struct __make_signed< signed short, true> {typedef short type;};
52template <> struct __make_signed<unsigned short, true> {typedef short type;};
53template <> struct __make_signed< signed int, true> {typedef int type;};
54template <> struct __make_signed<unsigned int, true> {typedef int type;};
55template <> struct __make_signed< signed long, true> {typedef long type;};
56template <> struct __make_signed<unsigned long, true> {typedef long type;};
57template <> struct __make_signed< signed long long, true> {typedef long long type;};
58template <> struct __make_signed<unsigned long long, true> {typedef long long type;};
59#ifndef _LIBCPP_HAS_NO_INT128
60template <> struct __make_signed<__int128_t, true> {typedef __int128_t type;};
61template <> struct __make_signed<__uint128_t, true> {typedef __int128_t type;};
62#endif
63
64template <class _Tp>
65struct _LIBCPP_TEMPLATE_VIS make_signed
66{
67 typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type;
68};
69
70#if _LIBCPP_STD_VER > 11
71template <class _Tp> using make_signed_t = typename make_signed<_Tp>::type;
72#endif
73
74_LIBCPP_END_NAMESPACE_STD
75
76#endif // _LIBCPP___TYPE_TRAITS_MAKE_SIGNED_H
lib/libcxx/include/__type_traits/make_unsigned.h created+89
...@@ -0,0 +1,89 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_MAKE_UNSIGNED_H
10#define _LIBCPP___TYPE_TRAITS_MAKE_UNSIGNED_H
11
12#include <__config>
13#include <__type_traits/apply_cv.h>
14#include <__type_traits/conditional.h>
15#include <__type_traits/is_enum.h>
16#include <__type_traits/is_integral.h>
17#include <__type_traits/is_unsigned.h>
18#include <__type_traits/nat.h>
19#include <__type_traits/remove_cv.h>
20#include <__type_traits/type_list.h>
21
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23# pragma GCC system_header
24#endif
25
26_LIBCPP_BEGIN_NAMESPACE_STD
27
28typedef
29 __type_list<unsigned char,
30 __type_list<unsigned short,
31 __type_list<unsigned int,
32 __type_list<unsigned long,
33 __type_list<unsigned long long,
34#ifndef _LIBCPP_HAS_NO_INT128
35 __type_list<__uint128_t,
36#endif
37 __nat
38#ifndef _LIBCPP_HAS_NO_INT128
39 >
40#endif
41 > > > > > __unsigned_types;
42
43template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
44struct __make_unsigned {};
45
46template <class _Tp>
47struct __make_unsigned<_Tp, true>
48{
49 typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type;
50};
51
52template <> struct __make_unsigned<bool, true> {};
53template <> struct __make_unsigned< signed short, true> {typedef unsigned short type;};
54template <> struct __make_unsigned<unsigned short, true> {typedef unsigned short type;};
55template <> struct __make_unsigned< signed int, true> {typedef unsigned int type;};
56template <> struct __make_unsigned<unsigned int, true> {typedef unsigned int type;};
57template <> struct __make_unsigned< signed long, true> {typedef unsigned long type;};
58template <> struct __make_unsigned<unsigned long, true> {typedef unsigned long type;};
59template <> struct __make_unsigned< signed long long, true> {typedef unsigned long long type;};
60template <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;};
61#ifndef _LIBCPP_HAS_NO_INT128
62template <> struct __make_unsigned<__int128_t, true> {typedef __uint128_t type;};
63template <> struct __make_unsigned<__uint128_t, true> {typedef __uint128_t type;};
64#endif
65
66template <class _Tp>
67struct _LIBCPP_TEMPLATE_VIS make_unsigned
68{
69 typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type;
70};
71
72#if _LIBCPP_STD_VER > 11
73template <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type;
74#endif
75
76#ifndef _LIBCPP_CXX03_LANG
77template <class _Tp>
78_LIBCPP_HIDE_FROM_ABI constexpr
79typename make_unsigned<_Tp>::type __to_unsigned_like(_Tp __x) noexcept {
80 return static_cast<typename make_unsigned<_Tp>::type>(__x);
81}
82#endif
83
84template <class _Tp, class _Up>
85using __copy_unsigned_t = __conditional_t<is_unsigned<_Tp>::value, typename make_unsigned<_Up>::type, _Up>;
86
87_LIBCPP_END_NAMESPACE_STD
88
89#endif // _LIBCPP___TYPE_TRAITS_MAKE_UNSIGNED_H
lib/libcxx/include/__type_traits/nat.h created+32
...@@ -0,0 +1,32 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_NAT_H
10#define _LIBCPP___TYPE_TRAITS_NAT_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
20struct __nat
21{
22#ifndef _LIBCPP_CXX03_LANG
23 __nat() = delete;
24 __nat(const __nat&) = delete;
25 __nat& operator=(const __nat&) = delete;
26 ~__nat() = delete;
27#endif
28};
29
30_LIBCPP_END_NAMESPACE_STD
31
32#endif // _LIBCPP___TYPE_TRAITS_NAT_H
lib/libcxx/include/__type_traits/negation.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___TYPE_TRAITS_NEGATION_H
10#define _LIBCPP___TYPE_TRAITS_NEGATION_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
21template <class _Pred>
22struct _Not : _BoolConstant<!_Pred::value> {};
23
24#if _LIBCPP_STD_VER > 14
25template <class _Tp>
26struct negation : _Not<_Tp> {};
27template<class _Tp>
28inline constexpr bool negation_v = negation<_Tp>::value;
29#endif // _LIBCPP_STD_VER > 14
30
31_LIBCPP_END_NAMESPACE_STD
32
33#endif // _LIBCPP___TYPE_TRAITS_NEGATION_H
lib/libcxx/include/__type_traits/promote.h created+95
...@@ -0,0 +1,95 @@
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_PROMOTE_H
10#define _LIBCPP___TYPE_TRAITS_PROMOTE_H
11
12#include <__config>
13#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_same.h>
15#include <__utility/declval.h>
16#include <cstddef>
17
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header
20#endif
21
22_LIBCPP_BEGIN_NAMESPACE_STD
23
24template <class _Tp>
25struct __numeric_type
26{
27 static void __test(...);
28 static float __test(float);
29 static double __test(char);
30 static double __test(int);
31 static double __test(unsigned);
32 static double __test(long);
33 static double __test(unsigned long);
34 static double __test(long long);
35 static double __test(unsigned long long);
36 static double __test(double);
37 static long double __test(long double);
38
39 typedef decltype(__test(declval<_Tp>())) type;
40 static const bool value = _IsNotSame<type, void>::value;
41};
42
43template <>
44struct __numeric_type<void>
45{
46 static const bool value = true;
47};
48
49template <class _A1, class _A2 = void, class _A3 = void,
50 bool = __numeric_type<_A1>::value &&
51 __numeric_type<_A2>::value &&
52 __numeric_type<_A3>::value>
53class __promote_imp
54{
55public:
56 static const bool value = false;
57};
58
59template <class _A1, class _A2, class _A3>
60class __promote_imp<_A1, _A2, _A3, true>
61{
62private:
63 typedef typename __promote_imp<_A1>::type __type1;
64 typedef typename __promote_imp<_A2>::type __type2;
65 typedef typename __promote_imp<_A3>::type __type3;
66public:
67 typedef decltype(__type1() + __type2() + __type3()) type;
68 static const bool value = true;
69};
70
71template <class _A1, class _A2>
72class __promote_imp<_A1, _A2, void, true>
73{
74private:
75 typedef typename __promote_imp<_A1>::type __type1;
76 typedef typename __promote_imp<_A2>::type __type2;
77public:
78 typedef decltype(__type1() + __type2()) type;
79 static const bool value = true;
80};
81
82template <class _A1>
83class __promote_imp<_A1, void, void, true>
84{
85public:
86 typedef typename __numeric_type<_A1>::type type;
87 static const bool value = true;
88};
89
90template <class _A1, class _A2 = void, class _A3 = void>
91class __promote : public __promote_imp<_A1, _A2, _A3> {};
92
93_LIBCPP_END_NAMESPACE_STD
94
95#endif // _LIBCPP___TYPE_TRAITS_PROMOTE_H
lib/libcxx/include/__type_traits/rank.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_RANK_H
10#define _LIBCPP___TYPE_TRAITS_RANK_H
11
12#include <__config>
13#include <__type_traits/integral_constant.h>
14#include <cstddef>
15
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header
18#endif
19
20_LIBCPP_BEGIN_NAMESPACE_STD
21
22template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank
23 : public integral_constant<size_t, 0> {};
24template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[]>
25 : public integral_constant<size_t, rank<_Tp>::value + 1> {};
26template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[_Np]>
27 : public integral_constant<size_t, rank<_Tp>::value + 1> {};
28
29#if _LIBCPP_STD_VER > 14
30template <class _Tp>
31inline constexpr size_t rank_v = rank<_Tp>::value;
32#endif
33
34_LIBCPP_END_NAMESPACE_STD
35
36#endif // _LIBCPP___TYPE_TRAITS_RANK_H
lib/libcxx/include/__type_traits/remove_all_extents.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___TYPE_TRAITS_REMOVE_ALL_EXTENTS_H
10#define _LIBCPP___TYPE_TRAITS_REMOVE_ALL_EXTENTS_H
11
12#include <__config>
13#include <cstddef>
14
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header
17#endif
18
19_LIBCPP_BEGIN_NAMESPACE_STD
20
21template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents
22 {typedef _Tp type;};
23template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[]>
24 {typedef typename remove_all_extents<_Tp>::type type;};
25template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[_Np]>
26 {typedef typename remove_all_extents<_Tp>::type type;};
27
28#if _LIBCPP_STD_VER > 11
29template <class _Tp> using remove_all_extents_t = typename remove_all_extents<_Tp>::type;
30#endif
31
32_LIBCPP_END_NAMESPACE_STD
33
34#endif // _LIBCPP___TYPE_TRAITS_REMOVE_ALL_EXTENTS_H
lib/libcxx/include/__type_traits/remove_const.h created+28
...@@ -0,0 +1,28 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_REMOVE_CONST_H
10#define _LIBCPP___TYPE_TRAITS_REMOVE_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> struct _LIBCPP_TEMPLATE_VIS remove_const {typedef _Tp type;};
21template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const<const _Tp> {typedef _Tp type;};
22#if _LIBCPP_STD_VER > 11
23template <class _Tp> using remove_const_t = typename remove_const<_Tp>::type;
24#endif
25
26_LIBCPP_END_NAMESPACE_STD
27
28#endif // _LIBCPP___TYPE_TRAITS_REMOVE_CONST_H
lib/libcxx/include/__type_traits/remove_cv.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___TYPE_TRAITS_REMOVE_CV_H
10#define _LIBCPP___TYPE_TRAITS_REMOVE_CV_H
11
12#include <__config>
13#include <__type_traits/remove_const.h>
14#include <__type_traits/remove_volatile.h>
15
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header
18#endif
19
20_LIBCPP_BEGIN_NAMESPACE_STD
21
22template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_cv
23{typedef typename remove_volatile<typename remove_const<_Tp>::type>::type type;};
24#if _LIBCPP_STD_VER > 11
25template <class _Tp> using remove_cv_t = typename remove_cv<_Tp>::type;
26#endif
27
28_LIBCPP_END_NAMESPACE_STD
29
30#endif // _LIBCPP___TYPE_TRAITS_REMOVE_CV_H
lib/libcxx/include/__type_traits/remove_cvref.h created+41
...@@ -0,0 +1,41 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_REMOVE_CVREF_H
10#define _LIBCPP___TYPE_TRAITS_REMOVE_CVREF_H
11
12#include <__config>
13#include <__type_traits/is_same.h>
14#include <__type_traits/remove_cv.h>
15#include <__type_traits/remove_reference.h>
16
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header
19#endif
20
21_LIBCPP_BEGIN_NAMESPACE_STD
22
23template <class _Tp>
24using __uncvref_t _LIBCPP_NODEBUG = typename remove_cv<typename remove_reference<_Tp>::type>::type;
25
26template <class _Tp, class _Up>
27struct __is_same_uncvref : _IsSame<__uncvref_t<_Tp>, __uncvref_t<_Up> > {};
28
29#if _LIBCPP_STD_VER > 17
30// remove_cvref - same as __uncvref
31template <class _Tp>
32struct remove_cvref {
33 using type _LIBCPP_NODEBUG = __uncvref_t<_Tp>;
34};
35
36template <class _Tp> using remove_cvref_t = typename remove_cvref<_Tp>::type;
37#endif
38
39_LIBCPP_END_NAMESPACE_STD
40
41#endif // _LIBCPP___TYPE_TRAITS_REMOVE_CVREF_H
lib/libcxx/include/__type_traits/remove_extent.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___TYPE_TRAITS_REMOVE_EXTENT_H
10#define _LIBCPP___TYPE_TRAITS_REMOVE_EXTENT_H
11
12#include <__config>
13#include <cstddef>
14
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header
17#endif
18
19_LIBCPP_BEGIN_NAMESPACE_STD
20
21template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent
22 {typedef _Tp type;};
23template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[]>
24 {typedef _Tp type;};
25template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[_Np]>
26 {typedef _Tp type;};
27
28#if _LIBCPP_STD_VER > 11
29template <class _Tp> using remove_extent_t = typename remove_extent<_Tp>::type;
30#endif
31
32_LIBCPP_END_NAMESPACE_STD
33
34#endif // _LIBCPP___TYPE_TRAITS_REMOVE_EXTENT_H
lib/libcxx/include/__type_traits/remove_pointer.h created+32
...@@ -0,0 +1,32 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_REMOVE_POINTER_H
10#define _LIBCPP___TYPE_TRAITS_REMOVE_POINTER_H
11
12#include <__config>
13
14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
15# pragma GCC system_header
16#endif
17
18_LIBCPP_BEGIN_NAMESPACE_STD
19
20template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer {typedef _LIBCPP_NODEBUG _Tp type;};
21template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp*> {typedef _LIBCPP_NODEBUG _Tp type;};
22template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const> {typedef _LIBCPP_NODEBUG _Tp type;};
23template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* volatile> {typedef _LIBCPP_NODEBUG _Tp type;};
24template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const volatile> {typedef _LIBCPP_NODEBUG _Tp type;};
25
26#if _LIBCPP_STD_VER > 11
27template <class _Tp> using remove_pointer_t = typename remove_pointer<_Tp>::type;
28#endif
29
30_LIBCPP_END_NAMESPACE_STD
31
32#endif // _LIBCPP___TYPE_TRAITS_REMOVE_POINTER_H
lib/libcxx/include/__type_traits/remove_reference.h created+31
...@@ -0,0 +1,31 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_REMOVE_REFERENCE_H
10#define _LIBCPP___TYPE_TRAITS_REMOVE_REFERENCE_H
11
12#include <__config>
13#include <cstddef>
14
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header
17#endif
18
19_LIBCPP_BEGIN_NAMESPACE_STD
20
21template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference {typedef _LIBCPP_NODEBUG _Tp type;};
22template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&> {typedef _LIBCPP_NODEBUG _Tp type;};
23template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&&> {typedef _LIBCPP_NODEBUG _Tp type;};
24
25#if _LIBCPP_STD_VER > 11
26template <class _Tp> using remove_reference_t = typename remove_reference<_Tp>::type;
27#endif
28
29_LIBCPP_END_NAMESPACE_STD
30
31#endif // _LIBCPP___TYPE_TRAITS_REMOVE_REFERENCE_H
lib/libcxx/include/__type_traits/remove_volatile.h created+28
...@@ -0,0 +1,28 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_REMOVE_VOLATILE_H
10#define _LIBCPP___TYPE_TRAITS_REMOVE_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> struct _LIBCPP_TEMPLATE_VIS remove_volatile {typedef _Tp type;};
21template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile<volatile _Tp> {typedef _Tp type;};
22#if _LIBCPP_STD_VER > 11
23template <class _Tp> using remove_volatile_t = typename remove_volatile<_Tp>::type;
24#endif
25
26_LIBCPP_END_NAMESPACE_STD
27
28#endif // _LIBCPP___TYPE_TRAITS_REMOVE_VOLATILE_H
lib/libcxx/include/__type_traits/type_identity.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___TYPE_TRAITS_TYPE_IDENTITY_H
10#define _LIBCPP___TYPE_TRAITS_TYPE_IDENTITY_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 __type_identity { typedef _Tp type; };
22
23template <class _Tp>
24using __type_identity_t _LIBCPP_NODEBUG = typename __type_identity<_Tp>::type;
25
26#if _LIBCPP_STD_VER > 17
27template<class _Tp> struct type_identity { typedef _Tp type; };
28template<class _Tp> using type_identity_t = typename type_identity<_Tp>::type;
29#endif
30
31_LIBCPP_END_NAMESPACE_STD
32
33#endif // _LIBCPP___TYPE_TRAITS_TYPE_IDENTITY_H
lib/libcxx/include/__type_traits/type_list.h created+44
...@@ -0,0 +1,44 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_TYPE_LIST_H
10#define _LIBCPP___TYPE_TRAITS_TYPE_LIST_H
11
12#include <__config>
13#include <cstddef>
14
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header
17#endif
18
19_LIBCPP_BEGIN_NAMESPACE_STD
20
21template <class _Hp, class _Tp>
22struct __type_list
23{
24 typedef _Hp _Head;
25 typedef _Tp _Tail;
26};
27
28template <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeList::_Head)> struct __find_first;
29
30template <class _Hp, class _Tp, size_t _Size>
31struct __find_first<__type_list<_Hp, _Tp>, _Size, true>
32{
33 typedef _LIBCPP_NODEBUG _Hp type;
34};
35
36template <class _Hp, class _Tp, size_t _Size>
37struct __find_first<__type_list<_Hp, _Tp>, _Size, false>
38{
39 typedef _LIBCPP_NODEBUG typename __find_first<_Tp, _Size>::type type;
40};
41
42_LIBCPP_END_NAMESPACE_STD
43
44#endif // _LIBCPP___TYPE_TRAITS_TYPE_LIST_H
lib/libcxx/include/__type_traits/underlying_type.h created+41
...@@ -0,0 +1,41 @@
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_UNDERLYING_TYPE_H
10#define _LIBCPP___TYPE_TRAITS_UNDERLYING_TYPE_H
11
12#include <__config>
13#include <__type_traits/is_enum.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, bool = is_enum<_Tp>::value> struct __underlying_type_impl;
22
23template <class _Tp>
24struct __underlying_type_impl<_Tp, false> {};
25
26template <class _Tp>
27struct __underlying_type_impl<_Tp, true>
28{
29 typedef __underlying_type(_Tp) type;
30};
31
32template <class _Tp>
33struct underlying_type : __underlying_type_impl<_Tp, is_enum<_Tp>::value> {};
34
35#if _LIBCPP_STD_VER > 11
36template <class _Tp> using underlying_type_t = typename underlying_type<_Tp>::type;
37#endif
38
39_LIBCPP_END_NAMESPACE_STD
40
41#endif // _LIBCPP___TYPE_TRAITS_UNDERLYING_TYPE_H
lib/libcxx/include/__type_traits/void_t.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___TYPE_TRAITS_VOID_T_H
10#define _LIBCPP___TYPE_TRAITS_VOID_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
20#if _LIBCPP_STD_VER > 14
21template <class...> using void_t = void;
22#endif
23
24template <class>
25struct __void_t { typedef void type; };
26
27_LIBCPP_END_NAMESPACE_STD
28
29#endif // _LIBCPP___TYPE_TRAITS_VOID_T_H
lib/libcxx/include/__undef_macros+2-19
...@@ -7,27 +7,10 @@...@@ -7,27 +7,10 @@
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
99
10
11#ifdef min10#ifdef min
12#if !defined(_LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS)11# undef min
13#if defined(_LIBCPP_WARNING)
14_LIBCPP_WARNING("macro min is incompatible with C++. Try #define NOMINMAX "
15 "before any Windows header. #undefing min")
16#else
17#warning: macro min is incompatible with C++. #undefing min
18#endif
19#endif
20#undef min
21#endif12#endif
2213
23#ifdef max14#ifdef max
24#if !defined(_LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS)15# undef max
25#if defined(_LIBCPP_WARNING)
26_LIBCPP_WARNING("macro max is incompatible with C++. Try #define NOMINMAX "
27 "before any Windows header. #undefing max")
28#else
29#warning: macro max is incompatible with C++. #undefing max
30#endif
31#endif
32#undef max
33#endif16#endif
lib/libcxx/include/__utility/as_const.h+1-1
...@@ -15,7 +15,7 @@...@@ -15,7 +15,7 @@
15#include <type_traits>15#include <type_traits>
1616
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header18# pragma GCC system_header
19#endif19#endif
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__utility/auto_cast.h+1-1
...@@ -14,7 +14,7 @@...@@ -14,7 +14,7 @@
14#include <type_traits>14#include <type_traits>
1515
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17#pragma GCC system_header17# pragma GCC system_header
18#endif18#endif
1919
20#define _LIBCPP_AUTO_CAST(expr) static_cast<typename decay<decltype((expr))>::type>(expr)20#define _LIBCPP_AUTO_CAST(expr) static_cast<typename decay<decltype((expr))>::type>(expr)
lib/libcxx/include/__utility/cmp.h+4-7
...@@ -16,7 +16,7 @@...@@ -16,7 +16,7 @@
16#include <type_traits>16#include <type_traits>
1717
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19#pragma GCC system_header19# pragma GCC system_header
20#endif20#endif
2121
22_LIBCPP_PUSH_MACROS22_LIBCPP_PUSH_MACROS
...@@ -24,19 +24,16 @@ _LIBCPP_PUSH_MACROS...@@ -24,19 +24,16 @@ _LIBCPP_PUSH_MACROS
2424
25_LIBCPP_BEGIN_NAMESPACE_STD25_LIBCPP_BEGIN_NAMESPACE_STD
2626
27#if !defined(_LIBCPP_HAS_NO_CONCEPTS)27#if _LIBCPP_STD_VER > 17
28template<class _Tp, class... _Up>28template<class _Tp, class... _Up>
29struct _IsSameAsAny : _Or<_IsSame<_Tp, _Up>...> {};29struct _IsSameAsAny : _Or<_IsSame<_Tp, _Up>...> {};
3030
31template<class _Tp>31template<class _Tp>
32concept __is_safe_integral_cmp = is_integral_v<_Tp> &&32concept __is_safe_integral_cmp = is_integral_v<_Tp> &&
33 !_IsSameAsAny<_Tp, bool, char33 !_IsSameAsAny<_Tp, bool, char, char16_t, char32_t
34#ifndef _LIBCPP_HAS_NO_CHAR8_T34#ifndef _LIBCPP_HAS_NO_CHAR8_T
35 , char8_t35 , char8_t
36#endif36#endif
37#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
38 , char16_t, char32_t
39#endif
40#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS37#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
41 , wchar_t38 , wchar_t
42#endif39#endif
...@@ -101,7 +98,7 @@ bool in_range(_Up __u) noexcept...@@ -101,7 +98,7 @@ bool in_range(_Up __u) noexcept
101 return _VSTD::cmp_less_equal(__u, numeric_limits<_Tp>::max()) &&98 return _VSTD::cmp_less_equal(__u, numeric_limits<_Tp>::max()) &&
102 _VSTD::cmp_greater_equal(__u, numeric_limits<_Tp>::min());99 _VSTD::cmp_greater_equal(__u, numeric_limits<_Tp>::min());
103}100}
104#endif101#endif // _LIBCPP_STD_VER > 17
105102
106_LIBCPP_END_NAMESPACE_STD103_LIBCPP_END_NAMESPACE_STD
107104
lib/libcxx/include/__utility/declval.h+1-1
...@@ -12,7 +12,7 @@...@@ -12,7 +12,7 @@
12#include <__config>12#include <__config>
1313
14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
15#pragma GCC system_header15# pragma GCC system_header
16#endif16#endif
1717
18_LIBCPP_BEGIN_NAMESPACE_STD18_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__utility/exchange.h+1-1
...@@ -15,7 +15,7 @@...@@ -15,7 +15,7 @@
15#include <type_traits>15#include <type_traits>
1616
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header18# pragma GCC system_header
19#endif19#endif
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__utility/forward.h+3-2
...@@ -11,10 +11,11 @@...@@ -11,10 +11,11 @@
11#define _LIBCPP___UTILITY_FORWARD_H11#define _LIBCPP___UTILITY_FORWARD_H
1212
13#include <__config>13#include <__config>
14#include <type_traits>14#include <__type_traits/is_reference.h>
15#include <__type_traits/remove_reference.h>
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
18#endif19#endif
1920
20_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__utility/in_place.h+1-1
...@@ -13,7 +13,7 @@...@@ -13,7 +13,7 @@
13#include <type_traits>13#include <type_traits>
1414
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16#pragma GCC system_header16# pragma GCC system_header
17#endif17#endif
1818
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__utility/integer_sequence.h+1-1
...@@ -13,7 +13,7 @@...@@ -13,7 +13,7 @@
13#include <type_traits>13#include <type_traits>
1414
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16#pragma GCC system_header16# pragma GCC system_header
17#endif17#endif
1818
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__utility/move.h+1-6
...@@ -14,7 +14,7 @@...@@ -14,7 +14,7 @@
14#include <type_traits>14#include <type_traits>
1515
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17#pragma GCC system_header17# pragma GCC system_header
18#endif18#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -26,15 +26,10 @@ move(_Tp&& __t) _NOEXCEPT {...@@ -26,15 +26,10 @@ move(_Tp&& __t) _NOEXCEPT {
26 return static_cast<_Up&&>(__t);26 return static_cast<_Up&&>(__t);
27}27}
2828
29#ifndef _LIBCPP_CXX03_LANG
30template <class _Tp>29template <class _Tp>
31using __move_if_noexcept_result_t =30using __move_if_noexcept_result_t =
32 typename conditional<!is_nothrow_move_constructible<_Tp>::value && is_copy_constructible<_Tp>::value, const _Tp&,31 typename conditional<!is_nothrow_move_constructible<_Tp>::value && is_copy_constructible<_Tp>::value, const _Tp&,
33 _Tp&&>::type;32 _Tp&&>::type;
34#else // _LIBCPP_CXX03_LANG
35template <class _Tp>
36using __move_if_noexcept_result_t = const _Tp&;
37#endif
3833
39template <class _Tp>34template <class _Tp>
40_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 __move_if_noexcept_result_t<_Tp>35_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 __move_if_noexcept_result_t<_Tp>
lib/libcxx/include/__utility/pair.h+21-5
...@@ -21,7 +21,7 @@...@@ -21,7 +21,7 @@
21#include <type_traits>21#include <type_traits>
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
25#endif25#endif
2626
27_LIBCPP_BEGIN_NAMESPACE_STD27_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -315,7 +315,7 @@ private:...@@ -315,7 +315,7 @@ private:
315#endif315#endif
316};316};
317317
318#if _LIBCPP_STD_VER >= 17318#if _LIBCPP_STD_VER > 14
319template<class _T1, class _T2>319template<class _T1, class _T2>
320pair(_T1, _T2) -> pair<_T1, _T2>;320pair(_T1, _T2) -> pair<_T1, _T2>;
321#endif321#endif
...@@ -330,7 +330,7 @@ operator==(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)...@@ -330,7 +330,7 @@ operator==(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
330 return __x.first == __y.first && __x.second == __y.second;330 return __x.first == __y.first && __x.second == __y.second;
331}331}
332332
333#if !defined(_LIBCPP_HAS_NO_CONCEPTS)333#if _LIBCPP_STD_VER > 17
334334
335template <class _T1, class _T2>335template <class _T1, class _T2>
336_LIBCPP_HIDE_FROM_ABI constexpr336_LIBCPP_HIDE_FROM_ABI constexpr
...@@ -345,7 +345,7 @@ operator<=>(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)...@@ -345,7 +345,7 @@ operator<=>(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
345 return _VSTD::__synth_three_way(__x.second, __y.second);345 return _VSTD::__synth_three_way(__x.second, __y.second);
346}346}
347347
348#else // !defined(_LIBCPP_HAS_NO_CONCEPTS)348#else // _LIBCPP_STD_VER > 17
349349
350template <class _T1, class _T2>350template <class _T1, class _T2>
351inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11351inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
...@@ -387,7 +387,23 @@ operator<=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)...@@ -387,7 +387,23 @@ operator<=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
387 return !(__y < __x);387 return !(__y < __x);
388}388}
389389
390#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)390#endif // _LIBCPP_STD_VER > 17
391
392#if _LIBCPP_STD_VER > 20
393template <class _T1, class _T2, class _U1, class _U2, template<class> class _TQual, template<class> class _UQual>
394 requires requires { typename pair<common_reference_t<_TQual<_T1>, _UQual<_U1>>,
395 common_reference_t<_TQual<_T2>, _UQual<_U2>>>; }
396struct basic_common_reference<pair<_T1, _T2>, pair<_U1, _U2>, _TQual, _UQual> {
397 using type = pair<common_reference_t<_TQual<_T1>, _UQual<_U1>>,
398 common_reference_t<_TQual<_T2>, _UQual<_U2>>>;
399};
400
401template <class _T1, class _T2, class _U1, class _U2>
402 requires requires { typename pair<common_type_t<_T1, _U1>, common_type_t<_T2, _U2>>; }
403struct common_type<pair<_T1, _T2>, pair<_U1, _U2>> {
404 using type = pair<common_type_t<_T1, _U1>, common_type_t<_T2, _U2>>;
405};
406#endif // _LIBCPP_STD_VER > 20
391407
392template <class _T1, class _T2>408template <class _T1, class _T2>
393inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17409inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
lib/libcxx/include/__utility/piecewise_construct.h+1-1
...@@ -12,7 +12,7 @@...@@ -12,7 +12,7 @@
12#include <__config>12#include <__config>
1313
14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
15#pragma GCC system_header15# pragma GCC system_header
16#endif16#endif
1717
18_LIBCPP_BEGIN_NAMESPACE_STD18_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__utility/priority_tag.h+1-1
...@@ -13,7 +13,7 @@...@@ -13,7 +13,7 @@
13#include <cstddef>13#include <cstddef>
1414
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16#pragma GCC system_header16# pragma GCC system_header
17#endif17#endif
1818
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__utility/rel_ops.h+1-1
...@@ -15,7 +15,7 @@...@@ -15,7 +15,7 @@
15#include <type_traits>15#include <type_traits>
1616
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header18# pragma GCC system_header
19#endif19#endif
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__utility/swap.h+1-1
...@@ -16,7 +16,7 @@...@@ -16,7 +16,7 @@
16#include <type_traits>16#include <type_traits>
1717
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19#pragma GCC system_header19# pragma GCC system_header
20#endif20#endif
2121
22_LIBCPP_BEGIN_NAMESPACE_STD22_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__utility/to_underlying.h+1-1
...@@ -14,7 +14,7 @@...@@ -14,7 +14,7 @@
14#include <type_traits>14#include <type_traits>
1515
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17#pragma GCC system_header17# pragma GCC system_header
18#endif18#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__utility/transaction.h+6-1
...@@ -15,7 +15,7 @@...@@ -15,7 +15,7 @@
15#include <type_traits>15#include <type_traits>
1616
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18#pragma GCC system_header18# pragma GCC system_header
19#endif19#endif
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -86,6 +86,11 @@ private:...@@ -86,6 +86,11 @@ private:
86 bool __completed_;86 bool __completed_;
87};87};
8888
89template <class _Rollback>
90_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __transaction<_Rollback> __make_transaction(_Rollback __rollback) {
91 return __transaction<_Rollback>(std::move(__rollback));
92}
93
89_LIBCPP_END_NAMESPACE_STD94_LIBCPP_END_NAMESPACE_STD
9095
91#endif // _LIBCPP___UTILITY_TRANSACTION_H96#endif // _LIBCPP___UTILITY_TRANSACTION_H
lib/libcxx/include/__utility/unreachable.h created+38
...@@ -0,0 +1,38 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___UTILITY_UNREACHABLE_H
10#define _LIBCPP___UTILITY_UNREACHABLE_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
20
21_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI inline void __libcpp_unreachable()
22{
23#if __has_builtin(__builtin_unreachable)
24 __builtin_unreachable();
25#else
26 std::abort();
27#endif
28}
29
30#if _LIBCPP_STD_VER > 20
31
32[[noreturn]] _LIBCPP_HIDE_FROM_ABI inline void unreachable() { __libcpp_unreachable(); }
33
34#endif // _LIBCPP_STD_VER > 20
35
36_LIBCPP_END_NAMESPACE_STD
37
38#endif
lib/libcxx/include/__variant/monostate.h+1-1
...@@ -15,7 +15,7 @@...@@ -15,7 +15,7 @@
15#include <cstddef>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
19#endif19#endif
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__verbose_abort created+27
...@@ -0,0 +1,27 @@
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___VERBOSE_ABORT
11#define _LIBCPP___VERBOSE_ABORT
12
13#include <__availability>
14#include <__config>
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_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_VERBOSE_ABORT _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2)
23void __libcpp_verbose_abort(const char *__format, ...);
24
25_LIBCPP_END_NAMESPACE_STD
26
27#endif // _LIBCPP___VERBOSE_ABORT
lib/libcxx/include/algorithm+1006-16
...@@ -19,14 +19,901 @@ namespace std...@@ -19,14 +19,901 @@ namespace std
19{19{
2020
21namespace ranges {21namespace ranges {
22
23 // [algorithms.results], algorithm result types
24 template <class I, class F>
25 struct in_fun_result; // since C++20
26
22 template <class I1, class I2>27 template <class I1, class I2>
23 struct in_in_result; // since C++2028 struct in_in_result; // since C++20
29
30 template <class I, class O>
31 struct in_out_result; // since C++20
2432
25 template <class I1, class I2, class O>33 template <class I1, class I2, class O>
26 struct in_in_out_result; // since C++2034 struct in_in_out_result; // since C++20
35
36 template <class I, class O1, class O2>
37 struct in_out_out_result; // since C++20
38
39 template <class I1, class I2>
40 struct min_max_result; // since C++20
41
42 template <class I>
43 struct in_found_result; // since C++20
44
45 template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
46 indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less> // since C++20
47 constexpr I min_element(I first, S last, Comp comp = {}, Proj proj = {});
48
49 template<forward_range R, class Proj = identity,
50 indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less> // since C++20
51 constexpr borrowed_iterator_t<R> min_element(R&& r, Comp comp = {}, Proj proj = {});
52
53 template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
54 indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less>
55 constexpr I ranges::max_element(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
56
57 template<forward_range R, class Proj = identity,
58 indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
59 constexpr borrowed_iterator_t<R> ranges::max_element(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
60
61 template<class I1, class I2>
62 using mismatch_result = in_in_result<I1, I2>;
63
64 template <input_iterator I1, sentinel_for<_I1> S1, input_iterator I2, sentinel_for<_I2> S2,
65 class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
66 requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2>
67 constexpr mismatch_result<_I1, _I2>
68 mismatch()(I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}) // since C++20
69
70 template <input_range R1, input_range R2,
71 class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
72 requires indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
73 constexpr mismatch_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>>
74 mismatch(R1&& r1, R2&& r2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}) // since C++20
75
76 requires indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*>
77 constexpr I find(I first, S last, const T& value, Proj proj = {}); // since C++20
78
79 template<input_range R, class T, class Proj = identity>
80 requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*>
81 constexpr borrowed_iterator_t<R>
82 find(R&& r, const T& value, Proj proj = {}); // since C++20
83
84 template<input_iterator I, sentinel_for<I> S, class Proj = identity,
85 indirect_unary_predicate<projected<I, Proj>> Pred>
86 constexpr I find_if(I first, S last, Pred pred, Proj proj = {}); // since C++20
87
88 template<input_range R, class Proj = identity,
89 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
90 constexpr borrowed_iterator_t<R>
91 find_if(R&& r, Pred pred, Proj proj = {}); // since C++20
92
93 template<input_iterator I, sentinel_for<I> S, class Proj = identity,
94 indirect_unary_predicate<projected<I, Proj>> Pred>
95 constexpr I find_if_not(I first, S last, Pred pred, Proj proj = {}); // since C++20
96
97 template<input_range R, class Proj = identity,
98 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
99 constexpr borrowed_iterator_t<R>
100 find_if_not(R&& r, Pred pred, Proj proj = {}); // since C++20
101
102 template<class T, class Proj = identity,
103 indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
104 constexpr const T& min(const T& a, const T& b, Comp comp = {}, Proj proj = {}); // since C++20
105
106 template<copyable T, class Proj = identity,
107 indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
108 constexpr T min(initializer_list<T> r, Comp comp = {}, Proj proj = {}); // since C++20
109
110 template<input_range R, class Proj = identity,
111 indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
112 requires indirectly_copyable_storable<iterator_t<R>, range_value_t<R>*>
113 constexpr range_value_t<R>
114 min(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
115
116 template<class T, class Proj = identity,
117 indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
118 constexpr const T& max(const T& a, const T& b, Comp comp = {}, Proj proj = {}); // since C++20
119
120 template<copyable T, class Proj = identity,
121 indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
122 constexpr T max(initializer_list<T> r, Comp comp = {}, Proj proj = {}); // since C++20
123
124 template<input_range R, class Proj = identity,
125 indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
126 requires indirectly_copyable_storable<iterator_t<R>, range_value_t<R>*>
127 constexpr range_value_t<R>
128 max(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
129
130 template<class I, class O>
131 using unary_transform_result = in_out_result<I, O>; // since C++20
132
133 template<class I1, class I2, class O>
134 using binary_transform_result = in_in_out_result<I1, I2, O>; // since C++20
135
136 template<input_iterator I, sentinel_for<I> S, weakly_incrementable O,
137 copy_constructible F, class Proj = identity>
138 requires indirectly_writable<O, indirect_result_t<F&, projected<I, Proj>>>
139 constexpr ranges::unary_transform_result<I, O>
140 transform(I first1, S last1, O result, F op, Proj proj = {}); // since C++20
141
142 template<input_range R, weakly_incrementable O, copy_constructible F,
143 class Proj = identity>
144 requires indirectly_writable<O, indirect_result_t<F&, projected<iterator_t<R>, Proj>>>
145 constexpr ranges::unary_transform_result<borrowed_iterator_t<R>, O>
146 transform(R&& r, O result, F op, Proj proj = {}); // since C++20
147
148 template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
149 weakly_incrementable O, copy_constructible F, class Proj1 = identity,
150 class Proj2 = identity>
151 requires indirectly_writable<O, indirect_result_t<F&, projected<I1, Proj1>,
152 projected<I2, Proj2>>>
153 constexpr ranges::binary_transform_result<I1, I2, O>
154 transform(I1 first1, S1 last1, I2 first2, S2 last2, O result,
155 F binary_op, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
156
157 template<input_range R1, input_range R2, weakly_incrementable O,
158 copy_constructible F, class Proj1 = identity, class Proj2 = identity>
159 requires indirectly_writable<O, indirect_result_t<F&, projected<iterator_t<R1>, Proj1>,
160 projected<iterator_t<R2>, Proj2>>>
161 constexpr ranges::binary_transform_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>, O>
162 transform(R1&& r1, R2&& r2, O result,
163 F binary_op, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
164
165 template<input_iterator I, sentinel_for<I> S, class T, class Proj = identity>
166 requires indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*>
167 constexpr iter_difference_t<I>
168 count(I first, S last, const T& value, Proj proj = {}); // since C++20
169
170 template<input_range R, class T, class Proj = identity>
171 requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*>
172 constexpr range_difference_t<R>
173 count(R&& r, const T& value, Proj proj = {}); // since C++20
174
175 template<input_iterator I, sentinel_for<I> S, class Proj = identity,
176 indirect_unary_predicate<projected<I, Proj>> Pred>
177 constexpr iter_difference_t<I>
178 count_if(I first, S last, Pred pred, Proj proj = {}); // since C++20
179
180 template<input_range R, class Proj = identity,
181 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
182 constexpr range_difference_t<R>
183 count_if(R&& r, Pred pred, Proj proj = {}); // since C++20
184
185 template<class T>
186 using minmax_result = min_max_result<T>;
187
188 template<class T, class Proj = identity,
189 indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
190 constexpr ranges::minmax_result<const T&>
191 minmax(const T& a, const T& b, Comp comp = {}, Proj proj = {}); // since C++20
192
193 template<copyable T, class Proj = identity,
194 indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
195 constexpr ranges::minmax_result<T>
196 minmax(initializer_list<T> r, Comp comp = {}, Proj proj = {}); // since C++20
197
198 template<input_range R, class Proj = identity,
199 indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
200 requires indirectly_copyable_storable<iterator_t<R>, range_value_t<R>*>
201 constexpr ranges::minmax_result<range_value_t<R>>
202 minmax(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
203
204 template<class I>
205 using minmax_element_result = min_max_result<I>;
206
207 template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
208 indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less>
209 constexpr ranges::minmax_element_result<I>
210 minmax_element(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
211
212 template<forward_range R, class Proj = identity,
213 indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
214 constexpr ranges::minmax_element_result<borrowed_iterator_t<R>>
215 minmax_element(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
216
217 template<class I, class O>
218 using copy_result = in_out_result<I, O>; // since C++20
219
220 template<class I, class O>
221 using copy_n_result = in_out_result<I, O>; // since C++20
222
223 template<class I, class O>
224 using copy_if_result = in_out_result<I, O>; // since C++20
225
226 template<class I1, class I2>
227 using copy_backward_result = in_out_result<I1, I2>; // since C++20
228
229 template<input_iterator I, sentinel_for<I> S, weakly_incrementable O>
230 requires indirectly_copyable<I, O>
231 constexpr ranges::copy_result<I, O> ranges::copy(I first, S last, O result); // since C++20
232
233 template<input_range R, weakly_incrementable O>
234 requires indirectly_copyable<iterator_t<R>, O>
235 constexpr ranges::copy_result<borrowed_iterator_t<R>, O> ranges::copy(R&& r, O result); // since C++20
236
237 template<input_iterator I, weakly_incrementable O>
238 requires indirectly_copyable<I, O>
239 constexpr ranges::copy_n_result<I, O>
240 ranges::copy_n(I first, iter_difference_t<I> n, O result); // since C++20
241
242 template<input_iterator I, sentinel_for<I> S, weakly_incrementable O, class Proj = identity,
243 indirect_unary_predicate<projected<I, Proj>> Pred>
244 requires indirectly_copyable<I, O>
245 constexpr ranges::copy_if_result<I, O>
246 ranges::copy_if(I first, S last, O result, Pred pred, Proj proj = {}); // since C++20
247
248 template<input_range R, weakly_incrementable O, class Proj = identity,
249 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
250 requires indirectly_copyable<iterator_t<R>, O>
251 constexpr ranges::copy_if_result<borrowed_iterator_t<R>, O>
252 ranges::copy_if(R&& r, O result, Pred pred, Proj proj = {}); // since C++20
253
254 template<bidirectional_iterator I1, sentinel_for<I1> S1, bidirectional_iterator I2>
255 requires indirectly_copyable<I1, I2>
256 constexpr ranges::copy_backward_result<I1, I2>
257 ranges::copy_backward(I1 first, S1 last, I2 result); // since C++20
258
259 template<bidirectional_range R, bidirectional_iterator I>
260 requires indirectly_copyable<iterator_t<R>, I>
261 constexpr ranges::copy_backward_result<borrowed_iterator_t<R>, I>
262 ranges::copy_backward(R&& r, I result); // since C++20
263
264 template<class I, class F>
265 using for_each_result = in_fun_result<I, F>; // since C++20
266
267 template<input_iterator I, sentinel_for<I> S, class Proj = identity,
268 indirectly_unary_invocable<projected<I, Proj>> Fun>
269 constexpr ranges::for_each_result<I, Fun>
270 ranges::for_each(I first, S last, Fun f, Proj proj = {}); // since C++20
271
272 template<input_range R, class Proj = identity,
273 indirectly_unary_invocable<projected<iterator_t<R>, Proj>> Fun>
274 constexpr ranges::for_each_result<borrowed_iterator_t<R>, Fun>
275 ranges::for_each(R&& r, Fun f, Proj proj = {}); // since C++20
276
277 template<input_iterator I, class Proj = identity,
278 indirectly_unary_invocable<projected<I, Proj>> Fun>
279 constexpr ranges::for_each_n_result<I, Fun>
280 ranges::for_each_n(I first, iter_difference_t<I> n, Fun f, Proj proj = {}); // since C++20
281
282 template<input_iterator I, sentinel_for<I> S, class Proj = identity,
283 indirect_unary_predicate<projected<I, Proj>> Pred>
284 constexpr bool ranges::is_partitioned(I first, S last, Pred pred, Proj proj = {}); // since C++20
285
286 template<input_range R, class Proj = identity,
287 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
288 constexpr bool ranges::is_partitioned(R&& r, Pred pred, Proj proj = {}); // since C++20
289
290 template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less,
291 class Proj = identity>
292 requires sortable<I, Comp, Proj>
293 constexpr I
294 ranges::push_heap(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
295
296 template<random_access_range R, class Comp = ranges::less, class Proj = identity>
297 requires sortable<iterator_t<R>, Comp, Proj>
298 constexpr borrowed_iterator_t<R>
299 ranges::push_heap(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
300
301 template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less,
302 class Proj = identity>
303 requires sortable<I, Comp, Proj>
304 constexpr I
305 ranges::pop_heap(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
306
307 template<random_access_range R, class Comp = ranges::less, class Proj = identity>
308 requires sortable<iterator_t<R>, Comp, Proj>
309 constexpr borrowed_iterator_t<R>
310 ranges::pop_heap(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
311
312 template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less,
313 class Proj = identity>
314 requires sortable<I, Comp, Proj>
315 constexpr I
316 ranges::make_heap(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
317
318 template<random_access_range R, class Comp = ranges::less, class Proj = identity>
319 requires sortable<iterator_t<R>, Comp, Proj>
320 constexpr borrowed_iterator_t<R>
321 ranges::make_heap(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
322
323 template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less,
324 class Proj = identity>
325 requires sortable<I, Comp, Proj>
326 constexpr I
327 ranges::sort_heap(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
328
329 template<random_access_range R, class Comp = ranges::less, class Proj = identity>
330 requires sortable<iterator_t<R>, Comp, Proj>
331 constexpr borrowed_iterator_t<R>
332 ranges::sort_heap(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
333
334 template<random_access_iterator I, sentinel_for<I> S, class Proj = identity,
335 indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less>
336 constexpr bool is_heap(I first, S last, Comp comp = {}, Proj proj = {}); // Since C++20
337
338 template<random_access_range R, class Proj = identity,
339 indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
340 constexpr bool is_heap(R&& r, Comp comp = {}, Proj proj = {}); // Since C++20
341
342 template<random_access_iterator I, sentinel_for<I> S, class Proj = identity,
343 indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less>
344 constexpr I is_heap_until(I first, S last, Comp comp = {}, Proj proj = {}); // Since C++20
345
346 template<random_access_range R, class Proj = identity,
347 indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
348 constexpr borrowed_iterator_t<R>
349 is_heap_until(R&& r, Comp comp = {}, Proj proj = {}); // Since C++20
350
351 template<bidirectional_iterator I, sentinel_for<I> S>
352 requires permutable<I>
353 constexpr I ranges::reverse(I first, S last); // since C++20
354
355 template<bidirectional_range R>
356 requires permutable<iterator_t<R>>
357 constexpr borrowed_iterator_t<R> ranges::reverse(R&& r); // since C++20
358
359 template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less,
360 class Proj = identity>
361 requires sortable<I, Comp, Proj>
362 constexpr I
363 ranges::sort(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
364
365 template<random_access_range R, class Comp = ranges::less, class Proj = identity>
366 requires sortable<iterator_t<R>, Comp, Proj>
367 constexpr borrowed_iterator_t<R>
368 ranges::sort(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
369
370 template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less,
371 class Proj = identity>
372 requires sortable<I, Comp, Proj>
373 I ranges::stable_sort(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
374
375 template<random_access_range R, class Comp = ranges::less, class Proj = identity>
376 requires sortable<iterator_t<R>, Comp, Proj>
377 borrowed_iterator_t<R>
378 ranges::stable_sort(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
379
380 template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less,
381 class Proj = identity>
382 requires sortable<I, Comp, Proj>
383 constexpr I
384 ranges::partial_sort(I first, I middle, S last, Comp comp = {}, Proj proj = {}); // since C++20
385
386 template<random_access_range R, class Comp = ranges::less, class Proj = identity>
387 requires sortable<iterator_t<R>, Comp, Proj>
388 constexpr borrowed_iterator_t<R>
389 ranges::partial_sort(R&& r, iterator_t<R> middle, Comp comp = {}, Proj proj = {}); // since C++20
390
391 template<class T, output_iterator<const T&> O, sentinel_for<O> S>
392 constexpr O ranges::fill(O first, S last, const T& value); // since C++20
393
394 template<class T, output_range<const T&> R>
395 constexpr borrowed_iterator_t<R> ranges::fill(R&& r, const T& value); // since C++20
396
397 template<class T, output_iterator<const T&> O>
398 constexpr O ranges::fill_n(O first, iter_difference_t<O> n, const T& value); // since C++20
399
400 template<input_or_output_iterator O, sentinel_for<O> S, copy_constructible F>
401 requires invocable<F&> && indirectly_writable<O, invoke_result_t<F&>>
402 constexpr O generate(O first, S last, F gen); // Since C++20
403
404 template<class R, copy_constructible F>
405 requires invocable<F&> && output_range<R, invoke_result_t<F&>>
406 constexpr borrowed_iterator_t<R> generate(R&& r, F gen); // Since C++20
407
408 template<input_or_output_iterator O, copy_constructible F>
409 requires invocable<F&> && indirectly_writable<O, invoke_result_t<F&>>
410 constexpr O generate_n(O first, iter_difference_t<O> n, F gen); // Since C++20
411
412 template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
413 class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
414 requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2>
415 constexpr bool ranges::equal(I1 first1, S1 last1, I2 first2, S2 last2,
416 Pred pred = {},
417 Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
418
419 template<input_range R1, input_range R2, class Pred = ranges::equal_to,
420 class Proj1 = identity, class Proj2 = identity>
421 requires indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
422 constexpr bool ranges::equal(R1&& r1, R2&& r2, Pred pred = {},
423 Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
424
425 template<input_iterator I, sentinel_for<I> S, class Proj = identity,
426 indirect_unary_predicate<projected<I, Proj>> Pred>
427 constexpr bool ranges::all_of(I first, S last, Pred pred, Proj proj = {}); // since C++20
428
429 template<input_range R, class Proj = identity,
430 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
431 constexpr bool ranges::all_of(R&& r, Pred pred, Proj proj = {}); // since C++20
432
433 template<input_iterator I, sentinel_for<I> S, class Proj = identity,
434 indirect_unary_predicate<projected<I, Proj>> Pred>
435 constexpr bool ranges::any_of(I first, S last, Pred pred, Proj proj = {}); // since C++20
436
437 template<input_range R, class Proj = identity,
438 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
439 constexpr bool ranges::any_of(R&& r, Pred pred, Proj proj = {}); // since C++20
440
441 template<input_iterator I, sentinel_for<I> S, class Proj = identity,
442 indirect_unary_predicate<projected<I, Proj>> Pred>
443 constexpr bool ranges::none_of(I first, S last, Pred pred, Proj proj = {}); // since C++20
444
445 template<input_range R, class Proj = identity,
446 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
447 constexpr bool ranges::none_of(R&& r, Pred pred, Proj proj = {}); // since C++20
448
449 template<input_iterator I1, sentinel_for<I1> S1,
450 random_access_iterator I2, sentinel_for<I2> S2,
451 class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity>
452 requires indirectly_copyable<I1, I2> && sortable<I2, Comp, Proj2> &&
453 indirect_strict_weak_order<Comp, projected<I1, Proj1>, projected<I2, Proj2>>
454 constexpr partial_sort_copy_result<I1, I2>
455 partial_sort_copy(I1 first, S1 last, I2 result_first, S2 result_last,
456 Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // Since C++20
457
458 template<input_range R1, random_access_range R2, class Comp = ranges::less,
459 class Proj1 = identity, class Proj2 = identity>
460 requires indirectly_copyable<iterator_t<R1>, iterator_t<R2>> &&
461 sortable<iterator_t<R2>, Comp, Proj2> &&
462 indirect_strict_weak_order<Comp, projected<iterator_t<R1>, Proj1>,
463 projected<iterator_t<R2>, Proj2>>
464 constexpr partial_sort_copy_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>>
465 partial_sort_copy(R1&& r, R2&& result_r, Comp comp = {},
466 Proj1 proj1 = {}, Proj2 proj2 = {}); // Since C++20
467
468 template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
469 indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less>
470 constexpr bool ranges::is_sorted(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
471
472 template<forward_range R, class Proj = identity,
473 indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
474 constexpr bool ranges::is_sorted(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
475
476 template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
477 indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less>
478 constexpr I ranges::is_sorted_until(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
479
480 template<forward_range R, class Proj = identity,
481 indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
482 constexpr borrowed_iterator_t<R>
483 ranges::is_sorted_until(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
484
485 template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less,
486 class Proj = identity>
487 requires sortable<I, Comp, Proj>
488 constexpr I
489 ranges::nth_element(I first, I nth, S last, Comp comp = {}, Proj proj = {}); // since C++20
490
491 template<random_access_range R, class Comp = ranges::less, class Proj = identity>
492 requires sortable<iterator_t<R>, Comp, Proj>
493 constexpr borrowed_iterator_t<R>
494 ranges::nth_element(R&& r, iterator_t<R> nth, Comp comp = {}, Proj proj = {}); // since C++20
495
496 template<forward_iterator I, sentinel_for<I> S, class T, class Proj = identity,
497 indirect_strict_weak_order<const T*, projected<I, Proj>> Comp = ranges::less>
498 constexpr I upper_bound(I first, S last, const T& value, Comp comp = {}, Proj proj = {}); // since C++20
499
500 template<forward_range R, class T, class Proj = identity,
501 indirect_strict_weak_order<const T*, projected<iterator_t<R>, Proj>> Comp =
502 ranges::less>
503 constexpr borrowed_iterator_t<R>
504 upper_bound(R&& r, const T& value, Comp comp = {}, Proj proj = {}); // since C++20
505
506 template<forward_iterator I, sentinel_for<I> S, class T, class Proj = identity,
507 indirect_strict_weak_order<const T*, projected<I, Proj>> Comp = ranges::less>
508 constexpr I lower_bound(I first, S last, const T& value, Comp comp = {},
509 Proj proj = {}); // since C++20
510 template<forward_range R, class T, class Proj = identity,
511 indirect_strict_weak_order<const T*, projected<iterator_t<R>, Proj>> Comp =
512 ranges::less>
513 constexpr borrowed_iterator_t<R>
514 lower_bound(R&& r, const T& value, Comp comp = {}, Proj proj = {}); // since C++20
515
516 template<forward_iterator I, sentinel_for<I> S, class T, class Proj = identity,
517 indirect_strict_weak_order<const T*, projected<I, Proj>> Comp = ranges::less>
518 constexpr bool binary_search(I first, S last, const T& value, Comp comp = {},
519 Proj proj = {}); // since C++20
520
521 template<forward_range R, class T, class Proj = identity,
522 indirect_strict_weak_order<const T*, projected<iterator_t<R>, Proj>> Comp =
523 ranges::less>
524 constexpr bool binary_search(R&& r, const T& value, Comp comp = {},
525 Proj proj = {}); // since C++20
526
527 template<permutable I, sentinel_for<I> S, class Proj = identity,
528 indirect_unary_predicate<projected<I, Proj>> Pred>
529 constexpr subrange<I>
530 partition(I first, S last, Pred pred, Proj proj = {}); // Since C++20
531
532 template<forward_range R, class Proj = identity,
533 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
534 requires permutable<iterator_t<R>>
535 constexpr borrowed_subrange_t<R>
536 partition(R&& r, Pred pred, Proj proj = {}); // Since C++20
537
538 template<bidirectional_iterator I, sentinel_for<I> S, class Proj = identity,
539 indirect_unary_predicate<projected<I, Proj>> Pred>
540 requires permutable<I>
541 subrange<I> stable_partition(I first, S last, Pred pred, Proj proj = {}); // Since C++20
542
543 template<bidirectional_range R, class Proj = identity,
544 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
545 requires permutable<iterator_t<R>>
546 borrowed_subrange_t<R> stable_partition(R&& r, Pred pred, Proj proj = {}); // Since C++20
547
548 template<input_iterator I1, sentinel_for<I1> S1, forward_iterator I2, sentinel_for<I2> S2,
549 class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
550 requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2>
551 constexpr I1 ranges::find_first_of(I1 first1, S1 last1, I2 first2, S2 last2,
552 Pred pred = {},
553 Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
554
555 template<input_range R1, forward_range R2,
556 class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
557 requires indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
558 constexpr borrowed_iterator_t<R1>
559 ranges::find_first_of(R1&& r1, R2&& r2,
560 Pred pred = {},
561 Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
562
563 template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
564 indirect_binary_predicate<projected<I, Proj>,
565 projected<I, Proj>> Pred = ranges::equal_to>
566 constexpr I ranges::adjacent_find(I first, S last, Pred pred = {}, Proj proj = {}); // since C+20
567
568 template<forward_range R, class Proj = identity,
569 indirect_binary_predicate<projected<iterator_t<R>, Proj>,
570 projected<iterator_t<R>, Proj>> Pred = ranges::equal_to>
571 constexpr borrowed_iterator_t<R> ranges::adjacent_find(R&& r, Pred pred = {}, Proj proj = {}); // since C++20
572
573 template<input_iterator I, sentinel_for<I> S, class T1, class T2, class Proj = identity>
574 requires indirectly_writable<I, const T2&> &&
575 indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T1*>
576 constexpr I
577 ranges::replace(I first, S last, const T1& old_value, const T2& new_value, Proj proj = {}); // since C++20
578
579 template<input_range R, class T1, class T2, class Proj = identity>
580 requires indirectly_writable<iterator_t<R>, const T2&> &&
581 indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T1*>
582 constexpr borrowed_iterator_t<R>
583 ranges::replace(R&& r, const T1& old_value, const T2& new_value, Proj proj = {}); // since C++20
584
585 template<input_iterator I, sentinel_for<I> S, class T, class Proj = identity,
586 indirect_unary_predicate<projected<I, Proj>> Pred>
587 requires indirectly_writable<I, const T&>
588 constexpr I ranges::replace_if(I first, S last, Pred pred, const T& new_value, Proj proj = {}); // since C++20
589
590 template<input_range R, class T, class Proj = identity,
591 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
592 requires indirectly_writable<iterator_t<R>, const T&>
593 constexpr borrowed_iterator_t<R>
594 ranges::replace_if(R&& r, Pred pred, const T& new_value, Proj proj = {}); // since C++20
595
596 template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
597 class Proj1 = identity, class Proj2 = identity,
598 indirect_strict_weak_order<projected<I1, Proj1>,
599 projected<I2, Proj2>> Comp = ranges::less>
600 constexpr bool
601 ranges::lexicographical_compare(I1 first1, S1 last1, I2 first2, S2 last2,
602 Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
603
604 template<input_range R1, input_range R2, class Proj1 = identity,
605 class Proj2 = identity,
606 indirect_strict_weak_order<projected<iterator_t<R1>, Proj1>,
607 projected<iterator_t<R2>, Proj2>> Comp = ranges::less>
608 constexpr bool
609 ranges::lexicographical_compare(R1&& r1, R2&& r2, Comp comp = {},
610 Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
611
612 template<bidirectional_iterator I1, sentinel_for<I1> S1, bidirectional_iterator I2>
613 requires indirectly_movable<I1, I2>
614 constexpr ranges::move_backward_result<I1, I2>
615 ranges::move_backward(I1 first, S1 last, I2 result); // since C++20
616
617 template<bidirectional_range R, bidirectional_iterator I>
618 requires indirectly_movable<iterator_t<R>, I>
619 constexpr ranges::move_backward_result<borrowed_iterator_t<R>, I>
620 ranges::move_backward(R&& r, I result); // since C++20
621
622 template<input_iterator I, sentinel_for<I> S, weakly_incrementable O>
623 requires indirectly_movable<I, O>
624 constexpr ranges::move_result<I, O>
625 ranges::move(I first, S last, O result); // since C++20
626
627 template<input_range R, weakly_incrementable O>
628 requires indirectly_movable<iterator_t<R>, O>
629 constexpr ranges::move_result<borrowed_iterator_t<R>, O>
630 ranges::move(R&& r, O result); // since C++20
631
632 template<class I, class O1, class O2>
633 using partition_copy_result = in_out_out_result<I, O1, O2>; // since C++20
634
635 template<input_iterator I, sentinel_for<I> S,
636 weakly_incrementable O1, weakly_incrementable O2,
637 class Proj = identity, indirect_unary_predicate<projected<I, Proj>> Pred>
638 requires indirectly_copyable<I, O1> && indirectly_copyable<I, O2>
639 constexpr partition_copy_result<I, O1, O2>
640 partition_copy(I first, S last, O1 out_true, O2 out_false, Pred pred,
641 Proj proj = {}); // Since C++20
642
643 template<input_range R, weakly_incrementable O1, weakly_incrementable O2,
644 class Proj = identity,
645 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
646 requires indirectly_copyable<iterator_t<R>, O1> &&
647 indirectly_copyable<iterator_t<R>, O2>
648 constexpr partition_copy_result<borrowed_iterator_t<R>, O1, O2>
649 partition_copy(R&& r, O1 out_true, O2 out_false, Pred pred, Proj proj = {}); // Since C++20
650
651 template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
652 indirect_unary_predicate<projected<I, Proj>> Pred>
653 constexpr I partition_point(I first, S last, Pred pred, Proj proj = {}); // Since C++20
654
655 template<forward_range R, class Proj = identity,
656 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
657 constexpr borrowed_iterator_t<R>
658 partition_point(R&& r, Pred pred, Proj proj = {}); // Since C++20
659
660 template<class I1, class I2, class O>
661 using merge_result = in_in_out_result<I1, I2, O>; // since C++20
662
663 template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
664 weakly_incrementable O, class Comp = ranges::less, class Proj1 = identity,
665 class Proj2 = identity>
666 requires mergeable<I1, I2, O, Comp, Proj1, Proj2>
667 constexpr merge_result<I1, I2, O>
668 merge(I1 first1, S1 last1, I2 first2, S2 last2, O result,
669 Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
670
671 template<input_range R1, input_range R2, weakly_incrementable O, class Comp = ranges::less,
672 class Proj1 = identity, class Proj2 = identity>
673 requires mergeable<iterator_t<R1>, iterator_t<R2>, O, Comp, Proj1, Proj2>
674 constexpr merge_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>, O>
675 merge(R1&& r1, R2&& r2, O result,
676 Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
677
678 template<permutable I, sentinel_for<I> S, class T, class Proj = identity>
679 requires indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*>
680 constexpr subrange<I> ranges::remove(I first, S last, const T& value, Proj proj = {}); // since C++20
681
682 template<forward_range R, class T, class Proj = identity>
683 requires permutable<iterator_t<R>> &&
684 indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*>
685 constexpr borrowed_subrange_t<R>
686 ranges::remove(R&& r, const T& value, Proj proj = {}); // since C++20
687
688 template<permutable I, sentinel_for<I> S, class Proj = identity,
689 indirect_unary_predicate<projected<I, Proj>> Pred>
690 constexpr subrange<I> ranges::remove_if(I first, S last, Pred pred, Proj proj = {}); // since C++20
691
692 template<forward_range R, class Proj = identity,
693 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
694 requires permutable<iterator_t<R>>
695 constexpr borrowed_subrange_t<R>
696 ranges::remove_if(R&& r, Pred pred, Proj proj = {}); // since C++20
697
698 template<class I, class O>
699 using set_difference_result = in_out_result<I, O>; // since C++20
700
701 template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
702 weakly_incrementable O, class Comp = ranges::less,
703 class Proj1 = identity, class Proj2 = identity>
704 requires mergeable<I1, I2, O, Comp, Proj1, Proj2>
705 constexpr set_difference_result<I1, O>
706 set_difference(I1 first1, S1 last1, I2 first2, S2 last2, O result,
707 Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
708
709 template<input_range R1, input_range R2, weakly_incrementable O,
710 class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity>
711 requires mergeable<iterator_t<R1>, iterator_t<R2>, O, Comp, Proj1, Proj2>
712 constexpr set_difference_result<borrowed_iterator_t<R1>, O>
713 set_difference(R1&& r1, R2&& r2, O result,
714 Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
715
716 template<class I1, class I2, class O>
717 using set_intersection_result = in_in_out_result<I1, I2, O>; // since C++20
718
719 template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
720 weakly_incrementable O, class Comp = ranges::less,
721 class Proj1 = identity, class Proj2 = identity>
722 requires mergeable<I1, I2, O, Comp, Proj1, Proj2>
723 constexpr set_intersection_result<I1, I2, O>
724 set_intersection(I1 first1, S1 last1, I2 first2, S2 last2, O result,
725 Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
726
727 template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
728 weakly_incrementable O, class Comp = ranges::less,
729 class Proj1 = identity, class Proj2 = identity>
730 requires mergeable<I1, I2, O, Comp, Proj1, Proj2>
731 constexpr set_intersection_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>, O>
732 set_intersection(R1&& r1, R2&& r2, O result,
733 Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
734
735 template <class _InIter, class _OutIter>
736 using reverse_copy_result = in_out_result<_InIter, _OutIter>; // since C++20
737
738 template<bidirectional_iterator I, sentinel_for<I> S, weakly_incrementable O>
739 requires indirectly_copyable<I, O>
740 constexpr ranges::reverse_copy_result<I, O>
741 ranges::reverse_copy(I first, S last, O result); // since C++20
742
743 template<bidirectional_range R, weakly_incrementable O>
744 requires indirectly_copyable<iterator_t<R>, O>
745 constexpr ranges::reverse_copy_result<borrowed_iterator_t<R>, O>
746 ranges::reverse_copy(R&& r, O result); // since C++20
747
748 template <class _InIter, class _OutIter>
749 using rotate_copy_result = in_out_result<_InIter, _OutIter>; // since C++20
750
751 template<forward_iterator I, sentinel_for<I> S, weakly_incrementable O>
752 requires indirectly_copyable<I, O>
753 constexpr ranges::rotate_copy_result<I, O>
754 ranges::rotate_copy(I first, I middle, S last, O result); // since C++20
755
756 template<forward_range R, weakly_incrementable O>
757 requires indirectly_copyable<iterator_t<R>, O>
758 constexpr ranges::rotate_copy_result<borrowed_iterator_t<R>, O>
759 ranges::rotate_copy(R&& r, iterator_t<R> middle, O result); // since C++20
760
761 template<random_access_iterator I, sentinel_for<I> S, class Gen>
762 requires permutable<I> &&
763 uniform_random_bit_generator<remove_reference_t<Gen>>
764 I shuffle(I first, S last, Gen&& g); // Since C++20
765
766 template<random_access_range R, class Gen>
767 requires permutable<iterator_t<R>> &&
768 uniform_random_bit_generator<remove_reference_t<Gen>>
769 borrowed_iterator_t<R> shuffle(R&& r, Gen&& g); // Since C++20
770
771 template<forward_iterator I1, sentinel_for<I1> S1, forward_iterator I2,
772 sentinel_for<I2> S2, class Pred = ranges::equal_to,
773 class Proj1 = identity, class Proj2 = identity>
774 requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2>
775 constexpr subrange<I1>
776 ranges::search(I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {},
777 Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
778
779 template<forward_range R1, forward_range R2, class Pred = ranges::equal_to,
780 class Proj1 = identity, class Proj2 = identity>
781 requires indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
782 constexpr borrowed_subrange_t<R1>
783 ranges::search(R1&& r1, R2&& r2, Pred pred = {},
784 Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
785
786 template<forward_iterator I, sentinel_for<I> S, class T,
787 class Pred = ranges::equal_to, class Proj = identity>
788 requires indirectly_comparable<I, const T*, Pred, Proj>
789 constexpr subrange<I>
790 ranges::search_n(I first, S last, iter_difference_t<I> count,
791 const T& value, Pred pred = {}, Proj proj = {}); // since C++20
792
793 template<forward_range R, class T, class Pred = ranges::equal_to,
794 class Proj = identity>
795 requires indirectly_comparable<iterator_t<R>, const T*, Pred, Proj>
796 constexpr borrowed_subrange_t<R>
797 ranges::search_n(R&& r, range_difference_t<R> count,
798 const T& value, Pred pred = {}, Proj proj = {}); // since C++20
799
800 template<forward_iterator I1, sentinel_for<I1> S1, forward_iterator I2, sentinel_for<I2> S2,
801 class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
802 requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2>
803 constexpr subrange<I1>
804 ranges::find_end(I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {},
805 Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
806
807 template<forward_range R1, forward_range R2,
808 class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
809 requires indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
810 constexpr borrowed_subrange_t<R1>
811 ranges::find_end(R1&& r1, R2&& r2, Pred pred = {},
812 Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
813
814 template<class I1, class I2, class O>
815 using set_symmetric_difference_result = in_in_out_result<I1, I2, O>; // since C++20
816
817 template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
818 weakly_incrementable O, class Comp = ranges::less,
819 class Proj1 = identity, class Proj2 = identity>
820 requires mergeable<I1, I2, O, Comp, Proj1, Proj2>
821 constexpr set_symmetric_difference_result<I1, I2, O>
822 set_symmetric_difference(I1 first1, S1 last1, I2 first2, S2 last2, O result,
823 Comp comp = {}, Proj1 proj1 = {},
824 Proj2 proj2 = {}); // since C++20
825
826 template<input_range R1, input_range R2, weakly_incrementable O,
827 class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity>
828 requires mergeable<iterator_t<R1>, iterator_t<R2>, O, Comp, Proj1, Proj2>
829 constexpr set_symmetric_difference_result<borrowed_iterator_t<R1>,
830 borrowed_iterator_t<R2>, O>
831 set_symmetric_difference(R1&& r1, R2&& r2, O result, Comp comp = {},
832 Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
833
834 template<forward_iterator I, sentinel_for<I> S, class T, class Proj = identity,
835 indirect_strict_weak_order<const T*, projected<I, Proj>> Comp = ranges::less>
836 constexpr subrange<I>
837 equal_range(I first, S last, const T& value, Comp comp = {}, Proj proj = {}); // since C++20
838
839 template<forward_range R, class T, class Proj = identity,
840 indirect_strict_weak_order<const T*, projected<iterator_t<R>, Proj>> Comp =
841 ranges::less>
842 constexpr borrowed_subrange_t<R>
843 equal_range(R&& r, const T& value, Comp comp = {}, Proj proj = {}); // since C++20
844
845 template<class I1, class I2, class O>
846 using set_union_result = in_in_out_result<I1, I2, O>; // since C++20
847
848 template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
849 weakly_incrementable O, class Comp = ranges::less,
850 class Proj1 = identity, class Proj2 = identity>
851 requires mergeable<I1, I2, O, Comp, Proj1, Proj2>
852 constexpr set_union_result<I1, I2, O>
853 set_union(I1 first1, S1 last1, I2 first2, S2 last2, O result, Comp comp = {},
854 Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
855
856 template<input_range R1, input_range R2, weakly_incrementable O,
857 class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity>
858 requires mergeable<iterator_t<R1>, iterator_t<R2>, O, Comp, Proj1, Proj2>
859 constexpr set_union_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>, O>
860 set_union(R1&& r1, R2&& r2, O result, Comp comp = {},
861 Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
862
863 template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
864 class Proj1 = identity, class Proj2 = identity,
865 indirect_strict_weak_order<projected<I1, Proj1>, projected<I2, Proj2>> Comp =
866 ranges::less>
867 constexpr bool includes(I1 first1, S1 last1, I2 first2, S2 last2, Comp comp = {},
868 Proj1 proj1 = {}, Proj2 proj2 = {}); // Since C++20
869
870 template<input_range R1, input_range R2, class Proj1 = identity,
871 class Proj2 = identity,
872 indirect_strict_weak_order<projected<iterator_t<R1>, Proj1>,
873 projected<iterator_t<R2>, Proj2>> Comp = ranges::less>
874 constexpr bool includes(R1&& r1, R2&& r2, Comp comp = {},
875 Proj1 proj1 = {}, Proj2 proj2 = {}); // Since C++20
876
877 template<bidirectional_iterator I, sentinel_for<I> S, class Comp = ranges::less,
878 class Proj = identity>
879 requires sortable<I, Comp, Proj>
880 I inplace_merge(I first, I middle, S last, Comp comp = {}, Proj proj = {}); // Since C++20
881
882 template<bidirectional_range R, class Comp = ranges::less, class Proj = identity>
883 requires sortable<iterator_t<R>, Comp, Proj>
884 borrowed_iterator_t<R>
885 inplace_merge(R&& r, iterator_t<R> middle, Comp comp = {},
886 Proj proj = {}); // Since C++20
887
888 template<permutable I, sentinel_for<I> S, class Proj = identity,
889 indirect_equivalence_relation<projected<I, Proj>> C = ranges::equal_to>
890 constexpr subrange<I> unique(I first, S last, C comp = {}, Proj proj = {}); // Since C++20
891
892 template<forward_range R, class Proj = identity,
893 indirect_equivalence_relation<projected<iterator_t<R>, Proj>> C = ranges::equal_to>
894 requires permutable<iterator_t<R>>
895 constexpr borrowed_subrange_t<R>
896 unique(R&& r, C comp = {}, Proj proj = {}); // Since C++20
897
898 template<input_iterator I, sentinel_for<I> S, weakly_incrementable O, class Proj = identity,
899 indirect_equivalence_relation<projected<I, Proj>> C = ranges::equal_to>
900 requires indirectly_copyable<I, O> &&
901 (forward_iterator<I> ||
902 (input_iterator<O> && same_as<iter_value_t<I>, iter_value_t<O>>) ||
903 indirectly_copyable_storable<I, O>)
904 constexpr unique_copy_result<I, O>
905 unique_copy(I first, S last, O result, C comp = {}, Proj proj = {}); // Since C++20
906
907 template<input_range R, weakly_incrementable O, class Proj = identity,
908 indirect_equivalence_relation<projected<iterator_t<R>, Proj>> C = ranges::equal_to>
909 requires indirectly_copyable<iterator_t<R>, O> &&
910 (forward_iterator<iterator_t<R>> ||
911 (input_iterator<O> && same_as<range_value_t<R>, iter_value_t<O>>) ||
912 indirectly_copyable_storable<iterator_t<R>, O>)
913 constexpr unique_copy_result<borrowed_iterator_t<R>, O>
914 unique_copy(R&& r, O result, C comp = {}, Proj proj = {}); // Since C++20
27}915}
28916
29template <class InputIterator, class Predicate>
30 constexpr bool // constexpr in C++20917 constexpr bool // constexpr in C++20
31 all_of(InputIterator first, InputIterator last, Predicate pred);918 all_of(InputIterator first, InputIterator last, Predicate pred);
32919
...@@ -192,10 +1079,35 @@ template <class BidirectionalIterator1, class BidirectionalIterator2>...@@ -192,10 +1079,35 @@ template <class BidirectionalIterator1, class BidirectionalIterator2>
192 copy_backward(BidirectionalIterator1 first, BidirectionalIterator1 last,1079 copy_backward(BidirectionalIterator1 first, BidirectionalIterator1 last,
193 BidirectionalIterator2 result);1080 BidirectionalIterator2 result);
1941081
1082// [alg.move], move
1083template<class InputIterator, class OutputIterator>
1084 constexpr OutputIterator move(InputIterator first, InputIterator last,
1085 OutputIterator result);
1086
1087template<class BidirectionalIterator1, class BidirectionalIterator2>
1088 constexpr BidirectionalIterator2
1089 move_backward(BidirectionalIterator1 first, BidirectionalIterator1 last,
1090 BidirectionalIterator2 result);
1091
195template <class ForwardIterator1, class ForwardIterator2>1092template <class ForwardIterator1, class ForwardIterator2>
196 constexpr ForwardIterator2 // constexpr in C++201093 constexpr ForwardIterator2 // constexpr in C++20
197 swap_ranges(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2);1094 swap_ranges(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2);
1981095
1096namespace ranges {
1097 template<class I1, class I2>
1098 using swap_ranges_result = in_in_result<I1, I2>;
1099
1100template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2>
1101 requires indirectly_swappable<I1, I2>
1102 constexpr ranges::swap_ranges_result<I1, I2>
1103 swap_ranges(I1 first1, S1 last1, I2 first2, S2 last2);
1104
1105template<input_range R1, input_range R2>
1106 requires indirectly_swappable<iterator_t<R1>, iterator_t<R2>>
1107 constexpr ranges::swap_ranges_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>>
1108 swap_ranges(R1&& r1, R2&& r2);
1109}
1110
199template <class ForwardIterator1, class ForwardIterator2>1111template <class ForwardIterator1, class ForwardIterator2>
200 constexpr void // constexpr in C++201112 constexpr void // constexpr in C++20
201 iter_swap(ForwardIterator1 a, ForwardIterator2 b);1113 iter_swap(ForwardIterator1 a, ForwardIterator2 b);
...@@ -648,28 +1560,18 @@ template <class BidirectionalIterator>...@@ -648,28 +1560,18 @@ template <class BidirectionalIterator>
648template <class BidirectionalIterator, class Compare>1560template <class BidirectionalIterator, class Compare>
649 constexpr bool // constexpr in C++201561 constexpr bool // constexpr in C++20
650 prev_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp);1562 prev_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp);
651
652namespace ranges {
653// [algorithms.results], algorithm result types
654template<class InputIterator, class OutputIterator>
655 struct in_out_result;
656}
657
658} // std1563} // std
6591564
660*/1565*/
6611566
662#include <__bits> // __libcpp_clz1567#include <__assert> // all public C++ headers provide the assertion handler
1568#include <__bits>
663#include <__config>1569#include <__config>
664#include <__debug>1570#include <__debug>
665#include <cstddef>1571#include <cstddef>
666#include <cstring>1572#include <cstring>
667#include <functional>
668#include <initializer_list>
669#include <iterator>
670#include <memory>1573#include <memory>
671#include <type_traits>1574#include <type_traits>
672#include <utility> // swap_ranges
673#include <version>1575#include <version>
6741576
675#include <__algorithm/adjacent_find.h>1577#include <__algorithm/adjacent_find.h>
...@@ -699,8 +1601,11 @@ template<class InputIterator, class OutputIterator>...@@ -699,8 +1601,11 @@ template<class InputIterator, class OutputIterator>
699#include <__algorithm/generate.h>1601#include <__algorithm/generate.h>
700#include <__algorithm/generate_n.h>1602#include <__algorithm/generate_n.h>
701#include <__algorithm/half_positive.h>1603#include <__algorithm/half_positive.h>
1604#include <__algorithm/in_found_result.h>
1605#include <__algorithm/in_fun_result.h>
702#include <__algorithm/in_in_out_result.h>1606#include <__algorithm/in_in_out_result.h>
703#include <__algorithm/in_in_result.h>1607#include <__algorithm/in_in_result.h>
1608#include <__algorithm/in_out_out_result.h>
704#include <__algorithm/in_out_result.h>1609#include <__algorithm/in_out_result.h>
705#include <__algorithm/includes.h>1610#include <__algorithm/includes.h>
706#include <__algorithm/inplace_merge.h>1611#include <__algorithm/inplace_merge.h>
...@@ -719,6 +1624,7 @@ template<class InputIterator, class OutputIterator>...@@ -719,6 +1624,7 @@ template<class InputIterator, class OutputIterator>
719#include <__algorithm/merge.h>1624#include <__algorithm/merge.h>
720#include <__algorithm/min.h>1625#include <__algorithm/min.h>
721#include <__algorithm/min_element.h>1626#include <__algorithm/min_element.h>
1627#include <__algorithm/min_max_result.h>
722#include <__algorithm/minmax.h>1628#include <__algorithm/minmax.h>
723#include <__algorithm/minmax_element.h>1629#include <__algorithm/minmax_element.h>
724#include <__algorithm/mismatch.h>1630#include <__algorithm/mismatch.h>
...@@ -735,6 +1641,81 @@ template<class InputIterator, class OutputIterator>...@@ -735,6 +1641,81 @@ template<class InputIterator, class OutputIterator>
735#include <__algorithm/pop_heap.h>1641#include <__algorithm/pop_heap.h>
736#include <__algorithm/prev_permutation.h>1642#include <__algorithm/prev_permutation.h>
737#include <__algorithm/push_heap.h>1643#include <__algorithm/push_heap.h>
1644#include <__algorithm/ranges_adjacent_find.h>
1645#include <__algorithm/ranges_all_of.h>
1646#include <__algorithm/ranges_any_of.h>
1647#include <__algorithm/ranges_binary_search.h>
1648#include <__algorithm/ranges_copy.h>
1649#include <__algorithm/ranges_copy_backward.h>
1650#include <__algorithm/ranges_copy_if.h>
1651#include <__algorithm/ranges_copy_n.h>
1652#include <__algorithm/ranges_count.h>
1653#include <__algorithm/ranges_count_if.h>
1654#include <__algorithm/ranges_equal.h>
1655#include <__algorithm/ranges_equal_range.h>
1656#include <__algorithm/ranges_fill.h>
1657#include <__algorithm/ranges_fill_n.h>
1658#include <__algorithm/ranges_find.h>
1659#include <__algorithm/ranges_find_end.h>
1660#include <__algorithm/ranges_find_first_of.h>
1661#include <__algorithm/ranges_find_if.h>
1662#include <__algorithm/ranges_find_if_not.h>
1663#include <__algorithm/ranges_for_each.h>
1664#include <__algorithm/ranges_for_each_n.h>
1665#include <__algorithm/ranges_generate.h>
1666#include <__algorithm/ranges_generate_n.h>
1667#include <__algorithm/ranges_includes.h>
1668#include <__algorithm/ranges_inplace_merge.h>
1669#include <__algorithm/ranges_is_heap.h>
1670#include <__algorithm/ranges_is_heap_until.h>
1671#include <__algorithm/ranges_is_partitioned.h>
1672#include <__algorithm/ranges_is_sorted.h>
1673#include <__algorithm/ranges_is_sorted_until.h>
1674#include <__algorithm/ranges_lexicographical_compare.h>
1675#include <__algorithm/ranges_lower_bound.h>
1676#include <__algorithm/ranges_make_heap.h>
1677#include <__algorithm/ranges_max.h>
1678#include <__algorithm/ranges_max_element.h>
1679#include <__algorithm/ranges_merge.h>
1680#include <__algorithm/ranges_min.h>
1681#include <__algorithm/ranges_min_element.h>
1682#include <__algorithm/ranges_minmax.h>
1683#include <__algorithm/ranges_minmax_element.h>
1684#include <__algorithm/ranges_mismatch.h>
1685#include <__algorithm/ranges_move.h>
1686#include <__algorithm/ranges_move_backward.h>
1687#include <__algorithm/ranges_none_of.h>
1688#include <__algorithm/ranges_nth_element.h>
1689#include <__algorithm/ranges_partial_sort.h>
1690#include <__algorithm/ranges_partial_sort_copy.h>
1691#include <__algorithm/ranges_partition.h>
1692#include <__algorithm/ranges_partition_copy.h>
1693#include <__algorithm/ranges_partition_point.h>
1694#include <__algorithm/ranges_pop_heap.h>
1695#include <__algorithm/ranges_push_heap.h>
1696#include <__algorithm/ranges_remove.h>
1697#include <__algorithm/ranges_remove_if.h>
1698#include <__algorithm/ranges_replace.h>
1699#include <__algorithm/ranges_replace_if.h>
1700#include <__algorithm/ranges_reverse.h>
1701#include <__algorithm/ranges_reverse_copy.h>
1702#include <__algorithm/ranges_rotate_copy.h>
1703#include <__algorithm/ranges_search.h>
1704#include <__algorithm/ranges_search_n.h>
1705#include <__algorithm/ranges_set_difference.h>
1706#include <__algorithm/ranges_set_intersection.h>
1707#include <__algorithm/ranges_set_symmetric_difference.h>
1708#include <__algorithm/ranges_set_union.h>
1709#include <__algorithm/ranges_shuffle.h>
1710#include <__algorithm/ranges_sort.h>
1711#include <__algorithm/ranges_sort_heap.h>
1712#include <__algorithm/ranges_stable_partition.h>
1713#include <__algorithm/ranges_stable_sort.h>
1714#include <__algorithm/ranges_swap_ranges.h>
1715#include <__algorithm/ranges_transform.h>
1716#include <__algorithm/ranges_unique.h>
1717#include <__algorithm/ranges_unique_copy.h>
1718#include <__algorithm/ranges_upper_bound.h>
738#include <__algorithm/remove.h>1719#include <__algorithm/remove.h>
739#include <__algorithm/remove_copy.h>1720#include <__algorithm/remove_copy.h>
740#include <__algorithm/remove_copy_if.h>1721#include <__algorithm/remove_copy_if.h>
...@@ -769,8 +1750,17 @@ template<class InputIterator, class OutputIterator>...@@ -769,8 +1750,17 @@ template<class InputIterator, class OutputIterator>
769#include <__algorithm/unwrap_iter.h>1750#include <__algorithm/unwrap_iter.h>
770#include <__algorithm/upper_bound.h>1751#include <__algorithm/upper_bound.h>
7711752
1753#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
1754# include <chrono>
1755# include <iterator>
1756# include <utility>
1757#endif
1758
1759// standard-mandated includes
1760#include <initializer_list>
1761
772#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)1762#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
773#pragma GCC system_header1763# pragma GCC system_header
774#endif1764#endif
7751765
776#if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 171766#if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17
lib/libcxx/include/any+14-2
...@@ -80,17 +80,26 @@ namespace std {...@@ -80,17 +80,26 @@ namespace std {
8080
81*/81*/
8282
83#include <__assert> // all public C++ headers provide the assertion handler
83#include <__availability>84#include <__availability>
84#include <__config>85#include <__config>
85#include <__utility/forward.h>86#include <__utility/forward.h>
87#include <__utility/in_place.h>
88#include <__utility/move.h>
89#include <__utility/unreachable.h>
86#include <cstdlib>90#include <cstdlib>
91#include <initializer_list>
87#include <memory>92#include <memory>
88#include <type_traits>93#include <type_traits>
89#include <typeinfo>94#include <typeinfo>
90#include <version>95#include <version>
9196
97#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
98# include <chrono>
99#endif
100
92#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)101#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
93#pragma GCC system_header102# pragma GCC system_header
94#endif103#endif
95104
96namespace std {105namespace std {
...@@ -262,7 +271,7 @@ public:...@@ -262,7 +271,7 @@ public:
262 is_copy_constructible<_Tp>::value>271 is_copy_constructible<_Tp>::value>
263 >272 >
264 _LIBCPP_INLINE_VISIBILITY273 _LIBCPP_INLINE_VISIBILITY
265 _Tp& emplace(_Args&&... args);274 _Tp& emplace(_Args&&...);
266275
267 template <class _ValueType, class _Up, class ..._Args,276 template <class _ValueType, class _Up, class ..._Args,
268 class _Tp = decay_t<_ValueType>,277 class _Tp = decay_t<_ValueType>,
...@@ -364,6 +373,7 @@ namespace __any_imp...@@ -364,6 +373,7 @@ namespace __any_imp
364 case _Action::_TypeInfo:373 case _Action::_TypeInfo:
365 return __type_info();374 return __type_info();
366 }375 }
376 __libcpp_unreachable();
367 }377 }
368378
369 template <class ..._Args>379 template <class ..._Args>
...@@ -447,6 +457,7 @@ namespace __any_imp...@@ -447,6 +457,7 @@ namespace __any_imp
447 case _Action::_TypeInfo:457 case _Action::_TypeInfo:
448 return __type_info();458 return __type_info();
449 }459 }
460 __libcpp_unreachable();
450 }461 }
451462
452 template <class ..._Args>463 template <class ..._Args>
...@@ -658,6 +669,7 @@ _RetType __pointer_or_func_cast(void*, /*IsFunction*/true_type) noexcept {...@@ -658,6 +669,7 @@ _RetType __pointer_or_func_cast(void*, /*IsFunction*/true_type) noexcept {
658}669}
659670
660template <class _ValueType>671template <class _ValueType>
672_LIBCPP_HIDE_FROM_ABI
661add_pointer_t<_ValueType>673add_pointer_t<_ValueType>
662any_cast(any * __any) _NOEXCEPT674any_cast(any * __any) _NOEXCEPT
663{675{
lib/libcxx/include/array+39-21
...@@ -108,19 +108,42 @@ template <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexce...@@ -108,19 +108,42 @@ template <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexce
108108
109*/109*/
110110
111#include <__algorithm/equal.h>
112#include <__algorithm/fill_n.h>
113#include <__algorithm/lexicographical_compare.h>
114#include <__algorithm/swap_ranges.h>
115#include <__assert> // all public C++ headers provide the assertion handler
111#include <__config>116#include <__config>
112#include <__debug>117#include <__iterator/reverse_iterator.h>
113#include <__tuple>118#include <__tuple>
114#include <algorithm>119#include <__utility/integer_sequence.h>
115#include <cstdlib> // for _LIBCPP_UNREACHABLE120#include <__utility/move.h>
116#include <iterator>121#include <__utility/unreachable.h>
117#include <stdexcept>122#include <stdexcept>
118#include <type_traits>123#include <type_traits>
119#include <utility>
120#include <version>124#include <version>
121125
126#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
127# include <algorithm>
128# include <iterator>
129# include <utility>
130#endif
131
132// standard-mandated includes
133
134// [iterator.range]
135#include <__iterator/access.h>
136#include <__iterator/data.h>
137#include <__iterator/empty.h>
138#include <__iterator/reverse_access.h>
139#include <__iterator/size.h>
140
141// [array.syn]
142#include <compare>
143#include <initializer_list>
144
122#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)145#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
123#pragma GCC system_header146# pragma GCC system_header
124#endif147#endif
125148
126_LIBCPP_BEGIN_NAMESPACE_STD149_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -309,54 +332,54 @@ struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0>...@@ -309,54 +332,54 @@ struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0>
309 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14332 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
310 reference operator[](size_type) _NOEXCEPT {333 reference operator[](size_type) _NOEXCEPT {
311 _LIBCPP_ASSERT(false, "cannot call array<T, 0>::operator[] on a zero-sized array");334 _LIBCPP_ASSERT(false, "cannot call array<T, 0>::operator[] on a zero-sized array");
312 _LIBCPP_UNREACHABLE();335 __libcpp_unreachable();
313 }336 }
314337
315 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11338 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
316 const_reference operator[](size_type) const _NOEXCEPT {339 const_reference operator[](size_type) const _NOEXCEPT {
317 _LIBCPP_ASSERT(false, "cannot call array<T, 0>::operator[] on a zero-sized array");340 _LIBCPP_ASSERT(false, "cannot call array<T, 0>::operator[] on a zero-sized array");
318 _LIBCPP_UNREACHABLE();341 __libcpp_unreachable();
319 }342 }
320343
321 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14344 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
322 reference at(size_type) {345 reference at(size_type) {
323 __throw_out_of_range("array<T, 0>::at");346 __throw_out_of_range("array<T, 0>::at");
324 _LIBCPP_UNREACHABLE();347 __libcpp_unreachable();
325 }348 }
326349
327 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11350 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
328 const_reference at(size_type) const {351 const_reference at(size_type) const {
329 __throw_out_of_range("array<T, 0>::at");352 __throw_out_of_range("array<T, 0>::at");
330 _LIBCPP_UNREACHABLE();353 __libcpp_unreachable();
331 }354 }
332355
333 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14356 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
334 reference front() _NOEXCEPT {357 reference front() _NOEXCEPT {
335 _LIBCPP_ASSERT(false, "cannot call array<T, 0>::front() on a zero-sized array");358 _LIBCPP_ASSERT(false, "cannot call array<T, 0>::front() on a zero-sized array");
336 _LIBCPP_UNREACHABLE();359 __libcpp_unreachable();
337 }360 }
338361
339 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11362 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
340 const_reference front() const _NOEXCEPT {363 const_reference front() const _NOEXCEPT {
341 _LIBCPP_ASSERT(false, "cannot call array<T, 0>::front() on a zero-sized array");364 _LIBCPP_ASSERT(false, "cannot call array<T, 0>::front() on a zero-sized array");
342 _LIBCPP_UNREACHABLE();365 __libcpp_unreachable();
343 }366 }
344367
345 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14368 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
346 reference back() _NOEXCEPT {369 reference back() _NOEXCEPT {
347 _LIBCPP_ASSERT(false, "cannot call array<T, 0>::back() on a zero-sized array");370 _LIBCPP_ASSERT(false, "cannot call array<T, 0>::back() on a zero-sized array");
348 _LIBCPP_UNREACHABLE();371 __libcpp_unreachable();
349 }372 }
350373
351 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11374 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
352 const_reference back() const _NOEXCEPT {375 const_reference back() const _NOEXCEPT {
353 _LIBCPP_ASSERT(false, "cannot call array<T, 0>::back() on a zero-sized array");376 _LIBCPP_ASSERT(false, "cannot call array<T, 0>::back() on a zero-sized array");
354 _LIBCPP_UNREACHABLE();377 __libcpp_unreachable();
355 }378 }
356};379};
357380
358381
359#if _LIBCPP_STD_VER >= 17382#if _LIBCPP_STD_VER > 14
360template<class _Tp, class... _Args,383template<class _Tp, class... _Args,
361 class = enable_if_t<__all<_IsSame<_Tp, _Args>::value...>::value>384 class = enable_if_t<__all<_IsSame<_Tp, _Args>::value...>::value>
362 >385 >
...@@ -415,12 +438,7 @@ operator>=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)...@@ -415,12 +438,7 @@ operator>=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
415438
416template <class _Tp, size_t _Size>439template <class _Tp, size_t _Size>
417inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17440inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
418typename enable_if441__enable_if_t<_Size == 0 || __is_swappable<_Tp>::value, void>
419<
420 _Size == 0 ||
421 __is_swappable<_Tp>::value,
422 void
423>::type
424swap(array<_Tp, _Size>& __x, array<_Tp, _Size>& __y)442swap(array<_Tp, _Size>& __x, array<_Tp, _Size>& __y)
425 _NOEXCEPT_(noexcept(__x.swap(__y)))443 _NOEXCEPT_(noexcept(__x.swap(__y)))
426{444{
lib/libcxx/include/atomic+15-25
...@@ -518,7 +518,9 @@ template <class T>...@@ -518,7 +518,9 @@ template <class T>
518518
519*/519*/
520520
521#include <__assert> // all public C++ headers provide the assertion handler
521#include <__availability>522#include <__availability>
523#include <__chrono/duration.h>
522#include <__config>524#include <__config>
523#include <__thread/poll_with_backoff.h>525#include <__thread/poll_with_backoff.h>
524#include <__thread/timed_backoff_policy.h>526#include <__thread/timed_backoff_policy.h>
...@@ -532,15 +534,19 @@ template <class T>...@@ -532,15 +534,19 @@ template <class T>
532# include <__threading_support>534# include <__threading_support>
533#endif535#endif
534536
537#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
538# include <chrono>
539#endif
540
535#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)541#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
536#pragma GCC system_header542# pragma GCC system_header
537#endif543#endif
538544
539#ifdef _LIBCPP_HAS_NO_ATOMIC_HEADER545#ifdef _LIBCPP_HAS_NO_ATOMIC_HEADER
540# error <atomic> is not implemented546# error <atomic> is not implemented
541#endif547#endif
542#ifdef kill_dependency548#ifdef kill_dependency
543# error C++ standard library is incompatible with <stdatomic.h>549# error <atomic> is incompatible with <stdatomic.h> before C++23. Please compile with -std=c++23.
544#endif550#endif
545551
546#define _LIBCPP_CHECK_STORE_MEMORY_ORDER(__m) \552#define _LIBCPP_CHECK_STORE_MEMORY_ORDER(__m) \
...@@ -900,8 +906,8 @@ struct __cxx_atomic_base_impl {...@@ -900,8 +906,8 @@ struct __cxx_atomic_base_impl {
900#else906#else
901 __cxx_atomic_base_impl() _NOEXCEPT : __a_value() {}907 __cxx_atomic_base_impl() _NOEXCEPT : __a_value() {}
902#endif // _LIBCPP_CXX03_LANG908#endif // _LIBCPP_CXX03_LANG
903 _LIBCPP_CONSTEXPR explicit __cxx_atomic_base_impl(_Tp value) _NOEXCEPT909 _LIBCPP_CONSTEXPR explicit __cxx_atomic_base_impl(_Tp __value) _NOEXCEPT
904 : __a_value(value) {}910 : __a_value(__value) {}
905 _LIBCPP_DISABLE_EXTENSION_WARNING _Atomic(_Tp) __a_value;911 _LIBCPP_DISABLE_EXTENSION_WARNING _Atomic(_Tp) __a_value;
906};912};
907913
...@@ -1445,15 +1451,15 @@ struct __cxx_atomic_impl : public _Base {...@@ -1445,15 +1451,15 @@ struct __cxx_atomic_impl : public _Base {
1445 "std::atomic<T> requires that 'T' be a trivially copyable type");1451 "std::atomic<T> requires that 'T' be a trivially copyable type");
14461452
1447 _LIBCPP_INLINE_VISIBILITY __cxx_atomic_impl() _NOEXCEPT = default;1453 _LIBCPP_INLINE_VISIBILITY __cxx_atomic_impl() _NOEXCEPT = default;
1448 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR explicit __cxx_atomic_impl(_Tp value) _NOEXCEPT1454 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR explicit __cxx_atomic_impl(_Tp __value) _NOEXCEPT
1449 : _Base(value) {}1455 : _Base(__value) {}
1450};1456};
14511457
1452#ifdef __linux__1458#if defined(__linux__) || (defined(_AIX) && !defined(__64BIT__))
1453 using __cxx_contention_t = int32_t;1459 using __cxx_contention_t = int32_t;
1454#else1460#else
1455 using __cxx_contention_t = int64_t;1461 using __cxx_contention_t = int64_t;
1456#endif //__linux__1462#endif // __linux__ || (_AIX && !__64BIT__)
14571463
1458using __cxx_atomic_contention_t = __cxx_atomic_impl<__cxx_contention_t>;1464using __cxx_atomic_contention_t = __cxx_atomic_impl<__cxx_contention_t>;
14591465
...@@ -1651,13 +1657,7 @@ struct __atomic_base // false...@@ -1651,13 +1657,7 @@ struct __atomic_base // false
1651 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR1657 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
1652 __atomic_base(_Tp __d) _NOEXCEPT : __a_(__d) {}1658 __atomic_base(_Tp __d) _NOEXCEPT : __a_(__d) {}
16531659
1654#ifndef _LIBCPP_CXX03_LANG
1655 __atomic_base(const __atomic_base&) = delete;1660 __atomic_base(const __atomic_base&) = delete;
1656#else
1657private:
1658 _LIBCPP_INLINE_VISIBILITY
1659 __atomic_base(const __atomic_base&);
1660#endif
1661};1661};
16621662
1663#if defined(__cpp_lib_atomic_is_always_lock_free)1663#if defined(__cpp_lib_atomic_is_always_lock_free)
...@@ -2439,19 +2439,10 @@ typedef struct atomic_flag...@@ -2439,19 +2439,10 @@ typedef struct atomic_flag
2439 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR2439 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
2440 atomic_flag(bool __b) _NOEXCEPT : __a_(__b) {} // EXTENSION2440 atomic_flag(bool __b) _NOEXCEPT : __a_(__b) {} // EXTENSION
24412441
2442#ifndef _LIBCPP_CXX03_LANG
2443 atomic_flag(const atomic_flag&) = delete;2442 atomic_flag(const atomic_flag&) = delete;
2444 atomic_flag& operator=(const atomic_flag&) = delete;2443 atomic_flag& operator=(const atomic_flag&) = delete;
2445 atomic_flag& operator=(const atomic_flag&) volatile = delete;2444 atomic_flag& operator=(const atomic_flag&) volatile = delete;
2446#else2445
2447private:
2448 _LIBCPP_INLINE_VISIBILITY
2449 atomic_flag(const atomic_flag&);
2450 _LIBCPP_INLINE_VISIBILITY
2451 atomic_flag& operator=(const atomic_flag&);
2452 _LIBCPP_INLINE_VISIBILITY
2453 atomic_flag& operator=(const atomic_flag&) volatile;
2454#endif
2455} atomic_flag;2446} atomic_flag;
24562447
24572448
...@@ -2705,7 +2696,6 @@ typedef atomic<__libcpp_unsigned_lock_free> atomic_unsigned_lock_free;...@@ -2705,7 +2696,6 @@ typedef atomic<__libcpp_unsigned_lock_free> atomic_unsigned_lock_free;
27052696
2706#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)2697#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
2707# if defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 14002698# if defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 1400
2708# pragma clang deprecated(ATOMIC_FLAG_INIT)
2709# pragma clang deprecated(ATOMIC_VAR_INIT)2699# pragma clang deprecated(ATOMIC_VAR_INIT)
2710# endif2700# endif
2711#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)2701#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
lib/libcxx/include/barrier+28-28
...@@ -45,20 +45,20 @@ namespace std...@@ -45,20 +45,20 @@ namespace std
4545
46*/46*/
4747
48#include <__assert> // all public C++ headers provide the assertion handler
48#include <__availability>49#include <__availability>
49#include <__config>50#include <__config>
50#include <__thread/timed_backoff_policy.h>51#include <__thread/timed_backoff_policy.h>
51#include <atomic>52#include <atomic>
52#ifndef _LIBCPP_HAS_NO_TREE_BARRIER53#include <limits>
53# include <memory>54#include <memory>
54#endif
5555
56#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)56#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
57#pragma GCC system_header57# pragma GCC system_header
58#endif58#endif
5959
60#ifdef _LIBCPP_HAS_NO_THREADS60#ifdef _LIBCPP_HAS_NO_THREADS
61# error <barrier> is not supported on this single threaded system61# error "<barrier> is not supported since libc++ has been configured without support for threads."
62#endif62#endif
6363
64_LIBCPP_PUSH_MACROS64_LIBCPP_PUSH_MACROS
...@@ -108,12 +108,12 @@ void __destroy_barrier_algorithm_base(__barrier_algorithm_base* __barrier);...@@ -108,12 +108,12 @@ void __destroy_barrier_algorithm_base(__barrier_algorithm_base* __barrier);
108108
109template<class _CompletionF>109template<class _CompletionF>
110class __barrier_base {110class __barrier_base {
111 ptrdiff_t __expected;111 ptrdiff_t __expected_;
112 unique_ptr<__barrier_algorithm_base,112 unique_ptr<__barrier_algorithm_base,
113 void (*)(__barrier_algorithm_base*)> __base;113 void (*)(__barrier_algorithm_base*)> __base_;
114 __atomic_base<ptrdiff_t> __expected_adjustment;114 __atomic_base<ptrdiff_t> __expected_adjustment_;
115 _CompletionF __completion;115 _CompletionF __completion_;
116 __atomic_base<__barrier_phase_t> __phase;116 __atomic_base<__barrier_phase_t> __phase_;
117117
118public:118public:
119 using arrival_token = __barrier_phase_t;119 using arrival_token = __barrier_phase_t;
...@@ -124,22 +124,22 @@ public:...@@ -124,22 +124,22 @@ public:
124124
125 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY125 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
126 __barrier_base(ptrdiff_t __expected, _CompletionF __completion = _CompletionF())126 __barrier_base(ptrdiff_t __expected, _CompletionF __completion = _CompletionF())
127 : __expected(__expected), __base(__construct_barrier_algorithm_base(this->__expected),127 : __expected_(__expected), __base_(__construct_barrier_algorithm_base(this->__expected_),
128 &__destroy_barrier_algorithm_base),128 &__destroy_barrier_algorithm_base),
129 __expected_adjustment(0), __completion(move(__completion)), __phase(0)129 __expected_adjustment_(0), __completion_(std::move(__completion)), __phase_(0)
130 {130 {
131 }131 }
132 [[nodiscard]] _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY132 [[nodiscard]] _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
133 arrival_token arrive(ptrdiff_t update)133 arrival_token arrive(ptrdiff_t __update)
134 {134 {
135 auto const __old_phase = __phase.load(memory_order_relaxed);135 auto const __old_phase = __phase_.load(memory_order_relaxed);
136 for(; update; --update)136 for(; __update; --__update)
137 if(__arrive_barrier_algorithm_base(__base.get(), __old_phase)) {137 if(__arrive_barrier_algorithm_base(__base_.get(), __old_phase)) {
138 __completion();138 __completion_();
139 __expected += __expected_adjustment.load(memory_order_relaxed);139 __expected_ += __expected_adjustment_.load(memory_order_relaxed);
140 __expected_adjustment.store(0, memory_order_relaxed);140 __expected_adjustment_.store(0, memory_order_relaxed);
141 __phase.store(__old_phase + 2, memory_order_release);141 __phase_.store(__old_phase + 2, memory_order_release);
142 __phase.notify_all();142 __phase_.notify_all();
143 }143 }
144 return __old_phase;144 return __old_phase;
145 }145 }
...@@ -147,14 +147,14 @@ public:...@@ -147,14 +147,14 @@ public:
147 void wait(arrival_token&& __old_phase) const147 void wait(arrival_token&& __old_phase) const
148 {148 {
149 auto const __test_fn = [this, __old_phase]() -> bool {149 auto const __test_fn = [this, __old_phase]() -> bool {
150 return __phase.load(memory_order_acquire) != __old_phase;150 return __phase_.load(memory_order_acquire) != __old_phase;
151 };151 };
152 __libcpp_thread_poll_with_backoff(__test_fn, __libcpp_timed_backoff_policy());152 __libcpp_thread_poll_with_backoff(__test_fn, __libcpp_timed_backoff_policy());
153 }153 }
154 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY154 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
155 void arrive_and_drop()155 void arrive_and_drop()
156 {156 {
157 __expected_adjustment.fetch_sub(1, memory_order_relaxed);157 __expected_adjustment_.fetch_sub(1, memory_order_relaxed);
158 (void)arrive(1);158 (void)arrive(1);
159 }159 }
160};160};
...@@ -190,7 +190,7 @@ public:...@@ -190,7 +190,7 @@ public:
190190
191 _LIBCPP_INLINE_VISIBILITY191 _LIBCPP_INLINE_VISIBILITY
192 __barrier_base(ptrdiff_t __expected, _CompletionF __completion = _CompletionF())192 __barrier_base(ptrdiff_t __expected, _CompletionF __completion = _CompletionF())
193 : __expected(__expected), __arrived(__expected), __completion(move(__completion)), __phase(false)193 : __expected(__expected), __arrived(__expected), __completion(std::move(__completion)), __phase(false)
194 {194 {
195 }195 }
196 [[nodiscard]] _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY196 [[nodiscard]] _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
...@@ -278,7 +278,7 @@ public:...@@ -278,7 +278,7 @@ public:
278 }278 }
279};279};
280280
281#endif //_LIBCPP_HAS_NO_TREE_BARRIER281#endif // !_LIBCPP_HAS_NO_TREE_BARRIER
282282
283template<class _CompletionF = __empty_completion>283template<class _CompletionF = __empty_completion>
284class barrier {284class barrier {
...@@ -300,9 +300,9 @@ public:...@@ -300,9 +300,9 @@ public:
300 barrier& operator=(barrier const&) = delete;300 barrier& operator=(barrier const&) = delete;
301301
302 [[nodiscard]] _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY302 [[nodiscard]] _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
303 arrival_token arrive(ptrdiff_t update = 1)303 arrival_token arrive(ptrdiff_t __update = 1)
304 {304 {
305 return __b.arrive(update);305 return __b.arrive(__update);
306 }306 }
307 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY307 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
308 void wait(arrival_token&& __phase) const308 void wait(arrival_token&& __phase) const
lib/libcxx/include/bit+107-198
...@@ -30,7 +30,7 @@ namespace std {...@@ -30,7 +30,7 @@ namespace std {
30 template <class T>30 template <class T>
31 constexpr T bit_floor(T x) noexcept; // C++2031 constexpr T bit_floor(T x) noexcept; // C++20
32 template <class T>32 template <class T>
33 constexpr T bit_width(T x) noexcept; // C++2033 constexpr int bit_width(T x) noexcept; // C++20
3434
35 // [bit.rotate], rotating35 // [bit.rotate], rotating
36 template<class T>36 template<class T>
...@@ -61,24 +61,26 @@ namespace std {...@@ -61,24 +61,26 @@ namespace std {
6161
62*/62*/
6363
64#include <__assert> // all public C++ headers provide the assertion handler
64#include <__bit/bit_cast.h>65#include <__bit/bit_cast.h>
65#include <__bit/byteswap.h>66#include <__bit/byteswap.h>
66#include <__bits> // __libcpp_clz67#include <__bits> // __libcpp_clz
68#include <__concepts/arithmetic.h>
67#include <__config>69#include <__config>
68#include <__debug>
69#include <limits>70#include <limits>
70#include <type_traits>71#include <type_traits>
71#include <version>72#include <version>
7273
73#if defined(__IBMCPP__)74#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
74#include "__support/ibm/support.h"75# include <iosfwd>
75#endif76#endif
77
76#if defined(_LIBCPP_COMPILER_MSVC)78#if defined(_LIBCPP_COMPILER_MSVC)
77#include <intrin.h>79# include <intrin.h>
78#endif80#endif
7981
80#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)82#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
81#pragma GCC system_header83# pragma GCC system_header
82#endif84#endif
8385
84_LIBCPP_PUSH_MACROS86_LIBCPP_PUSH_MACROS
...@@ -87,18 +89,7 @@ _LIBCPP_PUSH_MACROS...@@ -87,18 +89,7 @@ _LIBCPP_PUSH_MACROS
87_LIBCPP_BEGIN_NAMESPACE_STD89_LIBCPP_BEGIN_NAMESPACE_STD
8890
89template<class _Tp>91template<class _Tp>
90_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1192_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
91_Tp __rotl(_Tp __t, unsigned int __cnt) _NOEXCEPT
92{
93 static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__rotl requires an unsigned integer type");
94 const unsigned int __dig = numeric_limits<_Tp>::digits;
95 if ((__cnt % __dig) == 0)
96 return __t;
97 return (__t << (__cnt % __dig)) | (__t >> (__dig - (__cnt % __dig)));
98}
99
100template<class _Tp>
101_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
102_Tp __rotr(_Tp __t, unsigned int __cnt) _NOEXCEPT93_Tp __rotr(_Tp __t, unsigned int __cnt) _NOEXCEPT
103{94{
104 static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__rotr requires an unsigned integer type");95 static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__rotr requires an unsigned integer type");
...@@ -109,34 +100,7 @@ _Tp __rotr(_Tp __t, unsigned int __cnt) _NOEXCEPT...@@ -109,34 +100,7 @@ _Tp __rotr(_Tp __t, unsigned int __cnt) _NOEXCEPT
109}100}
110101
111template<class _Tp>102template<class _Tp>
112_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11103_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
113int __countr_zero(_Tp __t) _NOEXCEPT
114{
115 static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__countr_zero requires an unsigned integer type");
116 if (__t == 0)
117 return numeric_limits<_Tp>::digits;
118
119 if (sizeof(_Tp) <= sizeof(unsigned int))
120 return __libcpp_ctz(static_cast<unsigned int>(__t));
121 else if (sizeof(_Tp) <= sizeof(unsigned long))
122 return __libcpp_ctz(static_cast<unsigned long>(__t));
123 else if (sizeof(_Tp) <= sizeof(unsigned long long))
124 return __libcpp_ctz(static_cast<unsigned long long>(__t));
125 else
126 {
127 int __ret = 0;
128 const unsigned int __ulldigits = numeric_limits<unsigned long long>::digits;
129 while (static_cast<unsigned long long>(__t) == 0uLL)
130 {
131 __ret += __ulldigits;
132 __t >>= __ulldigits;
133 }
134 return __ret + __libcpp_ctz(static_cast<unsigned long long>(__t));
135 }
136}
137
138template<class _Tp>
139_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
140int __countl_zero(_Tp __t) _NOEXCEPT104int __countl_zero(_Tp __t) _NOEXCEPT
141{105{
142 static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__countl_zero requires an unsigned integer type");106 static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__countl_zero requires an unsigned integer type");
...@@ -144,13 +108,13 @@ int __countl_zero(_Tp __t) _NOEXCEPT...@@ -144,13 +108,13 @@ int __countl_zero(_Tp __t) _NOEXCEPT
144 return numeric_limits<_Tp>::digits;108 return numeric_limits<_Tp>::digits;
145109
146 if (sizeof(_Tp) <= sizeof(unsigned int))110 if (sizeof(_Tp) <= sizeof(unsigned int))
147 return __libcpp_clz(static_cast<unsigned int>(__t))111 return std::__libcpp_clz(static_cast<unsigned int>(__t))
148 - (numeric_limits<unsigned int>::digits - numeric_limits<_Tp>::digits);112 - (numeric_limits<unsigned int>::digits - numeric_limits<_Tp>::digits);
149 else if (sizeof(_Tp) <= sizeof(unsigned long))113 else if (sizeof(_Tp) <= sizeof(unsigned long))
150 return __libcpp_clz(static_cast<unsigned long>(__t))114 return std::__libcpp_clz(static_cast<unsigned long>(__t))
151 - (numeric_limits<unsigned long>::digits - numeric_limits<_Tp>::digits);115 - (numeric_limits<unsigned long>::digits - numeric_limits<_Tp>::digits);
152 else if (sizeof(_Tp) <= sizeof(unsigned long long))116 else if (sizeof(_Tp) <= sizeof(unsigned long long))
153 return __libcpp_clz(static_cast<unsigned long long>(__t))117 return std::__libcpp_clz(static_cast<unsigned long long>(__t))
154 - (numeric_limits<unsigned long long>::digits - numeric_limits<_Tp>::digits);118 - (numeric_limits<unsigned long long>::digits - numeric_limits<_Tp>::digits);
155 else119 else
156 {120 {
...@@ -158,8 +122,8 @@ int __countl_zero(_Tp __t) _NOEXCEPT...@@ -158,8 +122,8 @@ int __countl_zero(_Tp __t) _NOEXCEPT
158 int __iter = 0;122 int __iter = 0;
159 const unsigned int __ulldigits = numeric_limits<unsigned long long>::digits;123 const unsigned int __ulldigits = numeric_limits<unsigned long long>::digits;
160 while (true) {124 while (true) {
161 __t = __rotr(__t, __ulldigits);125 __t = std::__rotr(__t, __ulldigits);
162 if ((__iter = __countl_zero(static_cast<unsigned long long>(__t))) != __ulldigits)126 if ((__iter = std::__countl_zero(static_cast<unsigned long long>(__t))) != __ulldigits)
163 break;127 break;
164 __ret += __iter;128 __ret += __iter;
165 }129 }
...@@ -167,178 +131,123 @@ int __countl_zero(_Tp __t) _NOEXCEPT...@@ -167,178 +131,123 @@ int __countl_zero(_Tp __t) _NOEXCEPT
167 }131 }
168}132}
169133
170template<class _Tp>
171_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
172int __countl_one(_Tp __t) _NOEXCEPT
173{
174 static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__countl_one requires an unsigned integer type");
175 return __t != numeric_limits<_Tp>::max()
176 ? __countl_zero(static_cast<_Tp>(~__t))
177 : numeric_limits<_Tp>::digits;
178}
179
180template<class _Tp>
181_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
182int __countr_one(_Tp __t) _NOEXCEPT
183{
184 static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__countr_one requires an unsigned integer type");
185 return __t != numeric_limits<_Tp>::max()
186 ? __countr_zero(static_cast<_Tp>(~__t))
187 : numeric_limits<_Tp>::digits;
188}
189
190template<class _Tp>
191_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
192int __popcount(_Tp __t) _NOEXCEPT
193{
194 static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__popcount requires an unsigned integer type");
195 if (sizeof(_Tp) <= sizeof(unsigned int))
196 return __libcpp_popcount(static_cast<unsigned int>(__t));
197 else if (sizeof(_Tp) <= sizeof(unsigned long))
198 return __libcpp_popcount(static_cast<unsigned long>(__t));
199 else if (sizeof(_Tp) <= sizeof(unsigned long long))
200 return __libcpp_popcount(static_cast<unsigned long long>(__t));
201 else
202 {
203 int __ret = 0;
204 while (__t != 0)
205 {
206 __ret += __libcpp_popcount(static_cast<unsigned long long>(__t));
207 __t >>= numeric_limits<unsigned long long>::digits;
208 }
209 return __ret;
210 }
211}
212
213// integral log base 2
214template<class _Tp>
215_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
216unsigned __bit_log2(_Tp __t) _NOEXCEPT
217{
218 static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__bit_log2 requires an unsigned integer type");
219 return numeric_limits<_Tp>::digits - 1 - __countl_zero(__t);
220}
221
222template <class _Tp>
223_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
224bool __has_single_bit(_Tp __t) _NOEXCEPT
225{
226 static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__has_single_bit requires an unsigned integer type");
227 return __t != 0 && (((__t & (__t - 1)) == 0));
228}
229
230#if _LIBCPP_STD_VER > 17134#if _LIBCPP_STD_VER > 17
231135
232template<class _Tp>136template <__libcpp_unsigned_integer _Tp>
233_LIBCPP_INLINE_VISIBILITY constexpr137_LIBCPP_HIDE_FROM_ABI constexpr _Tp rotl(_Tp __t, unsigned int __cnt) noexcept {
234enable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, _Tp>138 const unsigned int __dig = numeric_limits<_Tp>::digits;
235rotl(_Tp __t, unsigned int __cnt) noexcept139 if ((__cnt % __dig) == 0)
236{140 return __t;
237 return __rotl(__t, __cnt);141 return (__t << (__cnt % __dig)) | (__t >> (__dig - (__cnt % __dig)));
238}142}
239143
240template<class _Tp>144template <__libcpp_unsigned_integer _Tp>
241_LIBCPP_INLINE_VISIBILITY constexpr145_LIBCPP_HIDE_FROM_ABI constexpr _Tp rotr(_Tp __t, unsigned int __cnt) noexcept {
242enable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, _Tp>146 return std::__rotr(__t, __cnt);
243rotr(_Tp __t, unsigned int __cnt) noexcept
244{
245 return __rotr(__t, __cnt);
246}147}
247148
248template<class _Tp>149template <__libcpp_unsigned_integer _Tp>
249_LIBCPP_INLINE_VISIBILITY constexpr150_LIBCPP_HIDE_FROM_ABI constexpr int countl_zero(_Tp __t) noexcept {
250enable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, int>151 return std::__countl_zero(__t);
251countl_zero(_Tp __t) noexcept
252{
253 return __countl_zero(__t);
254}152}
255153
256template<class _Tp>154template <__libcpp_unsigned_integer _Tp>
257_LIBCPP_INLINE_VISIBILITY constexpr155_LIBCPP_HIDE_FROM_ABI constexpr int countl_one(_Tp __t) noexcept {
258enable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, int>156 return __t != numeric_limits<_Tp>::max() ? std::countl_zero(static_cast<_Tp>(~__t)) : numeric_limits<_Tp>::digits;
259countl_one(_Tp __t) noexcept
260{
261 return __countl_one(__t);
262}157}
263158
264template<class _Tp>159template <__libcpp_unsigned_integer _Tp>
265_LIBCPP_INLINE_VISIBILITY constexpr160_LIBCPP_HIDE_FROM_ABI constexpr int countr_zero(_Tp __t) noexcept {
266enable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, int>161 if (__t == 0)
267countr_zero(_Tp __t) noexcept162 return numeric_limits<_Tp>::digits;
268{163
269 return __countr_zero(__t);164 if (sizeof(_Tp) <= sizeof(unsigned int))
165 return std::__libcpp_ctz(static_cast<unsigned int>(__t));
166 else if (sizeof(_Tp) <= sizeof(unsigned long))
167 return std::__libcpp_ctz(static_cast<unsigned long>(__t));
168 else if (sizeof(_Tp) <= sizeof(unsigned long long))
169 return std::__libcpp_ctz(static_cast<unsigned long long>(__t));
170 else {
171 int __ret = 0;
172 const unsigned int __ulldigits = numeric_limits<unsigned long long>::digits;
173 while (static_cast<unsigned long long>(__t) == 0uLL) {
174 __ret += __ulldigits;
175 __t >>= __ulldigits;
176 }
177 return __ret + std::__libcpp_ctz(static_cast<unsigned long long>(__t));
178 }
270}179}
271180
272template<class _Tp>181template <__libcpp_unsigned_integer _Tp>
273_LIBCPP_INLINE_VISIBILITY constexpr182_LIBCPP_HIDE_FROM_ABI constexpr int countr_one(_Tp __t) noexcept {
274enable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, int>183 return __t != numeric_limits<_Tp>::max() ? std::countr_zero(static_cast<_Tp>(~__t)) : numeric_limits<_Tp>::digits;
275countr_one(_Tp __t) noexcept
276{
277 return __countr_one(__t);
278}184}
279185
280template<class _Tp>186template <__libcpp_unsigned_integer _Tp>
281_LIBCPP_INLINE_VISIBILITY constexpr187_LIBCPP_HIDE_FROM_ABI constexpr int popcount(_Tp __t) noexcept {
282enable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, int>188 if (sizeof(_Tp) <= sizeof(unsigned int))
283popcount(_Tp __t) noexcept189 return std::__libcpp_popcount(static_cast<unsigned int>(__t));
284{190 else if (sizeof(_Tp) <= sizeof(unsigned long))
285 return __popcount(__t);191 return std::__libcpp_popcount(static_cast<unsigned long>(__t));
192 else if (sizeof(_Tp) <= sizeof(unsigned long long))
193 return std::__libcpp_popcount(static_cast<unsigned long long>(__t));
194 else {
195 int __ret = 0;
196 while (__t != 0) {
197 __ret += std::__libcpp_popcount(static_cast<unsigned long long>(__t));
198 __t >>= numeric_limits<unsigned long long>::digits;
199 }
200 return __ret;
201 }
286}202}
287203
288template <class _Tp>204template <__libcpp_unsigned_integer _Tp>
289_LIBCPP_INLINE_VISIBILITY constexpr205_LIBCPP_HIDE_FROM_ABI constexpr bool has_single_bit(_Tp __t) noexcept {
290enable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, bool>206 return __t != 0 && (((__t & (__t - 1)) == 0));
291has_single_bit(_Tp __t) noexcept
292{
293 return __has_single_bit(__t);
294}207}
295208
296template <class _Tp>209// integral log base 2
297_LIBCPP_INLINE_VISIBILITY constexpr210template <__libcpp_unsigned_integer _Tp>
298enable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, _Tp>211_LIBCPP_HIDE_FROM_ABI constexpr _Tp __bit_log2(_Tp __t) noexcept {
299bit_floor(_Tp __t) noexcept212 return numeric_limits<_Tp>::digits - 1 - std::countl_zero(__t);
300{
301 return __t == 0 ? 0 : _Tp{1} << __bit_log2(__t);
302}213}
303214
304template <class _Tp>215template <__libcpp_unsigned_integer _Tp>
305_LIBCPP_INLINE_VISIBILITY constexpr216_LIBCPP_HIDE_FROM_ABI constexpr _Tp bit_floor(_Tp __t) noexcept {
306enable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, _Tp>217 return __t == 0 ? 0 : _Tp{1} << std::__bit_log2(__t);
307bit_ceil(_Tp __t) noexcept218}
308{
309 if (__t < 2) return 1;
310 const unsigned __n = numeric_limits<_Tp>::digits - countl_zero((_Tp)(__t - 1u));
311 _LIBCPP_ASSERT(__n != numeric_limits<_Tp>::digits, "Bad input to bit_ceil");
312219
313 if constexpr (sizeof(_Tp) >= sizeof(unsigned))220template <__libcpp_unsigned_integer _Tp>
314 return _Tp{1} << __n;221_LIBCPP_HIDE_FROM_ABI constexpr _Tp bit_ceil(_Tp __t) noexcept {
315 else222 if (__t < 2)
316 {223 return 1;
317 const unsigned __extra = numeric_limits<unsigned>::digits - numeric_limits<_Tp>::digits;224 const unsigned __n = numeric_limits<_Tp>::digits - std::countl_zero((_Tp)(__t - 1u));
318 const unsigned __retVal = 1u << (__n + __extra);225 _LIBCPP_ASSERT(__n != numeric_limits<_Tp>::digits, "Bad input to bit_ceil");
319 return (_Tp) (__retVal >> __extra);226
320 }227 if constexpr (sizeof(_Tp) >= sizeof(unsigned))
228 return _Tp{1} << __n;
229 else {
230 const unsigned __extra = numeric_limits<unsigned>::digits - numeric_limits<_Tp>::digits;
231 const unsigned __retVal = 1u << (__n + __extra);
232 return (_Tp)(__retVal >> __extra);
233 }
321}234}
322235
323template <class _Tp>236template <__libcpp_unsigned_integer _Tp>
324_LIBCPP_INLINE_VISIBILITY constexpr237_LIBCPP_HIDE_FROM_ABI constexpr int bit_width(_Tp __t) noexcept {
325enable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, _Tp>238 return __t == 0 ? 0 : std::__bit_log2(__t) + 1;
326bit_width(_Tp __t) noexcept
327{
328 return __t == 0 ? 0 : __bit_log2(__t) + 1;
329}239}
330240
331enum class endian241enum class endian {
332{242 little = 0xDEAD,
333 little = 0xDEAD,243 big = 0xFACE,
334 big = 0xFACE,244# if defined(_LIBCPP_LITTLE_ENDIAN)
335#if defined(_LIBCPP_LITTLE_ENDIAN)245 native = little
336 native = little246# elif defined(_LIBCPP_BIG_ENDIAN)
337#elif defined(_LIBCPP_BIG_ENDIAN)247 native = big
338 native = big248# else
339#else249 native = 0xCAFE
340 native = 0xCAFE250# endif
341#endif
342};251};
343252
344#endif // _LIBCPP_STD_VER > 17253#endif // _LIBCPP_STD_VER > 17
lib/libcxx/include/bitset+17-9
...@@ -112,18 +112,23 @@ template <size_t N> struct hash<std::bitset<N>>;...@@ -112,18 +112,23 @@ template <size_t N> struct hash<std::bitset<N>>;
112112
113*/113*/
114114
115#include <__algorithm/fill.h>
116#include <__assert> // all public C++ headers provide the assertion handler
115#include <__bit_reference>117#include <__bit_reference>
116#include <__config>118#include <__config>
117#include <__functional_base>119#include <__functional/hash.h>
120#include <__functional/unary_function.h>
118#include <climits>121#include <climits>
119#include <cstddef>122#include <cstddef>
120#include <iosfwd>
121#include <stdexcept>123#include <stdexcept>
122#include <string>
123#include <version>124#include <version>
124125
126// standard-mandated includes
127#include <iosfwd>
128#include <string>
129
125#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)130#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
126#pragma GCC system_header131# pragma GCC system_header
127#endif132#endif
128133
129_LIBCPP_PUSH_MACROS134_LIBCPP_PUSH_MACROS
...@@ -713,9 +718,12 @@ public:...@@ -713,9 +718,12 @@ public:
713 bitset& flip(size_t __pos);718 bitset& flip(size_t __pos);
714719
715 // element access:720 // element access:
716 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR721#ifdef _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL
717 const_reference operator[](size_t __p) const {return base::__make_ref(__p);}722 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator[](size_t __p) const {return base::__make_ref(__p);}
718 _LIBCPP_INLINE_VISIBILITY reference operator[](size_t __p) {return base::__make_ref(__p);}723#else
724 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const_reference operator[](size_t __p) const {return base::__make_ref(__p);}
725#endif
726 _LIBCPP_HIDE_FROM_ABI reference operator[](size_t __p) {return base::__make_ref(__p);}
719 _LIBCPP_INLINE_VISIBILITY727 _LIBCPP_INLINE_VISIBILITY
720 unsigned long to_ulong() const;728 unsigned long to_ulong() const;
721 _LIBCPP_INLINE_VISIBILITY729 _LIBCPP_INLINE_VISIBILITY
...@@ -946,7 +954,7 @@ basic_string<_CharT, _Traits, _Allocator>...@@ -946,7 +954,7 @@ basic_string<_CharT, _Traits, _Allocator>
946bitset<_Size>::to_string(_CharT __zero, _CharT __one) const954bitset<_Size>::to_string(_CharT __zero, _CharT __one) const
947{955{
948 basic_string<_CharT, _Traits, _Allocator> __r(_Size, __zero);956 basic_string<_CharT, _Traits, _Allocator> __r(_Size, __zero);
949 for (size_t __i = 0; __i < _Size; ++__i)957 for (size_t __i = 0; __i != _Size; ++__i)
950 {958 {
951 if ((*this)[__i])959 if ((*this)[__i])
952 __r[_Size - 1 - __i] = __one;960 __r[_Size - 1 - __i] = __one;
...@@ -1082,7 +1090,7 @@ operator^(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT...@@ -1082,7 +1090,7 @@ operator^(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT
10821090
1083template <size_t _Size>1091template <size_t _Size>
1084struct _LIBCPP_TEMPLATE_VIS hash<bitset<_Size> >1092struct _LIBCPP_TEMPLATE_VIS hash<bitset<_Size> >
1085 : public unary_function<bitset<_Size>, size_t>1093 : public __unary_function<bitset<_Size>, size_t>
1086{1094{
1087 _LIBCPP_INLINE_VISIBILITY1095 _LIBCPP_INLINE_VISIBILITY
1088 size_t operator()(const bitset<_Size>& __bs) const _NOEXCEPT1096 size_t operator()(const bitset<_Size>& __bs) const _NOEXCEPT
lib/libcxx/include/cassert+2-1
...@@ -16,9 +16,10 @@ Macros:...@@ -16,9 +16,10 @@ Macros:
1616
17*/17*/
1818
19#include <__assert> // all public C++ headers provide the assertion handler
19#include <__config>20#include <__config>
20#include <assert.h>21#include <assert.h>
2122
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23#pragma GCC system_header24# pragma GCC system_header
24#endif25#endif
lib/libcxx/include/ccomplex+2-3
...@@ -17,12 +17,11 @@...@@ -17,12 +17,11 @@
1717
18*/18*/
1919
20#include <__assert> // all public C++ headers provide the assertion handler
20#include <complex>21#include <complex>
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
24#endif25#endif
2526
26// hh 080623 Created
27
28#endif // _LIBCPP_CCOMPLEX27#endif // _LIBCPP_CCOMPLEX
lib/libcxx/include/cctype+2-1
...@@ -34,11 +34,12 @@ int toupper(int c);...@@ -34,11 +34,12 @@ int toupper(int c);
34} // std34} // std
35*/35*/
3636
37#include <__assert> // all public C++ headers provide the assertion handler
37#include <__config>38#include <__config>
38#include <ctype.h>39#include <ctype.h>
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
42#endif43#endif
4344
44_LIBCPP_BEGIN_NAMESPACE_STD45_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/cerrno+2-1
...@@ -22,11 +22,12 @@ Macros:...@@ -22,11 +22,12 @@ Macros:
2222
23*/23*/
2424
25#include <__assert> // all public C++ headers provide the assertion handler
25#include <__config>26#include <__config>
26#include <errno.h>27#include <errno.h>
2728
28#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)29#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
29#pragma GCC system_header30# pragma GCC system_header
30#endif31#endif
3132
32#endif // _LIBCPP_CERRNO33#endif // _LIBCPP_CERRNO
lib/libcxx/include/cfenv+2-1
...@@ -52,11 +52,12 @@ int feupdateenv(const fenv_t* envp);...@@ -52,11 +52,12 @@ int feupdateenv(const fenv_t* envp);
52} // std52} // std
53*/53*/
5454
55#include <__assert> // all public C++ headers provide the assertion handler
55#include <__config>56#include <__config>
56#include <fenv.h>57#include <fenv.h>
5758
58#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)59#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
59#pragma GCC system_header60# pragma GCC system_header
60#endif61#endif
6162
62_LIBCPP_BEGIN_NAMESPACE_STD63_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/cfloat+2-1
...@@ -69,11 +69,12 @@ Macros:...@@ -69,11 +69,12 @@ Macros:
69 LDBL_TRUE_MIN // C1169 LDBL_TRUE_MIN // C11
70*/70*/
7171
72#include <__assert> // all public C++ headers provide the assertion handler
72#include <__config>73#include <__config>
73#include <float.h>74#include <float.h>
7475
75#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)76#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
76#pragma GCC system_header77# pragma GCC system_header
77#endif78#endif
7879
79#endif // _LIBCPP_CFLOAT80#endif // _LIBCPP_CFLOAT
lib/libcxx/include/charconv+311-123
...@@ -77,24 +77,32 @@ namespace std {...@@ -77,24 +77,32 @@ namespace std {
7777
78*/78*/
7979
80#include <__assert> // all public C++ headers provide the assertion handler
80#include <__availability>81#include <__availability>
81#include <__bits>82#include <__bits>
82#include <__charconv/chars_format.h>83#include <__charconv/chars_format.h>
83#include <__charconv/from_chars_result.h>84#include <__charconv/from_chars_result.h>
85#include <__charconv/tables.h>
86#include <__charconv/to_chars_base_10.h>
84#include <__charconv/to_chars_result.h>87#include <__charconv/to_chars_result.h>
85#include <__config>88#include <__config>
89#include <__debug>
86#include <__errc>90#include <__errc>
91#include <__type_traits/make_32_64_or_128_bit.h>
92#include <__utility/unreachable.h>
87#include <cmath> // for log2f93#include <cmath> // for log2f
88#include <cstdint>94#include <cstdint>
89#include <cstdlib> // for _LIBCPP_UNREACHABLE95#include <cstdlib>
90#include <cstring>96#include <cstring>
91#include <limits>97#include <limits>
92#include <type_traits>98#include <type_traits>
9399
94#include <__debug>100#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
101# include <iosfwd>
102#endif
95103
96#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)104#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
97#pragma GCC system_header105# pragma GCC system_header
98#endif106#endif
99107
100_LIBCPP_PUSH_MACROS108_LIBCPP_PUSH_MACROS
...@@ -102,11 +110,6 @@ _LIBCPP_PUSH_MACROS...@@ -102,11 +110,6 @@ _LIBCPP_PUSH_MACROS
102110
103_LIBCPP_BEGIN_NAMESPACE_STD111_LIBCPP_BEGIN_NAMESPACE_STD
104112
105namespace __itoa {
106_LIBCPP_AVAILABILITY_TO_CHARS _LIBCPP_FUNC_VIS char* __u64toa(uint64_t __value, char* __buffer) _NOEXCEPT;
107_LIBCPP_AVAILABILITY_TO_CHARS _LIBCPP_FUNC_VIS char* __u32toa(uint32_t __value, char* __buffer) _NOEXCEPT;
108} // namespace __itoa
109
110#ifndef _LIBCPP_CXX03_LANG113#ifndef _LIBCPP_CXX03_LANG
111114
112to_chars_result to_chars(char*, char*, bool, int = 10) = delete;115to_chars_result to_chars(char*, char*, bool, int = 10) = delete;
...@@ -115,79 +118,93 @@ from_chars_result from_chars(const char*, const char*, bool, int = 10) = delete;...@@ -115,79 +118,93 @@ from_chars_result from_chars(const char*, const char*, bool, int = 10) = delete;
115namespace __itoa118namespace __itoa
116{119{
117120
118static _LIBCPP_CONSTEXPR uint64_t __pow10_64[] = {
119 UINT64_C(0),
120 UINT64_C(10),
121 UINT64_C(100),
122 UINT64_C(1000),
123 UINT64_C(10000),
124 UINT64_C(100000),
125 UINT64_C(1000000),
126 UINT64_C(10000000),
127 UINT64_C(100000000),
128 UINT64_C(1000000000),
129 UINT64_C(10000000000),
130 UINT64_C(100000000000),
131 UINT64_C(1000000000000),
132 UINT64_C(10000000000000),
133 UINT64_C(100000000000000),
134 UINT64_C(1000000000000000),
135 UINT64_C(10000000000000000),
136 UINT64_C(100000000000000000),
137 UINT64_C(1000000000000000000),
138 UINT64_C(10000000000000000000),
139};
140
141static _LIBCPP_CONSTEXPR uint32_t __pow10_32[] = {
142 UINT32_C(0), UINT32_C(10), UINT32_C(100),
143 UINT32_C(1000), UINT32_C(10000), UINT32_C(100000),
144 UINT32_C(1000000), UINT32_C(10000000), UINT32_C(100000000),
145 UINT32_C(1000000000),
146};
147
148template <typename _Tp, typename = void>121template <typename _Tp, typename = void>
149struct _LIBCPP_HIDDEN __traits_base122struct _LIBCPP_HIDDEN __traits_base;
123
124template <typename _Tp>
125struct _LIBCPP_HIDDEN __traits_base<_Tp, __enable_if_t<sizeof(_Tp) <= sizeof(uint32_t)>>
150{126{
151 using type = uint64_t;127 using type = uint32_t;
152128
153 static _LIBCPP_INLINE_VISIBILITY int __width(_Tp __v)129 /// The width estimation using a log10 algorithm.
130 ///
131 /// The algorithm is based on
132 /// http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog10
133 /// Instead of using IntegerLogBase2 it uses __libcpp_clz. Since that
134 /// function requires its input to have at least one bit set the value of
135 /// zero is set to one. This means the first element of the lookup table is
136 /// zero.
137 static _LIBCPP_HIDE_FROM_ABI int __width(_Tp __v)
154 {138 {
155 auto __t = (64 - _VSTD::__libcpp_clz(static_cast<type>(__v | 1))) * 1233 >> 12;139 auto __t = (32 - std::__libcpp_clz(static_cast<type>(__v | 1))) * 1233 >> 12;
156 return __t - (__v < __pow10_64[__t]) + 1;140 return __t - (__v < __table<>::__pow10_32[__t]) + 1;
157 }141 }
158142
159 _LIBCPP_AVAILABILITY_TO_CHARS143 static _LIBCPP_HIDE_FROM_ABI char* __convert(char* __p, _Tp __v)
160 static _LIBCPP_INLINE_VISIBILITY char* __convert(_Tp __v, char* __p)
161 {144 {
162 return __u64toa(__v, __p);145 return __itoa::__base_10_u32(__p, __v);
163 }146 }
164147
165 static _LIBCPP_INLINE_VISIBILITY decltype(__pow10_64)& __pow() { return __pow10_64; }148 static _LIBCPP_HIDE_FROM_ABI decltype(__table<>::__pow10_32)& __pow() { return __table<>::__pow10_32; }
166};149};
167150
168template <typename _Tp>151template <typename _Tp>
169struct _LIBCPP_HIDDEN152struct _LIBCPP_HIDDEN
170 __traits_base<_Tp, decltype(void(uint32_t{declval<_Tp>()}))>153 __traits_base<_Tp, __enable_if_t<sizeof(_Tp) == sizeof(uint64_t)>> {
171{154 using type = uint64_t;
172 using type = uint32_t;155
156 /// The width estimation using a log10 algorithm.
157 ///
158 /// The algorithm is based on
159 /// http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog10
160 /// Instead of using IntegerLogBase2 it uses __libcpp_clz. Since that
161 /// function requires its input to have at least one bit set the value of
162 /// zero is set to one. This means the first element of the lookup table is
163 /// zero.
164 static _LIBCPP_HIDE_FROM_ABI int __width(_Tp __v) {
165 auto __t = (64 - std::__libcpp_clz(static_cast<type>(__v | 1))) * 1233 >> 12;
166 return __t - (__v < __table<>::__pow10_64[__t]) + 1;
167 }
173168
174 static _LIBCPP_INLINE_VISIBILITY int __width(_Tp __v)169 static _LIBCPP_HIDE_FROM_ABI char* __convert(char* __p, _Tp __v) { return __itoa::__base_10_u64(__p, __v); }
175 {
176 auto __t = (32 - _VSTD::__libcpp_clz(static_cast<type>(__v | 1))) * 1233 >> 12;
177 return __t - (__v < __pow10_32[__t]) + 1;
178 }
179170
180 _LIBCPP_AVAILABILITY_TO_CHARS171 static _LIBCPP_HIDE_FROM_ABI decltype(__table<>::__pow10_64)& __pow() { return __table<>::__pow10_64; }
181 static _LIBCPP_INLINE_VISIBILITY char* __convert(_Tp __v, char* __p)172};
182 {173
183 return __u32toa(__v, __p);174
184 }175# ifndef _LIBCPP_HAS_NO_INT128
176template <typename _Tp>
177struct _LIBCPP_HIDDEN
178 __traits_base<_Tp, __enable_if_t<sizeof(_Tp) == sizeof(__uint128_t)> > {
179 using type = __uint128_t;
180
181 /// The width estimation using a log10 algorithm.
182 ///
183 /// The algorithm is based on
184 /// http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog10
185 /// Instead of using IntegerLogBase2 it uses __libcpp_clz. Since that
186 /// function requires its input to have at least one bit set the value of
187 /// zero is set to one. This means the first element of the lookup table is
188 /// zero.
189 static _LIBCPP_HIDE_FROM_ABI int __width(_Tp __v) {
190 _LIBCPP_ASSERT(__v > numeric_limits<uint64_t>::max(), "The optimizations for this algorithm fail when this isn't true.");
191 // There's always a bit set in the upper 64-bits.
192 auto __t = (128 - std::__libcpp_clz(static_cast<uint64_t>(__v >> 64))) * 1233 >> 12;
193 _LIBCPP_ASSERT(__t >= __table<>::__pow10_128_offset, "Index out of bounds");
194 // __t is adjusted since the lookup table misses the lower entries.
195 return __t - (__v < __table<>::__pow10_128[__t - __table<>::__pow10_128_offset]) + 1;
196 }
197
198 static _LIBCPP_HIDE_FROM_ABI char* __convert(char* __p, _Tp __v) { return __itoa::__base_10_u128(__p, __v); }
185199
186 static _LIBCPP_INLINE_VISIBILITY decltype(__pow10_32)& __pow() { return __pow10_32; }200 // TODO FMT This pow function should get an index.
201 // By moving this to its own header it can be reused by the pow function in to_chars_base_10.
202 static _LIBCPP_HIDE_FROM_ABI decltype(__table<>::__pow10_128)& __pow() { return __table<>::__pow10_128; }
187};203};
204#endif
188205
189template <typename _Tp>206template <typename _Tp>
190inline _LIBCPP_INLINE_VISIBILITY bool207inline _LIBCPP_HIDE_FROM_ABI bool
191__mul_overflowed(unsigned char __a, _Tp __b, unsigned char& __r)208__mul_overflowed(unsigned char __a, _Tp __b, unsigned char& __r)
192{209{
193 auto __c = __a * __b;210 auto __c = __a * __b;
...@@ -196,7 +213,7 @@ __mul_overflowed(unsigned char __a, _Tp __b, unsigned char& __r)...@@ -196,7 +213,7 @@ __mul_overflowed(unsigned char __a, _Tp __b, unsigned char& __r)
196}213}
197214
198template <typename _Tp>215template <typename _Tp>
199inline _LIBCPP_INLINE_VISIBILITY bool216inline _LIBCPP_HIDE_FROM_ABI bool
200__mul_overflowed(unsigned short __a, _Tp __b, unsigned short& __r)217__mul_overflowed(unsigned short __a, _Tp __b, unsigned short& __r)
201{218{
202 auto __c = __a * __b;219 auto __c = __a * __b;
...@@ -205,7 +222,7 @@ __mul_overflowed(unsigned short __a, _Tp __b, unsigned short& __r)...@@ -205,7 +222,7 @@ __mul_overflowed(unsigned short __a, _Tp __b, unsigned short& __r)
205}222}
206223
207template <typename _Tp>224template <typename _Tp>
208inline _LIBCPP_INLINE_VISIBILITY bool225inline _LIBCPP_HIDE_FROM_ABI bool
209__mul_overflowed(_Tp __a, _Tp __b, _Tp& __r)226__mul_overflowed(_Tp __a, _Tp __b, _Tp& __r)
210{227{
211 static_assert(is_unsigned<_Tp>::value, "");228 static_assert(is_unsigned<_Tp>::value, "");
...@@ -219,7 +236,7 @@ __mul_overflowed(_Tp __a, _Tp __b, _Tp& __r)...@@ -219,7 +236,7 @@ __mul_overflowed(_Tp __a, _Tp __b, _Tp& __r)
219}236}
220237
221template <typename _Tp, typename _Up>238template <typename _Tp, typename _Up>
222inline _LIBCPP_INLINE_VISIBILITY bool239inline _LIBCPP_HIDE_FROM_ABI bool
223__mul_overflowed(_Tp __a, _Up __b, _Tp& __r)240__mul_overflowed(_Tp __a, _Up __b, _Tp& __r)
224{241{
225 return __mul_overflowed(__a, static_cast<_Tp>(__b), __r);242 return __mul_overflowed(__a, static_cast<_Tp>(__b), __r);
...@@ -228,12 +245,12 @@ __mul_overflowed(_Tp __a, _Up __b, _Tp& __r)...@@ -228,12 +245,12 @@ __mul_overflowed(_Tp __a, _Up __b, _Tp& __r)
228template <typename _Tp>245template <typename _Tp>
229struct _LIBCPP_HIDDEN __traits : __traits_base<_Tp>246struct _LIBCPP_HIDDEN __traits : __traits_base<_Tp>
230{247{
231 static _LIBCPP_CONSTEXPR int digits = numeric_limits<_Tp>::digits10 + 1;248 static constexpr int digits = numeric_limits<_Tp>::digits10 + 1;
232 using __traits_base<_Tp>::__pow;249 using __traits_base<_Tp>::__pow;
233 using typename __traits_base<_Tp>::type;250 using typename __traits_base<_Tp>::type;
234251
235 // precondition: at least one non-zero character available252 // precondition: at least one non-zero character available
236 static _LIBCPP_INLINE_VISIBILITY char const*253 static _LIBCPP_HIDE_FROM_ABI char const*
237 __read(char const* __p, char const* __ep, type& __a, type& __b)254 __read(char const* __p, char const* __ep, type& __a, type& __b)
238 {255 {
239 type __cprod[digits];256 type __cprod[digits];
...@@ -254,7 +271,7 @@ struct _LIBCPP_HIDDEN __traits : __traits_base<_Tp>...@@ -254,7 +271,7 @@ struct _LIBCPP_HIDDEN __traits : __traits_base<_Tp>
254 }271 }
255272
256 template <typename _It1, typename _It2, class _Up>273 template <typename _It1, typename _It2, class _Up>
257 static _LIBCPP_INLINE_VISIBILITY _Up274 static _LIBCPP_HIDE_FROM_ABI _Up
258 __inner_product(_It1 __first1, _It1 __last1, _It2 __first2, _Up __init)275 __inner_product(_It1 __first1, _It1 __last1, _It2 __first2, _Up __init)
259 {276 {
260 for (; __first1 < __last1; ++__first1, ++__first2)277 for (; __first1 < __last1; ++__first1, ++__first2)
...@@ -266,7 +283,7 @@ struct _LIBCPP_HIDDEN __traits : __traits_base<_Tp>...@@ -266,7 +283,7 @@ struct _LIBCPP_HIDDEN __traits : __traits_base<_Tp>
266} // namespace __itoa283} // namespace __itoa
267284
268template <typename _Tp>285template <typename _Tp>
269inline _LIBCPP_INLINE_VISIBILITY _Tp286inline _LIBCPP_HIDE_FROM_ABI _Tp
270__complement(_Tp __x)287__complement(_Tp __x)
271{288{
272 static_assert(is_unsigned<_Tp>::value, "cast to unsigned first");289 static_assert(is_unsigned<_Tp>::value, "cast to unsigned first");
...@@ -274,8 +291,7 @@ __complement(_Tp __x)...@@ -274,8 +291,7 @@ __complement(_Tp __x)
274}291}
275292
276template <typename _Tp>293template <typename _Tp>
277_LIBCPP_AVAILABILITY_TO_CHARS294inline _LIBCPP_HIDE_FROM_ABI to_chars_result
278inline _LIBCPP_INLINE_VISIBILITY to_chars_result
279__to_chars_itoa(char* __first, char* __last, _Tp __value, true_type)295__to_chars_itoa(char* __first, char* __last, _Tp __value, true_type)
280{296{
281 auto __x = __to_unsigned_like(__value);297 auto __x = __to_unsigned_like(__value);
...@@ -289,22 +305,42 @@ __to_chars_itoa(char* __first, char* __last, _Tp __value, true_type)...@@ -289,22 +305,42 @@ __to_chars_itoa(char* __first, char* __last, _Tp __value, true_type)
289}305}
290306
291template <typename _Tp>307template <typename _Tp>
292_LIBCPP_AVAILABILITY_TO_CHARS308inline _LIBCPP_HIDE_FROM_ABI to_chars_result
293inline _LIBCPP_INLINE_VISIBILITY to_chars_result
294__to_chars_itoa(char* __first, char* __last, _Tp __value, false_type)309__to_chars_itoa(char* __first, char* __last, _Tp __value, false_type)
295{310{
296 using __tx = __itoa::__traits<_Tp>;311 using __tx = __itoa::__traits<_Tp>;
297 auto __diff = __last - __first;312 auto __diff = __last - __first;
298313
299 if (__tx::digits <= __diff || __tx::__width(__value) <= __diff)314 if (__tx::digits <= __diff || __tx::__width(__value) <= __diff)
300 return {__tx::__convert(__value, __first), errc(0)};315 return {__tx::__convert(__first, __value), errc(0)};
316 else
317 return {__last, errc::value_too_large};
318}
319
320# ifndef _LIBCPP_HAS_NO_INT128
321template <>
322inline _LIBCPP_HIDE_FROM_ABI to_chars_result
323__to_chars_itoa(char* __first, char* __last, __uint128_t __value, false_type)
324{
325 // When the value fits in 64-bits use the 64-bit code path. This reduces
326 // the number of expensive calculations on 128-bit values.
327 //
328 // NOTE the 128-bit code path requires this optimization.
329 if(__value <= numeric_limits<uint64_t>::max())
330 return __to_chars_itoa(__first, __last, static_cast<uint64_t>(__value), false_type());
331
332 using __tx = __itoa::__traits<__uint128_t>;
333 auto __diff = __last - __first;
334
335 if (__tx::digits <= __diff || __tx::__width(__value) <= __diff)
336 return {__tx::__convert(__first, __value), errc(0)};
301 else337 else
302 return {__last, errc::value_too_large};338 return {__last, errc::value_too_large};
303}339}
340#endif
304341
305template <typename _Tp>342template <typename _Tp>
306_LIBCPP_AVAILABILITY_TO_CHARS343inline _LIBCPP_HIDE_FROM_ABI to_chars_result
307inline _LIBCPP_INLINE_VISIBILITY to_chars_result
308__to_chars_integral(char* __first, char* __last, _Tp __value, int __base,344__to_chars_integral(char* __first, char* __last, _Tp __value, int __base,
309 true_type)345 true_type)
310{346{
...@@ -318,8 +354,151 @@ __to_chars_integral(char* __first, char* __last, _Tp __value, int __base,...@@ -318,8 +354,151 @@ __to_chars_integral(char* __first, char* __last, _Tp __value, int __base,
318 return __to_chars_integral(__first, __last, __x, __base, false_type());354 return __to_chars_integral(__first, __last, __x, __base, false_type());
319}355}
320356
357namespace __itoa {
358
359template <unsigned _Base>
360struct _LIBCPP_HIDDEN __integral;
361
362template <>
363struct _LIBCPP_HIDDEN __integral<2> {
364 template <typename _Tp>
365 _LIBCPP_HIDE_FROM_ABI static constexpr int __width(_Tp __value) noexcept {
366 // If value == 0 still need one digit. If the value != this has no
367 // effect since the code scans for the most significant bit set. (Note
368 // that __libcpp_clz doesn't work for 0.)
369 return numeric_limits<_Tp>::digits - std::__libcpp_clz(__value | 1);
370 }
371
372 template <typename _Tp>
373 _LIBCPP_HIDE_FROM_ABI static to_chars_result __to_chars(char* __first, char* __last, _Tp __value) {
374 ptrdiff_t __cap = __last - __first;
375 int __n = __width(__value);
376 if (__n > __cap)
377 return {__last, errc::value_too_large};
378
379 __last = __first + __n;
380 char* __p = __last;
381 const unsigned __divisor = 16;
382 while (__value > __divisor) {
383 unsigned __c = __value % __divisor;
384 __value /= __divisor;
385 __p -= 4;
386 std::memcpy(__p, &__table<>::__base_2_lut[4 * __c], 4);
387 }
388 do {
389 unsigned __c = __value % 2;
390 __value /= 2;
391 *--__p = "01"[__c];
392 } while (__value != 0);
393 return {__last, errc(0)};
394 }
395};
396
397template <>
398struct _LIBCPP_HIDDEN __integral<8> {
399 template <typename _Tp>
400 _LIBCPP_HIDE_FROM_ABI static constexpr int __width(_Tp __value) noexcept {
401 // If value == 0 still need one digit. If the value != this has no
402 // effect since the code scans for the most significat bit set. (Note
403 // that __libcpp_clz doesn't work for 0.)
404 return ((numeric_limits<_Tp>::digits - std::__libcpp_clz(__value | 1)) + 2) / 3;
405 }
406
407 template <typename _Tp>
408 _LIBCPP_HIDE_FROM_ABI static to_chars_result __to_chars(char* __first, char* __last, _Tp __value) {
409 ptrdiff_t __cap = __last - __first;
410 int __n = __width(__value);
411 if (__n > __cap)
412 return {__last, errc::value_too_large};
413
414 __last = __first + __n;
415 char* __p = __last;
416 unsigned __divisor = 64;
417 while (__value > __divisor) {
418 unsigned __c = __value % __divisor;
419 __value /= __divisor;
420 __p -= 2;
421 std::memcpy(__p, &__table<>::__base_8_lut[2 * __c], 2);
422 }
423 do {
424 unsigned __c = __value % 8;
425 __value /= 8;
426 *--__p = "01234567"[__c];
427 } while (__value != 0);
428 return {__last, errc(0)};
429 }
430
431};
432
433template <>
434struct _LIBCPP_HIDDEN __integral<16> {
435 template <typename _Tp>
436 _LIBCPP_HIDE_FROM_ABI static constexpr int __width(_Tp __value) noexcept {
437 // If value == 0 still need one digit. If the value != this has no
438 // effect since the code scans for the most significat bit set. (Note
439 // that __libcpp_clz doesn't work for 0.)
440 return (numeric_limits<_Tp>::digits - std::__libcpp_clz(__value | 1) + 3) / 4;
441 }
442
443 template <typename _Tp>
444 _LIBCPP_HIDE_FROM_ABI static to_chars_result __to_chars(char* __first, char* __last, _Tp __value) {
445 ptrdiff_t __cap = __last - __first;
446 int __n = __width(__value);
447 if (__n > __cap)
448 return {__last, errc::value_too_large};
449
450 __last = __first + __n;
451 char* __p = __last;
452 unsigned __divisor = 256;
453 while (__value > __divisor) {
454 unsigned __c = __value % __divisor;
455 __value /= __divisor;
456 __p -= 2;
457 std::memcpy(__p, &__table<>::__base_16_lut[2 * __c], 2);
458 }
459 if (__first != __last)
460 do {
461 unsigned __c = __value % 16;
462 __value /= 16;
463 *--__p = "0123456789abcdef"[__c];
464 } while (__value != 0);
465 return {__last, errc(0)};
466 }
467};
468
469} // namespace __itoa
470
471template <unsigned _Base, typename _Tp,
472 typename enable_if<(sizeof(_Tp) >= sizeof(unsigned)), int>::type = 0>
473_LIBCPP_HIDE_FROM_ABI int
474__to_chars_integral_width(_Tp __value) {
475 return __itoa::__integral<_Base>::__width(__value);
476}
477
478template <unsigned _Base, typename _Tp,
479 typename enable_if<(sizeof(_Tp) < sizeof(unsigned)), int>::type = 0>
480_LIBCPP_HIDE_FROM_ABI int
481__to_chars_integral_width(_Tp __value) {
482 return std::__to_chars_integral_width<_Base>(static_cast<unsigned>(__value));
483}
484
485template <unsigned _Base, typename _Tp,
486 typename enable_if<(sizeof(_Tp) >= sizeof(unsigned)), int>::type = 0>
487_LIBCPP_HIDE_FROM_ABI to_chars_result
488__to_chars_integral(char* __first, char* __last, _Tp __value) {
489 return __itoa::__integral<_Base>::__to_chars(__first, __last, __value);
490}
491
492template <unsigned _Base, typename _Tp,
493 typename enable_if<(sizeof(_Tp) < sizeof(unsigned)), int>::type = 0>
494_LIBCPP_HIDE_FROM_ABI to_chars_result
495__to_chars_integral(char* __first, char* __last, _Tp __value) {
496 return std::__to_chars_integral<_Base>(__first, __last, static_cast<unsigned>(__value));
497}
498
321template <typename _Tp>499template <typename _Tp>
322_LIBCPP_AVAILABILITY_TO_CHARS _LIBCPP_INLINE_VISIBILITY int __to_chars_integral_width(_Tp __value, unsigned __base) {500_LIBCPP_HIDE_FROM_ABI int
501__to_chars_integral_width(_Tp __value, unsigned __base) {
323 _LIBCPP_ASSERT(__value >= 0, "The function requires a non-negative value.");502 _LIBCPP_ASSERT(__value >= 0, "The function requires a non-negative value.");
324503
325 unsigned __base_2 = __base * __base;504 unsigned __base_2 = __base * __base;
...@@ -341,18 +520,26 @@ _LIBCPP_AVAILABILITY_TO_CHARS _LIBCPP_INLINE_VISIBILITY int __to_chars_integral_...@@ -341,18 +520,26 @@ _LIBCPP_AVAILABILITY_TO_CHARS _LIBCPP_INLINE_VISIBILITY int __to_chars_integral_
341 __r += 4;520 __r += 4;
342 }521 }
343522
344 _LIBCPP_UNREACHABLE();523 __libcpp_unreachable();
345}524}
346525
347template <typename _Tp>526template <typename _Tp>
348_LIBCPP_AVAILABILITY_TO_CHARS527inline _LIBCPP_HIDE_FROM_ABI to_chars_result
349inline _LIBCPP_INLINE_VISIBILITY to_chars_result
350__to_chars_integral(char* __first, char* __last, _Tp __value, int __base,528__to_chars_integral(char* __first, char* __last, _Tp __value, int __base,
351 false_type)529 false_type)
352{530{
353 if (__base == 10)531 if (__base == 10) [[likely]]
354 return __to_chars_itoa(__first, __last, __value, false_type());532 return __to_chars_itoa(__first, __last, __value, false_type());
355533
534 switch (__base) {
535 case 2:
536 return __to_chars_integral<2>(__first, __last, __value);
537 case 8:
538 return __to_chars_integral<8>(__first, __last, __value);
539 case 16:
540 return __to_chars_integral<16>(__first, __last, __value);
541 }
542
356 ptrdiff_t __cap = __last - __first;543 ptrdiff_t __cap = __last - __first;
357 int __n = __to_chars_integral_width(__value, __base);544 int __n = __to_chars_integral_width(__value, __base);
358 if (__n > __cap)545 if (__n > __cap)
...@@ -369,25 +556,26 @@ __to_chars_integral(char* __first, char* __last, _Tp __value, int __base,...@@ -369,25 +556,26 @@ __to_chars_integral(char* __first, char* __last, _Tp __value, int __base,
369}556}
370557
371template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0>558template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0>
372_LIBCPP_AVAILABILITY_TO_CHARS559inline _LIBCPP_HIDE_FROM_ABI to_chars_result
373inline _LIBCPP_INLINE_VISIBILITY to_chars_result
374to_chars(char* __first, char* __last, _Tp __value)560to_chars(char* __first, char* __last, _Tp __value)
375{561{
376 return __to_chars_itoa(__first, __last, __value, is_signed<_Tp>());562 using _Type = __make_32_64_or_128_bit_t<_Tp>;
563 static_assert(!is_same<_Type, void>::value, "unsupported integral type used in to_chars");
564 return std::__to_chars_itoa(__first, __last, static_cast<_Type>(__value), is_signed<_Tp>());
377}565}
378566
379template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0>567template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0>
380_LIBCPP_AVAILABILITY_TO_CHARS568inline _LIBCPP_HIDE_FROM_ABI to_chars_result
381inline _LIBCPP_INLINE_VISIBILITY to_chars_result
382to_chars(char* __first, char* __last, _Tp __value, int __base)569to_chars(char* __first, char* __last, _Tp __value, int __base)
383{570{
384 _LIBCPP_ASSERT(2 <= __base && __base <= 36, "base not in [2, 36]");571 _LIBCPP_ASSERT(2 <= __base && __base <= 36, "base not in [2, 36]");
385 return __to_chars_integral(__first, __last, __value, __base,572
386 is_signed<_Tp>());573 using _Type = __make_32_64_or_128_bit_t<_Tp>;
574 return std::__to_chars_integral(__first, __last, static_cast<_Type>(__value), __base, is_signed<_Tp>());
387}575}
388576
389template <typename _It, typename _Tp, typename _Fn, typename... _Ts>577template <typename _It, typename _Tp, typename _Fn, typename... _Ts>
390inline _LIBCPP_INLINE_VISIBILITY from_chars_result578inline _LIBCPP_HIDE_FROM_ABI from_chars_result
391__sign_combinator(_It __first, _It __last, _Tp& __value, _Fn __f, _Ts... __args)579__sign_combinator(_It __first, _It __last, _Tp& __value, _Fn __f, _Ts... __args)
392{580{
393 using __tl = numeric_limits<_Tp>;581 using __tl = numeric_limits<_Tp>;
...@@ -410,13 +598,13 @@ __sign_combinator(_It __first, _It __last, _Tp& __value, _Fn __f, _Ts... __args)...@@ -410,13 +598,13 @@ __sign_combinator(_It __first, _It __last, _Tp& __value, _Fn __f, _Ts... __args)
410 if (__x <= __complement(__to_unsigned_like(__tl::min())))598 if (__x <= __complement(__to_unsigned_like(__tl::min())))
411 {599 {
412 __x = __complement(__x);600 __x = __complement(__x);
413 _VSTD::memcpy(&__value, &__x, sizeof(__x));601 std::memcpy(&__value, &__x, sizeof(__x));
414 return __r;602 return __r;
415 }603 }
416 }604 }
417 else605 else
418 {606 {
419 if (__x <= __tl::max())607 if (__x <= __to_unsigned_like(__tl::max()))
420 {608 {
421 __value = __x;609 __value = __x;
422 return __r;610 return __r;
...@@ -427,7 +615,7 @@ __sign_combinator(_It __first, _It __last, _Tp& __value, _Fn __f, _Ts... __args)...@@ -427,7 +615,7 @@ __sign_combinator(_It __first, _It __last, _Tp& __value, _Fn __f, _Ts... __args)
427}615}
428616
429template <typename _Tp>617template <typename _Tp>
430inline _LIBCPP_INLINE_VISIBILITY bool618inline _LIBCPP_HIDE_FROM_ABI bool
431__in_pattern(_Tp __c)619__in_pattern(_Tp __c)
432{620{
433 return '0' <= __c && __c <= '9';621 return '0' <= __c && __c <= '9';
...@@ -438,11 +626,11 @@ struct _LIBCPP_HIDDEN __in_pattern_result...@@ -438,11 +626,11 @@ struct _LIBCPP_HIDDEN __in_pattern_result
438 bool __ok;626 bool __ok;
439 int __val;627 int __val;
440628
441 explicit _LIBCPP_INLINE_VISIBILITY operator bool() const { return __ok; }629 explicit _LIBCPP_HIDE_FROM_ABI operator bool() const { return __ok; }
442};630};
443631
444template <typename _Tp>632template <typename _Tp>
445inline _LIBCPP_INLINE_VISIBILITY __in_pattern_result633inline _LIBCPP_HIDE_FROM_ABI __in_pattern_result
446__in_pattern(_Tp __c, int __base)634__in_pattern(_Tp __c, int __base)
447{635{
448 if (__base <= 10)636 if (__base <= 10)
...@@ -456,15 +644,15 @@ __in_pattern(_Tp __c, int __base)...@@ -456,15 +644,15 @@ __in_pattern(_Tp __c, int __base)
456}644}
457645
458template <typename _It, typename _Tp, typename _Fn, typename... _Ts>646template <typename _It, typename _Tp, typename _Fn, typename... _Ts>
459inline _LIBCPP_INLINE_VISIBILITY from_chars_result647inline _LIBCPP_HIDE_FROM_ABI from_chars_result
460__subject_seq_combinator(_It __first, _It __last, _Tp& __value, _Fn __f,648__subject_seq_combinator(_It __first, _It __last, _Tp& __value, _Fn __f,
461 _Ts... __args)649 _Ts... __args)
462{650{
463 auto __find_non_zero = [](_It __first, _It __last) {651 auto __find_non_zero = [](_It __firstit, _It __lastit) {
464 for (; __first != __last; ++__first)652 for (; __firstit != __lastit; ++__firstit)
465 if (*__first != '0')653 if (*__firstit != '0')
466 break;654 break;
467 return __first;655 return __firstit;
468 };656 };
469657
470 auto __p = __find_non_zero(__first, __last);658 auto __p = __find_non_zero(__first, __last);
...@@ -493,7 +681,7 @@ __subject_seq_combinator(_It __first, _It __last, _Tp& __value, _Fn __f,...@@ -493,7 +681,7 @@ __subject_seq_combinator(_It __first, _It __last, _Tp& __value, _Fn __f,
493}681}
494682
495template <typename _Tp, typename enable_if<is_unsigned<_Tp>::value, int>::type = 0>683template <typename _Tp, typename enable_if<is_unsigned<_Tp>::value, int>::type = 0>
496inline _LIBCPP_INLINE_VISIBILITY from_chars_result684inline _LIBCPP_HIDE_FROM_ABI from_chars_result
497__from_chars_atoi(const char* __first, const char* __last, _Tp& __value)685__from_chars_atoi(const char* __first, const char* __last, _Tp& __value)
498{686{
499 using __tx = __itoa::__traits<_Tp>;687 using __tx = __itoa::__traits<_Tp>;
...@@ -501,16 +689,16 @@ __from_chars_atoi(const char* __first, const char* __last, _Tp& __value)...@@ -501,16 +689,16 @@ __from_chars_atoi(const char* __first, const char* __last, _Tp& __value)
501689
502 return __subject_seq_combinator(690 return __subject_seq_combinator(
503 __first, __last, __value,691 __first, __last, __value,
504 [](const char* __first, const char* __last,692 [](const char* __f, const char* __l,
505 _Tp& __value) -> from_chars_result {693 _Tp& __val) -> from_chars_result {
506 __output_type __a, __b;694 __output_type __a, __b;
507 auto __p = __tx::__read(__first, __last, __a, __b);695 auto __p = __tx::__read(__f, __l, __a, __b);
508 if (__p == __last || !__in_pattern(*__p))696 if (__p == __l || !__in_pattern(*__p))
509 {697 {
510 __output_type __m = numeric_limits<_Tp>::max();698 __output_type __m = numeric_limits<_Tp>::max();
511 if (__m >= __a && __m - __a >= __b)699 if (__m >= __a && __m - __a >= __b)
512 {700 {
513 __value = __a + __b;701 __val = __a + __b;
514 return {__p, {}};702 return {__p, {}};
515 }703 }
516 }704 }
...@@ -519,7 +707,7 @@ __from_chars_atoi(const char* __first, const char* __last, _Tp& __value)...@@ -519,7 +707,7 @@ __from_chars_atoi(const char* __first, const char* __last, _Tp& __value)
519}707}
520708
521template <typename _Tp, typename enable_if<is_signed<_Tp>::value, int>::type = 0>709template <typename _Tp, typename enable_if<is_signed<_Tp>::value, int>::type = 0>
522inline _LIBCPP_INLINE_VISIBILITY from_chars_result710inline _LIBCPP_HIDE_FROM_ABI from_chars_result
523__from_chars_atoi(const char* __first, const char* __last, _Tp& __value)711__from_chars_atoi(const char* __first, const char* __last, _Tp& __value)
524{712{
525 using __t = decltype(__to_unsigned_like(__value));713 using __t = decltype(__to_unsigned_like(__value));
...@@ -527,7 +715,7 @@ __from_chars_atoi(const char* __first, const char* __last, _Tp& __value)...@@ -527,7 +715,7 @@ __from_chars_atoi(const char* __first, const char* __last, _Tp& __value)
527}715}
528716
529template <typename _Tp, typename enable_if<is_unsigned<_Tp>::value, int>::type = 0>717template <typename _Tp, typename enable_if<is_unsigned<_Tp>::value, int>::type = 0>
530inline _LIBCPP_INLINE_VISIBILITY from_chars_result718inline _LIBCPP_HIDE_FROM_ABI from_chars_result
531__from_chars_integral(const char* __first, const char* __last, _Tp& __value,719__from_chars_integral(const char* __first, const char* __last, _Tp& __value,
532 int __base)720 int __base)
533{721{
...@@ -536,23 +724,23 @@ __from_chars_integral(const char* __first, const char* __last, _Tp& __value,...@@ -536,23 +724,23 @@ __from_chars_integral(const char* __first, const char* __last, _Tp& __value,
536724
537 return __subject_seq_combinator(725 return __subject_seq_combinator(
538 __first, __last, __value,726 __first, __last, __value,
539 [](const char* __p, const char* __lastx, _Tp& __value,727 [](const char* __p, const char* __lastp, _Tp& __val,
540 int __base) -> from_chars_result {728 int __b) -> from_chars_result {
541 using __tl = numeric_limits<_Tp>;729 using __tl = numeric_limits<_Tp>;
542 auto __digits = __tl::digits / log2f(float(__base));730 auto __digits = __tl::digits / log2f(float(__b));
543 _Tp __a = __in_pattern(*__p++, __base).__val, __b = 0;731 _Tp __x = __in_pattern(*__p++, __b).__val, __y = 0;
544732
545 for (int __i = 1; __p != __lastx; ++__i, ++__p)733 for (int __i = 1; __p != __lastp; ++__i, ++__p)
546 {734 {
547 if (auto __c = __in_pattern(*__p, __base))735 if (auto __c = __in_pattern(*__p, __b))
548 {736 {
549 if (__i < __digits - 1)737 if (__i < __digits - 1)
550 __a = __a * __base + __c.__val;738 __x = __x * __b + __c.__val;
551 else739 else
552 {740 {
553 if (!__itoa::__mul_overflowed(__a, __base, __a))741 if (!__itoa::__mul_overflowed(__x, __b, __x))
554 ++__p;742 ++__p;
555 __b = __c.__val;743 __y = __c.__val;
556 break;744 break;
557 }745 }
558 }746 }
...@@ -560,11 +748,11 @@ __from_chars_integral(const char* __first, const char* __last, _Tp& __value,...@@ -560,11 +748,11 @@ __from_chars_integral(const char* __first, const char* __last, _Tp& __value,
560 break;748 break;
561 }749 }
562750
563 if (__p == __lastx || !__in_pattern(*__p, __base))751 if (__p == __lastp || !__in_pattern(*__p, __b))
564 {752 {
565 if (__tl::max() - __a >= __b)753 if (__tl::max() - __x >= __y)
566 {754 {
567 __value = __a + __b;755 __val = __x + __y;
568 return {__p, {}};756 return {__p, {}};
569 }757 }
570 }758 }
...@@ -574,7 +762,7 @@ __from_chars_integral(const char* __first, const char* __last, _Tp& __value,...@@ -574,7 +762,7 @@ __from_chars_integral(const char* __first, const char* __last, _Tp& __value,
574}762}
575763
576template <typename _Tp, typename enable_if<is_signed<_Tp>::value, int>::type = 0>764template <typename _Tp, typename enable_if<is_signed<_Tp>::value, int>::type = 0>
577inline _LIBCPP_INLINE_VISIBILITY from_chars_result765inline _LIBCPP_HIDE_FROM_ABI from_chars_result
578__from_chars_integral(const char* __first, const char* __last, _Tp& __value,766__from_chars_integral(const char* __first, const char* __last, _Tp& __value,
579 int __base)767 int __base)
580{768{
...@@ -584,14 +772,14 @@ __from_chars_integral(const char* __first, const char* __last, _Tp& __value,...@@ -584,14 +772,14 @@ __from_chars_integral(const char* __first, const char* __last, _Tp& __value,
584}772}
585773
586template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0>774template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0>
587inline _LIBCPP_INLINE_VISIBILITY from_chars_result775inline _LIBCPP_HIDE_FROM_ABI from_chars_result
588from_chars(const char* __first, const char* __last, _Tp& __value)776from_chars(const char* __first, const char* __last, _Tp& __value)
589{777{
590 return __from_chars_atoi(__first, __last, __value);778 return __from_chars_atoi(__first, __last, __value);
591}779}
592780
593template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0>781template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0>
594inline _LIBCPP_INLINE_VISIBILITY from_chars_result782inline _LIBCPP_HIDE_FROM_ABI from_chars_result
595from_chars(const char* __first, const char* __last, _Tp& __value, int __base)783from_chars(const char* __first, const char* __last, _Tp& __value, int __base)
596{784{
597 _LIBCPP_ASSERT(2 <= __base && __base <= 36, "base not in [2, 36]");785 _LIBCPP_ASSERT(2 <= __base && __base <= 36, "base not in [2, 36]");
lib/libcxx/include/chrono+19-7
...@@ -13,6 +13,8 @@...@@ -13,6 +13,8 @@
13/*13/*
14 chrono synopsis14 chrono synopsis
1515
16#include <compare> // C++20
17
16namespace std18namespace std
17{19{
18namespace chrono20namespace chrono
...@@ -325,11 +327,7 @@ struct last_spec;...@@ -325,11 +327,7 @@ struct last_spec;
325327
326class day;328class day;
327constexpr bool operator==(const day& x, const day& y) noexcept;329constexpr bool operator==(const day& x, const day& y) noexcept;
328constexpr bool operator!=(const day& x, const day& y) noexcept;330constexpr strong_ordering operator<=>(const day& x, const day& y) noexcept;
329constexpr bool operator< (const day& x, const day& y) noexcept;
330constexpr bool operator> (const day& x, const day& y) noexcept;
331constexpr bool operator<=(const day& x, const day& y) noexcept;
332constexpr bool operator>=(const day& x, const day& y) noexcept;
333constexpr day operator+(const day& x, const days& y) noexcept;331constexpr day operator+(const day& x, const days& y) noexcept;
334constexpr day operator+(const days& x, const day& y) noexcept;332constexpr day operator+(const days& x, const day& y) noexcept;
335constexpr day operator-(const day& x, const days& y) noexcept;333constexpr day operator-(const day& x, const days& y) noexcept;
...@@ -694,20 +692,34 @@ constexpr chrono::year operator ""y(unsigned lo...@@ -694,20 +692,34 @@ constexpr chrono::year operator ""y(unsigned lo
694} // std692} // std
695*/693*/
696694
695#include <__assert> // all public C++ headers provide the assertion handler
697#include <__chrono/calendar.h>696#include <__chrono/calendar.h>
698#include <__chrono/convert_to_timespec.h>697#include <__chrono/convert_to_timespec.h>
698#include <__chrono/day.h>
699#include <__chrono/duration.h>699#include <__chrono/duration.h>
700#include <__chrono/file_clock.h>700#include <__chrono/file_clock.h>
701#include <__chrono/hh_mm_ss.h>
701#include <__chrono/high_resolution_clock.h>702#include <__chrono/high_resolution_clock.h>
703#include <__chrono/literals.h>
704#include <__chrono/month.h>
705#include <__chrono/month_weekday.h>
706#include <__chrono/monthday.h>
702#include <__chrono/steady_clock.h>707#include <__chrono/steady_clock.h>
703#include <__chrono/system_clock.h>708#include <__chrono/system_clock.h>
704#include <__chrono/time_point.h>709#include <__chrono/time_point.h>
710#include <__chrono/weekday.h>
711#include <__chrono/year.h>
712#include <__chrono/year_month.h>
713#include <__chrono/year_month_day.h>
714#include <__chrono/year_month_weekday.h>
705#include <__config>715#include <__config>
706#include <compare>
707#include <version>716#include <version>
708717
718// standard-mandated includes
719#include <compare>
720
709#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)721#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
710#pragma GCC system_header722# pragma GCC system_header
711#endif723#endif
712724
713#endif // _LIBCPP_CHRONO725#endif // _LIBCPP_CHRONO
lib/libcxx/include/cinttypes+2-1
...@@ -234,12 +234,13 @@ uintmax_t wcstoumax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int...@@ -234,12 +234,13 @@ uintmax_t wcstoumax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int
234} // std234} // std
235*/235*/
236236
237#include <__assert> // all public C++ headers provide the assertion handler
237#include <__config>238#include <__config>
238#include <cstdint>239#include <cstdint>
239#include <inttypes.h>240#include <inttypes.h>
240241
241#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)242#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
242#pragma GCC system_header243# pragma GCC system_header
243#endif244#endif
244245
245_LIBCPP_BEGIN_NAMESPACE_STD246_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/ciso646+2-1
...@@ -15,10 +15,11 @@...@@ -15,10 +15,11 @@
1515
16*/16*/
1717
18#include <__assert> // all public C++ headers provide the assertion handler
18#include <__config>19#include <__config>
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
22#endif23#endif
2324
24#endif // _LIBCPP_CISO64625#endif // _LIBCPP_CISO646
lib/libcxx/include/climits+2-1
...@@ -37,11 +37,12 @@ Macros:...@@ -37,11 +37,12 @@ Macros:
3737
38*/38*/
3939
40#include <__assert> // all public C++ headers provide the assertion handler
40#include <__config>41#include <__config>
41#include <limits.h>42#include <limits.h>
4243
43#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)44#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
44#pragma GCC system_header45# pragma GCC system_header
45#endif46#endif
4647
47#endif // _LIBCPP_CLIMITS48#endif // _LIBCPP_CLIMITS
lib/libcxx/include/clocale+2-1
...@@ -34,11 +34,12 @@ lconv* localeconv();...@@ -34,11 +34,12 @@ lconv* localeconv();
3434
35*/35*/
3636
37#include <__assert> // all public C++ headers provide the assertion handler
37#include <__config>38#include <__config>
38#include <locale.h>39#include <locale.h>
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
42#endif43#endif
4344
44_LIBCPP_BEGIN_NAMESPACE_STD45_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/cmath+5-4
...@@ -304,13 +304,14 @@ constexpr long double lerp(long double a, long double b, long double t) noexcept...@@ -304,13 +304,14 @@ constexpr long double lerp(long double a, long double b, long double t) noexcept
304304
305*/305*/
306306
307#include <__assert> // all public C++ headers provide the assertion handler
307#include <__config>308#include <__config>
308#include <math.h>309#include <math.h>
309#include <type_traits>310#include <type_traits>
310#include <version>311#include <version>
311312
312#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)313#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
313#pragma GCC system_header314# pragma GCC system_header
314#endif315#endif
315316
316_LIBCPP_PUSH_MACROS317_LIBCPP_PUSH_MACROS
...@@ -529,9 +530,9 @@ using ::tgammal _LIBCPP_USING_IF_EXISTS;...@@ -529,9 +530,9 @@ using ::tgammal _LIBCPP_USING_IF_EXISTS;
529using ::truncl _LIBCPP_USING_IF_EXISTS;530using ::truncl _LIBCPP_USING_IF_EXISTS;
530531
531#if _LIBCPP_STD_VER > 14532#if _LIBCPP_STD_VER > 14
532inline _LIBCPP_INLINE_VISIBILITY float hypot( float x, float y, float z ) { return sqrt(x*x + y*y + z*z); }533inline _LIBCPP_INLINE_VISIBILITY float hypot( float __x, float __y, float __z ) { return sqrt(__x*__x + __y*__y + __z*__z); }
533inline _LIBCPP_INLINE_VISIBILITY double hypot( double x, double y, double z ) { return sqrt(x*x + y*y + z*z); }534inline _LIBCPP_INLINE_VISIBILITY double hypot( double __x, double __y, double __z ) { return sqrt(__x*__x + __y*__y + __z*__z); }
534inline _LIBCPP_INLINE_VISIBILITY long double hypot( long double x, long double y, long double z ) { return sqrt(x*x + y*y + z*z); }535inline _LIBCPP_INLINE_VISIBILITY long double hypot( long double __x, long double __y, long double __z ) { return sqrt(__x*__x + __y*__y + __z*__z); }
535536
536template <class _A1, class _A2, class _A3>537template <class _A1, class _A2, class _A3>
537inline _LIBCPP_INLINE_VISIBILITY538inline _LIBCPP_INLINE_VISIBILITY
lib/libcxx/include/codecvt+76-53
...@@ -54,17 +54,18 @@ class codecvt_utf8_utf16...@@ -54,17 +54,18 @@ class codecvt_utf8_utf16
5454
55*/55*/
5656
57#include <__assert> // all public C++ headers provide the assertion handler
57#include <__config>58#include <__config>
58#include <__locale>59#include <__locale>
59#include <version>60#include <version>
6061
61#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)62#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
62#pragma GCC system_header63# pragma GCC system_header
63#endif64#endif
6465
65_LIBCPP_BEGIN_NAMESPACE_STD66_LIBCPP_BEGIN_NAMESPACE_STD
6667
67enum codecvt_mode68enum _LIBCPP_DEPRECATED_IN_CXX17 codecvt_mode
68{69{
69 consume_header = 4,70 consume_header = 4,
70 generate_header = 2,71 generate_header = 2,
...@@ -81,17 +82,21 @@ class _LIBCPP_TYPE_VIS __codecvt_utf8<wchar_t>...@@ -81,17 +82,21 @@ class _LIBCPP_TYPE_VIS __codecvt_utf8<wchar_t>
81 : public codecvt<wchar_t, char, mbstate_t>82 : public codecvt<wchar_t, char, mbstate_t>
82{83{
83 unsigned long _Maxcode_;84 unsigned long _Maxcode_;
85_LIBCPP_SUPPRESS_DEPRECATED_PUSH
84 codecvt_mode _Mode_;86 codecvt_mode _Mode_;
87_LIBCPP_SUPPRESS_DEPRECATED_POP
85public:88public:
86 typedef wchar_t intern_type;89 typedef wchar_t intern_type;
87 typedef char extern_type;90 typedef char extern_type;
88 typedef mbstate_t state_type;91 typedef mbstate_t state_type;
8992
93_LIBCPP_SUPPRESS_DEPRECATED_PUSH
90 _LIBCPP_INLINE_VISIBILITY94 _LIBCPP_INLINE_VISIBILITY
91 explicit __codecvt_utf8(size_t __refs, unsigned long _Maxcode,95 explicit __codecvt_utf8(size_t __refs, unsigned long __maxcode,
92 codecvt_mode _Mode)96 codecvt_mode __mode)
93 : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),97 : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode),
94 _Mode_(_Mode) {}98 _Mode_(__mode) {}
99_LIBCPP_SUPPRESS_DEPRECATED_POP
95protected:100protected:
96 virtual result101 virtual result
97 do_out(state_type& __st,102 do_out(state_type& __st,
...@@ -125,10 +130,10 @@ public:...@@ -125,10 +130,10 @@ public:
125 typedef mbstate_t state_type;130 typedef mbstate_t state_type;
126131
127 _LIBCPP_INLINE_VISIBILITY132 _LIBCPP_INLINE_VISIBILITY
128 explicit __codecvt_utf8(size_t __refs, unsigned long _Maxcode,133 explicit __codecvt_utf8(size_t __refs, unsigned long __maxcode,
129 codecvt_mode _Mode)134 codecvt_mode __mode)
130 : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),135 : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode),
131 _Mode_(_Mode) {}136 _Mode_(__mode) {}
132_LIBCPP_SUPPRESS_DEPRECATED_POP137_LIBCPP_SUPPRESS_DEPRECATED_POP
133138
134protected:139protected:
...@@ -163,10 +168,10 @@ public:...@@ -163,10 +168,10 @@ public:
163 typedef mbstate_t state_type;168 typedef mbstate_t state_type;
164169
165 _LIBCPP_INLINE_VISIBILITY170 _LIBCPP_INLINE_VISIBILITY
166 explicit __codecvt_utf8(size_t __refs, unsigned long _Maxcode,171 explicit __codecvt_utf8(size_t __refs, unsigned long __maxcode,
167 codecvt_mode _Mode)172 codecvt_mode __mode)
168 : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),173 : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode),
169 _Mode_(_Mode) {}174 _Mode_(__mode) {}
170_LIBCPP_SUPPRESS_DEPRECATED_POP175_LIBCPP_SUPPRESS_DEPRECATED_POP
171176
172protected:177protected:
...@@ -188,9 +193,10 @@ protected:...@@ -188,9 +193,10 @@ protected:
188 virtual int do_max_length() const _NOEXCEPT;193 virtual int do_max_length() const _NOEXCEPT;
189};194};
190195
196_LIBCPP_SUPPRESS_DEPRECATED_PUSH
191template <class _Elem, unsigned long _Maxcode = 0x10ffff,197template <class _Elem, unsigned long _Maxcode = 0x10ffff,
192 codecvt_mode _Mode = (codecvt_mode)0>198 codecvt_mode _Mode = (codecvt_mode)0>
193class _LIBCPP_TEMPLATE_VIS codecvt_utf8199class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 codecvt_utf8
194 : public __codecvt_utf8<_Elem>200 : public __codecvt_utf8<_Elem>
195{201{
196public:202public:
...@@ -201,6 +207,7 @@ public:...@@ -201,6 +207,7 @@ public:
201 _LIBCPP_INLINE_VISIBILITY207 _LIBCPP_INLINE_VISIBILITY
202 ~codecvt_utf8() {}208 ~codecvt_utf8() {}
203};209};
210_LIBCPP_SUPPRESS_DEPRECATED_POP
204211
205// codecvt_utf16212// codecvt_utf16
206213
...@@ -212,17 +219,21 @@ class _LIBCPP_TYPE_VIS __codecvt_utf16<wchar_t, false>...@@ -212,17 +219,21 @@ class _LIBCPP_TYPE_VIS __codecvt_utf16<wchar_t, false>
212 : public codecvt<wchar_t, char, mbstate_t>219 : public codecvt<wchar_t, char, mbstate_t>
213{220{
214 unsigned long _Maxcode_;221 unsigned long _Maxcode_;
222_LIBCPP_SUPPRESS_DEPRECATED_PUSH
215 codecvt_mode _Mode_;223 codecvt_mode _Mode_;
224_LIBCPP_SUPPRESS_DEPRECATED_POP
216public:225public:
217 typedef wchar_t intern_type;226 typedef wchar_t intern_type;
218 typedef char extern_type;227 typedef char extern_type;
219 typedef mbstate_t state_type;228 typedef mbstate_t state_type;
220229
230_LIBCPP_SUPPRESS_DEPRECATED_PUSH
221 _LIBCPP_INLINE_VISIBILITY231 _LIBCPP_INLINE_VISIBILITY
222 explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,232 explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode,
223 codecvt_mode _Mode)233 codecvt_mode __mode)
224 : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),234 : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode),
225 _Mode_(_Mode) {}235 _Mode_(__mode) {}
236_LIBCPP_SUPPRESS_DEPRECATED_POP
226protected:237protected:
227 virtual result238 virtual result
228 do_out(state_type& __st,239 do_out(state_type& __st,
...@@ -247,17 +258,21 @@ class _LIBCPP_TYPE_VIS __codecvt_utf16<wchar_t, true>...@@ -247,17 +258,21 @@ class _LIBCPP_TYPE_VIS __codecvt_utf16<wchar_t, true>
247 : public codecvt<wchar_t, char, mbstate_t>258 : public codecvt<wchar_t, char, mbstate_t>
248{259{
249 unsigned long _Maxcode_;260 unsigned long _Maxcode_;
261_LIBCPP_SUPPRESS_DEPRECATED_PUSH
250 codecvt_mode _Mode_;262 codecvt_mode _Mode_;
263_LIBCPP_SUPPRESS_DEPRECATED_POP
251public:264public:
252 typedef wchar_t intern_type;265 typedef wchar_t intern_type;
253 typedef char extern_type;266 typedef char extern_type;
254 typedef mbstate_t state_type;267 typedef mbstate_t state_type;
255268
269_LIBCPP_SUPPRESS_DEPRECATED_PUSH
256 _LIBCPP_INLINE_VISIBILITY270 _LIBCPP_INLINE_VISIBILITY
257 explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,271 explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode,
258 codecvt_mode _Mode)272 codecvt_mode __mode)
259 : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),273 : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode),
260 _Mode_(_Mode) {}274 _Mode_(__mode) {}
275_LIBCPP_SUPPRESS_DEPRECATED_POP
261protected:276protected:
262 virtual result277 virtual result
263 do_out(state_type& __st,278 do_out(state_type& __st,
...@@ -291,10 +306,10 @@ public:...@@ -291,10 +306,10 @@ public:
291 typedef mbstate_t state_type;306 typedef mbstate_t state_type;
292307
293 _LIBCPP_INLINE_VISIBILITY308 _LIBCPP_INLINE_VISIBILITY
294 explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,309 explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode,
295 codecvt_mode _Mode)310 codecvt_mode __mode)
296 : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),311 : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode),
297 _Mode_(_Mode) {}312 _Mode_(__mode) {}
298_LIBCPP_SUPPRESS_DEPRECATED_POP313_LIBCPP_SUPPRESS_DEPRECATED_POP
299314
300protected:315protected:
...@@ -329,10 +344,10 @@ public:...@@ -329,10 +344,10 @@ public:
329 typedef mbstate_t state_type;344 typedef mbstate_t state_type;
330345
331 _LIBCPP_INLINE_VISIBILITY346 _LIBCPP_INLINE_VISIBILITY
332 explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,347 explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode,
333 codecvt_mode _Mode)348 codecvt_mode __mode)
334 : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),349 : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode),
335 _Mode_(_Mode) {}350 _Mode_(__mode) {}
336_LIBCPP_SUPPRESS_DEPRECATED_POP351_LIBCPP_SUPPRESS_DEPRECATED_POP
337352
338protected:353protected:
...@@ -367,10 +382,10 @@ public:...@@ -367,10 +382,10 @@ public:
367 typedef mbstate_t state_type;382 typedef mbstate_t state_type;
368383
369 _LIBCPP_INLINE_VISIBILITY384 _LIBCPP_INLINE_VISIBILITY
370 explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,385 explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode,
371 codecvt_mode _Mode)386 codecvt_mode __mode)
372 : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),387 : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode),
373 _Mode_(_Mode) {}388 _Mode_(__mode) {}
374_LIBCPP_SUPPRESS_DEPRECATED_POP389_LIBCPP_SUPPRESS_DEPRECATED_POP
375390
376protected:391protected:
...@@ -405,10 +420,10 @@ public:...@@ -405,10 +420,10 @@ public:
405 typedef mbstate_t state_type;420 typedef mbstate_t state_type;
406421
407 _LIBCPP_INLINE_VISIBILITY422 _LIBCPP_INLINE_VISIBILITY
408 explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,423 explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode,
409 codecvt_mode _Mode)424 codecvt_mode __mode)
410 : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),425 : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode),
411 _Mode_(_Mode) {}426 _Mode_(__mode) {}
412_LIBCPP_SUPPRESS_DEPRECATED_POP427_LIBCPP_SUPPRESS_DEPRECATED_POP
413428
414protected:429protected:
...@@ -430,9 +445,10 @@ protected:...@@ -430,9 +445,10 @@ protected:
430 virtual int do_max_length() const _NOEXCEPT;445 virtual int do_max_length() const _NOEXCEPT;
431};446};
432447
448_LIBCPP_SUPPRESS_DEPRECATED_PUSH
433template <class _Elem, unsigned long _Maxcode = 0x10ffff,449template <class _Elem, unsigned long _Maxcode = 0x10ffff,
434 codecvt_mode _Mode = (codecvt_mode)0>450 codecvt_mode _Mode = (codecvt_mode)0>
435class _LIBCPP_TEMPLATE_VIS codecvt_utf16451class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 codecvt_utf16
436 : public __codecvt_utf16<_Elem, _Mode & little_endian>452 : public __codecvt_utf16<_Elem, _Mode & little_endian>
437{453{
438public:454public:
...@@ -443,6 +459,7 @@ public:...@@ -443,6 +459,7 @@ public:
443 _LIBCPP_INLINE_VISIBILITY459 _LIBCPP_INLINE_VISIBILITY
444 ~codecvt_utf16() {}460 ~codecvt_utf16() {}
445};461};
462_LIBCPP_SUPPRESS_DEPRECATED_POP
446463
447// codecvt_utf8_utf16464// codecvt_utf8_utf16
448465
...@@ -454,17 +471,21 @@ class _LIBCPP_TYPE_VIS __codecvt_utf8_utf16<wchar_t>...@@ -454,17 +471,21 @@ class _LIBCPP_TYPE_VIS __codecvt_utf8_utf16<wchar_t>
454 : public codecvt<wchar_t, char, mbstate_t>471 : public codecvt<wchar_t, char, mbstate_t>
455{472{
456 unsigned long _Maxcode_;473 unsigned long _Maxcode_;
474_LIBCPP_SUPPRESS_DEPRECATED_PUSH
457 codecvt_mode _Mode_;475 codecvt_mode _Mode_;
476_LIBCPP_SUPPRESS_DEPRECATED_POP
458public:477public:
459 typedef wchar_t intern_type;478 typedef wchar_t intern_type;
460 typedef char extern_type;479 typedef char extern_type;
461 typedef mbstate_t state_type;480 typedef mbstate_t state_type;
462481
482_LIBCPP_SUPPRESS_DEPRECATED_PUSH
463 _LIBCPP_INLINE_VISIBILITY483 _LIBCPP_INLINE_VISIBILITY
464 explicit __codecvt_utf8_utf16(size_t __refs, unsigned long _Maxcode,484 explicit __codecvt_utf8_utf16(size_t __refs, unsigned long __maxcode,
465 codecvt_mode _Mode)485 codecvt_mode __mode)
466 : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),486 : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode),
467 _Mode_(_Mode) {}487 _Mode_(__mode) {}
488_LIBCPP_SUPPRESS_DEPRECATED_POP
468protected:489protected:
469 virtual result490 virtual result
470 do_out(state_type& __st,491 do_out(state_type& __st,
...@@ -498,10 +519,10 @@ public:...@@ -498,10 +519,10 @@ public:
498 typedef mbstate_t state_type;519 typedef mbstate_t state_type;
499520
500 _LIBCPP_INLINE_VISIBILITY521 _LIBCPP_INLINE_VISIBILITY
501 explicit __codecvt_utf8_utf16(size_t __refs, unsigned long _Maxcode,522 explicit __codecvt_utf8_utf16(size_t __refs, unsigned long __maxcode,
502 codecvt_mode _Mode)523 codecvt_mode __mode)
503 : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),524 : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode),
504 _Mode_(_Mode) {}525 _Mode_(__mode) {}
505_LIBCPP_SUPPRESS_DEPRECATED_POP526_LIBCPP_SUPPRESS_DEPRECATED_POP
506527
507protected:528protected:
...@@ -536,10 +557,10 @@ public:...@@ -536,10 +557,10 @@ public:
536 typedef mbstate_t state_type;557 typedef mbstate_t state_type;
537558
538 _LIBCPP_INLINE_VISIBILITY559 _LIBCPP_INLINE_VISIBILITY
539 explicit __codecvt_utf8_utf16(size_t __refs, unsigned long _Maxcode,560 explicit __codecvt_utf8_utf16(size_t __refs, unsigned long __maxcode,
540 codecvt_mode _Mode)561 codecvt_mode __mode)
541 : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),562 : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode),
542 _Mode_(_Mode) {}563 _Mode_(__mode) {}
543_LIBCPP_SUPPRESS_DEPRECATED_POP564_LIBCPP_SUPPRESS_DEPRECATED_POP
544565
545protected:566protected:
...@@ -561,9 +582,10 @@ protected:...@@ -561,9 +582,10 @@ protected:
561 virtual int do_max_length() const _NOEXCEPT;582 virtual int do_max_length() const _NOEXCEPT;
562};583};
563584
585_LIBCPP_SUPPRESS_DEPRECATED_PUSH
564template <class _Elem, unsigned long _Maxcode = 0x10ffff,586template <class _Elem, unsigned long _Maxcode = 0x10ffff,
565 codecvt_mode _Mode = (codecvt_mode)0>587 codecvt_mode _Mode = (codecvt_mode)0>
566class _LIBCPP_TEMPLATE_VIS codecvt_utf8_utf16588class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 codecvt_utf8_utf16
567 : public __codecvt_utf8_utf16<_Elem>589 : public __codecvt_utf8_utf16<_Elem>
568{590{
569public:591public:
...@@ -574,6 +596,7 @@ public:...@@ -574,6 +596,7 @@ public:
574 _LIBCPP_INLINE_VISIBILITY596 _LIBCPP_INLINE_VISIBILITY
575 ~codecvt_utf8_utf16() {}597 ~codecvt_utf8_utf16() {}
576};598};
599_LIBCPP_SUPPRESS_DEPRECATED_POP
577600
578_LIBCPP_END_NAMESPACE_STD601_LIBCPP_END_NAMESPACE_STD
579602
lib/libcxx/include/compare+2-1
...@@ -140,6 +140,7 @@ namespace std {...@@ -140,6 +140,7 @@ namespace std {
140}140}
141*/141*/
142142
143#include <__assert> // all public C++ headers provide the assertion handler
143#include <__compare/common_comparison_category.h>144#include <__compare/common_comparison_category.h>
144#include <__compare/compare_partial_order_fallback.h>145#include <__compare/compare_partial_order_fallback.h>
145#include <__compare/compare_strong_order_fallback.h>146#include <__compare/compare_strong_order_fallback.h>
...@@ -156,7 +157,7 @@ namespace std {...@@ -156,7 +157,7 @@ namespace std {
156#include <version>157#include <version>
157158
158#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)159#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
159#pragma GCC system_header160# pragma GCC system_header
160#endif161#endif
161162
162#endif // _LIBCPP_COMPARE163#endif // _LIBCPP_COMPARE
lib/libcxx/include/complex+2-1
...@@ -231,6 +231,7 @@ template<class T> complex<T> tanh (const complex<T>&);...@@ -231,6 +231,7 @@ template<class T> complex<T> tanh (const complex<T>&);
231231
232*/232*/
233233
234#include <__assert> // all public C++ headers provide the assertion handler
234#include <__config>235#include <__config>
235#include <cmath>236#include <cmath>
236#include <iosfwd>237#include <iosfwd>
...@@ -243,7 +244,7 @@ template<class T> complex<T> tanh (const complex<T>&);...@@ -243,7 +244,7 @@ template<class T> complex<T> tanh (const complex<T>&);
243#endif244#endif
244245
245#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)246#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
246#pragma GCC system_header247# pragma GCC system_header
247#endif248#endif
248249
249_LIBCPP_BEGIN_NAMESPACE_STD250_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/complex.h+1-1
...@@ -20,7 +20,7 @@...@@ -20,7 +20,7 @@
20#include <__config>20#include <__config>
2121
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23#pragma GCC system_header23# pragma GCC system_header
24#endif24#endif
2525
26#ifdef __cplusplus26#ifdef __cplusplus
lib/libcxx/include/concepts+2-1
...@@ -129,6 +129,7 @@ namespace std {...@@ -129,6 +129,7 @@ namespace std {
129129
130*/130*/
131131
132#include <__assert> // all public C++ headers provide the assertion handler
132#include <__concepts/arithmetic.h>133#include <__concepts/arithmetic.h>
133#include <__concepts/assignable.h>134#include <__concepts/assignable.h>
134#include <__concepts/boolean_testable.h>135#include <__concepts/boolean_testable.h>
...@@ -155,7 +156,7 @@ namespace std {...@@ -155,7 +156,7 @@ namespace std {
155#include <version>156#include <version>
156157
157#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)158#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
158#pragma GCC system_header159# pragma GCC system_header
159#endif160#endif
160161
161#endif // _LIBCPP_CONCEPTS162#endif // _LIBCPP_CONCEPTS
lib/libcxx/include/condition_variable+3-2
...@@ -106,13 +106,14 @@ public:...@@ -106,13 +106,14 @@ public:
106106
107*/107*/
108108
109#include <__assert> // all public C++ headers provide the assertion handler
109#include <__config>110#include <__config>
110#include <__mutex_base>111#include <__mutex_base>
111#include <memory>112#include <memory>
112#include <version>113#include <version>
113114
114#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)115#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
115#pragma GCC system_header116# pragma GCC system_header
116#endif117#endif
117118
118#ifndef _LIBCPP_HAS_NO_THREADS119#ifndef _LIBCPP_HAS_NO_THREADS
...@@ -260,7 +261,7 @@ condition_variable_any::wait_for(_Lock& __lock,...@@ -260,7 +261,7 @@ condition_variable_any::wait_for(_Lock& __lock,
260}261}
261262
262_LIBCPP_FUNC_VIS263_LIBCPP_FUNC_VIS
263void notify_all_at_thread_exit(condition_variable& cond, unique_lock<mutex> lk);264void notify_all_at_thread_exit(condition_variable&, unique_lock<mutex>);
264265
265_LIBCPP_END_NAMESPACE_STD266_LIBCPP_END_NAMESPACE_STD
266267
lib/libcxx/include/coroutine+9-1
...@@ -38,6 +38,7 @@ struct suspend_always;...@@ -38,6 +38,7 @@ struct suspend_always;
3838
39 */39 */
4040
41#include <__assert> // all public C++ headers provide the assertion handler
41#include <__config>42#include <__config>
42#include <__coroutine/coroutine_handle.h>43#include <__coroutine/coroutine_handle.h>
43#include <__coroutine/coroutine_traits.h>44#include <__coroutine/coroutine_traits.h>
...@@ -45,8 +46,15 @@ struct suspend_always;...@@ -45,8 +46,15 @@ struct suspend_always;
45#include <__coroutine/trivial_awaitables.h>46#include <__coroutine/trivial_awaitables.h>
46#include <version>47#include <version>
4748
49#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
50# include <iosfwd>
51#endif
52
53// standard-mandated includes
54#include <compare>
55
48#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER56#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
49#pragma GCC system_header57# pragma GCC system_header
50#endif58#endif
5159
52#endif // _LIBCPP_COROUTINE60#endif // _LIBCPP_COROUTINE
lib/libcxx/include/csetjmp+2-1
...@@ -30,11 +30,12 @@ void longjmp(jmp_buf env, int val);...@@ -30,11 +30,12 @@ void longjmp(jmp_buf env, int val);
3030
31*/31*/
3232
33#include <__assert> // all public C++ headers provide the assertion handler
33#include <__config>34#include <__config>
34#include <setjmp.h>35#include <setjmp.h>
3536
36#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)37#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
37#pragma GCC system_header38# pragma GCC system_header
38#endif39#endif
3940
40_LIBCPP_BEGIN_NAMESPACE_STD41_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/csignal+6-2
...@@ -39,11 +39,15 @@ int raise(int sig);...@@ -39,11 +39,15 @@ int raise(int sig);
3939
40*/40*/
4141
42#include <__assert> // all public C++ headers provide the assertion handler
42#include <__config>43#include <__config>
43#include <signal.h>44
45#if __has_include(<signal.h>)
46# include <signal.h>
47#endif
4448
45#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)49#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
46#pragma GCC system_header50# pragma GCC system_header
47#endif51#endif
4852
49_LIBCPP_BEGIN_NAMESPACE_STD53_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/cstdarg+2-1
...@@ -31,11 +31,12 @@ Types:...@@ -31,11 +31,12 @@ Types:
3131
32*/32*/
3333
34#include <__assert> // all public C++ headers provide the assertion handler
34#include <__config>35#include <__config>
35#include <stdarg.h>36#include <stdarg.h>
3637
37#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)38#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
38#pragma GCC system_header39# pragma GCC system_header
39#endif40#endif
4041
41_LIBCPP_BEGIN_NAMESPACE_STD42_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/cstdbool+2-1
...@@ -19,10 +19,11 @@ Macros:...@@ -19,10 +19,11 @@ Macros:
1919
20*/20*/
2121
22#include <__assert> // all public C++ headers provide the assertion handler
22#include <__config>23#include <__config>
2324
24#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)25#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
25#pragma GCC system_header26# pragma GCC system_header
26#endif27#endif
2728
28#undef __bool_true_false_are_defined29#undef __bool_true_false_are_defined
lib/libcxx/include/cstddef+11-38
...@@ -33,19 +33,21 @@ Types:...@@ -33,19 +33,21 @@ Types:
3333
34*/34*/
3535
36#include <__assert> // all public C++ headers provide the assertion handler
36#include <__config>37#include <__config>
38#include <__type_traits/enable_if.h>
39#include <__type_traits/integral_constant.h>
40#include <__type_traits/is_integral.h>
41#include <stddef.h>
37#include <version>42#include <version>
3843
39#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)44#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
40#pragma GCC system_header45# pragma GCC system_header
41#endif46#endif
4247
43// Don't include our own <stddef.h>; we don't want to declare ::nullptr_t.
44#include_next <stddef.h>
45#include <__nullptr>
46
47_LIBCPP_BEGIN_NAMESPACE_STD48_LIBCPP_BEGIN_NAMESPACE_STD
4849
50using ::nullptr_t;
49using ::ptrdiff_t _LIBCPP_USING_IF_EXISTS;51using ::ptrdiff_t _LIBCPP_USING_IF_EXISTS;
50using ::size_t _LIBCPP_USING_IF_EXISTS;52using ::size_t _LIBCPP_USING_IF_EXISTS;
5153
...@@ -53,34 +55,6 @@ using ::size_t _LIBCPP_USING_IF_EXISTS;...@@ -53,34 +55,6 @@ using ::size_t _LIBCPP_USING_IF_EXISTS;
53using ::max_align_t _LIBCPP_USING_IF_EXISTS;55using ::max_align_t _LIBCPP_USING_IF_EXISTS;
54#endif56#endif
5557
56template <class _Tp> struct __libcpp_is_integral { enum { value = 0 }; };
57template <> struct __libcpp_is_integral<bool> { enum { value = 1 }; };
58template <> struct __libcpp_is_integral<char> { enum { value = 1 }; };
59template <> struct __libcpp_is_integral<signed char> { enum { value = 1 }; };
60template <> struct __libcpp_is_integral<unsigned char> { enum { value = 1 }; };
61#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
62template <> struct __libcpp_is_integral<wchar_t> { enum { value = 1 }; };
63#endif
64#ifndef _LIBCPP_HAS_NO_CHAR8_T
65template <> struct __libcpp_is_integral<char8_t> { enum { value = 1 }; };
66#endif
67#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
68template <> struct __libcpp_is_integral<char16_t> { enum { value = 1 }; };
69template <> struct __libcpp_is_integral<char32_t> { enum { value = 1 }; };
70#endif
71template <> struct __libcpp_is_integral<short> { enum { value = 1 }; };
72template <> struct __libcpp_is_integral<unsigned short> { enum { value = 1 }; };
73template <> struct __libcpp_is_integral<int> { enum { value = 1 }; };
74template <> struct __libcpp_is_integral<unsigned int> { enum { value = 1 }; };
75template <> struct __libcpp_is_integral<long> { enum { value = 1 }; };
76template <> struct __libcpp_is_integral<unsigned long> { enum { value = 1 }; };
77template <> struct __libcpp_is_integral<long long> { enum { value = 1 }; };
78template <> struct __libcpp_is_integral<unsigned long long> { enum { value = 1 }; };
79#ifndef _LIBCPP_HAS_NO_INT128
80template <> struct __libcpp_is_integral<__int128_t> { enum { value = 1 }; };
81template <> struct __libcpp_is_integral<__uint128_t> { enum { value = 1 }; };
82#endif
83
84_LIBCPP_END_NAMESPACE_STD58_LIBCPP_END_NAMESPACE_STD
8559
86#if _LIBCPP_STD_VER > 1460#if _LIBCPP_STD_VER > 14
...@@ -88,11 +62,6 @@ namespace std // purposefully not versioned...@@ -88,11 +62,6 @@ namespace std // purposefully not versioned
88{62{
89enum class byte : unsigned char {};63enum class byte : unsigned char {};
9064
91
92template <bool> struct __enable_if_integral_imp {};
93template <> struct __enable_if_integral_imp<true> { using type = byte; };
94template <class _Tp> using _EnableByteOverload = typename __enable_if_integral_imp<__libcpp_is_integral<_Tp>::value>::type;
95
96constexpr byte operator| (byte __lhs, byte __rhs) noexcept65constexpr byte operator| (byte __lhs, byte __rhs) noexcept
97{66{
98 return static_cast<byte>(67 return static_cast<byte>(
...@@ -133,6 +102,10 @@ constexpr byte operator~ (byte __b) noexcept...@@ -133,6 +102,10 @@ constexpr byte operator~ (byte __b) noexcept
133 ~static_cast<unsigned int>(__b)102 ~static_cast<unsigned int>(__b)
134 ));103 ));
135}104}
105
106template <class _Tp>
107using _EnableByteOverload = __enable_if_t<is_integral<_Tp>::value, byte>;
108
136template <class _Integer>109template <class _Integer>
137 constexpr _EnableByteOverload<_Integer> &110 constexpr _EnableByteOverload<_Integer> &
138 operator<<=(byte& __lhs, _Integer __shift) noexcept111 operator<<=(byte& __lhs, _Integer __shift) noexcept
lib/libcxx/include/cstdint+2-1
...@@ -140,11 +140,12 @@ Types:...@@ -140,11 +140,12 @@ Types:
140} // std140} // std
141*/141*/
142142
143#include <__assert> // all public C++ headers provide the assertion handler
143#include <__config>144#include <__config>
144#include <stdint.h>145#include <stdint.h>
145146
146#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)147#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
147#pragma GCC system_header148# pragma GCC system_header
148#endif149#endif
149150
150_LIBCPP_BEGIN_NAMESPACE_STD151_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/cstdio+2-1
...@@ -95,11 +95,12 @@ void perror(const char* s);...@@ -95,11 +95,12 @@ void perror(const char* s);
95} // std95} // std
96*/96*/
9797
98#include <__assert> // all public C++ headers provide the assertion handler
98#include <__config>99#include <__config>
99#include <stdio.h>100#include <stdio.h>
100101
101#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)102#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
102#pragma GCC system_header103# pragma GCC system_header
103#endif104#endif
104105
105_LIBCPP_BEGIN_NAMESPACE_STD106_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/cstdlib+4-11
...@@ -81,17 +81,12 @@ void *aligned_alloc(size_t alignment, size_t size); // C11...@@ -81,17 +81,12 @@ void *aligned_alloc(size_t alignment, size_t size); // C11
8181
82*/82*/
8383
84#include <__assert> // all public C++ headers provide the assertion handler
84#include <__config>85#include <__config>
85#include <stdlib.h>86#include <stdlib.h>
8687
87#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)88#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
88#pragma GCC system_header89# pragma GCC system_header
89#endif
90
91#ifdef __GNUC__
92#define _LIBCPP_UNREACHABLE() __builtin_unreachable()
93#else
94#define _LIBCPP_UNREACHABLE() _VSTD::abort()
95#endif90#endif
9691
97_LIBCPP_BEGIN_NAMESPACE_STD92_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -121,10 +116,8 @@ using ::abort _LIBCPP_USING_IF_EXISTS;...@@ -121,10 +116,8 @@ using ::abort _LIBCPP_USING_IF_EXISTS;
121using ::atexit _LIBCPP_USING_IF_EXISTS;116using ::atexit _LIBCPP_USING_IF_EXISTS;
122using ::exit _LIBCPP_USING_IF_EXISTS;117using ::exit _LIBCPP_USING_IF_EXISTS;
123using ::_Exit _LIBCPP_USING_IF_EXISTS;118using ::_Exit _LIBCPP_USING_IF_EXISTS;
124#ifndef _LIBCPP_WINDOWS_STORE_APP
125using ::getenv _LIBCPP_USING_IF_EXISTS;119using ::getenv _LIBCPP_USING_IF_EXISTS;
126using ::system _LIBCPP_USING_IF_EXISTS;120using ::system _LIBCPP_USING_IF_EXISTS;
127#endif
128using ::bsearch _LIBCPP_USING_IF_EXISTS;121using ::bsearch _LIBCPP_USING_IF_EXISTS;
129using ::qsort _LIBCPP_USING_IF_EXISTS;122using ::qsort _LIBCPP_USING_IF_EXISTS;
130using ::abs _LIBCPP_USING_IF_EXISTS;123using ::abs _LIBCPP_USING_IF_EXISTS;
...@@ -138,11 +131,11 @@ using ::mbtowc _LIBCPP_USING_IF_EXISTS;...@@ -138,11 +131,11 @@ using ::mbtowc _LIBCPP_USING_IF_EXISTS;
138using ::wctomb _LIBCPP_USING_IF_EXISTS;131using ::wctomb _LIBCPP_USING_IF_EXISTS;
139using ::mbstowcs _LIBCPP_USING_IF_EXISTS;132using ::mbstowcs _LIBCPP_USING_IF_EXISTS;
140using ::wcstombs _LIBCPP_USING_IF_EXISTS;133using ::wcstombs _LIBCPP_USING_IF_EXISTS;
141#if !defined(_LIBCPP_CXX03_LANG) && defined(_LIBCPP_HAS_QUICK_EXIT)134#if !defined(_LIBCPP_CXX03_LANG)
142using ::at_quick_exit _LIBCPP_USING_IF_EXISTS;135using ::at_quick_exit _LIBCPP_USING_IF_EXISTS;
143using ::quick_exit _LIBCPP_USING_IF_EXISTS;136using ::quick_exit _LIBCPP_USING_IF_EXISTS;
144#endif137#endif
145#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_ALIGNED_ALLOC)138#if _LIBCPP_STD_VER > 14
146using ::aligned_alloc _LIBCPP_USING_IF_EXISTS;139using ::aligned_alloc _LIBCPP_USING_IF_EXISTS;
147#endif140#endif
148141
lib/libcxx/include/cstring+2-1
...@@ -56,11 +56,12 @@ size_t strlen(const char* s);...@@ -56,11 +56,12 @@ size_t strlen(const char* s);
5656
57*/57*/
5858
59#include <__assert> // all public C++ headers provide the assertion handler
59#include <__config>60#include <__config>
60#include <string.h>61#include <string.h>
6162
62#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)63#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
63#pragma GCC system_header64# pragma GCC system_header
64#endif65#endif
6566
66_LIBCPP_BEGIN_NAMESPACE_STD67_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/ctgmath+2-1
...@@ -18,11 +18,12 @@...@@ -18,11 +18,12 @@
1818
19*/19*/
2020
21#include <__assert> // all public C++ headers provide the assertion handler
21#include <ccomplex>22#include <ccomplex>
22#include <cmath>23#include <cmath>
2324
24#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)25#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
25#pragma GCC system_header26# pragma GCC system_header
26#endif27#endif
2728
28#endif // _LIBCPP_CTGMATH29#endif // _LIBCPP_CTGMATH
lib/libcxx/include/ctime+4-17
...@@ -45,25 +45,12 @@ int timespec_get( struct timespec *ts, int base); // C++17...@@ -45,25 +45,12 @@ int timespec_get( struct timespec *ts, int base); // C++17
4545
46*/46*/
4747
48#include <__assert> // all public C++ headers provide the assertion handler
48#include <__config>49#include <__config>
49#include <time.h>50#include <time.h>
5051
51#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)52#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
52#pragma GCC system_header53# pragma GCC system_header
53#endif
54
55// FIXME:
56// Apple SDKs don't define ::timespec_get unconditionally in C++ mode. This
57// should be fixed in future SDKs, but for the time being we need to avoid
58// trying to use that declaration when the SDK doesn't provide it. Note that
59// we're detecting this here instead of in <__config> because we can't include
60// system headers from <__config>, since it leads to circular module dependencies.
61// This is also meant to be a very temporary workaround until the SDKs are fixed.
62#if defined(__APPLE__) && !__has_attribute(using_if_exists)
63# include <sys/cdefs.h>
64# if defined(_LIBCPP_HAS_TIMESPEC_GET) && (__DARWIN_C_LEVEL < __DARWIN_C_FULL)
65# define _LIBCPP_HAS_TIMESPEC_GET_NOT_ACTUALLY_PROVIDED
66# endif
67#endif54#endif
6855
69_LIBCPP_BEGIN_NAMESPACE_STD56_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -72,7 +59,7 @@ using ::clock_t _LIBCPP_USING_IF_EXISTS;...@@ -72,7 +59,7 @@ using ::clock_t _LIBCPP_USING_IF_EXISTS;
72using ::size_t _LIBCPP_USING_IF_EXISTS;59using ::size_t _LIBCPP_USING_IF_EXISTS;
73using ::time_t _LIBCPP_USING_IF_EXISTS;60using ::time_t _LIBCPP_USING_IF_EXISTS;
74using ::tm _LIBCPP_USING_IF_EXISTS;61using ::tm _LIBCPP_USING_IF_EXISTS;
75#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_TIMESPEC_GET)62#if _LIBCPP_STD_VER > 14
76using ::timespec _LIBCPP_USING_IF_EXISTS;63using ::timespec _LIBCPP_USING_IF_EXISTS;
77#endif64#endif
78using ::clock _LIBCPP_USING_IF_EXISTS;65using ::clock _LIBCPP_USING_IF_EXISTS;
...@@ -84,7 +71,7 @@ using ::ctime _LIBCPP_USING_IF_EXISTS;...@@ -84,7 +71,7 @@ using ::ctime _LIBCPP_USING_IF_EXISTS;
84using ::gmtime _LIBCPP_USING_IF_EXISTS;71using ::gmtime _LIBCPP_USING_IF_EXISTS;
85using ::localtime _LIBCPP_USING_IF_EXISTS;72using ::localtime _LIBCPP_USING_IF_EXISTS;
86using ::strftime _LIBCPP_USING_IF_EXISTS;73using ::strftime _LIBCPP_USING_IF_EXISTS;
87#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_TIMESPEC_GET) && !defined(_LIBCPP_HAS_TIMESPEC_GET_NOT_ACTUALLY_PROVIDED)74#if _LIBCPP_STD_VER > 14
88using ::timespec_get _LIBCPP_USING_IF_EXISTS;75using ::timespec_get _LIBCPP_USING_IF_EXISTS;
89#endif76#endif
9077
lib/libcxx/include/ctype.h+1-1
...@@ -32,7 +32,7 @@ int toupper(int c);...@@ -32,7 +32,7 @@ int toupper(int c);
32#include <__config>32#include <__config>
3333
34#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)34#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
35#pragma GCC system_header35# pragma GCC system_header
36#endif36#endif
3737
38#include_next <ctype.h>38#include_next <ctype.h>
lib/libcxx/include/cuchar created+61
...@@ -0,0 +1,61 @@
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_CUCHAR
11#define _LIBCPP_CUCHAR
12
13/*
14 cuchar synopsis // since C++11
15
16Macros:
17
18 __STDC_UTF_16__
19 __STDC_UTF_32__
20
21namespace std {
22
23Types:
24
25 mbstate_t
26 size_t
27
28size_t mbrtoc16(char16_t* pc16, const char* s, size_t n, mbstate_t* ps);
29size_t c16rtomb(char* s, char16_t c16, mbstate_t* ps);
30size_t mbrtoc32(char32_t* pc32, const char* s, size_t n, mbstate_t* ps);
31size_t c32rtomb(char* s, char32_t c32, mbstate_t* ps);
32
33} // std
34
35*/
36
37#include <__assert> // all public C++ headers provide the assertion handler
38#include <__config>
39#include <uchar.h>
40
41#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
42# pragma GCC system_header
43#endif
44
45_LIBCPP_BEGIN_NAMESPACE_STD
46
47#if !defined(_LIBCPP_CXX03_LANG)
48
49using ::mbstate_t _LIBCPP_USING_IF_EXISTS;
50using ::size_t _LIBCPP_USING_IF_EXISTS;
51
52using ::mbrtoc16 _LIBCPP_USING_IF_EXISTS;
53using ::c16rtomb _LIBCPP_USING_IF_EXISTS;
54using ::mbrtoc32 _LIBCPP_USING_IF_EXISTS;
55using ::c32rtomb _LIBCPP_USING_IF_EXISTS;
56
57#endif // _LIBCPP_CXX03_LANG
58
59_LIBCPP_END_NAMESPACE_STD
60
61#endif // _LIBCPP_CUCHAR
lib/libcxx/include/cwchar+2-1
...@@ -102,12 +102,13 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len,...@@ -102,12 +102,13 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len,
102102
103*/103*/
104104
105#include <__assert> // all public C++ headers provide the assertion handler
105#include <__config>106#include <__config>
106#include <cwctype>107#include <cwctype>
107#include <wchar.h>108#include <wchar.h>
108109
109#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)110#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
110#pragma GCC system_header111# pragma GCC system_header
111#endif112#endif
112113
113_LIBCPP_BEGIN_NAMESPACE_STD114_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/cwctype+2-1
...@@ -49,12 +49,13 @@ wctrans_t wctrans(const char* property);...@@ -49,12 +49,13 @@ wctrans_t wctrans(const char* property);
4949
50*/50*/
5151
52#include <__assert> // all public C++ headers provide the assertion handler
52#include <__config>53#include <__config>
53#include <cctype>54#include <cctype>
54#include <wctype.h>55#include <wctype.h>
5556
56#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)57#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
57#pragma GCC system_header58# pragma GCC system_header
58#endif59#endif
5960
60_LIBCPP_BEGIN_NAMESPACE_STD61_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/deque+54-23
...@@ -160,22 +160,52 @@ template <class T, class Allocator, class Predicate>...@@ -160,22 +160,52 @@ template <class T, class Allocator, class Predicate>
160160
161*/161*/
162162
163#include <__algorithm/copy.h>
164#include <__algorithm/copy_backward.h>
165#include <__algorithm/equal.h>
166#include <__algorithm/fill_n.h>
167#include <__algorithm/lexicographical_compare.h>
168#include <__algorithm/min.h>
169#include <__algorithm/remove.h>
170#include <__algorithm/remove_if.h>
171#include <__algorithm/unwrap_iter.h>
172#include <__assert> // all public C++ headers provide the assertion handler
163#include <__config>173#include <__config>
164#include <__debug>174#include <__format/enable_insertable.h>
165#include <__iterator/iterator_traits.h>175#include <__iterator/iterator_traits.h>
176#include <__iterator/next.h>
177#include <__iterator/prev.h>
178#include <__iterator/reverse_iterator.h>
166#include <__split_buffer>179#include <__split_buffer>
167#include <__utility/forward.h>180#include <__utility/forward.h>
168#include <algorithm>181#include <__utility/move.h>
169#include <compare>182#include <__utility/swap.h>
170#include <initializer_list>
171#include <iterator>
172#include <limits>183#include <limits>
173#include <stdexcept>184#include <stdexcept>
174#include <type_traits>185#include <type_traits>
175#include <version>186#include <version>
176187
188#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
189# include <algorithm>
190# include <functional>
191# include <iterator>
192#endif
193
194// standard-mandated includes
195
196// [iterator.range]
197#include <__iterator/access.h>
198#include <__iterator/data.h>
199#include <__iterator/empty.h>
200#include <__iterator/reverse_access.h>
201#include <__iterator/size.h>
202
203// [deque.syn]
204#include <compare>
205#include <initializer_list>
206
177#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)207#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
178#pragma GCC system_header208# pragma GCC system_header
179#endif209#endif
180210
181_LIBCPP_PUSH_MACROS211_LIBCPP_PUSH_MACROS
...@@ -442,7 +472,7 @@ public:...@@ -442,7 +472,7 @@ public:
442 {return !(__x < __y);}472 {return !(__x < __y);}
443473
444private:474private:
445 _LIBCPP_INLINE_VISIBILITY __deque_iterator(__map_iterator __m, pointer __p) _NOEXCEPT475 _LIBCPP_INLINE_VISIBILITY explicit __deque_iterator(__map_iterator __m, pointer __p) _NOEXCEPT
446 : __m_iter_(__m), __ptr_(__p) {}476 : __m_iter_(__m), __ptr_(__p) {}
447477
448 template <class _Tp, class _Ap> friend class __deque_base;478 template <class _Tp, class _Ap> friend class __deque_base;
...@@ -1304,7 +1334,7 @@ public:...@@ -1304,7 +1334,7 @@ public:
1304 deque(_InputIter __f, _InputIter __l, const allocator_type& __a,1334 deque(_InputIter __f, _InputIter __l, const allocator_type& __a,
1305 typename enable_if<__is_cpp17_input_iterator<_InputIter>::value>::type* = 0);1335 typename enable_if<__is_cpp17_input_iterator<_InputIter>::value>::type* = 0);
1306 deque(const deque& __c);1336 deque(const deque& __c);
1307 deque(const deque& __c, const __identity_t<allocator_type>& __a);1337 deque(const deque& __c, const __type_identity_t<allocator_type>& __a);
13081338
1309 deque& operator=(const deque& __c);1339 deque& operator=(const deque& __c);
13101340
...@@ -1318,7 +1348,7 @@ public:...@@ -1318,7 +1348,7 @@ public:
1318 _LIBCPP_INLINE_VISIBILITY1348 _LIBCPP_INLINE_VISIBILITY
1319 deque(deque&& __c) _NOEXCEPT_(is_nothrow_move_constructible<__base>::value);1349 deque(deque&& __c) _NOEXCEPT_(is_nothrow_move_constructible<__base>::value);
1320 _LIBCPP_INLINE_VISIBILITY1350 _LIBCPP_INLINE_VISIBILITY
1321 deque(deque&& __c, const __identity_t<allocator_type>& __a);1351 deque(deque&& __c, const __type_identity_t<allocator_type>& __a);
1322 _LIBCPP_INLINE_VISIBILITY1352 _LIBCPP_INLINE_VISIBILITY
1323 deque& operator=(deque&& __c)1353 deque& operator=(deque&& __c)
1324 _NOEXCEPT_(__alloc_traits::propagate_on_container_move_assignment::value &&1354 _NOEXCEPT_(__alloc_traits::propagate_on_container_move_assignment::value &&
...@@ -1434,12 +1464,10 @@ public:...@@ -1434,12 +1464,10 @@ public:
1434 iterator insert(const_iterator __p, size_type __n, const value_type& __v);1464 iterator insert(const_iterator __p, size_type __n, const value_type& __v);
1435 template <class _InputIter>1465 template <class _InputIter>
1436 iterator insert(const_iterator __p, _InputIter __f, _InputIter __l,1466 iterator insert(const_iterator __p, _InputIter __f, _InputIter __l,
1437 typename enable_if<__is_cpp17_input_iterator<_InputIter>::value1467 typename enable_if<__is_exactly_cpp17_input_iterator<_InputIter>::value>::type* = 0);
1438 &&!__is_cpp17_forward_iterator<_InputIter>::value>::type* = 0);
1439 template <class _ForwardIterator>1468 template <class _ForwardIterator>
1440 iterator insert(const_iterator __p, _ForwardIterator __f, _ForwardIterator __l,1469 iterator insert(const_iterator __p, _ForwardIterator __f, _ForwardIterator __l,
1441 typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value1470 typename enable_if<__is_exactly_cpp17_forward_iterator<_ForwardIterator>::value>::type* = 0);
1442 &&!__is_cpp17_bidirectional_iterator<_ForwardIterator>::value>::type* = 0);
1443 template <class _BiIter>1471 template <class _BiIter>
1444 iterator insert(const_iterator __p, _BiIter __f, _BiIter __l,1472 iterator insert(const_iterator __p, _BiIter __f, _BiIter __l,
1445 typename enable_if<__is_cpp17_bidirectional_iterator<_BiIter>::value>::type* = 0);1473 typename enable_if<__is_cpp17_bidirectional_iterator<_BiIter>::value>::type* = 0);
...@@ -1526,8 +1554,7 @@ public:...@@ -1526,8 +1554,7 @@ public:
15261554
1527 template <class _InpIter>1555 template <class _InpIter>
1528 void __append(_InpIter __f, _InpIter __l,1556 void __append(_InpIter __f, _InpIter __l,
1529 typename enable_if<__is_cpp17_input_iterator<_InpIter>::value &&1557 typename enable_if<__is_exactly_cpp17_input_iterator<_InpIter>::value>::type* = 0);
1530 !__is_cpp17_forward_iterator<_InpIter>::value>::type* = 0);
1531 template <class _ForIter>1558 template <class _ForIter>
1532 void __append(_ForIter __f, _ForIter __l,1559 void __append(_ForIter __f, _ForIter __l,
1533 typename enable_if<__is_cpp17_forward_iterator<_ForIter>::value>::type* = 0);1560 typename enable_if<__is_cpp17_forward_iterator<_ForIter>::value>::type* = 0);
...@@ -1640,7 +1667,7 @@ deque<_Tp, _Allocator>::deque(const deque& __c)...@@ -1640,7 +1667,7 @@ deque<_Tp, _Allocator>::deque(const deque& __c)
1640}1667}
16411668
1642template <class _Tp, class _Allocator>1669template <class _Tp, class _Allocator>
1643deque<_Tp, _Allocator>::deque(const deque& __c, const __identity_t<allocator_type>& __a)1670deque<_Tp, _Allocator>::deque(const deque& __c, const __type_identity_t<allocator_type>& __a)
1644 : __base(__a)1671 : __base(__a)
1645{1672{
1646 __append(__c.begin(), __c.end());1673 __append(__c.begin(), __c.end());
...@@ -1683,7 +1710,7 @@ deque<_Tp, _Allocator>::deque(deque&& __c)...@@ -1683,7 +1710,7 @@ deque<_Tp, _Allocator>::deque(deque&& __c)
16831710
1684template <class _Tp, class _Allocator>1711template <class _Tp, class _Allocator>
1685inline1712inline
1686deque<_Tp, _Allocator>::deque(deque&& __c, const __identity_t<allocator_type>& __a)1713deque<_Tp, _Allocator>::deque(deque&& __c, const __type_identity_t<allocator_type>& __a)
1687 : __base(_VSTD::move(__c), __a)1714 : __base(_VSTD::move(__c), __a)
1688{1715{
1689 if (__a != __c.__alloc())1716 if (__a != __c.__alloc())
...@@ -2236,8 +2263,7 @@ template <class _Tp, class _Allocator>...@@ -2236,8 +2263,7 @@ template <class _Tp, class _Allocator>
2236template <class _InputIter>2263template <class _InputIter>
2237typename deque<_Tp, _Allocator>::iterator2264typename deque<_Tp, _Allocator>::iterator
2238deque<_Tp, _Allocator>::insert(const_iterator __p, _InputIter __f, _InputIter __l,2265deque<_Tp, _Allocator>::insert(const_iterator __p, _InputIter __f, _InputIter __l,
2239 typename enable_if<__is_cpp17_input_iterator<_InputIter>::value2266 typename enable_if<__is_exactly_cpp17_input_iterator<_InputIter>::value>::type*)
2240 &&!__is_cpp17_forward_iterator<_InputIter>::value>::type*)
2241{2267{
2242 __split_buffer<value_type, allocator_type&> __buf(__base::__alloc());2268 __split_buffer<value_type, allocator_type&> __buf(__base::__alloc());
2243 __buf.__construct_at_end(__f, __l);2269 __buf.__construct_at_end(__f, __l);
...@@ -2249,8 +2275,7 @@ template <class _Tp, class _Allocator>...@@ -2249,8 +2275,7 @@ template <class _Tp, class _Allocator>
2249template <class _ForwardIterator>2275template <class _ForwardIterator>
2250typename deque<_Tp, _Allocator>::iterator2276typename deque<_Tp, _Allocator>::iterator
2251deque<_Tp, _Allocator>::insert(const_iterator __p, _ForwardIterator __f, _ForwardIterator __l,2277deque<_Tp, _Allocator>::insert(const_iterator __p, _ForwardIterator __f, _ForwardIterator __l,
2252 typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value2278 typename enable_if<__is_exactly_cpp17_forward_iterator<_ForwardIterator>::value>::type*)
2253 &&!__is_cpp17_bidirectional_iterator<_ForwardIterator>::value>::type*)
2254{2279{
2255 size_type __n = _VSTD::distance(__f, __l);2280 size_type __n = _VSTD::distance(__f, __l);
2256 __split_buffer<value_type, allocator_type&> __buf(__n, 0, __base::__alloc());2281 __split_buffer<value_type, allocator_type&> __buf(__n, 0, __base::__alloc());
...@@ -2332,8 +2357,7 @@ template <class _Tp, class _Allocator>...@@ -2332,8 +2357,7 @@ template <class _Tp, class _Allocator>
2332template <class _InpIter>2357template <class _InpIter>
2333void2358void
2334deque<_Tp, _Allocator>::__append(_InpIter __f, _InpIter __l,2359deque<_Tp, _Allocator>::__append(_InpIter __f, _InpIter __l,
2335 typename enable_if<__is_cpp17_input_iterator<_InpIter>::value &&2360 typename enable_if<__is_exactly_cpp17_input_iterator<_InpIter>::value>::type*)
2336 !__is_cpp17_forward_iterator<_InpIter>::value>::type*)
2337{2361{
2338 for (; __f != __l; ++__f)2362 for (; __f != __l; ++__f)
2339#ifdef _LIBCPP_CXX03_LANG2363#ifdef _LIBCPP_CXX03_LANG
...@@ -3019,8 +3043,15 @@ erase_if(deque<_Tp, _Allocator>& __c, _Predicate __pred) {...@@ -3019,8 +3043,15 @@ erase_if(deque<_Tp, _Allocator>& __c, _Predicate __pred) {
3019 __c.erase(_VSTD::remove_if(__c.begin(), __c.end(), __pred), __c.end());3043 __c.erase(_VSTD::remove_if(__c.begin(), __c.end(), __pred), __c.end());
3020 return __old_size - __c.size();3044 return __old_size - __c.size();
3021}3045}
3046
3047template <>
3048inline constexpr bool __format::__enable_insertable<std::deque<char>> = true;
3049#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
3050template <>
3051inline constexpr bool __format::__enable_insertable<std::deque<wchar_t>> = true;
3022#endif3052#endif
30233053
3054#endif // _LIBCPP_STD_VER > 17
30243055
3025_LIBCPP_END_NAMESPACE_STD3056_LIBCPP_END_NAMESPACE_STD
30263057
lib/libcxx/include/errno.h+1-1
...@@ -25,7 +25,7 @@ Macros:...@@ -25,7 +25,7 @@ Macros:
25#include <__config>25#include <__config>
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
29#endif29#endif
3030
31#include_next <errno.h>31#include_next <errno.h>
lib/libcxx/include/exception+10-13
...@@ -76,6 +76,7 @@ template <class E> void rethrow_if_nested(const E& e);...@@ -76,6 +76,7 @@ template <class E> void rethrow_if_nested(const E& e);
7676
77*/77*/
7878
79#include <__assert> // all public C++ headers provide the assertion handler
79#include <__availability>80#include <__availability>
80#include <__config>81#include <__config>
81#include <__memory/addressof.h>82#include <__memory/addressof.h>
...@@ -89,7 +90,7 @@ template <class E> void rethrow_if_nested(const E& e);...@@ -89,7 +90,7 @@ template <class E> void rethrow_if_nested(const E& e);
89#endif90#endif
9091
91#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)92#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
92#pragma GCC system_header93# pragma GCC system_header
93#endif94#endif
9495
95namespace std // purposefully not using versioning namespace96namespace std // purposefully not using versioning namespace
...@@ -189,15 +190,11 @@ make_exception_ptr(_Ep __e) _NOEXCEPT...@@ -189,15 +190,11 @@ make_exception_ptr(_Ep __e) _NOEXCEPT
189190
190class _LIBCPP_TYPE_VIS exception_ptr191class _LIBCPP_TYPE_VIS exception_ptr
191{192{
192#if defined(__clang__)193_LIBCPP_DIAGNOSTIC_PUSH
193#pragma clang diagnostic push194_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wunused-private-field")
194#pragma clang diagnostic ignored "-Wunused-private-field"
195#endif
196 void* __ptr1_;195 void* __ptr1_;
197 void* __ptr2_;196 void* __ptr2_;
198#if defined(__clang__)197_LIBCPP_DIAGNOSTIC_POP
199#pragma clang diagnostic pop
200#endif
201public:198public:
202 exception_ptr() _NOEXCEPT;199 exception_ptr() _NOEXCEPT;
203 exception_ptr(nullptr_t) _NOEXCEPT;200 exception_ptr(nullptr_t) _NOEXCEPT;
...@@ -219,7 +216,7 @@ _LIBCPP_FUNC_VIS void swap(exception_ptr&, exception_ptr&) _NOEXCEPT;...@@ -219,7 +216,7 @@ _LIBCPP_FUNC_VIS void swap(exception_ptr&, exception_ptr&) _NOEXCEPT;
219216
220_LIBCPP_FUNC_VIS exception_ptr __copy_exception_ptr(void *__except, const void* __ptr);217_LIBCPP_FUNC_VIS exception_ptr __copy_exception_ptr(void *__except, const void* __ptr);
221_LIBCPP_FUNC_VIS exception_ptr current_exception() _NOEXCEPT;218_LIBCPP_FUNC_VIS exception_ptr current_exception() _NOEXCEPT;
222_LIBCPP_NORETURN _LIBCPP_FUNC_VIS void rethrow_exception(exception_ptr p);219_LIBCPP_NORETURN _LIBCPP_FUNC_VIS void rethrow_exception(exception_ptr);
223220
224// This is a built-in template function which automagically extracts the required221// This is a built-in template function which automagically extracts the required
225// information.222// information.
...@@ -304,16 +301,16 @@ throw_with_nested(_Tp&& __t)...@@ -304,16 +301,16 @@ throw_with_nested(_Tp&& __t)
304}301}
305302
306template <class _From, class _To>303template <class _From, class _To>
307struct __can_dynamic_cast : public _LIBCPP_BOOL_CONSTANT(304struct __can_dynamic_cast : _BoolConstant<
308 is_polymorphic<_From>::value &&305 is_polymorphic<_From>::value &&
309 (!is_base_of<_To, _From>::value ||306 (!is_base_of<_To, _From>::value ||
310 is_convertible<const _From*, const _To*>::value)) {};307 is_convertible<const _From*, const _To*>::value)> {};
311308
312template <class _Ep>309template <class _Ep>
313inline _LIBCPP_INLINE_VISIBILITY310inline _LIBCPP_INLINE_VISIBILITY
314void311void
315rethrow_if_nested(const _Ep& __e,312rethrow_if_nested(const _Ep& __e,
316 typename enable_if< __can_dynamic_cast<_Ep, nested_exception>::value>::type* = 0)313 __enable_if_t< __can_dynamic_cast<_Ep, nested_exception>::value>* = 0)
317{314{
318 const nested_exception* __nep = dynamic_cast<const nested_exception*>(_VSTD::addressof(__e));315 const nested_exception* __nep = dynamic_cast<const nested_exception*>(_VSTD::addressof(__e));
319 if (__nep)316 if (__nep)
...@@ -324,7 +321,7 @@ template <class _Ep>...@@ -324,7 +321,7 @@ template <class _Ep>
324inline _LIBCPP_INLINE_VISIBILITY321inline _LIBCPP_INLINE_VISIBILITY
325void322void
326rethrow_if_nested(const _Ep&,323rethrow_if_nested(const _Ep&,
327 typename enable_if<!__can_dynamic_cast<_Ep, nested_exception>::value>::type* = 0)324 __enable_if_t<!__can_dynamic_cast<_Ep, nested_exception>::value>* = 0)
328{325{
329}326}
330327
lib/libcxx/include/execution+2-1
...@@ -10,6 +10,7 @@...@@ -10,6 +10,7 @@
10#ifndef _LIBCPP_EXECUTION10#ifndef _LIBCPP_EXECUTION
11#define _LIBCPP_EXECUTION11#define _LIBCPP_EXECUTION
1212
13#include <__assert> // all public C++ headers provide the assertion handler
13#include <__config>14#include <__config>
14#include <version>15#include <version>
1516
...@@ -18,7 +19,7 @@...@@ -18,7 +19,7 @@
18#endif19#endif
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
22#endif23#endif
2324
24#endif // _LIBCPP_EXECUTION25#endif // _LIBCPP_EXECUTION
lib/libcxx/include/experimental/__config+1-14
...@@ -13,7 +13,7 @@...@@ -13,7 +13,7 @@
13#include <__config>13#include <__config>
1414
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16#pragma GCC system_header16# pragma GCC system_header
17#endif17#endif
1818
19#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL namespace std { namespace experimental {19#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL namespace std { namespace experimental {
...@@ -32,19 +32,6 @@...@@ -32,19 +32,6 @@
32#define _LIBCPP_END_NAMESPACE_LFTS_PMR _LIBCPP_END_NAMESPACE_LFTS }32#define _LIBCPP_END_NAMESPACE_LFTS_PMR _LIBCPP_END_NAMESPACE_LFTS }
33#define _VSTD_LFTS_PMR _VSTD_LFTS::pmr33#define _VSTD_LFTS_PMR _VSTD_LFTS::pmr
3434
35#if defined(_LIBCPP_NO_EXPERIMENTAL_DEPRECATION_WARNING_FILESYSTEM)
36# define _LIBCPP_DEPRECATED_EXPERIMENTAL_FILESYSTEM /* nothing */
37#else
38# define _LIBCPP_DEPRECATED_EXPERIMENTAL_FILESYSTEM __attribute__((deprecated("std::experimental::filesystem has now been deprecated in favor of C++17's std::filesystem. Please stop using it and start using std::filesystem. This experimental version will be removed in LLVM 11. You can remove this warning by defining the _LIBCPP_NO_EXPERIMENTAL_DEPRECATION_WARNING_FILESYSTEM macro.")))
39#endif
40
41#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_FILESYSTEM \
42 _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL namespace filesystem _LIBCPP_DEPRECATED_EXPERIMENTAL_FILESYSTEM { \
43 inline namespace v1 {
44
45#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL_FILESYSTEM \
46 } } _LIBCPP_END_NAMESPACE_EXPERIMENTAL
47
48#if !defined(__cpp_coroutines) || __cpp_coroutines < 201703L35#if !defined(__cpp_coroutines) || __cpp_coroutines < 201703L
49#define _LIBCPP_HAS_NO_EXPERIMENTAL_COROUTINES36#define _LIBCPP_HAS_NO_EXPERIMENTAL_COROUTINES
50#endif37#endif
lib/libcxx/include/experimental/__memory+1-2
...@@ -10,7 +10,6 @@...@@ -10,7 +10,6 @@
10#ifndef _LIBCPP_EXPERIMENTAL___MEMORY10#ifndef _LIBCPP_EXPERIMENTAL___MEMORY
11#define _LIBCPP_EXPERIMENTAL___MEMORY11#define _LIBCPP_EXPERIMENTAL___MEMORY
1212
13#include <__functional_base>
14#include <__memory/allocator_arg_t.h>13#include <__memory/allocator_arg_t.h>
15#include <__memory/uses_allocator.h>14#include <__memory/uses_allocator.h>
16#include <experimental/__config>15#include <experimental/__config>
...@@ -18,7 +17,7 @@...@@ -18,7 +17,7 @@
18#include <type_traits>17#include <type_traits>
1918
20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
21#pragma GCC system_header20# pragma GCC system_header
22#endif21#endif
2322
24_LIBCPP_BEGIN_NAMESPACE_LFTS23_LIBCPP_BEGIN_NAMESPACE_LFTS
lib/libcxx/include/experimental/algorithm+2-1
...@@ -31,13 +31,14 @@ ForwardIterator search(ForwardIterator first, ForwardIterator last,...@@ -31,13 +31,14 @@ ForwardIterator search(ForwardIterator first, ForwardIterator last,
3131
32*/32*/
3333
34#include <__assert> // all public C++ headers provide the assertion handler
34#include <__debug>35#include <__debug>
35#include <algorithm>36#include <algorithm>
36#include <experimental/__config>37#include <experimental/__config>
37#include <type_traits>38#include <type_traits>
3839
39#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)40#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
40#pragma GCC system_header41# pragma GCC system_header
41#endif42#endif
4243
43_LIBCPP_BEGIN_NAMESPACE_LFTS44_LIBCPP_BEGIN_NAMESPACE_LFTS
lib/libcxx/include/experimental/coroutine+4-11
...@@ -45,24 +45,17 @@ template <class P> struct hash<coroutine_handle<P>>;...@@ -45,24 +45,17 @@ template <class P> struct hash<coroutine_handle<P>>;
4545
46 */46 */
4747
48#include <__debug>48#include <__assert> // all public C++ headers provide the assertion handler
49#include <__functional/hash.h>
50#include <__functional/operations.h>
49#include <cstddef>51#include <cstddef>
50#include <experimental/__config>52#include <experimental/__config>
51#include <functional>
52#include <memory> // for hash<T*>53#include <memory> // for hash<T*>
53#include <new>54#include <new>
54#include <type_traits>55#include <type_traits>
5556
56#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)57#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
57#pragma GCC system_header58# pragma GCC system_header
58#endif
59
60#ifdef _LIBCPP_HAS_NO_EXPERIMENTAL_COROUTINES
61# if defined(_LIBCPP_WARNING)
62 _LIBCPP_WARNING("<experimental/coroutine> cannot be used with this compiler")
63# else
64# warning <experimental/coroutine> cannot be used with this compiler
65# endif
66#endif59#endif
6760
68#ifndef _LIBCPP_HAS_NO_EXPERIMENTAL_COROUTINES61#ifndef _LIBCPP_HAS_NO_EXPERIMENTAL_COROUTINES
lib/libcxx/include/experimental/deque+3-1
...@@ -9,6 +9,7 @@...@@ -9,6 +9,7 @@
99
10#ifndef _LIBCPP_EXPERIMENTAL_DEQUE10#ifndef _LIBCPP_EXPERIMENTAL_DEQUE
11#define _LIBCPP_EXPERIMENTAL_DEQUE11#define _LIBCPP_EXPERIMENTAL_DEQUE
12
12/*13/*
13 experimental/deque synopsis14 experimental/deque synopsis
1415
...@@ -28,12 +29,13 @@ namespace pmr {...@@ -28,12 +29,13 @@ namespace pmr {
2829
29 */30 */
3031
32#include <__assert> // all public C++ headers provide the assertion handler
31#include <deque>33#include <deque>
32#include <experimental/__config>34#include <experimental/__config>
33#include <experimental/memory_resource>35#include <experimental/memory_resource>
3436
35#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)37#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
36#pragma GCC system_header38# pragma GCC system_header
37#endif39#endif
3840
39_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR41_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
lib/libcxx/include/experimental/filesystem deleted-256
...@@ -1,256 +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#ifndef _LIBCPP_EXPERIMENTAL_FILESYSTEM
10#define _LIBCPP_EXPERIMENTAL_FILESYSTEM
11/*
12 filesystem synopsis
13
14 namespace std { namespace experimental { namespace filesystem { inline namespace v1 {
15
16 class path;
17
18 void swap(path& lhs, path& rhs) noexcept;
19 size_t hash_value(const path& p) noexcept;
20
21 bool operator==(const path& lhs, const path& rhs) noexcept;
22 bool operator!=(const path& lhs, const path& rhs) noexcept;
23 bool operator< (const path& lhs, const path& rhs) noexcept;
24 bool operator<=(const path& lhs, const path& rhs) noexcept;
25 bool operator> (const path& lhs, const path& rhs) noexcept;
26 bool operator>=(const path& lhs, const path& rhs) noexcept;
27
28 path operator/ (const path& lhs, const path& rhs);
29
30 // fs.path.io operators are friends of path.
31 template <class charT, class traits>
32 friend basic_ostream<charT, traits>&
33 operator<<(basic_ostream<charT, traits>& os, const path& p);
34
35 template <class charT, class traits>
36 friend basic_istream<charT, traits>&
37 operator>>(basic_istream<charT, traits>& is, path& p);
38
39 template <class Source>
40 path u8path(const Source& source);
41 template <class InputIterator>
42 path u8path(InputIterator first, InputIterator last);
43
44 class filesystem_error;
45 class directory_entry;
46
47 class directory_iterator;
48
49 // enable directory_iterator range-based for statements
50 directory_iterator begin(directory_iterator iter) noexcept;
51 directory_iterator end(const directory_iterator&) noexcept;
52
53 class recursive_directory_iterator;
54
55 // enable recursive_directory_iterator range-based for statements
56 recursive_directory_iterator begin(recursive_directory_iterator iter) noexcept;
57 recursive_directory_iterator end(const recursive_directory_iterator&) noexcept;
58
59 class file_status;
60
61 struct space_info
62 {
63 uintmax_t capacity;
64 uintmax_t free;
65 uintmax_t available;
66 };
67
68 enum class file_type;
69 enum class perms;
70 enum class perm_options;
71 enum class copy_options;
72 enum class directory_options;
73
74 typedef chrono::time_point<trivial-clock> file_time_type;
75
76 // operational functions
77
78 path absolute(const path& p);
79 path absolute(const path& p, error_code &ec);
80
81 path canonical(const path& p);
82 path canonical(const path& p, error_code& ec);
83
84 void copy(const path& from, const path& to);
85 void copy(const path& from, const path& to, error_code& ec);
86 void copy(const path& from, const path& to, copy_options options);
87 void copy(const path& from, const path& to, copy_options options,
88 error_code& ec);
89
90 bool copy_file(const path& from, const path& to);
91 bool copy_file(const path& from, const path& to, error_code& ec);
92 bool copy_file(const path& from, const path& to, copy_options option);
93 bool copy_file(const path& from, const path& to, copy_options option,
94 error_code& ec);
95
96 void copy_symlink(const path& existing_symlink, const path& new_symlink);
97 void copy_symlink(const path& existing_symlink, const path& new_symlink,
98 error_code& ec) noexcept;
99
100 bool create_directories(const path& p);
101 bool create_directories(const path& p, error_code& ec);
102
103 bool create_directory(const path& p);
104 bool create_directory(const path& p, error_code& ec) noexcept;
105
106 bool create_directory(const path& p, const path& attributes);
107 bool create_directory(const path& p, const path& attributes,
108 error_code& ec) noexcept;
109
110 void create_directory_symlink(const path& to, const path& new_symlink);
111 void create_directory_symlink(const path& to, const path& new_symlink,
112 error_code& ec) noexcept;
113
114 void create_hard_link(const path& to, const path& new_hard_link);
115 void create_hard_link(const path& to, const path& new_hard_link,
116 error_code& ec) noexcept;
117
118 void create_symlink(const path& to, const path& new_symlink);
119 void create_symlink(const path& to, const path& new_symlink,
120 error_code& ec) noexcept;
121
122 path current_path();
123 path current_path(error_code& ec);
124 void current_path(const path& p);
125 void current_path(const path& p, error_code& ec) noexcept;
126
127 bool exists(file_status s) noexcept;
128 bool exists(const path& p);
129 bool exists(const path& p, error_code& ec) noexcept;
130
131 bool equivalent(const path& p1, const path& p2);
132 bool equivalent(const path& p1, const path& p2, error_code& ec) noexcept;
133
134 uintmax_t file_size(const path& p);
135 uintmax_t file_size(const path& p, error_code& ec) noexcept;
136
137 uintmax_t hard_link_count(const path& p);
138 uintmax_t hard_link_count(const path& p, error_code& ec) noexcept;
139
140 bool is_block_file(file_status s) noexcept;
141 bool is_block_file(const path& p);
142 bool is_block_file(const path& p, error_code& ec) noexcept;
143
144 bool is_character_file(file_status s) noexcept;
145 bool is_character_file(const path& p);
146 bool is_character_file(const path& p, error_code& ec) noexcept;
147
148 bool is_directory(file_status s) noexcept;
149 bool is_directory(const path& p);
150 bool is_directory(const path& p, error_code& ec) noexcept;
151
152 bool is_empty(const path& p);
153 bool is_empty(const path& p, error_code& ec) noexcept;
154
155 bool is_fifo(file_status s) noexcept;
156 bool is_fifo(const path& p);
157 bool is_fifo(const path& p, error_code& ec) noexcept;
158
159 bool is_other(file_status s) noexcept;
160 bool is_other(const path& p);
161 bool is_other(const path& p, error_code& ec) noexcept;
162
163 bool is_regular_file(file_status s) noexcept;
164 bool is_regular_file(const path& p);
165 bool is_regular_file(const path& p, error_code& ec) noexcept;
166
167 bool is_socket(file_status s) noexcept;
168 bool is_socket(const path& p);
169 bool is_socket(const path& p, error_code& ec) noexcept;
170
171 bool is_symlink(file_status s) noexcept;
172 bool is_symlink(const path& p);
173 bool is_symlink(const path& p, error_code& ec) noexcept;
174
175 file_time_type last_write_time(const path& p);
176 file_time_type last_write_time(const path& p, error_code& ec) noexcept;
177 void last_write_time(const path& p, file_time_type new_time);
178 void last_write_time(const path& p, file_time_type new_time,
179 error_code& ec) noexcept;
180
181 void permissions(const path& p, perms prms,
182 perm_options opts=perm_options::replace);
183 void permissions(const path& p, perms prms, error_code& ec) noexcept;
184 void permissions(const path& p, perms prms, perm_options opts,
185 error_code& ec);
186
187 path proximate(const path& p, error_code& ec);
188 path proximate(const path& p, const path& base = current_path());
189 path proximate(const path& p, const path& base, error_code &ec);
190
191 path read_symlink(const path& p);
192 path read_symlink(const path& p, error_code& ec);
193
194 path relative(const path& p, error_code& ec);
195 path relative(const path& p, const path& base=current_path());
196 path relative(const path& p, const path& base, error_code& ec);
197
198 bool remove(const path& p);
199 bool remove(const path& p, error_code& ec) noexcept;
200
201 uintmax_t remove_all(const path& p);
202 uintmax_t remove_all(const path& p, error_code& ec);
203
204 void rename(const path& from, const path& to);
205 void rename(const path& from, const path& to, error_code& ec) noexcept;
206
207 void resize_file(const path& p, uintmax_t size);
208 void resize_file(const path& p, uintmax_t size, error_code& ec) noexcept;
209
210 space_info space(const path& p);
211 space_info space(const path& p, error_code& ec) noexcept;
212
213 file_status status(const path& p);
214 file_status status(const path& p, error_code& ec) noexcept;
215
216 bool status_known(file_status s) noexcept;
217
218 file_status symlink_status(const path& p);
219 file_status symlink_status(const path& p, error_code& ec) noexcept;
220
221 path temp_directory_path();
222 path temp_directory_path(error_code& ec);
223
224 path weakly_canonical(path const& p);
225 path weakly_canonical(path const& p, error_code& ec);
226
227
228} } } } // namespaces std::experimental::filesystem::v1
229
230*/
231
232#include <experimental/__config>
233#include <filesystem>
234
235#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
236#pragma GCC system_header
237#endif
238
239_LIBCPP_PUSH_MACROS
240#include <__undef_macros>
241
242#ifndef _LIBCPP_CXX03_LANG
243
244#define __cpp_lib_experimental_filesystem 201406
245
246_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_FILESYSTEM
247
248using namespace _VSTD_FS;
249
250_LIBCPP_END_NAMESPACE_EXPERIMENTAL_FILESYSTEM
251
252#endif // !_LIBCPP_CXX03_LANG
253
254_LIBCPP_POP_MACROS
255
256#endif // _LIBCPP_EXPERIMENTAL_FILESYSTEM
lib/libcxx/include/experimental/forward_list+3-1
...@@ -9,6 +9,7 @@...@@ -9,6 +9,7 @@
99
10#ifndef _LIBCPP_EXPERIMENTAL_FORWARD_LIST10#ifndef _LIBCPP_EXPERIMENTAL_FORWARD_LIST
11#define _LIBCPP_EXPERIMENTAL_FORWARD_LIST11#define _LIBCPP_EXPERIMENTAL_FORWARD_LIST
12
12/*13/*
13 experimental/forward_list synopsis14 experimental/forward_list synopsis
1415
...@@ -28,12 +29,13 @@ namespace pmr {...@@ -28,12 +29,13 @@ namespace pmr {
2829
29 */30 */
3031
32#include <__assert> // all public C++ headers provide the assertion handler
31#include <experimental/__config>33#include <experimental/__config>
32#include <experimental/memory_resource>34#include <experimental/memory_resource>
33#include <forward_list>35#include <forward_list>
3436
35#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)37#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
36#pragma GCC system_header38# pragma GCC system_header
37#endif39#endif
3840
39_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR41_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
lib/libcxx/include/experimental/functional+30-51
...@@ -18,29 +18,6 @@...@@ -18,29 +18,6 @@
18namespace std {18namespace std {
19namespace experimental {19namespace experimental {
20inline namespace fundamentals_v1 {20inline namespace fundamentals_v1 {
21
22 // See C++14 20.9.9, Function object binders
23 template <class T> constexpr bool is_bind_expression_v
24 = is_bind_expression<T>::value;
25 template <class T> constexpr int is_placeholder_v
26 = is_placeholder<T>::value;
27
28 // 4.2, Class template function
29 template<class> class function; // undefined
30 template<class R, class... ArgTypes> class function<R(ArgTypes...)>;
31
32 template<class R, class... ArgTypes>
33 void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&);
34
35 template<class R, class... ArgTypes>
36 bool operator==(const function<R(ArgTypes...)>&, nullptr_t) noexcept;
37 template<class R, class... ArgTypes>
38 bool operator==(nullptr_t, const function<R(ArgTypes...)>&) noexcept;
39 template<class R, class... ArgTypes>
40 bool operator!=(const function<R(ArgTypes...)>&, nullptr_t) noexcept;
41 template<class R, class... ArgTypes>
42 bool operator!=(nullptr_t, const function<R(ArgTypes...)>&) noexcept;
43
44 // 4.3, Searchers21 // 4.3, Searchers
45 template<class ForwardIterator, class BinaryPredicate = equal_to<>>22 template<class ForwardIterator, class BinaryPredicate = equal_to<>>
46 class default_searcher;23 class default_searcher;
...@@ -79,16 +56,14 @@ inline namespace fundamentals_v1 {...@@ -79,16 +56,14 @@ inline namespace fundamentals_v1 {
79 } // namespace fundamentals_v156 } // namespace fundamentals_v1
80 } // namespace experimental57 } // namespace experimental
8158
82 template<class R, class... ArgTypes, class Alloc>
83 struct uses_allocator<experimental::function<R(ArgTypes...)>, Alloc>;
84
85} // namespace std59} // namespace std
8660
87*/61*/
8862
63#include <__assert> // all public C++ headers provide the assertion handler
89#include <__debug>64#include <__debug>
65#include <__functional/identity.h>
90#include <__memory/uses_allocator.h>66#include <__memory/uses_allocator.h>
91#include <algorithm>
92#include <array>67#include <array>
93#include <experimental/__config>68#include <experimental/__config>
94#include <functional>69#include <functional>
...@@ -97,7 +72,7 @@ inline namespace fundamentals_v1 {...@@ -97,7 +72,7 @@ inline namespace fundamentals_v1 {
97#include <vector>72#include <vector>
9873
99#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)74#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
100#pragma GCC system_header75# pragma GCC system_header
101#endif76#endif
10277
103_LIBCPP_PUSH_MACROS78_LIBCPP_PUSH_MACROS
...@@ -105,10 +80,20 @@ _LIBCPP_PUSH_MACROS...@@ -105,10 +80,20 @@ _LIBCPP_PUSH_MACROS
10580
106_LIBCPP_BEGIN_NAMESPACE_LFTS81_LIBCPP_BEGIN_NAMESPACE_LFTS
10782
83#ifdef _LIBCPP_NO_EXPERIMENTAL_DEPRECATION_WARNING_SEARCHERS
84# define _LIBCPP_DEPRECATED_DEFAULT_SEARCHER
85# define _LIBCPP_DEPRECATED_BOYER_MOORE_SEARCHER
86# define _LIBCPP_DEPRECATED_BOYER_MOORE_HORSPOOL_SEARCHER
87#else
88# define _LIBCPP_DEPRECATED_DEFAULT_SEARCHER _LIBCPP_DEPRECATED_("std::exprerimental::default_searcher will be removed in LLVM 17. Use std::default_searcher instead")
89# define _LIBCPP_DEPRECATED_BOYER_MOORE_SEARCHER _LIBCPP_DEPRECATED_("std::exprerimental::boyer_moore_searcher will be removed in LLVM 17. Use std::boyer_moore_searcher instead")
90# define _LIBCPP_DEPRECATED_BOYER_MOORE_HORSPOOL_SEARCHER _LIBCPP_DEPRECATED_("std::exprerimental::boyer_moore_horspool_searcher will be removed in LLVM 17. Use std::boyer_moore_horspool_searcher instead")
91#endif
92
108#if _LIBCPP_STD_VER > 1193#if _LIBCPP_STD_VER > 11
109// default searcher94// default searcher
110template<class _ForwardIterator, class _BinaryPredicate = equal_to<>>95template<class _ForwardIterator, class _BinaryPredicate = equal_to<>>
111class _LIBCPP_TEMPLATE_VIS default_searcher {96class _LIBCPP_DEPRECATED_DEFAULT_SEARCHER _LIBCPP_TEMPLATE_VIS default_searcher {
112public:97public:
113 _LIBCPP_INLINE_VISIBILITY98 _LIBCPP_INLINE_VISIBILITY
114 default_searcher(_ForwardIterator __f, _ForwardIterator __l,99 default_searcher(_ForwardIterator __f, _ForwardIterator __l,
...@@ -120,9 +105,8 @@ public:...@@ -120,9 +105,8 @@ public:
120 pair<_ForwardIterator2, _ForwardIterator2>105 pair<_ForwardIterator2, _ForwardIterator2>
121 operator () (_ForwardIterator2 __f, _ForwardIterator2 __l) const106 operator () (_ForwardIterator2 __f, _ForwardIterator2 __l) const
122 {107 {
123 return _VSTD::__search(__f, __l, __first_, __last_, __pred_,108 auto __proj = __identity();
124 typename iterator_traits<_ForwardIterator>::iterator_category(),109 return std::__search_impl(__f, __l, __first_, __last_, __pred_, __proj, __proj);
125 typename iterator_traits<_ForwardIterator2>::iterator_category());
126 }110 }
127111
128private:112private:
...@@ -132,7 +116,7 @@ private:...@@ -132,7 +116,7 @@ private:
132 };116 };
133117
134template<class _ForwardIterator, class _BinaryPredicate = equal_to<>>118template<class _ForwardIterator, class _BinaryPredicate = equal_to<>>
135_LIBCPP_INLINE_VISIBILITY119_LIBCPP_DEPRECATED_DEFAULT_SEARCHER _LIBCPP_INLINE_VISIBILITY
136default_searcher<_ForwardIterator, _BinaryPredicate>120default_searcher<_ForwardIterator, _BinaryPredicate>
137make_default_searcher( _ForwardIterator __f, _ForwardIterator __l, _BinaryPredicate __p = _BinaryPredicate ())121make_default_searcher( _ForwardIterator __f, _ForwardIterator __l, _BinaryPredicate __p = _BinaryPredicate ())
138{122{
...@@ -144,7 +128,6 @@ template<class _Key, class _Value, class _Hash, class _BinaryPredicate, bool /*u...@@ -144,7 +128,6 @@ template<class _Key, class _Value, class _Hash, class _BinaryPredicate, bool /*u
144// General case for BM data searching; use a map128// General case for BM data searching; use a map
145template<class _Key, typename _Value, class _Hash, class _BinaryPredicate>129template<class _Key, typename _Value, class _Hash, class _BinaryPredicate>
146class _BMSkipTable<_Key, _Value, _Hash, _BinaryPredicate, false> {130class _BMSkipTable<_Key, _Value, _Hash, _BinaryPredicate, false> {
147public: // TODO private:
148 typedef _Value value_type;131 typedef _Value value_type;
149 typedef _Key key_type;132 typedef _Key key_type;
150133
...@@ -179,7 +162,7 @@ private:...@@ -179,7 +162,7 @@ private:
179 typedef _Key key_type;162 typedef _Key key_type;
180163
181 typedef typename make_unsigned<key_type>::type unsigned_key_type;164 typedef typename make_unsigned<key_type>::type unsigned_key_type;
182 typedef std::array<value_type, numeric_limits<unsigned_key_type>::max()> skip_map;165 typedef std::array<value_type, 256> skip_map;
183 skip_map __table;166 skip_map __table;
184167
185public:168public:
...@@ -206,7 +189,7 @@ public:...@@ -206,7 +189,7 @@ public:
206template <class _RandomAccessIterator1,189template <class _RandomAccessIterator1,
207 class _Hash = hash<typename iterator_traits<_RandomAccessIterator1>::value_type>,190 class _Hash = hash<typename iterator_traits<_RandomAccessIterator1>::value_type>,
208 class _BinaryPredicate = equal_to<>>191 class _BinaryPredicate = equal_to<>>
209class _LIBCPP_TEMPLATE_VIS boyer_moore_searcher {192class _LIBCPP_DEPRECATED_BOYER_MOORE_SEARCHER _LIBCPP_TEMPLATE_VIS boyer_moore_searcher {
210private:193private:
211 typedef typename std::iterator_traits<_RandomAccessIterator1>::difference_type difference_type;194 typedef typename std::iterator_traits<_RandomAccessIterator1>::difference_type difference_type;
212 typedef typename std::iterator_traits<_RandomAccessIterator1>::value_type value_type;195 typedef typename std::iterator_traits<_RandomAccessIterator1>::value_type value_type;
...@@ -236,11 +219,9 @@ public:...@@ -236,11 +219,9 @@ public:
236 pair<_RandomAccessIterator2, _RandomAccessIterator2>219 pair<_RandomAccessIterator2, _RandomAccessIterator2>
237 operator ()(_RandomAccessIterator2 __f, _RandomAccessIterator2 __l) const220 operator ()(_RandomAccessIterator2 __f, _RandomAccessIterator2 __l) const
238 {221 {
239 static_assert ( std::is_same<222 static_assert(__is_same_uncvref<typename iterator_traits<_RandomAccessIterator1>::value_type,
240 typename std::__uncvref<typename std::iterator_traits<_RandomAccessIterator1>::value_type>::type,223 typename iterator_traits<_RandomAccessIterator2>::value_type>::value,
241 typename std::__uncvref<typename std::iterator_traits<_RandomAccessIterator2>::value_type>::type224 "Corpus and Pattern iterators must point to the same type");
242 >::value,
243 "Corpus and Pattern iterators must point to the same type" );
244225
245 if (__f == __l ) return make_pair(__l, __l); // empty corpus226 if (__f == __l ) return make_pair(__l, __l); // empty corpus
246 if (__first_ == __last_) return make_pair(__f, __f); // empty pattern227 if (__first_ == __last_) return make_pair(__f, __f); // empty pattern
...@@ -253,7 +234,7 @@ public:...@@ -253,7 +234,7 @@ public:
253 return this->__search(__f, __l);234 return this->__search(__f, __l);
254 }235 }
255236
256public: // TODO private:237private:
257 _RandomAccessIterator1 __first_;238 _RandomAccessIterator1 __first_;
258 _RandomAccessIterator1 __last_;239 _RandomAccessIterator1 __last_;
259 _BinaryPredicate __pred_;240 _BinaryPredicate __pred_;
...@@ -320,7 +301,7 @@ public: // TODO private:...@@ -320,7 +301,7 @@ public: // TODO private:
320 vector<difference_type> & __suffix = *__suffix_.get();301 vector<difference_type> & __suffix = *__suffix_.get();
321 if (__count > 0)302 if (__count > 0)
322 {303 {
323 vector<value_type> __scratch(__count);304 vector<difference_type> __scratch(__count);
324305
325 __compute_bm_prefix(__f, __l, __pred, __scratch);306 __compute_bm_prefix(__f, __l, __pred, __scratch);
326 for ( size_t __i = 0; __i <= __count; __i++ )307 for ( size_t __i = 0; __i <= __count; __i++ )
...@@ -345,7 +326,7 @@ public: // TODO private:...@@ -345,7 +326,7 @@ public: // TODO private:
345template<class _RandomAccessIterator,326template<class _RandomAccessIterator,
346 class _Hash = hash<typename iterator_traits<_RandomAccessIterator>::value_type>,327 class _Hash = hash<typename iterator_traits<_RandomAccessIterator>::value_type>,
347 class _BinaryPredicate = equal_to<>>328 class _BinaryPredicate = equal_to<>>
348_LIBCPP_INLINE_VISIBILITY329_LIBCPP_DEPRECATED_BOYER_MOORE_SEARCHER _LIBCPP_INLINE_VISIBILITY
349boyer_moore_searcher<_RandomAccessIterator, _Hash, _BinaryPredicate>330boyer_moore_searcher<_RandomAccessIterator, _Hash, _BinaryPredicate>
350make_boyer_moore_searcher( _RandomAccessIterator __f, _RandomAccessIterator __l,331make_boyer_moore_searcher( _RandomAccessIterator __f, _RandomAccessIterator __l,
351 _Hash __hf = _Hash(), _BinaryPredicate __p = _BinaryPredicate ())332 _Hash __hf = _Hash(), _BinaryPredicate __p = _BinaryPredicate ())
...@@ -357,7 +338,7 @@ make_boyer_moore_searcher( _RandomAccessIterator __f, _RandomAccessIterator __l,...@@ -357,7 +338,7 @@ make_boyer_moore_searcher( _RandomAccessIterator __f, _RandomAccessIterator __l,
357template <class _RandomAccessIterator1,338template <class _RandomAccessIterator1,
358 class _Hash = hash<typename iterator_traits<_RandomAccessIterator1>::value_type>,339 class _Hash = hash<typename iterator_traits<_RandomAccessIterator1>::value_type>,
359 class _BinaryPredicate = equal_to<>>340 class _BinaryPredicate = equal_to<>>
360class _LIBCPP_TEMPLATE_VIS boyer_moore_horspool_searcher {341class _LIBCPP_DEPRECATED_BOYER_MOORE_HORSPOOL_SEARCHER _LIBCPP_TEMPLATE_VIS boyer_moore_horspool_searcher {
361private:342private:
362 typedef typename std::iterator_traits<_RandomAccessIterator1>::difference_type difference_type;343 typedef typename std::iterator_traits<_RandomAccessIterator1>::difference_type difference_type;
363 typedef typename std::iterator_traits<_RandomAccessIterator1>::value_type value_type;344 typedef typename std::iterator_traits<_RandomAccessIterator1>::value_type value_type;
...@@ -388,11 +369,9 @@ public:...@@ -388,11 +369,9 @@ public:
388 pair<_RandomAccessIterator2, _RandomAccessIterator2>369 pair<_RandomAccessIterator2, _RandomAccessIterator2>
389 operator ()(_RandomAccessIterator2 __f, _RandomAccessIterator2 __l) const370 operator ()(_RandomAccessIterator2 __f, _RandomAccessIterator2 __l) const
390 {371 {
391 static_assert ( std::is_same<372 static_assert(__is_same_uncvref<typename std::iterator_traits<_RandomAccessIterator1>::value_type,
392 typename std::__uncvref<typename std::iterator_traits<_RandomAccessIterator1>::value_type>::type,373 typename std::iterator_traits<_RandomAccessIterator2>::value_type>::value,
393 typename std::__uncvref<typename std::iterator_traits<_RandomAccessIterator2>::value_type>::type374 "Corpus and Pattern iterators must point to the same type");
394 >::value,
395 "Corpus and Pattern iterators must point to the same type" );
396375
397 if (__f == __l ) return make_pair(__l, __l); // empty corpus376 if (__f == __l ) return make_pair(__l, __l); // empty corpus
398 if (__first_ == __last_) return make_pair(__f, __f); // empty pattern377 if (__first_ == __last_) return make_pair(__f, __f); // empty pattern
...@@ -440,7 +419,7 @@ private:...@@ -440,7 +419,7 @@ private:
440template<class _RandomAccessIterator,419template<class _RandomAccessIterator,
441 class _Hash = hash<typename iterator_traits<_RandomAccessIterator>::value_type>,420 class _Hash = hash<typename iterator_traits<_RandomAccessIterator>::value_type>,
442 class _BinaryPredicate = equal_to<>>421 class _BinaryPredicate = equal_to<>>
443_LIBCPP_INLINE_VISIBILITY422_LIBCPP_DEPRECATED_BOYER_MOORE_HORSPOOL_SEARCHER _LIBCPP_INLINE_VISIBILITY
444boyer_moore_horspool_searcher<_RandomAccessIterator, _Hash, _BinaryPredicate>423boyer_moore_horspool_searcher<_RandomAccessIterator, _Hash, _BinaryPredicate>
445make_boyer_moore_horspool_searcher( _RandomAccessIterator __f, _RandomAccessIterator __l,424make_boyer_moore_horspool_searcher( _RandomAccessIterator __f, _RandomAccessIterator __l,
446 _Hash __hf = _Hash(), _BinaryPredicate __p = _BinaryPredicate ())425 _Hash __hf = _Hash(), _BinaryPredicate __p = _BinaryPredicate ())
lib/libcxx/include/experimental/iterator+3-1
...@@ -52,14 +52,16 @@ namespace std {...@@ -52,14 +52,16 @@ namespace std {
5252
53*/53*/
5454
55#include <__assert> // all public C++ headers provide the assertion handler
55#include <__memory/addressof.h>56#include <__memory/addressof.h>
56#include <__utility/forward.h>57#include <__utility/forward.h>
57#include <__utility/move.h>58#include <__utility/move.h>
58#include <experimental/__config>59#include <experimental/__config>
60#include <iosfwd> // char_traits
59#include <iterator>61#include <iterator>
6062
61#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)63#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
62#pragma GCC system_header64# pragma GCC system_header
63#endif65#endif
6466
65#if _LIBCPP_STD_VER > 1167#if _LIBCPP_STD_VER > 11
lib/libcxx/include/experimental/list+3-1
...@@ -9,6 +9,7 @@...@@ -9,6 +9,7 @@
99
10#ifndef _LIBCPP_EXPERIMENTAL_LIST10#ifndef _LIBCPP_EXPERIMENTAL_LIST
11#define _LIBCPP_EXPERIMENTAL_LIST11#define _LIBCPP_EXPERIMENTAL_LIST
12
12/*13/*
13 experimental/list synopsis14 experimental/list synopsis
1415
...@@ -28,12 +29,13 @@ namespace pmr {...@@ -28,12 +29,13 @@ namespace pmr {
2829
29 */30 */
3031
32#include <__assert> // all public C++ headers provide the assertion handler
31#include <experimental/__config>33#include <experimental/__config>
32#include <experimental/memory_resource>34#include <experimental/memory_resource>
33#include <list>35#include <list>
3436
35#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)37#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
36#pragma GCC system_header38# pragma GCC system_header
37#endif39#endif
3840
39_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR41_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
lib/libcxx/include/experimental/map+3-1
...@@ -9,6 +9,7 @@...@@ -9,6 +9,7 @@
99
10#ifndef _LIBCPP_EXPERIMENTAL_MAP10#ifndef _LIBCPP_EXPERIMENTAL_MAP
11#define _LIBCPP_EXPERIMENTAL_MAP11#define _LIBCPP_EXPERIMENTAL_MAP
12
12/*13/*
13 experimental/map synopsis14 experimental/map synopsis
1415
...@@ -33,12 +34,13 @@ namespace pmr {...@@ -33,12 +34,13 @@ namespace pmr {
3334
34 */35 */
3536
37#include <__assert> // all public C++ headers provide the assertion handler
36#include <experimental/__config>38#include <experimental/__config>
37#include <experimental/memory_resource>39#include <experimental/memory_resource>
38#include <map>40#include <map>
3941
40#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)42#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
41#pragma GCC system_header43# pragma GCC system_header
42#endif44#endif
4345
44_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR46_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
lib/libcxx/include/experimental/memory_resource+3-3
...@@ -64,8 +64,9 @@ namespace pmr {...@@ -64,8 +64,9 @@ namespace pmr {
6464
65 */65 */
6666
67#include <__debug>67#include <__assert> // all public C++ headers provide the assertion handler
68#include <__tuple>68#include <__tuple>
69#include <__utility/move.h>
69#include <cstddef>70#include <cstddef>
70#include <cstdlib>71#include <cstdlib>
71#include <experimental/__config>72#include <experimental/__config>
...@@ -75,10 +76,9 @@ namespace pmr {...@@ -75,10 +76,9 @@ namespace pmr {
75#include <new>76#include <new>
76#include <stdexcept>77#include <stdexcept>
77#include <type_traits>78#include <type_traits>
78#include <utility>
7979
80#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)80#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
81#pragma GCC system_header81# pragma GCC system_header
82#endif82#endif
8383
84_LIBCPP_PUSH_MACROS84_LIBCPP_PUSH_MACROS
lib/libcxx/include/experimental/propagate_const+7-3
...@@ -9,6 +9,7 @@...@@ -9,6 +9,7 @@
99
10#ifndef _LIBCPP_EXPERIMENTAL_PROPAGATE_CONST10#ifndef _LIBCPP_EXPERIMENTAL_PROPAGATE_CONST
11#define _LIBCPP_EXPERIMENTAL_PROPAGATE_CONST11#define _LIBCPP_EXPERIMENTAL_PROPAGATE_CONST
12
12/*13/*
13 propagate_const synopsis14 propagate_const synopsis
1415
...@@ -106,13 +107,16 @@...@@ -106,13 +107,16 @@
106107
107*/108*/
108109
110#include <__assert> // all public C++ headers provide the assertion handler
111#include <__functional/operations.h>
112#include <__utility/forward.h>
113#include <__utility/move.h>
114#include <__utility/swap.h>
109#include <experimental/__config>115#include <experimental/__config>
110#include <functional>
111#include <type_traits>116#include <type_traits>
112#include <utility>
113117
114#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)118#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
115#pragma GCC system_header119# pragma GCC system_header
116#endif120#endif
117121
118#if _LIBCPP_STD_VER > 11122#if _LIBCPP_STD_VER > 11
lib/libcxx/include/experimental/regex+3-1
...@@ -9,6 +9,7 @@...@@ -9,6 +9,7 @@
99
10#ifndef _LIBCPP_EXPERIMENTAL_REGEX10#ifndef _LIBCPP_EXPERIMENTAL_REGEX
11#define _LIBCPP_EXPERIMENTAL_REGEX11#define _LIBCPP_EXPERIMENTAL_REGEX
12
12/*13/*
13 experimental/regex synopsis14 experimental/regex synopsis
1415
...@@ -35,13 +36,14 @@ namespace pmr {...@@ -35,13 +36,14 @@ namespace pmr {
3536
36 */37 */
3738
39#include <__assert> // all public C++ headers provide the assertion handler
38#include <experimental/__config>40#include <experimental/__config>
39#include <experimental/memory_resource>41#include <experimental/memory_resource>
40#include <experimental/string>42#include <experimental/string>
41#include <regex>43#include <regex>
4244
43#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)45#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
44#pragma GCC system_header46# pragma GCC system_header
45#endif47#endif
4648
47_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR49_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
lib/libcxx/include/experimental/set+3-1
...@@ -9,6 +9,7 @@...@@ -9,6 +9,7 @@
99
10#ifndef _LIBCPP_EXPERIMENTAL_SET10#ifndef _LIBCPP_EXPERIMENTAL_SET
11#define _LIBCPP_EXPERIMENTAL_SET11#define _LIBCPP_EXPERIMENTAL_SET
12
12/*13/*
13 experimental/set synopsis14 experimental/set synopsis
1415
...@@ -33,12 +34,13 @@ namespace pmr {...@@ -33,12 +34,13 @@ namespace pmr {
3334
34 */35 */
3536
37#include <__assert> // all public C++ headers provide the assertion handler
36#include <experimental/__config>38#include <experimental/__config>
37#include <experimental/memory_resource>39#include <experimental/memory_resource>
38#include <set>40#include <set>
3941
40#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)42#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
41#pragma GCC system_header43# pragma GCC system_header
42#endif44#endif
4345
44_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR46_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
lib/libcxx/include/experimental/simd+19-9
...@@ -649,14 +649,20 @@ public:...@@ -649,14 +649,20 @@ public:
649649
650*/650*/
651651
652#include <algorithm>652#include <__assert> // all public C++ headers provide the assertion handler
653#include <__functional/operations.h>
653#include <array>654#include <array>
654#include <cstddef>655#include <cstddef>
655#include <experimental/__config>656#include <experimental/__config>
656#include <functional>657#include <tuple>
658
659#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
660# include <algorithm>
661# include <functional>
662#endif
657663
658#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)664#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
659#pragma GCC system_header665# pragma GCC system_header
660#endif666#endif
661667
662_LIBCPP_PUSH_MACROS668_LIBCPP_PUSH_MACROS
...@@ -1236,32 +1242,32 @@ _Tp reduce(const simd<_Tp, _Abi>&, _BinaryOp = _BinaryOp());...@@ -1236,32 +1242,32 @@ _Tp reduce(const simd<_Tp, _Abi>&, _BinaryOp = _BinaryOp());
1236template <class _MaskType, class _SimdType, class _BinaryOp>1242template <class _MaskType, class _SimdType, class _BinaryOp>
1237typename _SimdType::value_type1243typename _SimdType::value_type
1238reduce(const const_where_expression<_MaskType, _SimdType>&,1244reduce(const const_where_expression<_MaskType, _SimdType>&,
1239 typename _SimdType::value_type neutral_element, _BinaryOp binary_op);1245 typename _SimdType::value_type __neutral_element, _BinaryOp);
12401246
1241template <class _MaskType, class _SimdType>1247template <class _MaskType, class _SimdType>
1242typename _SimdType::value_type1248typename _SimdType::value_type
1243reduce(const const_where_expression<_MaskType, _SimdType>&,1249reduce(const const_where_expression<_MaskType, _SimdType>&,
1244 plus<typename _SimdType::value_type> binary_op = {});1250 plus<typename _SimdType::value_type> = {});
12451251
1246template <class _MaskType, class _SimdType>1252template <class _MaskType, class _SimdType>
1247typename _SimdType::value_type1253typename _SimdType::value_type
1248reduce(const const_where_expression<_MaskType, _SimdType>&,1254reduce(const const_where_expression<_MaskType, _SimdType>&,
1249 multiplies<typename _SimdType::value_type> binary_op);1255 multiplies<typename _SimdType::value_type>);
12501256
1251template <class _MaskType, class _SimdType>1257template <class _MaskType, class _SimdType>
1252typename _SimdType::value_type1258typename _SimdType::value_type
1253reduce(const const_where_expression<_MaskType, _SimdType>&,1259reduce(const const_where_expression<_MaskType, _SimdType>&,
1254 bit_and<typename _SimdType::value_type> binary_op);1260 bit_and<typename _SimdType::value_type>);
12551261
1256template <class _MaskType, class _SimdType>1262template <class _MaskType, class _SimdType>
1257typename _SimdType::value_type1263typename _SimdType::value_type
1258reduce(const const_where_expression<_MaskType, _SimdType>&,1264reduce(const const_where_expression<_MaskType, _SimdType>&,
1259 bit_or<typename _SimdType::value_type> binary_op);1265 bit_or<typename _SimdType::value_type>);
12601266
1261template <class _MaskType, class _SimdType>1267template <class _MaskType, class _SimdType>
1262typename _SimdType::value_type1268typename _SimdType::value_type
1263reduce(const const_where_expression<_MaskType, _SimdType>&,1269reduce(const const_where_expression<_MaskType, _SimdType>&,
1264 bit_xor<typename _SimdType::value_type> binary_op);1270 bit_xor<typename _SimdType::value_type>);
12651271
1266template <class _Tp, class _Abi>1272template <class _Tp, class _Abi>
1267_Tp hmin(const simd<_Tp, _Abi>&);1273_Tp hmin(const simd<_Tp, _Abi>&);
...@@ -1471,6 +1477,7 @@ public:...@@ -1471,6 +1477,7 @@ public:
1471 simd operator+() const;1477 simd operator+() const;
1472 simd operator-() const;1478 simd operator-() const;
14731479
1480#if 0
1474 // binary operators [simd.binary]1481 // binary operators [simd.binary]
1475 friend simd operator+(const simd&, const simd&);1482 friend simd operator+(const simd&, const simd&);
1476 friend simd operator-(const simd&, const simd&);1483 friend simd operator-(const simd&, const simd&);
...@@ -1507,6 +1514,7 @@ public:...@@ -1507,6 +1514,7 @@ public:
1507 friend mask_type operator<=(const simd&, const simd&);1514 friend mask_type operator<=(const simd&, const simd&);
1508 friend mask_type operator>(const simd&, const simd&);1515 friend mask_type operator>(const simd&, const simd&);
1509 friend mask_type operator<(const simd&, const simd&);1516 friend mask_type operator<(const simd&, const simd&);
1517#endif
1510};1518};
15111519
1512// [simd.mask.class]1520// [simd.mask.class]
...@@ -1546,6 +1554,7 @@ public:...@@ -1546,6 +1554,7 @@ public:
1546 // unary operators [simd.mask.unary]1554 // unary operators [simd.mask.unary]
1547 simd_mask operator!() const noexcept;1555 simd_mask operator!() const noexcept;
15481556
1557#if 0
1549 // simd_mask binary operators [simd.mask.binary]1558 // simd_mask binary operators [simd.mask.binary]
1550 friend simd_mask operator&&(const simd_mask&, const simd_mask&) noexcept;1559 friend simd_mask operator&&(const simd_mask&, const simd_mask&) noexcept;
1551 friend simd_mask operator||(const simd_mask&, const simd_mask&) noexcept;1560 friend simd_mask operator||(const simd_mask&, const simd_mask&) noexcept;
...@@ -1561,6 +1570,7 @@ public:...@@ -1561,6 +1570,7 @@ public:
1561 // simd_mask compares [simd.mask.comparison]1570 // simd_mask compares [simd.mask.comparison]
1562 friend simd_mask operator==(const simd_mask&, const simd_mask&) noexcept;1571 friend simd_mask operator==(const simd_mask&, const simd_mask&) noexcept;
1563 friend simd_mask operator!=(const simd_mask&, const simd_mask&) noexcept;1572 friend simd_mask operator!=(const simd_mask&, const simd_mask&) noexcept;
1573#endif
1564};1574};
15651575
1566#endif // _LIBCPP_STD_VER >= 171576#endif // _LIBCPP_STD_VER >= 17
lib/libcxx/include/experimental/string+3-1
...@@ -9,6 +9,7 @@...@@ -9,6 +9,7 @@
99
10#ifndef _LIBCPP_EXPERIMENTAL_STRING10#ifndef _LIBCPP_EXPERIMENTAL_STRING
11#define _LIBCPP_EXPERIMENTAL_STRING11#define _LIBCPP_EXPERIMENTAL_STRING
12
12/*13/*
13 experimental/string synopsis14 experimental/string synopsis
1415
...@@ -37,12 +38,13 @@ namespace pmr {...@@ -37,12 +38,13 @@ namespace pmr {
3738
38 */39 */
3940
41#include <__assert> // all public C++ headers provide the assertion handler
40#include <experimental/__config>42#include <experimental/__config>
41#include <experimental/memory_resource>43#include <experimental/memory_resource>
42#include <string>44#include <string>
4345
44#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)46#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
45#pragma GCC system_header47# pragma GCC system_header
46#endif48#endif
4749
48_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR50_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
lib/libcxx/include/experimental/type_traits+2-1
...@@ -68,6 +68,7 @@ inline namespace fundamentals_v1 {...@@ -68,6 +68,7 @@ inline namespace fundamentals_v1 {
6868
69 */69 */
7070
71#include <__assert> // all public C++ headers provide the assertion handler
71#include <experimental/__config>72#include <experimental/__config>
7273
73#if _LIBCPP_STD_VER > 1174#if _LIBCPP_STD_VER > 11
...@@ -76,7 +77,7 @@ inline namespace fundamentals_v1 {...@@ -76,7 +77,7 @@ inline namespace fundamentals_v1 {
76#include <type_traits>77#include <type_traits>
7778
78#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)79#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
79#pragma GCC system_header80# pragma GCC system_header
80#endif81#endif
8182
82_LIBCPP_BEGIN_NAMESPACE_LFTS83_LIBCPP_BEGIN_NAMESPACE_LFTS
lib/libcxx/include/experimental/unordered_map+11-1
...@@ -9,6 +9,7 @@...@@ -9,6 +9,7 @@
99
10#ifndef _LIBCPP_EXPERIMENTAL_UNORDERED_MAP10#ifndef _LIBCPP_EXPERIMENTAL_UNORDERED_MAP
11#define _LIBCPP_EXPERIMENTAL_UNORDERED_MAP11#define _LIBCPP_EXPERIMENTAL_UNORDERED_MAP
12
12/*13/*
13 experimental/unordered_map synopsis14 experimental/unordered_map synopsis
1415
...@@ -39,12 +40,21 @@ namespace pmr {...@@ -39,12 +40,21 @@ namespace pmr {
3940
40 */41 */
4142
43#include <__assert> // all public C++ headers provide the assertion handler
42#include <experimental/__config>44#include <experimental/__config>
43#include <experimental/memory_resource>45#include <experimental/memory_resource>
44#include <unordered_map>46#include <unordered_map>
4547
48#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
49# include <algorithm>
50# include <array>
51# include <bit>
52# include <functional>
53# include <vector>
54#endif
55
46#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)56#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
47#pragma GCC system_header57# pragma GCC system_header
48#endif58#endif
4959
50_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR60_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
lib/libcxx/include/experimental/unordered_set+3-1
...@@ -9,6 +9,7 @@...@@ -9,6 +9,7 @@
99
10#ifndef _LIBCPP_EXPERIMENTAL_UNORDERED_SET10#ifndef _LIBCPP_EXPERIMENTAL_UNORDERED_SET
11#define _LIBCPP_EXPERIMENTAL_UNORDERED_SET11#define _LIBCPP_EXPERIMENTAL_UNORDERED_SET
12
12/*13/*
13 experimental/unordered_set synopsis14 experimental/unordered_set synopsis
1415
...@@ -33,12 +34,13 @@ namespace pmr {...@@ -33,12 +34,13 @@ namespace pmr {
3334
34 */35 */
3536
37#include <__assert> // all public C++ headers provide the assertion handler
36#include <experimental/__config>38#include <experimental/__config>
37#include <experimental/memory_resource>39#include <experimental/memory_resource>
38#include <unordered_set>40#include <unordered_set>
3941
40#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)42#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
41#pragma GCC system_header43# pragma GCC system_header
42#endif44#endif
4345
44_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR46_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
lib/libcxx/include/experimental/utility+2-1
...@@ -30,11 +30,12 @@ inline namespace fundamentals_v1 {...@@ -30,11 +30,12 @@ inline namespace fundamentals_v1 {
3030
31 */31 */
3232
33#include <__assert> // all public C++ headers provide the assertion handler
33#include <experimental/__config>34#include <experimental/__config>
34#include <utility>35#include <utility>
3536
36#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)37#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
37#pragma GCC system_header38# pragma GCC system_header
38#endif39#endif
3940
40_LIBCPP_BEGIN_NAMESPACE_LFTS41_LIBCPP_BEGIN_NAMESPACE_LFTS
lib/libcxx/include/experimental/vector+3-1
...@@ -9,6 +9,7 @@...@@ -9,6 +9,7 @@
99
10#ifndef _LIBCPP_EXPERIMENTAL_VECTOR10#ifndef _LIBCPP_EXPERIMENTAL_VECTOR
11#define _LIBCPP_EXPERIMENTAL_VECTOR11#define _LIBCPP_EXPERIMENTAL_VECTOR
12
12/*13/*
13 experimental/vector synopsis14 experimental/vector synopsis
1415
...@@ -28,12 +29,13 @@ namespace pmr {...@@ -28,12 +29,13 @@ namespace pmr {
2829
29 */30 */
3031
32#include <__assert> // all public C++ headers provide the assertion handler
31#include <experimental/__config>33#include <experimental/__config>
32#include <experimental/memory_resource>34#include <experimental/memory_resource>
33#include <vector>35#include <vector>
3436
35#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)37#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
36#pragma GCC system_header38# pragma GCC system_header
37#endif39#endif
3840
39_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR41_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
lib/libcxx/include/ext/__hash+13-13
...@@ -10,9 +10,9 @@...@@ -10,9 +10,9 @@
10#ifndef _LIBCPP_EXT_HASH10#ifndef _LIBCPP_EXT_HASH
11#define _LIBCPP_EXT_HASH11#define _LIBCPP_EXT_HASH
1212
13#pragma GCC system_header13# pragma GCC system_header
1414
15#include <__string>15#include <__config>
16#include <cstring>16#include <cstring>
17#include <string>17#include <string>
1818
...@@ -21,7 +21,7 @@ namespace __gnu_cxx {...@@ -21,7 +21,7 @@ namespace __gnu_cxx {
21template <typename _Tp> struct _LIBCPP_TEMPLATE_VIS hash { };21template <typename _Tp> struct _LIBCPP_TEMPLATE_VIS hash { };
2222
23template <> struct _LIBCPP_TEMPLATE_VIS hash<const char*>23template <> struct _LIBCPP_TEMPLATE_VIS hash<const char*>
24 : public std::unary_function<const char*, size_t>24 : public std::__unary_function<const char*, size_t>
25{25{
26 _LIBCPP_INLINE_VISIBILITY26 _LIBCPP_INLINE_VISIBILITY
27 size_t operator()(const char *__c) const _NOEXCEPT27 size_t operator()(const char *__c) const _NOEXCEPT
...@@ -31,7 +31,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<const char*>...@@ -31,7 +31,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<const char*>
31};31};
3232
33template <> struct _LIBCPP_TEMPLATE_VIS hash<char *>33template <> struct _LIBCPP_TEMPLATE_VIS hash<char *>
34 : public std::unary_function<char*, size_t>34 : public std::__unary_function<char*, size_t>
35{35{
36 _LIBCPP_INLINE_VISIBILITY36 _LIBCPP_INLINE_VISIBILITY
37 size_t operator()(char *__c) const _NOEXCEPT37 size_t operator()(char *__c) const _NOEXCEPT
...@@ -41,7 +41,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<char *>...@@ -41,7 +41,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<char *>
41};41};
4242
43template <> struct _LIBCPP_TEMPLATE_VIS hash<char>43template <> struct _LIBCPP_TEMPLATE_VIS hash<char>
44 : public std::unary_function<char, size_t>44 : public std::__unary_function<char, size_t>
45{45{
46 _LIBCPP_INLINE_VISIBILITY46 _LIBCPP_INLINE_VISIBILITY
47 size_t operator()(char __c) const _NOEXCEPT47 size_t operator()(char __c) const _NOEXCEPT
...@@ -51,7 +51,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<char>...@@ -51,7 +51,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<char>
51};51};
5252
53template <> struct _LIBCPP_TEMPLATE_VIS hash<signed char>53template <> struct _LIBCPP_TEMPLATE_VIS hash<signed char>
54 : public std::unary_function<signed char, size_t>54 : public std::__unary_function<signed char, size_t>
55{55{
56 _LIBCPP_INLINE_VISIBILITY56 _LIBCPP_INLINE_VISIBILITY
57 size_t operator()(signed char __c) const _NOEXCEPT57 size_t operator()(signed char __c) const _NOEXCEPT
...@@ -61,7 +61,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<signed char>...@@ -61,7 +61,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<signed char>
61};61};
6262
63template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned char>63template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned char>
64 : public std::unary_function<unsigned char, size_t>64 : public std::__unary_function<unsigned char, size_t>
65{65{
66 _LIBCPP_INLINE_VISIBILITY66 _LIBCPP_INLINE_VISIBILITY
67 size_t operator()(unsigned char __c) const _NOEXCEPT67 size_t operator()(unsigned char __c) const _NOEXCEPT
...@@ -71,7 +71,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned char>...@@ -71,7 +71,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned char>
71};71};
7272
73template <> struct _LIBCPP_TEMPLATE_VIS hash<short>73template <> struct _LIBCPP_TEMPLATE_VIS hash<short>
74 : public std::unary_function<short, size_t>74 : public std::__unary_function<short, size_t>
75{75{
76 _LIBCPP_INLINE_VISIBILITY76 _LIBCPP_INLINE_VISIBILITY
77 size_t operator()(short __c) const _NOEXCEPT77 size_t operator()(short __c) const _NOEXCEPT
...@@ -81,7 +81,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<short>...@@ -81,7 +81,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<short>
81};81};
8282
83template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned short>83template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned short>
84 : public std::unary_function<unsigned short, size_t>84 : public std::__unary_function<unsigned short, size_t>
85{85{
86 _LIBCPP_INLINE_VISIBILITY86 _LIBCPP_INLINE_VISIBILITY
87 size_t operator()(unsigned short __c) const _NOEXCEPT87 size_t operator()(unsigned short __c) const _NOEXCEPT
...@@ -91,7 +91,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned short>...@@ -91,7 +91,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned short>
91};91};
9292
93template <> struct _LIBCPP_TEMPLATE_VIS hash<int>93template <> struct _LIBCPP_TEMPLATE_VIS hash<int>
94 : public std::unary_function<int, size_t>94 : public std::__unary_function<int, size_t>
95{95{
96 _LIBCPP_INLINE_VISIBILITY96 _LIBCPP_INLINE_VISIBILITY
97 size_t operator()(int __c) const _NOEXCEPT97 size_t operator()(int __c) const _NOEXCEPT
...@@ -101,7 +101,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<int>...@@ -101,7 +101,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<int>
101};101};
102102
103template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned int>103template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned int>
104 : public std::unary_function<unsigned int, size_t>104 : public std::__unary_function<unsigned int, size_t>
105{105{
106 _LIBCPP_INLINE_VISIBILITY106 _LIBCPP_INLINE_VISIBILITY
107 size_t operator()(unsigned int __c) const _NOEXCEPT107 size_t operator()(unsigned int __c) const _NOEXCEPT
...@@ -111,7 +111,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned int>...@@ -111,7 +111,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned int>
111};111};
112112
113template <> struct _LIBCPP_TEMPLATE_VIS hash<long>113template <> struct _LIBCPP_TEMPLATE_VIS hash<long>
114 : public std::unary_function<long, size_t>114 : public std::__unary_function<long, size_t>
115{115{
116 _LIBCPP_INLINE_VISIBILITY116 _LIBCPP_INLINE_VISIBILITY
117 size_t operator()(long __c) const _NOEXCEPT117 size_t operator()(long __c) const _NOEXCEPT
...@@ -121,7 +121,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<long>...@@ -121,7 +121,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<long>
121};121};
122122
123template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned long>123template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned long>
124 : public std::unary_function<unsigned long, size_t>124 : public std::__unary_function<unsigned long, size_t>
125{125{
126 _LIBCPP_INLINE_VISIBILITY126 _LIBCPP_INLINE_VISIBILITY
127 size_t operator()(unsigned long __c) const _NOEXCEPT127 size_t operator()(unsigned long __c) const _NOEXCEPT
lib/libcxx/include/ext/hash_map+19-13
...@@ -201,13 +201,19 @@ template <class Key, class T, class Hash, class Pred, class Alloc>...@@ -201,13 +201,19 @@ template <class Key, class T, class Hash, class Pred, class Alloc>
201201
202*/202*/
203203
204#include <__assert> // all public C++ headers provide the assertion handler
204#include <__config>205#include <__config>
205#include <__hash_table>206#include <__hash_table>
207#include <algorithm>
206#include <ext/__hash>208#include <ext/__hash>
207#include <functional>209#include <functional>
208#include <stdexcept>210#include <stdexcept>
209#include <type_traits>211#include <type_traits>
210212
213#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
214# include <iterator>
215#endif
216
211#if defined(__DEPRECATED) && __DEPRECATED217#if defined(__DEPRECATED) && __DEPRECATED
212#if defined(_LIBCPP_WARNING)218#if defined(_LIBCPP_WARNING)
213 _LIBCPP_WARNING("Use of the header <ext/hash_map> is deprecated. Migrate to <unordered_map>")219 _LIBCPP_WARNING("Use of the header <ext/hash_map> is deprecated. Migrate to <unordered_map>")
...@@ -217,7 +223,7 @@ template <class Key, class T, class Hash, class Pred, class Alloc>...@@ -217,7 +223,7 @@ template <class Key, class T, class Hash, class Pred, class Alloc>
217#endif223#endif
218224
219#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)225#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
220#pragma GCC system_header226# pragma GCC system_header
221#endif227#endif
222228
223namespace __gnu_cxx {229namespace __gnu_cxx {
...@@ -599,7 +605,7 @@ public:...@@ -599,7 +605,7 @@ public:
599 {return __table_.bucket_size(__n);}605 {return __table_.bucket_size(__n);}
600606
601 _LIBCPP_INLINE_VISIBILITY607 _LIBCPP_INLINE_VISIBILITY
602 void resize(size_type __n) {__table_.rehash(__n);}608 void resize(size_type __n) {__table_.__rehash_unique(__n);}
603609
604private:610private:
605 __node_holder __construct_node(const key_type& __k);611 __node_holder __construct_node(const key_type& __k);
...@@ -610,7 +616,7 @@ hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map(...@@ -610,7 +616,7 @@ hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map(
610 size_type __n, const hasher& __hf, const key_equal& __eql)616 size_type __n, const hasher& __hf, const key_equal& __eql)
611 : __table_(__hf, __eql)617 : __table_(__hf, __eql)
612{618{
613 __table_.rehash(__n);619 __table_.__rehash_unique(__n);
614}620}
615621
616template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>622template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
...@@ -619,7 +625,7 @@ hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map(...@@ -619,7 +625,7 @@ hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map(
619 const allocator_type& __a)625 const allocator_type& __a)
620 : __table_(__hf, __eql, __a)626 : __table_(__hf, __eql, __a)
621{627{
622 __table_.rehash(__n);628 __table_.__rehash_unique(__n);
623}629}
624630
625template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>631template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
...@@ -637,7 +643,7 @@ hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map(...@@ -637,7 +643,7 @@ hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map(
637 const hasher& __hf, const key_equal& __eql)643 const hasher& __hf, const key_equal& __eql)
638 : __table_(__hf, __eql)644 : __table_(__hf, __eql)
639{645{
640 __table_.rehash(__n);646 __table_.__rehash_unique(__n);
641 insert(__first, __last);647 insert(__first, __last);
642}648}
643649
...@@ -648,7 +654,7 @@ hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map(...@@ -648,7 +654,7 @@ hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map(
648 const hasher& __hf, const key_equal& __eql, const allocator_type& __a)654 const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
649 : __table_(__hf, __eql, __a)655 : __table_(__hf, __eql, __a)
650{656{
651 __table_.rehash(__n);657 __table_.__rehash_unique(__n);
652 insert(__first, __last);658 insert(__first, __last);
653}659}
654660
...@@ -657,7 +663,7 @@ hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map(...@@ -657,7 +663,7 @@ hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map(
657 const hash_map& __u)663 const hash_map& __u)
658 : __table_(__u.__table_)664 : __table_(__u.__table_)
659{665{
660 __table_.rehash(__u.bucket_count());666 __table_.__rehash_unique(__u.bucket_count());
661 insert(__u.begin(), __u.end());667 insert(__u.begin(), __u.end());
662}668}
663669
...@@ -868,7 +874,7 @@ public:...@@ -868,7 +874,7 @@ public:
868 {return __table_.bucket_size(__n);}874 {return __table_.bucket_size(__n);}
869875
870 _LIBCPP_INLINE_VISIBILITY876 _LIBCPP_INLINE_VISIBILITY
871 void resize(size_type __n) {__table_.rehash(__n);}877 void resize(size_type __n) {__table_.__rehash_multi(__n);}
872};878};
873879
874template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>880template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
...@@ -876,7 +882,7 @@ hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap(...@@ -876,7 +882,7 @@ hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap(
876 size_type __n, const hasher& __hf, const key_equal& __eql)882 size_type __n, const hasher& __hf, const key_equal& __eql)
877 : __table_(__hf, __eql)883 : __table_(__hf, __eql)
878{884{
879 __table_.rehash(__n);885 __table_.__rehash_multi(__n);
880}886}
881887
882template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>888template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
...@@ -885,7 +891,7 @@ hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap(...@@ -885,7 +891,7 @@ hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap(
885 const allocator_type& __a)891 const allocator_type& __a)
886 : __table_(__hf, __eql, __a)892 : __table_(__hf, __eql, __a)
887{893{
888 __table_.rehash(__n);894 __table_.__rehash_multi(__n);
889}895}
890896
891template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>897template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
...@@ -903,7 +909,7 @@ hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap(...@@ -903,7 +909,7 @@ hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap(
903 const hasher& __hf, const key_equal& __eql)909 const hasher& __hf, const key_equal& __eql)
904 : __table_(__hf, __eql)910 : __table_(__hf, __eql)
905{911{
906 __table_.rehash(__n);912 __table_.__rehash_multi(__n);
907 insert(__first, __last);913 insert(__first, __last);
908}914}
909915
...@@ -914,7 +920,7 @@ hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap(...@@ -914,7 +920,7 @@ hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap(
914 const hasher& __hf, const key_equal& __eql, const allocator_type& __a)920 const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
915 : __table_(__hf, __eql, __a)921 : __table_(__hf, __eql, __a)
916{922{
917 __table_.rehash(__n);923 __table_.__rehash_multi(__n);
918 insert(__first, __last);924 insert(__first, __last);
919}925}
920926
...@@ -923,7 +929,7 @@ hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap(...@@ -923,7 +929,7 @@ hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap(
923 const hash_multimap& __u)929 const hash_multimap& __u)
924 : __table_(__u.__table_)930 : __table_(__u.__table_)
925{931{
926 __table_.rehash(__u.bucket_count());932 __table_.__rehash_multi(__u.bucket_count());
927 insert(__u.begin(), __u.end());933 insert(__u.begin(), __u.end());
928}934}
929935
lib/libcxx/include/ext/hash_set+19-13
...@@ -192,11 +192,17 @@ template <class Value, class Hash, class Pred, class Alloc>...@@ -192,11 +192,17 @@ template <class Value, class Hash, class Pred, class Alloc>
192192
193*/193*/
194194
195#include <__assert> // all public C++ headers provide the assertion handler
195#include <__config>196#include <__config>
196#include <__hash_table>197#include <__hash_table>
198#include <algorithm>
197#include <ext/__hash>199#include <ext/__hash>
198#include <functional>200#include <functional>
199201
202#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
203# include <iterator>
204#endif
205
200#if defined(__DEPRECATED) && __DEPRECATED206#if defined(__DEPRECATED) && __DEPRECATED
201#if defined(_LIBCPP_WARNING)207#if defined(_LIBCPP_WARNING)
202 _LIBCPP_WARNING("Use of the header <ext/hash_set> is deprecated. Migrate to <unordered_set>")208 _LIBCPP_WARNING("Use of the header <ext/hash_set> is deprecated. Migrate to <unordered_set>")
...@@ -206,7 +212,7 @@ template <class Value, class Hash, class Pred, class Alloc>...@@ -206,7 +212,7 @@ template <class Value, class Hash, class Pred, class Alloc>
206#endif212#endif
207213
208#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)214#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
209#pragma GCC system_header215# pragma GCC system_header
210#endif216#endif
211217
212namespace __gnu_cxx {218namespace __gnu_cxx {
...@@ -327,7 +333,7 @@ public:...@@ -327,7 +333,7 @@ public:
327 size_type elems_in_bucket(size_type __n) const {return __table_.bucket_size(__n);}333 size_type elems_in_bucket(size_type __n) const {return __table_.bucket_size(__n);}
328334
329 _LIBCPP_INLINE_VISIBILITY335 _LIBCPP_INLINE_VISIBILITY
330 void resize(size_type __n) {__table_.rehash(__n);}336 void resize(size_type __n) {__table_.__rehash_unique(__n);}
331};337};
332338
333template <class _Value, class _Hash, class _Pred, class _Alloc>339template <class _Value, class _Hash, class _Pred, class _Alloc>
...@@ -335,7 +341,7 @@ hash_set<_Value, _Hash, _Pred, _Alloc>::hash_set(size_type __n,...@@ -335,7 +341,7 @@ hash_set<_Value, _Hash, _Pred, _Alloc>::hash_set(size_type __n,
335 const hasher& __hf, const key_equal& __eql)341 const hasher& __hf, const key_equal& __eql)
336 : __table_(__hf, __eql)342 : __table_(__hf, __eql)
337{343{
338 __table_.rehash(__n);344 __table_.__rehash_unique(__n);
339}345}
340346
341template <class _Value, class _Hash, class _Pred, class _Alloc>347template <class _Value, class _Hash, class _Pred, class _Alloc>
...@@ -343,7 +349,7 @@ hash_set<_Value, _Hash, _Pred, _Alloc>::hash_set(size_type __n,...@@ -343,7 +349,7 @@ hash_set<_Value, _Hash, _Pred, _Alloc>::hash_set(size_type __n,
343 const hasher& __hf, const key_equal& __eql, const allocator_type& __a)349 const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
344 : __table_(__hf, __eql, __a)350 : __table_(__hf, __eql, __a)
345{351{
346 __table_.rehash(__n);352 __table_.__rehash_unique(__n);
347}353}
348354
349template <class _Value, class _Hash, class _Pred, class _Alloc>355template <class _Value, class _Hash, class _Pred, class _Alloc>
...@@ -361,7 +367,7 @@ hash_set<_Value, _Hash, _Pred, _Alloc>::hash_set(...@@ -361,7 +367,7 @@ hash_set<_Value, _Hash, _Pred, _Alloc>::hash_set(
361 const hasher& __hf, const key_equal& __eql)367 const hasher& __hf, const key_equal& __eql)
362 : __table_(__hf, __eql)368 : __table_(__hf, __eql)
363{369{
364 __table_.rehash(__n);370 __table_.__rehash_unique(__n);
365 insert(__first, __last);371 insert(__first, __last);
366}372}
367373
...@@ -372,7 +378,7 @@ hash_set<_Value, _Hash, _Pred, _Alloc>::hash_set(...@@ -372,7 +378,7 @@ hash_set<_Value, _Hash, _Pred, _Alloc>::hash_set(
372 const hasher& __hf, const key_equal& __eql, const allocator_type& __a)378 const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
373 : __table_(__hf, __eql, __a)379 : __table_(__hf, __eql, __a)
374{380{
375 __table_.rehash(__n);381 __table_.__rehash_unique(__n);
376 insert(__first, __last);382 insert(__first, __last);
377}383}
378384
...@@ -381,7 +387,7 @@ hash_set<_Value, _Hash, _Pred, _Alloc>::hash_set(...@@ -381,7 +387,7 @@ hash_set<_Value, _Hash, _Pred, _Alloc>::hash_set(
381 const hash_set& __u)387 const hash_set& __u)
382 : __table_(__u.__table_)388 : __table_(__u.__table_)
383{389{
384 __table_.rehash(__u.bucket_count());390 __table_.__rehash_unique(__u.bucket_count());
385 insert(__u.begin(), __u.end());391 insert(__u.begin(), __u.end());
386}392}
387393
...@@ -547,7 +553,7 @@ public:...@@ -547,7 +553,7 @@ public:
547 size_type elems_in_bucket(size_type __n) const {return __table_.bucket_size(__n);}553 size_type elems_in_bucket(size_type __n) const {return __table_.bucket_size(__n);}
548554
549 _LIBCPP_INLINE_VISIBILITY555 _LIBCPP_INLINE_VISIBILITY
550 void resize(size_type __n) {__table_.rehash(__n);}556 void resize(size_type __n) {__table_.__rehash_multi(__n);}
551};557};
552558
553template <class _Value, class _Hash, class _Pred, class _Alloc>559template <class _Value, class _Hash, class _Pred, class _Alloc>
...@@ -555,7 +561,7 @@ hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset(...@@ -555,7 +561,7 @@ hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset(
555 size_type __n, const hasher& __hf, const key_equal& __eql)561 size_type __n, const hasher& __hf, const key_equal& __eql)
556 : __table_(__hf, __eql)562 : __table_(__hf, __eql)
557{563{
558 __table_.rehash(__n);564 __table_.__rehash_multi(__n);
559}565}
560566
561template <class _Value, class _Hash, class _Pred, class _Alloc>567template <class _Value, class _Hash, class _Pred, class _Alloc>
...@@ -564,7 +570,7 @@ hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset(...@@ -564,7 +570,7 @@ hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset(
564 const allocator_type& __a)570 const allocator_type& __a)
565 : __table_(__hf, __eql, __a)571 : __table_(__hf, __eql, __a)
566{572{
567 __table_.rehash(__n);573 __table_.__rehash_multi(__n);
568}574}
569575
570template <class _Value, class _Hash, class _Pred, class _Alloc>576template <class _Value, class _Hash, class _Pred, class _Alloc>
...@@ -582,7 +588,7 @@ hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset(...@@ -582,7 +588,7 @@ hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset(
582 const hasher& __hf, const key_equal& __eql)588 const hasher& __hf, const key_equal& __eql)
583 : __table_(__hf, __eql)589 : __table_(__hf, __eql)
584{590{
585 __table_.rehash(__n);591 __table_.__rehash_multi(__n);
586 insert(__first, __last);592 insert(__first, __last);
587}593}
588594
...@@ -593,7 +599,7 @@ hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset(...@@ -593,7 +599,7 @@ hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset(
593 const hasher& __hf, const key_equal& __eql, const allocator_type& __a)599 const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
594 : __table_(__hf, __eql, __a)600 : __table_(__hf, __eql, __a)
595{601{
596 __table_.rehash(__n);602 __table_.__rehash_multi(__n);
597 insert(__first, __last);603 insert(__first, __last);
598}604}
599605
...@@ -602,7 +608,7 @@ hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset(...@@ -602,7 +608,7 @@ hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset(
602 const hash_multiset& __u)608 const hash_multiset& __u)
603 : __table_(__u.__table_)609 : __table_(__u.__table_)
604{610{
605 __table_.rehash(__u.bucket_count());611 __table_.__rehash_multi(__u.bucket_count());
606 insert(__u.begin(), __u.end());612 insert(__u.begin(), __u.end());
607}613}
608614
lib/libcxx/include/fenv.h+1-1
...@@ -53,7 +53,7 @@ int feupdateenv(const fenv_t* envp);...@@ -53,7 +53,7 @@ int feupdateenv(const fenv_t* envp);
53#include <__config>53#include <__config>
5454
55#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)55#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
56#pragma GCC system_header56# pragma GCC system_header
57#endif57#endif
5858
59#include_next <fenv.h>59#include_next <fenv.h>
lib/libcxx/include/filesystem+7-3
...@@ -8,6 +8,7 @@...@@ -8,6 +8,7 @@
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
9#ifndef _LIBCPP_FILESYSTEM9#ifndef _LIBCPP_FILESYSTEM
10#define _LIBCPP_FILESYSTEM10#define _LIBCPP_FILESYSTEM
11
11/*12/*
12 filesystem synopsis13 filesystem synopsis
1314
...@@ -238,6 +239,7 @@ inline constexpr bool std::ranges::enable_view<std::filesystem::recursive_direct...@@ -238,6 +239,7 @@ inline constexpr bool std::ranges::enable_view<std::filesystem::recursive_direct
238239
239*/240*/
240241
242#include <__assert> // all public C++ headers provide the assertion handler
241#include <__config>243#include <__config>
242#include <__filesystem/copy_options.h>244#include <__filesystem/copy_options.h>
243#include <__filesystem/directory_entry.h>245#include <__filesystem/directory_entry.h>
...@@ -255,15 +257,17 @@ inline constexpr bool std::ranges::enable_view<std::filesystem::recursive_direct...@@ -255,15 +257,17 @@ inline constexpr bool std::ranges::enable_view<std::filesystem::recursive_direct
255#include <__filesystem/recursive_directory_iterator.h>257#include <__filesystem/recursive_directory_iterator.h>
256#include <__filesystem/space_info.h>258#include <__filesystem/space_info.h>
257#include <__filesystem/u8path.h>259#include <__filesystem/u8path.h>
258#include <compare>
259#include <version>260#include <version>
260261
262// standard-mandated includes
263#include <compare>
264
261#if defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)265#if defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)
262# error "The Filesystem library is not supported since libc++ has been configured with LIBCXX_ENABLE_FILESYSTEM disabled"266# error "The <filesystem> library is not supported since libc++ has been configured without support for a filesystem."
263#endif267#endif
264268
265#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)269#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
266#pragma GCC system_header270# pragma GCC system_header
267#endif271#endif
268272
269#endif // _LIBCPP_FILESYSTEM273#endif // _LIBCPP_FILESYSTEM
lib/libcxx/include/float.h+1-1
...@@ -73,7 +73,7 @@ Macros:...@@ -73,7 +73,7 @@ Macros:
73#include <__config>73#include <__config>
7474
75#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)75#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
76#pragma GCC system_header76# pragma GCC system_header
77#endif77#endif
7878
79#include_next <float.h>79#include_next <float.h>
lib/libcxx/include/format+383-149
...@@ -23,15 +23,26 @@ namespace std {...@@ -23,15 +23,26 @@ namespace std {
23 using format_args = basic_format_args<format_context>;23 using format_args = basic_format_args<format_context>;
24 using wformat_args = basic_format_args<wformat_context>;24 using wformat_args = basic_format_args<wformat_context>;
2525
26 // [format.fmt.string], class template basic-format-string
27 template<class charT, class... Args>
28 struct basic-format-string; // exposition only
29
30 template<class... Args>
31 using format-string = // exposition only
32 basic-format-string<char, type_identity_t<Args>...>;
33 template<class... Args>
34 using wformat-string = // exposition only
35 basic-format-string<wchar_t, type_identity_t<Args>...>;
36
26 // [format.functions], formatting functions37 // [format.functions], formatting functions
27 template<class... Args>38 template<class... Args>
28 string format(string_view fmt, const Args&... args);39 string format(format-string<Args...> fmt, Args&&... args);
29 template<class... Args>40 template<class... Args>
30 wstring format(wstring_view fmt, const Args&... args);41 wstring format(wformat-string<Args...> fmt, Args&&... args);
31 template<class... Args>42 template<class... Args>
32 string format(const locale& loc, string_view fmt, const Args&... args);43 string format(const locale& loc, format-string<Args...> fmt, Args&&... args);
33 template<class... Args>44 template<class... Args>
34 wstring format(const locale& loc, wstring_view fmt, const Args&... args);45 wstring format(const locale& loc, wformat-string<Args...> fmt, Args&&... args);
3546
36 string vformat(string_view fmt, format_args args);47 string vformat(string_view fmt, format_args args);
37 wstring vformat(wstring_view fmt, wformat_args args);48 wstring vformat(wstring_view fmt, wformat_args args);
...@@ -39,13 +50,13 @@ namespace std {...@@ -39,13 +50,13 @@ namespace std {
39 wstring vformat(const locale& loc, wstring_view fmt, wformat_args args);50 wstring vformat(const locale& loc, wstring_view fmt, wformat_args args);
4051
41 template<class Out, class... Args>52 template<class Out, class... Args>
42 Out format_to(Out out, string_view fmt, const Args&... args);53 Out format_to(Out out, format-string<Args...> fmt, Args&&... args);
43 template<class Out, class... Args>54 template<class Out, class... Args>
44 Out format_to(Out out, wstring_view fmt, const Args&... args);55 Out format_to(Out out, wformat-string<Args...> fmt, Args&&... args);
45 template<class Out, class... Args>56 template<class Out, class... Args>
46 Out format_to(Out out, const locale& loc, string_view fmt, const Args&... args);57 Out format_to(Out out, const locale& loc, format-string<Args...> fmt, Args&&... args);
47 template<class Out, class... Args>58 template<class Out, class... Args>
48 Out format_to(Out out, const locale& loc, wstring_view fmt, const Args&... args);59 Out format_to(Out out, const locale& loc, wformat-string<Args...> fmt, Args&&... args);
4960
50 template<class Out>61 template<class Out>
51 Out vformat_to(Out out, string_view fmt, format_args args);62 Out vformat_to(Out out, string_view fmt, format_args args);
...@@ -64,27 +75,27 @@ namespace std {...@@ -64,27 +75,27 @@ namespace std {
64 };75 };
65 template<class Out, class... Args>76 template<class Out, class... Args>
66 format_to_n_result<Out> format_to_n(Out out, iter_difference_t<Out> n,77 format_to_n_result<Out> format_to_n(Out out, iter_difference_t<Out> n,
67 string_view fmt, const Args&... args);78 format-string<Args...> fmt, Args&&... args);
68 template<class Out, class... Args>79 template<class Out, class... Args>
69 format_to_n_result<Out> format_to_n(Out out, iter_difference_t<Out> n,80 format_to_n_result<Out> format_to_n(Out out, iter_difference_t<Out> n,
70 wstring_view fmt, const Args&... args);81 wformat-string<Args...> fmt, Args&&... args);
71 template<class Out, class... Args>82 template<class Out, class... Args>
72 format_to_n_result<Out> format_to_n(Out out, iter_difference_t<Out> n,83 format_to_n_result<Out> format_to_n(Out out, iter_difference_t<Out> n,
73 const locale& loc, string_view fmt,84 const locale& loc, format-string<Args...> fmt,
74 const Args&... args);85 Args&&... args);
75 template<class Out, class... Args>86 template<class Out, class... Args>
76 format_to_n_result<Out> format_to_n(Out out, iter_difference_t<Out> n,87 format_to_n_result<Out> format_to_n(Out out, iter_difference_t<Out> n,
77 const locale& loc, wstring_view fmt,88 const locale& loc, wformat-string<Args...> fmt,
78 const Args&... args);89 Args&&... args);
7990
80 template<class... Args>91 template<class... Args>
81 size_t formatted_size(string_view fmt, const Args&... args);92 size_t formatted_size(format-string<Args...> fmt, Args&&... args);
82 template<class... Args>93 template<class... Args>
83 size_t formatted_size(wstring_view fmt, const Args&... args);94 size_t formatted_size(wformat-string<Args...> fmt, Args&&... args);
84 template<class... Args>95 template<class... Args>
85 size_t formatted_size(const locale& loc, string_view fmt, const Args&... args);96 size_t formatted_size(const locale& loc, format-string<Args...> fmt, Args&&... args);
86 template<class... Args>97 template<class... Args>
87 size_t formatted_size(const locale& loc, wstring_view fmt, const Args&... args);98 size_t formatted_size(const locale& loc, wformat-string<Args...> fmt, Args&&... args);
8899
89 // [format.formatter], formatter100 // [format.formatter], formatter
90 template<class T, class charT = char> struct formatter;101 template<class T, class charT = char> struct formatter;
...@@ -106,10 +117,10 @@ namespace std {...@@ -106,10 +117,10 @@ namespace std {
106117
107 template<class Context = format_context, class... Args>118 template<class Context = format_context, class... Args>
108 format-arg-store<Context, Args...>119 format-arg-store<Context, Args...>
109 make_format_args(const Args&... args);120 make_format_args(Args&&... args);
110 template<class... Args>121 template<class... Args>
111 format-arg-store<wformat_context, Args...>122 format-arg-store<wformat_context, Args...>
112 make_wformat_args(const Args&... args);123 make_wformat_args(Args&&... args);
113124
114 // [format.error], class format_error125 // [format.error], class format_error
115 class format_error;126 class format_error;
...@@ -117,14 +128,20 @@ namespace std {...@@ -117,14 +128,20 @@ namespace std {
117128
118*/129*/
119130
131#include <__assert> // all public C++ headers provide the assertion handler
120// Make sure all feature-test macros are available.132// Make sure all feature-test macros are available.
121#include <version>133#include <version>
122// Enable the contents of the header only when libc++ was built with LIBCXX_ENABLE_INCOMPLETE_FEATURES.134// Enable the contents of the header only when libc++ was built with experimental features enabled.
123#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)135#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)
124136
137#include <__algorithm/clamp.h>
125#include <__config>138#include <__config>
126#include <__debug>139#include <__debug>
140#include <__format/buffer.h>
141#include <__format/concepts.h>
142#include <__format/enable_insertable.h>
127#include <__format/format_arg.h>143#include <__format/format_arg.h>
144#include <__format/format_arg_store.h>
128#include <__format/format_args.h>145#include <__format/format_args.h>
129#include <__format/format_context.h>146#include <__format/format_context.h>
130#include <__format/format_error.h>147#include <__format/format_error.h>
...@@ -140,6 +157,9 @@ namespace std {...@@ -140,6 +157,9 @@ namespace std {
140#include <__format/formatter_pointer.h>157#include <__format/formatter_pointer.h>
141#include <__format/formatter_string.h>158#include <__format/formatter_string.h>
142#include <__format/parser_std_format_spec.h>159#include <__format/parser_std_format_spec.h>
160#include <__format/unicode.h>
161#include <__iterator/back_insert_iterator.h>
162#include <__iterator/incrementable_traits.h>
143#include <__variant/monostate.h>163#include <__variant/monostate.h>
144#include <array>164#include <array>
145#include <concepts>165#include <concepts>
...@@ -152,22 +172,13 @@ namespace std {...@@ -152,22 +172,13 @@ namespace std {
152#endif172#endif
153173
154#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)174#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
155#pragma GCC system_header175# pragma GCC system_header
156#endif176#endif
157177
158_LIBCPP_PUSH_MACROS
159#include <__undef_macros>
160
161_LIBCPP_BEGIN_NAMESPACE_STD178_LIBCPP_BEGIN_NAMESPACE_STD
162179
163#if _LIBCPP_STD_VER > 17180#if _LIBCPP_STD_VER > 17
164181
165// TODO FMT Remove this once we require compilers with proper C++20 support.
166// If the compiler has no concepts support, the format header will be disabled.
167// Without concepts support enable_if needs to be used and that too much effort
168// to support compilers with partial C++20 support.
169#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
170
171// TODO FMT Move the implementation in this file to its own granular headers.182// TODO FMT Move the implementation in this file to its own granular headers.
172183
173// TODO FMT Evaluate which templates should be external templates. This184// TODO FMT Evaluate which templates should be external templates. This
...@@ -180,35 +191,193 @@ using format_args = basic_format_args<format_context>;...@@ -180,35 +191,193 @@ using format_args = basic_format_args<format_context>;
180using wformat_args = basic_format_args<wformat_context>;191using wformat_args = basic_format_args<wformat_context>;
181#endif192#endif
182193
183template <class _Context, class... _Args>
184struct _LIBCPP_TEMPLATE_VIS __format_arg_store {
185 // TODO FMT Use a built-in array.
186 array<basic_format_arg<_Context>, sizeof...(_Args)> __args;
187};
188
189template <class _Context = format_context, class... _Args>194template <class _Context = format_context, class... _Args>
190_LIBCPP_HIDE_FROM_ABI __format_arg_store<_Context, _Args...>195_LIBCPP_HIDE_FROM_ABI __format_arg_store<_Context, _Args...> make_format_args(_Args&&... __args) {
191make_format_args(const _Args&... __args) {196 return _VSTD::__format_arg_store<_Context, _Args...>(__args...);
192 return {basic_format_arg<_Context>(__args)...};
193}197}
194198
195#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS199#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
196template <class... _Args>200template <class... _Args>
197_LIBCPP_HIDE_FROM_ABI __format_arg_store<wformat_context, _Args...>201_LIBCPP_HIDE_FROM_ABI __format_arg_store<wformat_context, _Args...> make_wformat_args(_Args&&... __args) {
198make_wformat_args(const _Args&... __args) {202 return _VSTD::__format_arg_store<wformat_context, _Args...>(__args...);
199 return _VSTD::make_format_args<wformat_context>(__args...);
200}203}
201#endif204#endif
202205
203namespace __format {206namespace __format {
204207
208/// Helper class parse and handle argument.
209///
210/// When parsing a handle which is not enabled the code is ill-formed.
211/// This helper uses the parser of the appropriate formatter for the stored type.
212template <class _CharT>
213class _LIBCPP_TEMPLATE_VIS __compile_time_handle {
214public:
215 _LIBCPP_HIDE_FROM_ABI
216 constexpr void __parse(basic_format_parse_context<_CharT>& __parse_ctx) const { __parse_(__parse_ctx); }
217
218 template <class _Tp>
219 _LIBCPP_HIDE_FROM_ABI constexpr void __enable() {
220 __parse_ = [](basic_format_parse_context<_CharT>& __parse_ctx) {
221 formatter<_Tp, _CharT> __f;
222 __parse_ctx.advance_to(__f.parse(__parse_ctx));
223 };
224 }
225
226 // Before calling __parse the proper handler needs to be set with __enable.
227 // The default handler isn't a core constant expression.
228 _LIBCPP_HIDE_FROM_ABI constexpr __compile_time_handle()
229 : __parse_([](basic_format_parse_context<_CharT>&) { __throw_format_error("Not a handle"); }) {}
230
231private:
232 void (*__parse_)(basic_format_parse_context<_CharT>&);
233};
234
235// Dummy format_context only providing the parts used during constant
236// validation of the basic-format-string.
237template <class _CharT>
238struct _LIBCPP_TEMPLATE_VIS __compile_time_basic_format_context {
239public:
240 using char_type = _CharT;
241
242 _LIBCPP_HIDE_FROM_ABI constexpr explicit __compile_time_basic_format_context(
243 const __arg_t* __args, const __compile_time_handle<_CharT>* __handles, size_t __size)
244 : __args_(__args), __handles_(__handles), __size_(__size) {}
245
246 // During the compile-time validation nothing needs to be written.
247 // Therefore all operations of this iterator are a NOP.
248 struct iterator {
249 _LIBCPP_HIDE_FROM_ABI constexpr iterator& operator=(_CharT) { return *this; }
250 _LIBCPP_HIDE_FROM_ABI constexpr iterator& operator*() { return *this; }
251 _LIBCPP_HIDE_FROM_ABI constexpr iterator operator++(int) { return *this; }
252 };
253
254 _LIBCPP_HIDE_FROM_ABI constexpr __arg_t arg(size_t __id) const {
255 if (__id >= __size_)
256 __throw_format_error("Argument index out of bounds");
257 return __args_[__id];
258 }
259
260 _LIBCPP_HIDE_FROM_ABI constexpr const __compile_time_handle<_CharT>& __handle(size_t __id) const {
261 if (__id >= __size_)
262 __throw_format_error("Argument index out of bounds");
263 return __handles_[__id];
264 }
265
266 _LIBCPP_HIDE_FROM_ABI constexpr iterator out() { return {}; }
267 _LIBCPP_HIDE_FROM_ABI constexpr void advance_to(iterator) {}
268
269private:
270 const __arg_t* __args_;
271 const __compile_time_handle<_CharT>* __handles_;
272 size_t __size_;
273};
274
275_LIBCPP_HIDE_FROM_ABI
276constexpr void __compile_time_validate_integral(__arg_t __type) {
277 switch (__type) {
278 case __arg_t::__int:
279 case __arg_t::__long_long:
280 case __arg_t::__i128:
281 case __arg_t::__unsigned:
282 case __arg_t::__unsigned_long_long:
283 case __arg_t::__u128:
284 return;
285
286 default:
287 __throw_format_error("Argument isn't an integral type");
288 }
289}
290
291// _HasPrecision does the formatter have a precision?
292template <class _CharT, class _Tp, bool _HasPrecision = false>
293_LIBCPP_HIDE_FROM_ABI constexpr void
294__compile_time_validate_argument(basic_format_parse_context<_CharT>& __parse_ctx,
295 __compile_time_basic_format_context<_CharT>& __ctx) {
296 formatter<_Tp, _CharT> __formatter;
297 __parse_ctx.advance_to(__formatter.parse(__parse_ctx));
298 // [format.string.std]/7
299 // ... If the corresponding formatting argument is not of integral type, or
300 // its value is negative for precision or non-positive for width, an
301 // exception of type format_error is thrown.
302 //
303 // Validate whether the arguments are integrals.
304 if constexpr (requires(formatter<_Tp, _CharT> __f) { __f.__width_needs_substitution(); }) {
305 // TODO FMT Remove this when parser v1 has been phased out.
306 if (__formatter.__width_needs_substitution())
307 __format::__compile_time_validate_integral(__ctx.arg(__formatter.__width));
308
309 if constexpr (_HasPrecision)
310 if (__formatter.__precision_needs_substitution())
311 __format::__compile_time_validate_integral(__ctx.arg(__formatter.__precision));
312 } else {
313 if (__formatter.__parser_.__width_as_arg_)
314 __format::__compile_time_validate_integral(__ctx.arg(__formatter.__parser_.__width_));
315
316 if constexpr (_HasPrecision)
317 if (__formatter.__parser_.__precision_as_arg_)
318 __format::__compile_time_validate_integral(__ctx.arg(__formatter.__parser_.__precision_));
319 }
320}
321
322template <class _CharT>
323_LIBCPP_HIDE_FROM_ABI constexpr void __compile_time_visit_format_arg(basic_format_parse_context<_CharT>& __parse_ctx,
324 __compile_time_basic_format_context<_CharT>& __ctx,
325 __arg_t __type) {
326 switch (__type) {
327 case __arg_t::__none:
328 __throw_format_error("Invalid argument");
329 case __arg_t::__boolean:
330 return __format::__compile_time_validate_argument<_CharT, bool>(__parse_ctx, __ctx);
331 case __arg_t::__char_type:
332 return __format::__compile_time_validate_argument<_CharT, _CharT>(__parse_ctx, __ctx);
333 case __arg_t::__int:
334 return __format::__compile_time_validate_argument<_CharT, int>(__parse_ctx, __ctx);
335 case __arg_t::__long_long:
336 return __format::__compile_time_validate_argument<_CharT, long long>(__parse_ctx, __ctx);
337 case __arg_t::__i128:
338# ifndef _LIBCPP_HAS_NO_INT128
339 return __format::__compile_time_validate_argument<_CharT, __int128_t>(__parse_ctx, __ctx);
340# else
341 __throw_format_error("Invalid argument");
342# endif
343 return;
344 case __arg_t::__unsigned:
345 return __format::__compile_time_validate_argument<_CharT, unsigned>(__parse_ctx, __ctx);
346 case __arg_t::__unsigned_long_long:
347 return __format::__compile_time_validate_argument<_CharT, unsigned long long>(__parse_ctx, __ctx);
348 case __arg_t::__u128:
349# ifndef _LIBCPP_HAS_NO_INT128
350 return __format::__compile_time_validate_argument<_CharT, __uint128_t>(__parse_ctx, __ctx);
351# else
352 __throw_format_error("Invalid argument");
353# endif
354 return;
355 case __arg_t::__float:
356 return __format::__compile_time_validate_argument<_CharT, float, true>(__parse_ctx, __ctx);
357 case __arg_t::__double:
358 return __format::__compile_time_validate_argument<_CharT, double, true>(__parse_ctx, __ctx);
359 case __arg_t::__long_double:
360 return __format::__compile_time_validate_argument<_CharT, long double, true>(__parse_ctx, __ctx);
361 case __arg_t::__const_char_type_ptr:
362 return __format::__compile_time_validate_argument<_CharT, const _CharT*, true>(__parse_ctx, __ctx);
363 case __arg_t::__string_view:
364 return __format::__compile_time_validate_argument<_CharT, basic_string_view<_CharT>, true>(__parse_ctx, __ctx);
365 case __arg_t::__ptr:
366 return __format::__compile_time_validate_argument<_CharT, const void*>(__parse_ctx, __ctx);
367 case __arg_t::__handle:
368 __throw_format_error("Handle should use __compile_time_validate_handle_argument");
369 }
370 __throw_format_error("Invalid argument");
371}
372
205template <class _CharT, class _ParseCtx, class _Ctx>373template <class _CharT, class _ParseCtx, class _Ctx>
206_LIBCPP_HIDE_FROM_ABI const _CharT*374_LIBCPP_HIDE_FROM_ABI constexpr const _CharT*
207__handle_replacement_field(const _CharT* __begin, const _CharT* __end,375__handle_replacement_field(const _CharT* __begin, const _CharT* __end,
208 _ParseCtx& __parse_ctx, _Ctx& __ctx) {376 _ParseCtx& __parse_ctx, _Ctx& __ctx) {
209 __format::__parse_number_result __r =377 __format::__parse_number_result __r =
210 __format::__parse_arg_id(__begin, __end, __parse_ctx);378 __format::__parse_arg_id(__begin, __end, __parse_ctx);
211379
380 bool __parse = *__r.__ptr == _CharT(':');
212 switch (*__r.__ptr) {381 switch (*__r.__ptr) {
213 case _CharT(':'):382 case _CharT(':'):
214 // The arg-id has a format-specifier, advance the input to the format-spec.383 // The arg-id has a format-specifier, advance the input to the format-spec.
...@@ -223,19 +392,27 @@ __handle_replacement_field(const _CharT* __begin, const _CharT* __end,...@@ -223,19 +392,27 @@ __handle_replacement_field(const _CharT* __begin, const _CharT* __end,
223 "The replacement field arg-id should terminate at a ':' or '}'");392 "The replacement field arg-id should terminate at a ':' or '}'");
224 }393 }
225394
226 _VSTD::visit_format_arg(395 if constexpr (same_as<_Ctx, __compile_time_basic_format_context<_CharT>>) {
227 [&](auto __arg) {396 __arg_t __type = __ctx.arg(__r.__value);
228 if constexpr (same_as<decltype(__arg), monostate>)397 if (__type == __arg_t::__handle)
229 __throw_format_error("Argument index out of bounds");398 __ctx.__handle(__r.__value).__parse(__parse_ctx);
230 else if constexpr (same_as<decltype(__arg), typename basic_format_arg<_Ctx>::handle>)399 else
231 __arg.format(__parse_ctx, __ctx);400 __format::__compile_time_visit_format_arg(__parse_ctx, __ctx, __type);
232 else {401 } else
233 formatter<decltype(__arg), _CharT> __formatter;402 _VSTD::visit_format_arg(
234 __parse_ctx.advance_to(__formatter.parse(__parse_ctx));403 [&](auto __arg) {
235 __ctx.advance_to(__formatter.format(__arg, __ctx));404 if constexpr (same_as<decltype(__arg), monostate>)
236 }405 __throw_format_error("Argument index out of bounds");
237 },406 else if constexpr (same_as<decltype(__arg), typename basic_format_arg<_Ctx>::handle>)
238 __ctx.arg(__r.__value));407 __arg.format(__parse_ctx, __ctx);
408 else {
409 formatter<decltype(__arg), _CharT> __formatter;
410 if (__parse)
411 __parse_ctx.advance_to(__formatter.parse(__parse_ctx));
412 __ctx.advance_to(__formatter.format(__arg, __ctx));
413 }
414 },
415 __ctx.arg(__r.__value));
239416
240 __begin = __parse_ctx.begin();417 __begin = __parse_ctx.begin();
241 if (__begin == __end || *__begin != _CharT('}'))418 if (__begin == __end || *__begin != _CharT('}'))
...@@ -245,7 +422,7 @@ __handle_replacement_field(const _CharT* __begin, const _CharT* __end,...@@ -245,7 +422,7 @@ __handle_replacement_field(const _CharT* __begin, const _CharT* __end,
245}422}
246423
247template <class _ParseCtx, class _Ctx>424template <class _ParseCtx, class _Ctx>
248_LIBCPP_HIDE_FROM_ABI typename _Ctx::iterator425_LIBCPP_HIDE_FROM_ABI constexpr typename _Ctx::iterator
249__vformat_to(_ParseCtx&& __parse_ctx, _Ctx&& __ctx) {426__vformat_to(_ParseCtx&& __parse_ctx, _Ctx&& __ctx) {
250 using _CharT = typename _ParseCtx::char_type;427 using _CharT = typename _ParseCtx::char_type;
251 static_assert(same_as<typename _Ctx::char_type, _CharT>);428 static_assert(same_as<typename _Ctx::char_type, _CharT>);
...@@ -290,6 +467,56 @@ __vformat_to(_ParseCtx&& __parse_ctx, _Ctx&& __ctx) {...@@ -290,6 +467,56 @@ __vformat_to(_ParseCtx&& __parse_ctx, _Ctx&& __ctx) {
290467
291} // namespace __format468} // namespace __format
292469
470template <class _CharT, class... _Args>
471struct _LIBCPP_TEMPLATE_VIS __basic_format_string {
472 basic_string_view<_CharT> __str_;
473
474 template <class _Tp>
475 requires convertible_to<const _Tp&, basic_string_view<_CharT>>
476 consteval __basic_format_string(const _Tp& __str) : __str_{__str} {
477 __format::__vformat_to(basic_format_parse_context<_CharT>{__str_, sizeof...(_Args)},
478 _Context{__types_.data(), __handles_.data(), sizeof...(_Args)});
479 }
480
481private:
482 using _Context = __format::__compile_time_basic_format_context<_CharT>;
483
484 static constexpr array<__format::__arg_t, sizeof...(_Args)> __types_{
485 __format::__determine_arg_t<_Context, remove_cvref_t<_Args>>()...};
486
487 // TODO FMT remove this work-around when the AIX ICE has been resolved.
488# if defined(_AIX) && defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 1400
489 template <class _Tp>
490 static constexpr __format::__compile_time_handle<_CharT> __get_handle() {
491 __format::__compile_time_handle<_CharT> __handle;
492 if (__format::__determine_arg_t<_Context, _Tp>() == __format::__arg_t::__handle)
493 __handle.template __enable<_Tp>();
494
495 return __handle;
496 }
497
498 static constexpr array<__format::__compile_time_handle<_CharT>, sizeof...(_Args)> __handles_{
499 __get_handle<_Args>()...};
500# else
501 static constexpr array<__format::__compile_time_handle<_CharT>, sizeof...(_Args)> __handles_{[] {
502 using _Tp = remove_cvref_t<_Args>;
503 __format::__compile_time_handle<_CharT> __handle;
504 if (__format::__determine_arg_t<_Context, _Tp>() == __format::__arg_t::__handle)
505 __handle.template __enable<_Tp>();
506
507 return __handle;
508 }()...};
509# endif
510};
511
512template <class... _Args>
513using __format_string_t = __basic_format_string<char, type_identity_t<_Args>...>;
514
515#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
516template <class... _Args>
517using __wformat_string_t = __basic_format_string<wchar_t, type_identity_t<_Args>...>;
518#endif
519
293template <class _OutIt, class _CharT, class _FormatOutIt>520template <class _OutIt, class _CharT, class _FormatOutIt>
294requires(output_iterator<_OutIt, const _CharT&>) _LIBCPP_HIDE_FROM_ABI _OutIt521requires(output_iterator<_OutIt, const _CharT&>) _LIBCPP_HIDE_FROM_ABI _OutIt
295 __vformat_to(522 __vformat_to(
...@@ -300,14 +527,18 @@ requires(output_iterator<_OutIt, const _CharT&>) _LIBCPP_HIDE_FROM_ABI _OutIt...@@ -300,14 +527,18 @@ requires(output_iterator<_OutIt, const _CharT&>) _LIBCPP_HIDE_FROM_ABI _OutIt
300 basic_format_parse_context{__fmt, __args.__size()},527 basic_format_parse_context{__fmt, __args.__size()},
301 _VSTD::__format_context_create(_VSTD::move(__out_it), __args));528 _VSTD::__format_context_create(_VSTD::move(__out_it), __args));
302 else {529 else {
303 basic_string<_CharT> __str;530 __format::__format_buffer<_OutIt, _CharT> __buffer{_VSTD::move(__out_it)};
304 _VSTD::__format::__vformat_to(531 _VSTD::__format::__vformat_to(
305 basic_format_parse_context{__fmt, __args.__size()},532 basic_format_parse_context{__fmt, __args.__size()},
306 _VSTD::__format_context_create(_VSTD::back_inserter(__str), __args));533 _VSTD::__format_context_create(__buffer.make_output_iterator(),
307 return _VSTD::copy_n(__str.begin(), __str.size(), _VSTD::move(__out_it));534 __args));
535 return _VSTD::move(__buffer).out();
308 }536 }
309}537}
310538
539// The function is _LIBCPP_ALWAYS_INLINE since the compiler is bad at inlining
540// https://reviews.llvm.org/D110499#inline-1180704
541// TODO FMT Evaluate whether we want to file a Clang bug report regarding this.
311template <output_iterator<const char&> _OutIt>542template <output_iterator<const char&> _OutIt>
312_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt543_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt
313vformat_to(_OutIt __out_it, string_view __fmt, format_args __args) {544vformat_to(_OutIt __out_it, string_view __fmt, format_args __args) {
...@@ -324,16 +555,16 @@ vformat_to(_OutIt __out_it, wstring_view __fmt, wformat_args __args) {...@@ -324,16 +555,16 @@ vformat_to(_OutIt __out_it, wstring_view __fmt, wformat_args __args) {
324555
325template <output_iterator<const char&> _OutIt, class... _Args>556template <output_iterator<const char&> _OutIt, class... _Args>
326_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt557_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt
327format_to(_OutIt __out_it, string_view __fmt, const _Args&... __args) {558format_to(_OutIt __out_it, __format_string_t<_Args...> __fmt, _Args&&... __args) {
328 return _VSTD::vformat_to(_VSTD::move(__out_it), __fmt,559 return _VSTD::vformat_to(_VSTD::move(__out_it), __fmt.__str_,
329 _VSTD::make_format_args(__args...));560 _VSTD::make_format_args(__args...));
330}561}
331562
332#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS563#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
333template <output_iterator<const wchar_t&> _OutIt, class... _Args>564template <output_iterator<const wchar_t&> _OutIt, class... _Args>
334_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt565_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt
335format_to(_OutIt __out_it, wstring_view __fmt, const _Args&... __args) {566format_to(_OutIt __out_it, __wformat_string_t<_Args...> __fmt, _Args&&... __args) {
336 return _VSTD::vformat_to(_VSTD::move(__out_it), __fmt,567 return _VSTD::vformat_to(_VSTD::move(__out_it), __fmt.__str_,
337 _VSTD::make_wformat_args(__args...));568 _VSTD::make_wformat_args(__args...));
338}569}
339#endif570#endif
...@@ -355,60 +586,63 @@ vformat(wstring_view __fmt, wformat_args __args) {...@@ -355,60 +586,63 @@ vformat(wstring_view __fmt, wformat_args __args) {
355#endif586#endif
356587
357template <class... _Args>588template <class... _Args>
358_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT string589_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT string format(__format_string_t<_Args...> __fmt,
359format(string_view __fmt, const _Args&... __args) {590 _Args&&... __args) {
360 return _VSTD::vformat(__fmt, _VSTD::make_format_args(__args...));591 return _VSTD::vformat(__fmt.__str_, _VSTD::make_format_args(__args...));
361}592}
362593
363#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS594#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
364template <class... _Args>595template <class... _Args>
365_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT wstring596_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT wstring
366format(wstring_view __fmt, const _Args&... __args) {597format(__wformat_string_t<_Args...> __fmt, _Args&&... __args) {
367 return _VSTD::vformat(__fmt, _VSTD::make_wformat_args(__args...));598 return _VSTD::vformat(__fmt.__str_, _VSTD::make_wformat_args(__args...));
368}599}
369#endif600#endif
370601
602template <class _Context, class _OutIt, class _CharT>
603_LIBCPP_HIDE_FROM_ABI format_to_n_result<_OutIt> __vformat_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n,
604 basic_string_view<_CharT> __fmt,
605 basic_format_args<_Context> __args) {
606 __format::__format_to_n_buffer<_OutIt, _CharT> __buffer{_VSTD::move(__out_it), __n};
607 _VSTD::__format::__vformat_to(basic_format_parse_context{__fmt, __args.__size()},
608 _VSTD::__format_context_create(__buffer.make_output_iterator(), __args));
609 return _VSTD::move(__buffer).result();
610}
611
371template <output_iterator<const char&> _OutIt, class... _Args>612template <output_iterator<const char&> _OutIt, class... _Args>
372_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt>613_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt>
373format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, string_view __fmt,614format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, __format_string_t<_Args...> __fmt, _Args&&... __args) {
374 const _Args&... __args) {615 return _VSTD::__vformat_to_n<format_context>(_VSTD::move(__out_it), __n, __fmt.__str_, _VSTD::make_format_args(__args...));
375 // TODO FMT Improve PoC: using std::string is inefficient.
376 string __str = _VSTD::vformat(__fmt, _VSTD::make_format_args(__args...));
377 iter_difference_t<_OutIt> __s = __str.size();
378 iter_difference_t<_OutIt> __m =
379 _VSTD::clamp(__n, iter_difference_t<_OutIt>(0), __s);
380 __out_it = _VSTD::copy_n(__str.begin(), __m, _VSTD::move(__out_it));
381 return {_VSTD::move(__out_it), __s};
382}616}
383617
384#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS618#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
385template <output_iterator<const wchar_t&> _OutIt, class... _Args>619template <output_iterator<const wchar_t&> _OutIt, class... _Args>
386_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt>620_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt>
387format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, wstring_view __fmt,621format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, __wformat_string_t<_Args...> __fmt,
388 const _Args&... __args) {622 _Args&&... __args) {
389 // TODO FMT Improve PoC: using std::string is inefficient.623 return _VSTD::__vformat_to_n<wformat_context>(_VSTD::move(__out_it), __n, __fmt.__str_, _VSTD::make_wformat_args(__args...));
390 wstring __str = _VSTD::vformat(__fmt, _VSTD::make_wformat_args(__args...));
391 iter_difference_t<_OutIt> __s = __str.size();
392 iter_difference_t<_OutIt> __m =
393 _VSTD::clamp(__n, iter_difference_t<_OutIt>(0), __s);
394 __out_it = _VSTD::copy_n(__str.begin(), __m, _VSTD::move(__out_it));
395 return {_VSTD::move(__out_it), __s};
396}624}
397#endif625#endif
398626
627template <class _CharT>
628_LIBCPP_HIDE_FROM_ABI size_t __vformatted_size(basic_string_view<_CharT> __fmt, auto __args) {
629 __format::__formatted_size_buffer<_CharT> __buffer;
630 _VSTD::__format::__vformat_to(basic_format_parse_context{__fmt, __args.__size()},
631 _VSTD::__format_context_create(__buffer.make_output_iterator(), __args));
632 return _VSTD::move(__buffer).result();
633}
634
399template <class... _Args>635template <class... _Args>
400_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t636_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t
401formatted_size(string_view __fmt, const _Args&... __args) {637formatted_size(__format_string_t<_Args...> __fmt, _Args&&... __args) {
402 // TODO FMT Improve PoC: using std::string is inefficient.638 return _VSTD::__vformatted_size(__fmt.__str_, basic_format_args{_VSTD::make_format_args(__args...)});
403 return _VSTD::vformat(__fmt, _VSTD::make_format_args(__args...)).size();
404}639}
405640
406#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS641#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
407template <class... _Args>642template <class... _Args>
408_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t643_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t
409formatted_size(wstring_view __fmt, const _Args&... __args) {644formatted_size(__wformat_string_t<_Args...> __fmt, _Args&&... __args) {
410 // TODO FMT Improve PoC: using std::string is inefficient.645 return _VSTD::__vformatted_size(__fmt.__str_, basic_format_args{_VSTD::make_wformat_args(__args...)});
411 return _VSTD::vformat(__fmt, _VSTD::make_wformat_args(__args...)).size();
412}646}
413#endif647#endif
414648
...@@ -425,12 +659,12 @@ requires(output_iterator<_OutIt, const _CharT&>) _LIBCPP_HIDE_FROM_ABI _OutIt...@@ -425,12 +659,12 @@ requires(output_iterator<_OutIt, const _CharT&>) _LIBCPP_HIDE_FROM_ABI _OutIt
425 _VSTD::__format_context_create(_VSTD::move(__out_it), __args,659 _VSTD::__format_context_create(_VSTD::move(__out_it), __args,
426 _VSTD::move(__loc)));660 _VSTD::move(__loc)));
427 else {661 else {
428 basic_string<_CharT> __str;662 __format::__format_buffer<_OutIt, _CharT> __buffer{_VSTD::move(__out_it)};
429 _VSTD::__format::__vformat_to(663 _VSTD::__format::__vformat_to(
430 basic_format_parse_context{__fmt, __args.__size()},664 basic_format_parse_context{__fmt, __args.__size()},
431 _VSTD::__format_context_create(_VSTD::back_inserter(__str), __args,665 _VSTD::__format_context_create(__buffer.make_output_iterator(),
432 _VSTD::move(__loc)));666 __args, _VSTD::move(__loc)));
433 return _VSTD::copy_n(__str.begin(), __str.size(), _VSTD::move(__out_it));667 return _VSTD::move(__buffer).out();
434 }668 }
435}669}
436670
...@@ -451,17 +685,17 @@ _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt v...@@ -451,17 +685,17 @@ _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt v
451#endif685#endif
452686
453template <output_iterator<const char&> _OutIt, class... _Args>687template <output_iterator<const char&> _OutIt, class... _Args>
454_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt format_to(688_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt
455 _OutIt __out_it, locale __loc, string_view __fmt, const _Args&... __args) {689format_to(_OutIt __out_it, locale __loc, __format_string_t<_Args...> __fmt, _Args&&... __args) {
456 return _VSTD::vformat_to(_VSTD::move(__out_it), _VSTD::move(__loc), __fmt,690 return _VSTD::vformat_to(_VSTD::move(__out_it), _VSTD::move(__loc), __fmt.__str_,
457 _VSTD::make_format_args(__args...));691 _VSTD::make_format_args(__args...));
458}692}
459693
460#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS694#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
461template <output_iterator<const wchar_t&> _OutIt, class... _Args>695template <output_iterator<const wchar_t&> _OutIt, class... _Args>
462_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt format_to(696_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt
463 _OutIt __out_it, locale __loc, wstring_view __fmt, const _Args&... __args) {697format_to(_OutIt __out_it, locale __loc, __wformat_string_t<_Args...> __fmt, _Args&&... __args) {
464 return _VSTD::vformat_to(_VSTD::move(__out_it), _VSTD::move(__loc), __fmt,698 return _VSTD::vformat_to(_VSTD::move(__out_it), _VSTD::move(__loc), __fmt.__str_,
465 _VSTD::make_wformat_args(__args...));699 _VSTD::make_wformat_args(__args...));
466}700}
467#endif701#endif
...@@ -485,80 +719,80 @@ vformat(locale __loc, wstring_view __fmt, wformat_args __args) {...@@ -485,80 +719,80 @@ vformat(locale __loc, wstring_view __fmt, wformat_args __args) {
485#endif719#endif
486720
487template <class... _Args>721template <class... _Args>
488_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT string722_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT string format(locale __loc,
489format(locale __loc, string_view __fmt, const _Args&... __args) {723 __format_string_t<_Args...> __fmt,
490 return _VSTD::vformat(_VSTD::move(__loc), __fmt,724 _Args&&... __args) {
725 return _VSTD::vformat(_VSTD::move(__loc), __fmt.__str_,
491 _VSTD::make_format_args(__args...));726 _VSTD::make_format_args(__args...));
492}727}
493728
494#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS729#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
495template <class... _Args>730template <class... _Args>
496_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT wstring731_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT wstring
497format(locale __loc, wstring_view __fmt, const _Args&... __args) {732format(locale __loc, __wformat_string_t<_Args...> __fmt, _Args&&... __args) {
498 return _VSTD::vformat(_VSTD::move(__loc), __fmt,733 return _VSTD::vformat(_VSTD::move(__loc), __fmt.__str_,
499 _VSTD::make_wformat_args(__args...));734 _VSTD::make_wformat_args(__args...));
500}735}
501#endif736#endif
502737
738template <class _Context, class _OutIt, class _CharT>
739_LIBCPP_HIDE_FROM_ABI format_to_n_result<_OutIt> __vformat_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n,
740 locale __loc, basic_string_view<_CharT> __fmt,
741 basic_format_args<_Context> __args) {
742 __format::__format_to_n_buffer<_OutIt, _CharT> __buffer{_VSTD::move(__out_it), __n};
743 _VSTD::__format::__vformat_to(
744 basic_format_parse_context{__fmt, __args.__size()},
745 _VSTD::__format_context_create(__buffer.make_output_iterator(), __args, _VSTD::move(__loc)));
746 return _VSTD::move(__buffer).result();
747}
748
503template <output_iterator<const char&> _OutIt, class... _Args>749template <output_iterator<const char&> _OutIt, class... _Args>
504_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt>750_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt>
505format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, locale __loc,751format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, locale __loc, __format_string_t<_Args...> __fmt,
506 string_view __fmt, const _Args&... __args) {752 _Args&&... __args) {
507 // TODO FMT Improve PoC: using std::string is inefficient.753 return _VSTD::__vformat_to_n<format_context>(_VSTD::move(__out_it), __n, _VSTD::move(__loc), __fmt.__str_,
508 string __str = _VSTD::vformat(_VSTD::move(__loc), __fmt,754 _VSTD::make_format_args(__args...));
509 _VSTD::make_format_args(__args...));
510 iter_difference_t<_OutIt> __s = __str.size();
511 iter_difference_t<_OutIt> __m =
512 _VSTD::clamp(__n, iter_difference_t<_OutIt>(0), __s);
513 __out_it = _VSTD::copy_n(__str.begin(), __m, _VSTD::move(__out_it));
514 return {_VSTD::move(__out_it), __s};
515}755}
516756
517#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS757#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
518template <output_iterator<const wchar_t&> _OutIt, class... _Args>758template <output_iterator<const wchar_t&> _OutIt, class... _Args>
519_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt>759_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt>
520format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, locale __loc,760format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, locale __loc, __wformat_string_t<_Args...> __fmt,
521 wstring_view __fmt, const _Args&... __args) {761 _Args&&... __args) {
522 // TODO FMT Improve PoC: using std::string is inefficient.762 return _VSTD::__vformat_to_n<wformat_context>(_VSTD::move(__out_it), __n, _VSTD::move(__loc), __fmt.__str_,
523 wstring __str = _VSTD::vformat(_VSTD::move(__loc), __fmt,763 _VSTD::make_wformat_args(__args...));
524 _VSTD::make_wformat_args(__args...));
525 iter_difference_t<_OutIt> __s = __str.size();
526 iter_difference_t<_OutIt> __m =
527 _VSTD::clamp(__n, iter_difference_t<_OutIt>(0), __s);
528 __out_it = _VSTD::copy_n(__str.begin(), __m, _VSTD::move(__out_it));
529 return {_VSTD::move(__out_it), __s};
530}764}
531#endif765#endif
532766
767template <class _CharT>
768_LIBCPP_HIDE_FROM_ABI size_t __vformatted_size(locale __loc, basic_string_view<_CharT> __fmt, auto __args) {
769 __format::__formatted_size_buffer<_CharT> __buffer;
770 _VSTD::__format::__vformat_to(
771 basic_format_parse_context{__fmt, __args.__size()},
772 _VSTD::__format_context_create(__buffer.make_output_iterator(), __args, _VSTD::move(__loc)));
773 return _VSTD::move(__buffer).result();
774}
775
533template <class... _Args>776template <class... _Args>
534_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t777_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t
535formatted_size(locale __loc, string_view __fmt, const _Args&... __args) {778formatted_size(locale __loc, __format_string_t<_Args...> __fmt, _Args&&... __args) {
536 // TODO FMT Improve PoC: using std::string is inefficient.779 return _VSTD::__vformatted_size(_VSTD::move(__loc), __fmt.__str_, basic_format_args{_VSTD::make_format_args(__args...)});
537 return _VSTD::vformat(_VSTD::move(__loc), __fmt,
538 _VSTD::make_format_args(__args...))
539 .size();
540}780}
541781
542#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS782#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
543template <class... _Args>783template <class... _Args>
544_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t784_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t
545formatted_size(locale __loc, wstring_view __fmt, const _Args&... __args) {785formatted_size(locale __loc, __wformat_string_t<_Args...> __fmt, _Args&&... __args) {
546 // TODO FMT Improve PoC: using std::string is inefficient.786 return _VSTD::__vformatted_size(_VSTD::move(__loc), __fmt.__str_, basic_format_args{_VSTD::make_wformat_args(__args...)});
547 return _VSTD::vformat(_VSTD::move(__loc), __fmt,
548 _VSTD::make_wformat_args(__args...))
549 .size();
550}787}
551#endif788#endif
552789
553#endif // _LIBCPP_HAS_NO_LOCALIZATION790#endif // _LIBCPP_HAS_NO_LOCALIZATION
554791
555#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
556#endif //_LIBCPP_STD_VER > 17792#endif //_LIBCPP_STD_VER > 17
557793
558_LIBCPP_END_NAMESPACE_STD794_LIBCPP_END_NAMESPACE_STD
559795
560_LIBCPP_POP_MACROS
561
562#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)796#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)
563797
564#endif // _LIBCPP_FORMAT798#endif // _LIBCPP_FORMAT
lib/libcxx/include/forward_list+42-41
...@@ -179,18 +179,43 @@ template <class T, class Allocator, class Predicate>...@@ -179,18 +179,43 @@ template <class T, class Allocator, class Predicate>
179179
180*/180*/
181181
182#include <__algorithm/comp.h>
183#include <__algorithm/lexicographical_compare.h>
184#include <__algorithm/min.h>
185#include <__assert> // all public C++ headers provide the assertion handler
182#include <__config>186#include <__config>
187#include <__iterator/distance.h>
188#include <__iterator/iterator_traits.h>
189#include <__iterator/move_iterator.h>
190#include <__iterator/next.h>
191#include <__memory/swap_allocator.h>
183#include <__utility/forward.h>192#include <__utility/forward.h>
184#include <algorithm>
185#include <initializer_list>
186#include <iterator>
187#include <limits>193#include <limits>
188#include <memory>194#include <memory>
189#include <type_traits>195#include <type_traits>
190#include <version>196#include <version>
191197
198#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
199# include <algorithm>
200# include <functional>
201# include <iterator>
202#endif
203
204// standard-mandated includes
205
206// [iterator.range]
207#include <__iterator/access.h>
208#include <__iterator/data.h>
209#include <__iterator/empty.h>
210#include <__iterator/reverse_access.h>
211#include <__iterator/size.h>
212
213// [forward.list.syn]
214#include <compare>
215#include <initializer_list>
216
192#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)217#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
193#pragma GCC system_header218# pragma GCC system_header
194#endif219#endif
195220
196_LIBCPP_PUSH_MACROS221_LIBCPP_PUSH_MACROS
...@@ -679,17 +704,13 @@ public:...@@ -679,17 +704,13 @@ public:
679704
680 template <class _InputIterator>705 template <class _InputIterator>
681 forward_list(_InputIterator __f, _InputIterator __l,706 forward_list(_InputIterator __f, _InputIterator __l,
682 typename enable_if<707 __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>* = nullptr);
683 __is_cpp17_input_iterator<_InputIterator>::value
684 >::type* = nullptr);
685 template <class _InputIterator>708 template <class _InputIterator>
686 forward_list(_InputIterator __f, _InputIterator __l,709 forward_list(_InputIterator __f, _InputIterator __l,
687 const allocator_type& __a,710 const allocator_type& __a,
688 typename enable_if<711 __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>* = nullptr);
689 __is_cpp17_input_iterator<_InputIterator>::value
690 >::type* = nullptr);
691 forward_list(const forward_list& __x);712 forward_list(const forward_list& __x);
692 forward_list(const forward_list& __x, const __identity_t<allocator_type>& __a);713 forward_list(const forward_list& __x, const __type_identity_t<allocator_type>& __a);
693714
694 forward_list& operator=(const forward_list& __x);715 forward_list& operator=(const forward_list& __x);
695716
...@@ -698,7 +719,7 @@ public:...@@ -698,7 +719,7 @@ public:
698 forward_list(forward_list&& __x)719 forward_list(forward_list&& __x)
699 _NOEXCEPT_(is_nothrow_move_constructible<base>::value)720 _NOEXCEPT_(is_nothrow_move_constructible<base>::value)
700 : base(_VSTD::move(__x)) {}721 : base(_VSTD::move(__x)) {}
701 forward_list(forward_list&& __x, const __identity_t<allocator_type>& __a);722 forward_list(forward_list&& __x, const __type_identity_t<allocator_type>& __a);
702723
703 forward_list(initializer_list<value_type> __il);724 forward_list(initializer_list<value_type> __il);
704 forward_list(initializer_list<value_type> __il, const allocator_type& __a);725 forward_list(initializer_list<value_type> __il, const allocator_type& __a);
...@@ -719,11 +740,7 @@ public:...@@ -719,11 +740,7 @@ public:
719 // ~forward_list() = default;740 // ~forward_list() = default;
720741
721 template <class _InputIterator>742 template <class _InputIterator>
722 typename enable_if743 __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, void>
723 <
724 __is_cpp17_input_iterator<_InputIterator>::value,
725 void
726 >::type
727 assign(_InputIterator __f, _InputIterator __l);744 assign(_InputIterator __f, _InputIterator __l);
728 void assign(size_type __n, const value_type& __v);745 void assign(size_type __n, const value_type& __v);
729746
...@@ -799,12 +816,8 @@ public:...@@ -799,12 +816,8 @@ public:
799 iterator insert_after(const_iterator __p, const value_type& __v);816 iterator insert_after(const_iterator __p, const value_type& __v);
800 iterator insert_after(const_iterator __p, size_type __n, const value_type& __v);817 iterator insert_after(const_iterator __p, size_type __n, const value_type& __v);
801 template <class _InputIterator>818 template <class _InputIterator>
802 _LIBCPP_INLINE_VISIBILITY819 _LIBCPP_INLINE_VISIBILITY
803 typename enable_if820 __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, iterator>
804 <
805 __is_cpp17_input_iterator<_InputIterator>::value,
806 iterator
807 >::type
808 insert_after(const_iterator __p, _InputIterator __f, _InputIterator __l);821 insert_after(const_iterator __p, _InputIterator __f, _InputIterator __l);
809822
810 iterator erase_after(const_iterator __p);823 iterator erase_after(const_iterator __p);
...@@ -953,9 +966,7 @@ forward_list<_Tp, _Alloc>::forward_list(size_type __n, const value_type& __v)...@@ -953,9 +966,7 @@ forward_list<_Tp, _Alloc>::forward_list(size_type __n, const value_type& __v)
953template <class _Tp, class _Alloc>966template <class _Tp, class _Alloc>
954template <class _InputIterator>967template <class _InputIterator>
955forward_list<_Tp, _Alloc>::forward_list(_InputIterator __f, _InputIterator __l,968forward_list<_Tp, _Alloc>::forward_list(_InputIterator __f, _InputIterator __l,
956 typename enable_if<969 __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>*)
957 __is_cpp17_input_iterator<_InputIterator>::value
958 >::type*)
959{970{
960 insert_after(cbefore_begin(), __f, __l);971 insert_after(cbefore_begin(), __f, __l);
961}972}
...@@ -964,9 +975,7 @@ template <class _Tp, class _Alloc>...@@ -964,9 +975,7 @@ template <class _Tp, class _Alloc>
964template <class _InputIterator>975template <class _InputIterator>
965forward_list<_Tp, _Alloc>::forward_list(_InputIterator __f, _InputIterator __l,976forward_list<_Tp, _Alloc>::forward_list(_InputIterator __f, _InputIterator __l,
966 const allocator_type& __a,977 const allocator_type& __a,
967 typename enable_if<978 __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>*)
968 __is_cpp17_input_iterator<_InputIterator>::value
969 >::type*)
970 : base(__a)979 : base(__a)
971{980{
972 insert_after(cbefore_begin(), __f, __l);981 insert_after(cbefore_begin(), __f, __l);
...@@ -981,7 +990,7 @@ forward_list<_Tp, _Alloc>::forward_list(const forward_list& __x)...@@ -981,7 +990,7 @@ forward_list<_Tp, _Alloc>::forward_list(const forward_list& __x)
981990
982template <class _Tp, class _Alloc>991template <class _Tp, class _Alloc>
983forward_list<_Tp, _Alloc>::forward_list(const forward_list& __x,992forward_list<_Tp, _Alloc>::forward_list(const forward_list& __x,
984 const __identity_t<allocator_type>& __a)993 const __type_identity_t<allocator_type>& __a)
985 : base(__a)994 : base(__a)
986{995{
987 insert_after(cbefore_begin(), __x.begin(), __x.end());996 insert_after(cbefore_begin(), __x.begin(), __x.end());
...@@ -1002,7 +1011,7 @@ forward_list<_Tp, _Alloc>::operator=(const forward_list& __x)...@@ -1002,7 +1011,7 @@ forward_list<_Tp, _Alloc>::operator=(const forward_list& __x)
1002#ifndef _LIBCPP_CXX03_LANG1011#ifndef _LIBCPP_CXX03_LANG
1003template <class _Tp, class _Alloc>1012template <class _Tp, class _Alloc>
1004forward_list<_Tp, _Alloc>::forward_list(forward_list&& __x,1013forward_list<_Tp, _Alloc>::forward_list(forward_list&& __x,
1005 const __identity_t<allocator_type>& __a)1014 const __type_identity_t<allocator_type>& __a)
1006 : base(_VSTD::move(__x), __a)1015 : base(_VSTD::move(__x), __a)
1007{1016{
1008 if (base::__alloc() != __x.__alloc())1017 if (base::__alloc() != __x.__alloc())
...@@ -1076,11 +1085,7 @@ forward_list<_Tp, _Alloc>::operator=(initializer_list<value_type> __il)...@@ -1076,11 +1085,7 @@ forward_list<_Tp, _Alloc>::operator=(initializer_list<value_type> __il)
10761085
1077template <class _Tp, class _Alloc>1086template <class _Tp, class _Alloc>
1078template <class _InputIterator>1087template <class _InputIterator>
1079typename enable_if1088__enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, void>
1080<
1081 __is_cpp17_input_iterator<_InputIterator>::value,
1082 void
1083>::type
1084forward_list<_Tp, _Alloc>::assign(_InputIterator __f, _InputIterator __l)1089forward_list<_Tp, _Alloc>::assign(_InputIterator __f, _InputIterator __l)
1085{1090{
1086 iterator __i = before_begin();1091 iterator __i = before_begin();
...@@ -1272,11 +1277,7 @@ forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, size_type __n,...@@ -1272,11 +1277,7 @@ forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, size_type __n,
12721277
1273template <class _Tp, class _Alloc>1278template <class _Tp, class _Alloc>
1274template <class _InputIterator>1279template <class _InputIterator>
1275typename enable_if1280__enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, typename forward_list<_Tp, _Alloc>::iterator>
1276<
1277 __is_cpp17_input_iterator<_InputIterator>::value,
1278 typename forward_list<_Tp, _Alloc>::iterator
1279>::type
1280forward_list<_Tp, _Alloc>::insert_after(const_iterator __p,1281forward_list<_Tp, _Alloc>::insert_after(const_iterator __p,
1281 _InputIterator __f, _InputIterator __l)1282 _InputIterator __f, _InputIterator __l)
1282{1283{
lib/libcxx/include/fstream+31-13
...@@ -179,12 +179,17 @@ typedef basic_fstream<wchar_t> wfstream;...@@ -179,12 +179,17 @@ typedef basic_fstream<wchar_t> wfstream;
179179
180*/180*/
181181
182#include <__algorithm/max.h>
183#include <__assert> // all public C++ headers provide the assertion handler
182#include <__availability>184#include <__availability>
183#include <__config>185#include <__config>
184#include <__debug>
185#include <__locale>186#include <__locale>
187#include <__utility/move.h>
188#include <__utility/swap.h>
189#include <__utility/unreachable.h>
186#include <cstdio>190#include <cstdio>
187#include <cstdlib>191#include <cstdlib>
192#include <cstring>
188#include <istream>193#include <istream>
189#include <ostream>194#include <ostream>
190#include <version>195#include <version>
...@@ -194,7 +199,7 @@ typedef basic_fstream<wchar_t> wfstream;...@@ -194,7 +199,7 @@ typedef basic_fstream<wchar_t> wfstream;
194#endif199#endif
195200
196#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)201#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
197#pragma GCC system_header202# pragma GCC system_header
198#endif203#endif
199204
200_LIBCPP_PUSH_MACROS205_LIBCPP_PUSH_MACROS
...@@ -414,25 +419,38 @@ basic_filebuf<_CharT, _Traits>::swap(basic_filebuf& __rhs)...@@ -414,25 +419,38 @@ basic_filebuf<_CharT, _Traits>::swap(basic_filebuf& __rhs)
414 basic_streambuf<char_type, traits_type>::swap(__rhs);419 basic_streambuf<char_type, traits_type>::swap(__rhs);
415 if (__extbuf_ != __extbuf_min_ && __rhs.__extbuf_ != __rhs.__extbuf_min_)420 if (__extbuf_ != __extbuf_min_ && __rhs.__extbuf_ != __rhs.__extbuf_min_)
416 {421 {
417 _VSTD::swap(__extbuf_, __rhs.__extbuf_);422 // Neither *this nor __rhs uses the small buffer, so we can simply swap the pointers.
418 _VSTD::swap(__extbufnext_, __rhs.__extbufnext_);423 std::swap(__extbuf_, __rhs.__extbuf_);
419 _VSTD::swap(__extbufend_, __rhs.__extbufend_);424 std::swap(__extbufnext_, __rhs.__extbufnext_);
425 std::swap(__extbufend_, __rhs.__extbufend_);
420 }426 }
421 else427 else
422 {428 {
423 ptrdiff_t __ln = __extbufnext_ - __extbuf_;429 ptrdiff_t __ln = __extbufnext_ ? __extbufnext_ - __extbuf_ : 0;
424 ptrdiff_t __le = __extbufend_ - __extbuf_;430 ptrdiff_t __le = __extbufend_ ? __extbufend_ - __extbuf_ : 0;
425 ptrdiff_t __rn = __rhs.__extbufnext_ - __rhs.__extbuf_;431 ptrdiff_t __rn = __rhs.__extbufnext_ ? __rhs.__extbufnext_ - __rhs.__extbuf_ : 0;
426 ptrdiff_t __re = __rhs.__extbufend_ - __rhs.__extbuf_;432 ptrdiff_t __re = __rhs.__extbufend_ ? __rhs.__extbufend_ - __rhs.__extbuf_ : 0;
427 if (__extbuf_ == __extbuf_min_ && __rhs.__extbuf_ != __rhs.__extbuf_min_)433 if (__extbuf_ == __extbuf_min_ && __rhs.__extbuf_ != __rhs.__extbuf_min_)
428 {434 {
435 // *this uses the small buffer, but __rhs doesn't.
429 __extbuf_ = __rhs.__extbuf_;436 __extbuf_ = __rhs.__extbuf_;
430 __rhs.__extbuf_ = __rhs.__extbuf_min_;437 __rhs.__extbuf_ = __rhs.__extbuf_min_;
438 std::memmove(__rhs.__extbuf_min_, __extbuf_min_, sizeof(__extbuf_min_));
431 }439 }
432 else if (__extbuf_ != __extbuf_min_ && __rhs.__extbuf_ == __rhs.__extbuf_min_)440 else if (__extbuf_ != __extbuf_min_ && __rhs.__extbuf_ == __rhs.__extbuf_min_)
433 {441 {
442 // *this doesn't use the small buffer, but __rhs does.
434 __rhs.__extbuf_ = __extbuf_;443 __rhs.__extbuf_ = __extbuf_;
435 __extbuf_ = __extbuf_min_;444 __extbuf_ = __extbuf_min_;
445 std::memmove(__extbuf_min_, __rhs.__extbuf_min_, sizeof(__extbuf_min_));
446 }
447 else
448 {
449 // Both *this and __rhs use the small buffer.
450 char __tmp[sizeof(__extbuf_min_)];
451 std::memmove(__tmp, __extbuf_min_, sizeof(__extbuf_min_));
452 std::memmove(__extbuf_min_, __rhs.__extbuf_min_, sizeof(__extbuf_min_));
453 std::memmove(__rhs.__extbuf_min_, __tmp, sizeof(__extbuf_min_));
436 }454 }
437 __extbufnext_ = __extbuf_ + __rn;455 __extbufnext_ = __extbuf_ + __rn;
438 __extbufend_ = __extbuf_ + __re;456 __extbufend_ = __extbuf_ + __re;
...@@ -538,7 +556,7 @@ const char* basic_filebuf<_CharT, _Traits>::__make_mdstring(...@@ -538,7 +556,7 @@ const char* basic_filebuf<_CharT, _Traits>::__make_mdstring(
538 default:556 default:
539 return nullptr;557 return nullptr;
540 }558 }
541 _LIBCPP_UNREACHABLE();559 __libcpp_unreachable();
542}560}
543561
544template <class _CharT, class _Traits>562template <class _CharT, class _Traits>
...@@ -1716,9 +1734,9 @@ basic_fstream<_CharT, _Traits>::close()...@@ -1716,9 +1734,9 @@ basic_fstream<_CharT, _Traits>::close()
1716}1734}
17171735
1718#if defined(_LIBCPP_ABI_ENABLE_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1)1736#if defined(_LIBCPP_ABI_ENABLE_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1)
1719_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ifstream<char>)1737extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ifstream<char>;
1720_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ofstream<char>)1738extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ofstream<char>;
1721_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_filebuf<char>)1739extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_filebuf<char>;
1722#endif1740#endif
17231741
1724_LIBCPP_END_NAMESPACE_STD1742_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/functional+17-2
...@@ -482,6 +482,16 @@ template <> struct hash<long double>;...@@ -482,6 +482,16 @@ template <> struct hash<long double>;
482template<class T> struct hash<T*>;482template<class T> struct hash<T*>;
483template <> struct hash<nullptr_t>; // C++17483template <> struct hash<nullptr_t>; // C++17
484484
485namespace ranges {
486 // [range.cmp], concept-constrained comparisons
487 struct equal_to;
488 struct not_equal_to;
489 struct greater;
490 struct less;
491 struct greater_equal;
492 struct less_equal;
493}
494
485} // std495} // std
486496
487POLICY: For non-variadic implementations, the number of arguments is limited497POLICY: For non-variadic implementations, the number of arguments is limited
...@@ -491,6 +501,7 @@ POLICY: For non-variadic implementations, the number of arguments is limited...@@ -491,6 +501,7 @@ POLICY: For non-variadic implementations, the number of arguments is limited
491*/501*/
492502
493#include <__algorithm/search.h>503#include <__algorithm/search.h>
504#include <__assert> // all public C++ headers provide the assertion handler
494#include <__compare/compare_three_way.h>505#include <__compare/compare_three_way.h>
495#include <__config>506#include <__config>
496#include <__debug>507#include <__debug>
...@@ -501,6 +512,7 @@ POLICY: For non-variadic implementations, the number of arguments is limited...@@ -501,6 +512,7 @@ POLICY: For non-variadic implementations, the number of arguments is limited
501#include <__functional/bind_front.h>512#include <__functional/bind_front.h>
502#include <__functional/binder1st.h>513#include <__functional/binder1st.h>
503#include <__functional/binder2nd.h>514#include <__functional/binder2nd.h>
515#include <__functional/boyer_moore_searcher.h>
504#include <__functional/compose.h>516#include <__functional/compose.h>
505#include <__functional/default_searcher.h>517#include <__functional/default_searcher.h>
506#include <__functional/function.h>518#include <__functional/function.h>
...@@ -525,11 +537,14 @@ POLICY: For non-variadic implementations, the number of arguments is limited...@@ -525,11 +537,14 @@ POLICY: For non-variadic implementations, the number of arguments is limited
525#include <tuple>537#include <tuple>
526#include <type_traits>538#include <type_traits>
527#include <typeinfo>539#include <typeinfo>
528#include <utility>
529#include <version>540#include <version>
530541
542#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
543# include <utility>
544#endif
545
531#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)546#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
532#pragma GCC system_header547# pragma GCC system_header
533#endif548#endif
534549
535#endif // _LIBCPP_FUNCTIONAL550#endif // _LIBCPP_FUNCTIONAL
lib/libcxx/include/future+22-46
...@@ -361,14 +361,16 @@ template <class R, class Alloc> struct uses_allocator<packaged_task<R>, Alloc>;...@@ -361,14 +361,16 @@ template <class R, class Alloc> struct uses_allocator<packaged_task<R>, Alloc>;
361361
362*/362*/
363363
364#include <__assert> // all public C++ headers provide the assertion handler
364#include <__availability>365#include <__availability>
366#include <__chrono/duration.h>
367#include <__chrono/time_point.h>
365#include <__config>368#include <__config>
366#include <__debug>
367#include <__memory/allocator_arg_t.h>369#include <__memory/allocator_arg_t.h>
368#include <__memory/uses_allocator.h>370#include <__memory/uses_allocator.h>
369#include <__utility/auto_cast.h>371#include <__utility/auto_cast.h>
370#include <__utility/forward.h>372#include <__utility/forward.h>
371#include <chrono>373#include <__utility/move.h>
372#include <exception>374#include <exception>
373#include <memory>375#include <memory>
374#include <mutex>376#include <mutex>
...@@ -376,13 +378,17 @@ template <class R, class Alloc> struct uses_allocator<packaged_task<R>, Alloc>;...@@ -376,13 +378,17 @@ template <class R, class Alloc> struct uses_allocator<packaged_task<R>, Alloc>;
376#include <thread>378#include <thread>
377#include <version>379#include <version>
378380
381#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
382# include <chrono>
383#endif
384
379#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)385#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
380#pragma GCC system_header386# pragma GCC system_header
381#endif387#endif
382388
383#ifdef _LIBCPP_HAS_NO_THREADS389#ifdef _LIBCPP_HAS_NO_THREADS
384#error <future> is not supported on this single threaded system390# error "<future> is not supported since libc++ has been configured without support for threads."
385#else // !_LIBCPP_HAS_NO_THREADS391#endif
386392
387_LIBCPP_BEGIN_NAMESPACE_STD393_LIBCPP_BEGIN_NAMESPACE_STD
388394
...@@ -399,7 +405,7 @@ _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(future_errc)...@@ -399,7 +405,7 @@ _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(future_errc)
399template <>405template <>
400struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<future_errc> : public true_type {};406struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<future_errc> : public true_type {};
401407
402#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS408#ifdef _LIBCPP_CXX03_LANG
403template <>409template <>
404struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<future_errc::__lx> : public true_type { };410struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<future_errc::__lx> : public true_type { };
405#endif411#endif
...@@ -413,7 +419,7 @@ _LIBCPP_DECLARE_STRONG_ENUM(launch)...@@ -413,7 +419,7 @@ _LIBCPP_DECLARE_STRONG_ENUM(launch)
413};419};
414_LIBCPP_DECLARE_STRONG_ENUM_EPILOG(launch)420_LIBCPP_DECLARE_STRONG_ENUM_EPILOG(launch)
415421
416#ifndef _LIBCPP_HAS_NO_STRONG_ENUMS422#ifndef _LIBCPP_CXX03_LANG
417423
418typedef underlying_type<launch>::type __launch_underlying_type;424typedef underlying_type<launch>::type __launch_underlying_type;
419425
...@@ -473,7 +479,7 @@ operator^=(launch& __x, launch __y)...@@ -473,7 +479,7 @@ operator^=(launch& __x, launch __y)
473 __x = __x ^ __y; return __x;479 __x = __x ^ __y; return __x;
474}480}
475481
476#endif // !_LIBCPP_HAS_NO_STRONG_ENUMS482#endif // !_LIBCPP_CXX03_LANG
477483
478//enum class future_status484//enum class future_status
479_LIBCPP_DECLARE_STRONG_ENUM(future_status)485_LIBCPP_DECLARE_STRONG_ENUM(future_status)
...@@ -519,12 +525,12 @@ _LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY...@@ -519,12 +525,12 @@ _LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
519#ifndef _LIBCPP_NO_EXCEPTIONS525#ifndef _LIBCPP_NO_EXCEPTIONS
520_LIBCPP_AVAILABILITY_FUTURE_ERROR526_LIBCPP_AVAILABILITY_FUTURE_ERROR
521#endif527#endif
522void __throw_future_error(future_errc _Ev)528void __throw_future_error(future_errc __ev)
523{529{
524#ifndef _LIBCPP_NO_EXCEPTIONS530#ifndef _LIBCPP_NO_EXCEPTIONS
525 throw future_error(make_error_code(_Ev));531 throw future_error(make_error_code(__ev));
526#else532#else
527 ((void)_Ev);533 ((void)__ev);
528 _VSTD::abort();534 _VSTD::abort();
529#endif535#endif
530}536}
...@@ -1100,7 +1106,7 @@ future<_Rp>::future(__assoc_state<_Rp>* __state)...@@ -1100,7 +1106,7 @@ future<_Rp>::future(__assoc_state<_Rp>* __state)
11001106
1101struct __release_shared_count1107struct __release_shared_count
1102{1108{
1103 void operator()(__shared_count* p) {p->__release_shared();}1109 void operator()(__shared_count* __p) {__p->__release_shared();}
1104};1110};
11051111
1106template <class _Rp>1112template <class _Rp>
...@@ -1885,25 +1891,11 @@ public:...@@ -1885,25 +1891,11 @@ public:
1885 _LIBCPP_INLINE_VISIBILITY1891 _LIBCPP_INLINE_VISIBILITY
1886 packaged_task() _NOEXCEPT : __p_(nullptr) {}1892 packaged_task() _NOEXCEPT : __p_(nullptr) {}
1887 template <class _Fp,1893 template <class _Fp,
1888 class = typename enable_if1894 class = __enable_if_t<!is_same<__uncvref_t<_Fp>, packaged_task>::value> >
1889 <
1890 !is_same<
1891 typename __uncvref<_Fp>::type,
1892 packaged_task
1893 >::value
1894 >::type
1895 >
1896 _LIBCPP_INLINE_VISIBILITY1895 _LIBCPP_INLINE_VISIBILITY
1897 explicit packaged_task(_Fp&& __f) : __f_(_VSTD::forward<_Fp>(__f)) {}1896 explicit packaged_task(_Fp&& __f) : __f_(_VSTD::forward<_Fp>(__f)) {}
1898 template <class _Fp, class _Allocator,1897 template <class _Fp, class _Allocator,
1899 class = typename enable_if1898 class = __enable_if_t<!is_same<__uncvref_t<_Fp>, packaged_task>::value> >
1900 <
1901 !is_same<
1902 typename __uncvref<_Fp>::type,
1903 packaged_task
1904 >::value
1905 >::type
1906 >
1907 _LIBCPP_INLINE_VISIBILITY1899 _LIBCPP_INLINE_VISIBILITY
1908 packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f)1900 packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f)
1909 : __f_(allocator_arg, __a, _VSTD::forward<_Fp>(__f)),1901 : __f_(allocator_arg, __a, _VSTD::forward<_Fp>(__f)),
...@@ -2014,25 +2006,11 @@ public:...@@ -2014,25 +2006,11 @@ public:
2014 _LIBCPP_INLINE_VISIBILITY2006 _LIBCPP_INLINE_VISIBILITY
2015 packaged_task() _NOEXCEPT : __p_(nullptr) {}2007 packaged_task() _NOEXCEPT : __p_(nullptr) {}
2016 template <class _Fp,2008 template <class _Fp,
2017 class = typename enable_if2009 class = __enable_if_t<!is_same<__uncvref_t<_Fp>, packaged_task>::value> >
2018 <
2019 !is_same<
2020 typename __uncvref<_Fp>::type,
2021 packaged_task
2022 >::value
2023 >::type
2024 >
2025 _LIBCPP_INLINE_VISIBILITY2010 _LIBCPP_INLINE_VISIBILITY
2026 explicit packaged_task(_Fp&& __f) : __f_(_VSTD::forward<_Fp>(__f)) {}2011 explicit packaged_task(_Fp&& __f) : __f_(_VSTD::forward<_Fp>(__f)) {}
2027 template <class _Fp, class _Allocator,2012 template <class _Fp, class _Allocator,
2028 class = typename enable_if2013 class = __enable_if_t<!is_same<__uncvref_t<_Fp>, packaged_task>::value> >
2029 <
2030 !is_same<
2031 typename __uncvref<_Fp>::type,
2032 packaged_task
2033 >::value
2034 >::type
2035 >
2036 _LIBCPP_INLINE_VISIBILITY2014 _LIBCPP_INLINE_VISIBILITY
2037 packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f)2015 packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f)
2038 : __f_(allocator_arg, __a, _VSTD::forward<_Fp>(__f)),2016 : __f_(allocator_arg, __a, _VSTD::forward<_Fp>(__f)),
...@@ -2458,6 +2436,4 @@ future<void>::share() _NOEXCEPT...@@ -2458,6 +2436,4 @@ future<void>::share() _NOEXCEPT
24582436
2459_LIBCPP_END_NAMESPACE_STD2437_LIBCPP_END_NAMESPACE_STD
24602438
2461#endif // !_LIBCPP_HAS_NO_THREADS
2462
2463#endif // _LIBCPP_FUTURE2439#endif // _LIBCPP_FUTURE
lib/libcxx/include/initializer_list+2-1
...@@ -42,11 +42,12 @@ template<class E> const E* end(initializer_list<E> il) noexcept; // constexpr in...@@ -42,11 +42,12 @@ template<class E> const E* end(initializer_list<E> il) noexcept; // constexpr in
4242
43*/43*/
4444
45#include <__assert> // all public C++ headers provide the assertion handler
45#include <__config>46#include <__config>
46#include <cstddef>47#include <cstddef>
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
50#endif51#endif
5152
52namespace std // purposefully not versioned53namespace std // purposefully not versioned
lib/libcxx/include/inttypes.h+1-1
...@@ -238,7 +238,7 @@ uintmax_t wcstoumax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int...@@ -238,7 +238,7 @@ uintmax_t wcstoumax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int
238#include <__config>238#include <__config>
239239
240#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)240#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
241#pragma GCC system_header241# pragma GCC system_header
242#endif242#endif
243243
244/* C99 stdlib (e.g. glibc < 2.18) does not provide format macros needed244/* C99 stdlib (e.g. glibc < 2.18) does not provide format macros needed
lib/libcxx/include/iomanip+84-91
...@@ -42,13 +42,13 @@ template <class charT, class traits, class Allocator>...@@ -42,13 +42,13 @@ template <class charT, class traits, class Allocator>
4242
43*/43*/
4444
45#include <__assert> // all public C++ headers provide the assertion handler
45#include <__config>46#include <__config>
46#include <__string>
47#include <istream>47#include <istream>
48#include <version>48#include <version>
4949
50#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)50#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
51#pragma GCC system_header51# pragma GCC system_header
52#endif52#endif
5353
54_LIBCPP_BEGIN_NAMESPACE_STD54_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -513,16 +513,17 @@ put_time(const tm* __tm, const _CharT* __fmt)...@@ -513,16 +513,17 @@ put_time(const tm* __tm, const _CharT* __fmt)
513 return __iom_t10<_CharT>(__tm, __fmt);513 return __iom_t10<_CharT>(__tm, __fmt);
514}514}
515515
516template <class _CharT, class _Traits, class _ForwardIterator>516#if _LIBCPP_STD_VER >= 11
517basic_ostream<_CharT, _Traits> &517
518__quoted_output ( basic_ostream<_CharT, _Traits> &__os,518template <class _CharT, class _Traits>
519 _ForwardIterator __first, _ForwardIterator __last, _CharT __delim, _CharT __escape )519_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
520__quoted_output(basic_ostream<_CharT, _Traits>& __os,
521 const _CharT *__first, const _CharT *__last, _CharT __delim, _CharT __escape)
520{522{
521 basic_string<_CharT, _Traits> __str;523 basic_string<_CharT, _Traits> __str;
522 __str.push_back(__delim);524 __str.push_back(__delim);
523 for ( ; __first != __last; ++ __first )525 for (; __first != __last; ++__first) {
524 {526 if (_Traits::eq(*__first, __escape) || _Traits::eq(*__first, __delim))
525 if (_Traits::eq (*__first, __escape) || _Traits::eq (*__first, __delim))
526 __str.push_back(__escape);527 __str.push_back(__escape);
527 __str.push_back(*__first);528 __str.push_back(*__first);
528 }529 }
...@@ -531,139 +532,131 @@ __quoted_output ( basic_ostream<_CharT, _Traits> &__os,...@@ -531,139 +532,131 @@ __quoted_output ( basic_ostream<_CharT, _Traits> &__os,
531}532}
532533
533template <class _CharT, class _Traits, class _String>534template <class _CharT, class _Traits, class _String>
534basic_istream<_CharT, _Traits> &535_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
535__quoted_input ( basic_istream<_CharT, _Traits> &__is, _String & __string, _CharT __delim, _CharT __escape )536__quoted_input(basic_istream<_CharT, _Traits>& __is, _String& __string, _CharT __delim, _CharT __escape)
536{537{
537 __string.clear ();538 __string.clear();
538 _CharT __c;539 _CharT __c;
539 __is >> __c;540 __is >> __c;
540 if ( __is.fail ())541 if (__is.fail())
541 return __is;542 return __is;
542543
543 if (!_Traits::eq (__c, __delim)) // no delimiter, read the whole string544 if (!_Traits::eq(__c, __delim)) {
544 {545 // no delimiter, read the whole string
545 __is.unget ();546 __is.unget();
546 __is >> __string;547 __is >> __string;
547 return __is;548 return __is;
548 }549 }
549550
550 __save_flags<_CharT, _Traits> sf(__is);551 __save_flags<_CharT, _Traits> __sf(__is);
551 noskipws (__is);552 std::noskipws(__is);
552 while (true)553 while (true) {
553 {
554 __is >> __c;554 __is >> __c;
555 if ( __is.fail ())555 if (__is.fail())
556 break;556 break;
557 if (_Traits::eq (__c, __escape))557 if (_Traits::eq(__c, __escape)) {
558 {
559 __is >> __c;558 __is >> __c;
560 if ( __is.fail ())559 if (__is.fail())
561 break;560 break;
562 }561 } else if (_Traits::eq(__c, __delim))
563 else if (_Traits::eq (__c, __delim))
564 break;562 break;
565 __string.push_back ( __c );563 __string.push_back(__c);
566 }564 }
567 return __is;565 return __is;
568}566}
569567
570568template <class _CharT, class _Traits>
571template <class _CharT, class _Traits, class _Iter>569struct _LIBCPP_HIDDEN __quoted_output_proxy
572basic_ostream<_CharT, _Traits>& operator<<(
573 basic_ostream<_CharT, _Traits>& __os,
574 const __quoted_output_proxy<_CharT, _Iter, _Traits> & __proxy)
575{570{
576 return __quoted_output (__os, __proxy.__first, __proxy.__last, __proxy.__delim, __proxy.__escape);571 const _CharT *__first_;
577}572 const _CharT *__last_;
573 _CharT __delim_;
574 _CharT __escape_;
578575
579template <class _CharT, class _Traits, class _Allocator>576 _LIBCPP_HIDE_FROM_ABI
580struct __quoted_proxy577 explicit __quoted_output_proxy(const _CharT *__f, const _CharT *__l, _CharT __d, _CharT __e)
581{578 : __first_(__f), __last_(__l), __delim_(__d), __escape_(__e) {}
582 basic_string<_CharT, _Traits, _Allocator> &__string;
583 _CharT __delim;
584 _CharT __escape;
585579
586 __quoted_proxy(basic_string<_CharT, _Traits, _Allocator> &__s, _CharT __d, _CharT __e)580 template<class _T2, __enable_if_t<_IsSame<_Traits, void>::value || _IsSame<_Traits, _T2>::value>* = nullptr>
587 : __string(__s), __delim(__d), __escape(__e) {}581 friend _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _T2>&
582 operator<<(basic_ostream<_CharT, _T2>& __os, const __quoted_output_proxy& __p) {
583 return std::__quoted_output(__os, __p.__first_, __p.__last_, __p.__delim_, __p.__escape_);
584 }
588};585};
589586
590template <class _CharT, class _Traits, class _Allocator>587template <class _CharT, class _Traits, class _Allocator>
591_LIBCPP_INLINE_VISIBILITY588struct _LIBCPP_HIDDEN __quoted_proxy
592basic_ostream<_CharT, _Traits>& operator<<(
593 basic_ostream<_CharT, _Traits>& __os,
594 const __quoted_proxy<_CharT, _Traits, _Allocator> & __proxy)
595{589{
596 return __quoted_output (__os, __proxy.__string.cbegin (), __proxy.__string.cend (), __proxy.__delim, __proxy.__escape);590 basic_string<_CharT, _Traits, _Allocator>& __string_;
597}591 _CharT __delim_;
598592 _CharT __escape_;
599// extractor for non-const basic_string& proxies
600template <class _CharT, class _Traits, class _Allocator>
601_LIBCPP_INLINE_VISIBILITY
602basic_istream<_CharT, _Traits>& operator>>(
603 basic_istream<_CharT, _Traits>& __is,
604 const __quoted_proxy<_CharT, _Traits, _Allocator> & __proxy)
605{
606 return __quoted_input ( __is, __proxy.__string, __proxy.__delim, __proxy.__escape );
607}
608593
594 _LIBCPP_HIDE_FROM_ABI
595 explicit __quoted_proxy(basic_string<_CharT, _Traits, _Allocator>& __s, _CharT __d, _CharT __e)
596 : __string_(__s), __delim_(__d), __escape_(__e) {}
609597
610template <class _CharT>598 friend _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
611_LIBCPP_INLINE_VISIBILITY599 operator<<(basic_ostream<_CharT, _Traits>& __os, const __quoted_proxy& __p) {
612__quoted_output_proxy<_CharT, const _CharT *>600 return std::__quoted_output(__os, __p.__string_.data(), __p.__string_.data() + __p.__string_.size(), __p.__delim_, __p.__escape_);
613quoted ( const _CharT *__s, _CharT __delim = _CharT('"'), _CharT __escape =_CharT('\\'))601 }
614{
615 const _CharT *__end = __s;
616 while ( *__end ) ++__end;
617 return __quoted_output_proxy<_CharT, const _CharT *> ( __s, __end, __delim, __escape );
618}
619602
603 friend _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
604 operator>>(basic_istream<_CharT, _Traits>& __is, const __quoted_proxy& __p) {
605 return std::__quoted_input(__is, __p.__string_, __p.__delim_, __p.__escape_);
606 }
607};
620608
621template <class _CharT, class _Traits, class _Allocator>609template <class _CharT, class _Traits, class _Allocator>
622_LIBCPP_INLINE_VISIBILITY610_LIBCPP_HIDE_FROM_ABI
623__quoted_output_proxy<_CharT, typename basic_string <_CharT, _Traits, _Allocator>::const_iterator>611__quoted_output_proxy<_CharT, _Traits>
624__quoted ( const basic_string <_CharT, _Traits, _Allocator> &__s, _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\'))612__quoted(const basic_string<_CharT, _Traits, _Allocator>& __s, _CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\'))
625{613{
626 return __quoted_output_proxy<_CharT,614 return __quoted_output_proxy<_CharT, _Traits>(__s.data(), __s.data() + __s.size(), __delim, __escape);
627 typename basic_string <_CharT, _Traits, _Allocator>::const_iterator>
628 ( __s.cbegin(), __s.cend (), __delim, __escape );
629}615}
630616
631template <class _CharT, class _Traits, class _Allocator>617template <class _CharT, class _Traits, class _Allocator>
632_LIBCPP_INLINE_VISIBILITY618_LIBCPP_HIDE_FROM_ABI
633__quoted_proxy<_CharT, _Traits, _Allocator>619__quoted_proxy<_CharT, _Traits, _Allocator>
634__quoted ( basic_string <_CharT, _Traits, _Allocator> &__s, _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\'))620__quoted(basic_string<_CharT, _Traits, _Allocator>& __s, _CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\'))
635{621{
636 return __quoted_proxy<_CharT, _Traits, _Allocator>( __s, __delim, __escape );622 return __quoted_proxy<_CharT, _Traits, _Allocator>(__s, __delim, __escape);
637}623}
638624
625#endif // _LIBCPP_STD_VER >= 11
639626
640#if _LIBCPP_STD_VER > 11627#if _LIBCPP_STD_VER > 11
641628
629template <class _CharT>
630_LIBCPP_HIDE_FROM_ABI
631auto quoted(const _CharT *__s, _CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\'))
632{
633 const _CharT *__end = __s;
634 while (*__end) ++__end;
635 return __quoted_output_proxy<_CharT, void>(__s, __end, __delim, __escape);
636}
637
642template <class _CharT, class _Traits, class _Allocator>638template <class _CharT, class _Traits, class _Allocator>
643_LIBCPP_INLINE_VISIBILITY639_LIBCPP_HIDE_FROM_ABI
644__quoted_output_proxy<_CharT, typename basic_string <_CharT, _Traits, _Allocator>::const_iterator>640auto quoted(const basic_string<_CharT, _Traits, _Allocator>& __s, _CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\'))
645quoted ( const basic_string <_CharT, _Traits, _Allocator> &__s, _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\'))
646{641{
647 return __quoted(__s, __delim, __escape);642 return __quoted_output_proxy<_CharT, _Traits>(__s.data(), __s.data() + __s.size(), __delim, __escape);
648}643}
649644
650template <class _CharT, class _Traits, class _Allocator>645template <class _CharT, class _Traits, class _Allocator>
651_LIBCPP_INLINE_VISIBILITY646_LIBCPP_HIDE_FROM_ABI
652__quoted_proxy<_CharT, _Traits, _Allocator>647auto quoted(basic_string<_CharT, _Traits, _Allocator>& __s, _CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\'))
653quoted ( basic_string <_CharT, _Traits, _Allocator> &__s, _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\'))
654{648{
655 return __quoted(__s, __delim, __escape);649 return __quoted_proxy<_CharT, _Traits, _Allocator>(__s, __delim, __escape);
656}650}
657651
658template <class _CharT, class _Traits>652template <class _CharT, class _Traits>
659__quoted_output_proxy<_CharT, const _CharT *, _Traits>653_LIBCPP_HIDE_FROM_ABI
660quoted (basic_string_view <_CharT, _Traits> __sv,654auto quoted(basic_string_view<_CharT, _Traits> __sv, _CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\'))
661 _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\'))
662{655{
663 return __quoted_output_proxy<_CharT, const _CharT *, _Traits>656 return __quoted_output_proxy<_CharT, _Traits>(__sv.data(), __sv.data() + __sv.size(), __delim, __escape);
664 ( __sv.data(), __sv.data() + __sv.size(), __delim, __escape );
665}657}
666#endif658
659#endif // _LIBCPP_STD_VER > 11
667660
668_LIBCPP_END_NAMESPACE_STD661_LIBCPP_END_NAMESPACE_STD
669662
lib/libcxx/include/ios+15-3
...@@ -211,17 +211,27 @@ storage-class-specifier const error_category& iostream_category() noexcept;...@@ -211,17 +211,27 @@ storage-class-specifier const error_category& iostream_category() noexcept;
211*/211*/
212212
213#include <__config>213#include <__config>
214
215#if defined(_LIBCPP_HAS_NO_LOCALIZATION)
216# error "The iostreams library is not supported since libc++ has been configured without support for localization."
217#endif
218
219#include <__assert> // all public C++ headers provide the assertion handler
220#include <__ios/fpos.h>
214#include <__locale>221#include <__locale>
215#include <iosfwd>222#include <__utility/swap.h>
216#include <system_error>223#include <system_error>
217#include <version>224#include <version>
218225
226// standard-mandated includes
227#include <iosfwd>
228
219#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)229#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
220#include <atomic> // for __xindex_230#include <atomic> // for __xindex_
221#endif231#endif
222232
223#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)233#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
224#pragma GCC system_header234# pragma GCC system_header
225#endif235#endif
226236
227_LIBCPP_BEGIN_NAMESPACE_STD237_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -402,7 +412,7 @@ _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(io_errc)...@@ -402,7 +412,7 @@ _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(io_errc)
402template <>412template <>
403struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<io_errc> : public true_type { };413struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<io_errc> : public true_type { };
404414
405#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS415#ifdef _LIBCPP_CXX03_LANG
406template <>416template <>
407struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<io_errc::__lx> : public true_type { };417struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<io_errc::__lx> : public true_type { };
408#endif418#endif
...@@ -780,6 +790,8 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -780,6 +790,8 @@ inline _LIBCPP_INLINE_VISIBILITY
780_CharT790_CharT
781basic_ios<_CharT, _Traits>::fill(char_type __ch)791basic_ios<_CharT, _Traits>::fill(char_type __ch)
782{792{
793 if (traits_type::eq_int_type(traits_type::eof(), __fill_))
794 __fill_ = widen(' ');
783 char_type __r = __fill_;795 char_type __r = __fill_;
784 __fill_ = __ch;796 __fill_ = __ch;
785 return __r;797 return __r;
lib/libcxx/include/iosfwd+2-3
...@@ -94,12 +94,13 @@ using u32streampos = fpos<char_traits<char32_t>::state_type>;...@@ -94,12 +94,13 @@ using u32streampos = fpos<char_traits<char32_t>::state_type>;
9494
95*/95*/
9696
97#include <__assert> // all public C++ headers provide the assertion handler
97#include <__config>98#include <__config>
98#include <__mbstate_t.h>99#include <__mbstate_t.h>
99#include <version>100#include <version>
100101
101#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)102#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
102#pragma GCC system_header103# pragma GCC system_header
103#endif104#endif
104105
105_LIBCPP_BEGIN_NAMESPACE_STD106_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -231,10 +232,8 @@ typedef fpos<mbstate_t> wstreampos;...@@ -231,10 +232,8 @@ typedef fpos<mbstate_t> wstreampos;
231#ifndef _LIBCPP_HAS_NO_CHAR8_T232#ifndef _LIBCPP_HAS_NO_CHAR8_T
232typedef fpos<mbstate_t> u8streampos;233typedef fpos<mbstate_t> u8streampos;
233#endif234#endif
234#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
235typedef fpos<mbstate_t> u16streampos;235typedef fpos<mbstate_t> u16streampos;
236typedef fpos<mbstate_t> u32streampos;236typedef fpos<mbstate_t> u32streampos;
237#endif
238237
239#if defined(_NEWLIB_VERSION)238#if defined(_NEWLIB_VERSION)
240// On newlib, off_t is 'long int'239// On newlib, off_t is 'long int'
lib/libcxx/include/iostream+5-2
...@@ -33,15 +33,18 @@ extern wostream wclog;...@@ -33,15 +33,18 @@ extern wostream wclog;
3333
34*/34*/
3535
36#include <__assert> // all public C++ headers provide the assertion handler
36#include <__config>37#include <__config>
38#include <version>
39
40// standard-mandated includes
37#include <ios>41#include <ios>
38#include <istream>42#include <istream>
39#include <ostream>43#include <ostream>
40#include <streambuf>44#include <streambuf>
41#include <version>
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
lib/libcxx/include/istream+7-5
...@@ -158,13 +158,15 @@ template <class Stream, class T>...@@ -158,13 +158,15 @@ template <class Stream, class T>
158158
159*/159*/
160160
161#include <__assert> // all public C++ headers provide the assertion handler
161#include <__config>162#include <__config>
163#include <__iterator/istreambuf_iterator.h>
162#include <__utility/forward.h>164#include <__utility/forward.h>
163#include <ostream>165#include <ostream>
164#include <version>166#include <version>
165167
166#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)168#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
167#pragma GCC system_header169# pragma GCC system_header
168#endif170#endif
169171
170_LIBCPP_PUSH_MACROS172_LIBCPP_PUSH_MACROS
...@@ -1592,7 +1594,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x)...@@ -1592,7 +1594,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x)
1592 size_t __c = 0;1594 size_t __c = 0;
1593 _CharT __zero = __ct.widen('0');1595 _CharT __zero = __ct.widen('0');
1594 _CharT __one = __ct.widen('1');1596 _CharT __one = __ct.widen('1');
1595 while (__c < _Size)1597 while (__c != _Size)
1596 {1598 {
1597 typename _Traits::int_type __i = __is.rdbuf()->sgetc();1599 typename _Traits::int_type __i = __is.rdbuf()->sgetc();
1598 if (_Traits::eq_int_type(__i, _Traits::eof()))1600 if (_Traits::eq_int_type(__i, _Traits::eof()))
...@@ -1627,11 +1629,11 @@ operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x)...@@ -1627,11 +1629,11 @@ operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x)
1627 return __is;1629 return __is;
1628}1630}
16291631
1630_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istream<char>)1632extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istream<char>;
1631#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS1633#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
1632_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istream<wchar_t>)1634extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istream<wchar_t>;
1633#endif1635#endif
1634_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_iostream<char>)1636extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_iostream<char>;
16351637
1636_LIBCPP_END_NAMESPACE_STD1638_LIBCPP_END_NAMESPACE_STD
16371639
lib/libcxx/include/iterator+132-29
...@@ -136,6 +136,13 @@ template<class In, class Out>...@@ -136,6 +136,13 @@ template<class In, class Out>
136template<class In, class Out>136template<class In, class Out>
137 concept indirectly_movable_storable = see below; // since C++20137 concept indirectly_movable_storable = see below; // since C++20
138138
139// [alg.req.ind.copy], concept indirectly_copyable
140template<class In, class Out>
141 concept indirectly_copyable = see below; // since C++20
142
143template<class In, class Out>
144 concept indirectly_copyable_storable = see below; // since C++20
145
139// [alg.req.ind.swap], concept indirectly_swappable146// [alg.req.ind.swap], concept indirectly_swappable
140template<class I1, class I2 = I1>147template<class I1, class I2 = I1>
141 concept indirectly_swappable = see below; // since C++20148 concept indirectly_swappable = see below; // since C++20
...@@ -145,6 +152,19 @@ template<class I1, class I2, class R, class P1 = identity,...@@ -145,6 +152,19 @@ template<class I1, class I2, class R, class P1 = identity,
145 concept indirectly_comparable =152 concept indirectly_comparable =
146 indirect_binary_predicate<R, projected<I1, P1>, projected<I2, P2>>; // since C++20153 indirect_binary_predicate<R, projected<I1, P1>, projected<I2, P2>>; // since C++20
147154
155// [alg.req.permutable], concept permutable
156template<class I>
157 concept permutable = see below; // since C++20
158
159 // [alg.req.mergeable], concept mergeable
160template<class I1, class I2, class Out,
161 class R = ranges::less, class P1 = identity, class P2 = identity>
162 concept mergeable = see below; // since C++20
163
164// [alg.req.sortable], concept sortable
165template<class I, class R = ranges::less, class P = identity>
166 concept sortable = see below; // since C++20
167
148template<input_or_output_iterator I, sentinel_for<I> S>168template<input_or_output_iterator I, sentinel_for<I> S>
149 requires (!same_as<I, S> && copyable<I>)169 requires (!same_as<I, S> && copyable<I>)
150class common_iterator; // since C++20170class common_iterator; // since C++20
...@@ -165,6 +185,7 @@ struct output_iterator_tag {};...@@ -165,6 +185,7 @@ struct output_iterator_tag {};
165struct forward_iterator_tag : public input_iterator_tag {};185struct forward_iterator_tag : public input_iterator_tag {};
166struct bidirectional_iterator_tag : public forward_iterator_tag {};186struct bidirectional_iterator_tag : public forward_iterator_tag {};
167struct random_access_iterator_tag : public bidirectional_iterator_tag {};187struct random_access_iterator_tag : public bidirectional_iterator_tag {};
188struct contiguous_iterator_tag : public random_access_iterator_tag {};
168189
169// 27.4.3, iterator operations190// 27.4.3, iterator operations
170template <class InputIterator, class Distance> // constexpr in C++17191template <class InputIterator, class Distance> // constexpr in C++17
...@@ -204,10 +225,17 @@ class reverse_iterator...@@ -204,10 +225,17 @@ class reverse_iterator
204protected:225protected:
205 Iterator current;226 Iterator current;
206public:227public:
207 typedef Iterator iterator_type;228 using iterator_type = Iterator;
208 typedef typename iterator_traits<Iterator>::difference_type difference_type;229 using iterator_concept = see below; // since C++20
209 typedef typename iterator_traits<Iterator>::reference reference;230 using iterator_category = typename iterator_traits<Iterator>::iterator_category; // since C++17, until C++20
210 typedef typename iterator_traits<Iterator>::pointer pointer;231 using iterator_category = see below; // since C++20
232 using value_type = typename iterator_traits<Iterator>::value_type; // since C++17, until C++20
233 using value_type = iter_value_t<Iterator>; // since C++20
234 using difference_type = typename iterator_traits<Iterator>::difference_type; // until C++20
235 using difference_type = iter_difference_t<Iterator>; // since C++20
236 using pointer = typename iterator_traits<Iterator>::pointer;
237 using reference = typename iterator_traits<Iterator>::reference; // until C++20
238 using reference = iter_reference_t<Iterator>; // since C++20
211239
212 constexpr reverse_iterator();240 constexpr reverse_iterator();
213 constexpr explicit reverse_iterator(Iterator x);241 constexpr explicit reverse_iterator(Iterator x);
...@@ -215,7 +243,8 @@ public:...@@ -215,7 +243,8 @@ public:
215 template <class U> constexpr reverse_iterator& operator=(const reverse_iterator<U>& u);243 template <class U> constexpr reverse_iterator& operator=(const reverse_iterator<U>& u);
216 constexpr Iterator base() const;244 constexpr Iterator base() const;
217 constexpr reference operator*() const;245 constexpr reference operator*() const;
218 constexpr pointer operator->() const;246 constexpr pointer operator->() const; // until C++20
247 constexpr pointer operator->() const requires see below; // since C++20
219 constexpr reverse_iterator& operator++();248 constexpr reverse_iterator& operator++();
220 constexpr reverse_iterator operator++(int);249 constexpr reverse_iterator operator++(int);
221 constexpr reverse_iterator& operator--();250 constexpr reverse_iterator& operator--();
...@@ -224,7 +253,14 @@ public:...@@ -224,7 +253,14 @@ public:
224 constexpr reverse_iterator& operator+=(difference_type n);253 constexpr reverse_iterator& operator+=(difference_type n);
225 constexpr reverse_iterator operator- (difference_type n) const;254 constexpr reverse_iterator operator- (difference_type n) const;
226 constexpr reverse_iterator& operator-=(difference_type n);255 constexpr reverse_iterator& operator-=(difference_type n);
227 constexpr reference operator[](difference_type n) const;256 constexpr unspecified operator[](difference_type n) const;
257
258 friend constexpr iter_rvalue_reference_t<Iterator>
259 iter_move(const reverse_iterator& i) noexcept(see below);
260 template<indirectly_swappable<Iterator> Iterator2>
261 friend constexpr void
262 iter_swap(const reverse_iterator& x,
263 const reverse_iterator<Iterator2>& y) noexcept(see below);
228};264};
229265
230template <class Iterator1, class Iterator2>266template <class Iterator1, class Iterator2>
...@@ -233,11 +269,11 @@ operator==(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator...@@ -233,11 +269,11 @@ operator==(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator
233269
234template <class Iterator1, class Iterator2>270template <class Iterator1, class Iterator2>
235constexpr bool // constexpr in C++17271constexpr bool // constexpr in C++17
236operator<(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y);272operator!=(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y);
237273
238template <class Iterator1, class Iterator2>274template <class Iterator1, class Iterator2>
239constexpr bool // constexpr in C++17275constexpr bool // constexpr in C++17
240operator!=(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y);276operator<(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y);
241277
242template <class Iterator1, class Iterator2>278template <class Iterator1, class Iterator2>
243constexpr bool // constexpr in C++17279constexpr bool // constexpr in C++17
...@@ -245,11 +281,16 @@ operator>(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2...@@ -245,11 +281,16 @@ operator>(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2
245281
246template <class Iterator1, class Iterator2>282template <class Iterator1, class Iterator2>
247constexpr bool // constexpr in C++17283constexpr bool // constexpr in C++17
248operator>=(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y);284operator<=(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y);
249285
250template <class Iterator1, class Iterator2>286template <class Iterator1, class Iterator2>
251constexpr bool // constexpr in C++17287constexpr bool // constexpr in C++17
252operator<=(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y);288operator>=(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y);
289
290template<class Iterator1, three_way_comparable_with<Iterator1> Iterator2>
291 constexpr compare_three_way_result_t<Iterator1, Iterator2>
292 operator<=>(const reverse_iterator<Iterator1>& x,
293 const reverse_iterator<Iterator2>& y);
253294
254template <class Iterator1, class Iterator2>295template <class Iterator1, class Iterator2>
255constexpr auto296constexpr auto
...@@ -264,6 +305,11 @@ operator+(typename reverse_iterator<Iterator>::difference_type n,...@@ -264,6 +305,11 @@ operator+(typename reverse_iterator<Iterator>::difference_type n,
264template <class Iterator>305template <class Iterator>
265constexpr reverse_iterator<Iterator> make_reverse_iterator(Iterator i); // C++14, constexpr in C++17306constexpr reverse_iterator<Iterator> make_reverse_iterator(Iterator i); // C++14, constexpr in C++17
266307
308template<class Iterator1, class Iterator2>
309 requires (!sized_sentinel_for<Iterator1, Iterator2>)
310 inline constexpr bool disable_sized_sentinel_for<reverse_iterator<Iterator1>,
311 reverse_iterator<Iterator2>> = true;
312
267template <class Container>313template <class Container>
268class back_insert_iterator314class back_insert_iterator
269 : public iterator<output_iterator_tag, void, void, void, void> // until C++17315 : public iterator<output_iterator_tag, void, void, void, void> // until C++17
...@@ -332,18 +378,21 @@ public:...@@ -332,18 +378,21 @@ public:
332 insert_iterator& operator++(int); // constexpr in C++20378 insert_iterator& operator++(int); // constexpr in C++20
333};379};
334380
335template <class Container, class Iterator>381template <class Container>
336insert_iterator<Container> inserter(Container& x, Iterator i); // constexpr in C++20382insert_iterator<Container> inserter(Container& x, typename Container::iterator i); // until C++20
383template <class Container>
384constexpr insert_iterator<Container> inserter(Container& x, ranges::iterator_t<Container> i); // since C++20
337385
338template <class Iterator>386template <class Iterator>
339class move_iterator {387class move_iterator {
340public:388public:
341 typedef Iterator iterator_type;389 using iterator_type = Iterator;
342 typedef typename iterator_traits<Iterator>::difference_type difference_type;390 using iterator_concept = input_iterator_tag; // From C++20
343 typedef Iterator pointer;391 using iterator_category = see below; // not always present starting from C++20
344 typedef typename iterator_traits<Iterator>::value_type value_type;392 using value_type = iter_value_t<Iterator>; // Until C++20, iterator_traits<Iterator>::value_type
345 typedef typename iterator_traits<Iterator>::iterator_category iterator_category;393 using difference_type = iter_difference_t<Iterator>; // Until C++20, iterator_traits<Iterator>::difference_type;
346 typedef value_type&& reference;394 using pointer = Iterator;
395 using reference = iter_rvalue_reference_t<Iterator>; // Until C++20, value_type&&
347396
348 constexpr move_iterator(); // all the constexprs are in C++17397 constexpr move_iterator(); // all the constexprs are in C++17
349 constexpr explicit move_iterator(Iterator i);398 constexpr explicit move_iterator(Iterator i);
...@@ -351,18 +400,40 @@ public:...@@ -351,18 +400,40 @@ public:
351 constexpr move_iterator(const move_iterator<U>& u);400 constexpr move_iterator(const move_iterator<U>& u);
352 template <class U>401 template <class U>
353 constexpr move_iterator& operator=(const move_iterator<U>& u);402 constexpr move_iterator& operator=(const move_iterator<U>& u);
354 constexpr iterator_type base() const;403
404 constexpr iterator_type base() const; // Until C++20
405 constexpr const Iterator& base() const & noexcept; // From C++20
406 constexpr Iterator base() &&; // From C++20
407
355 constexpr reference operator*() const;408 constexpr reference operator*() const;
356 constexpr pointer operator->() const;409 constexpr pointer operator->() const; // Deprecated in C++20
357 constexpr move_iterator& operator++();410 constexpr move_iterator& operator++();
358 constexpr move_iterator operator++(int);411 constexpr auto operator++(int); // Return type was move_iterator until C++20
359 constexpr move_iterator& operator--();412 constexpr move_iterator& operator--();
360 constexpr move_iterator operator--(int);413 constexpr move_iterator operator--(int);
361 constexpr move_iterator operator+(difference_type n) const;414 constexpr move_iterator operator+(difference_type n) const;
362 constexpr move_iterator& operator+=(difference_type n);415 constexpr move_iterator& operator+=(difference_type n);
363 constexpr move_iterator operator-(difference_type n) const;416 constexpr move_iterator operator-(difference_type n) const;
364 constexpr move_iterator& operator-=(difference_type n);417 constexpr move_iterator& operator-=(difference_type n);
365 constexpr unspecified operator[](difference_type n) const;418 constexpr reference operator[](difference_type n) const; // Return type unspecified until C++20
419
420 template<sentinel_for<Iterator> S>
421 friend constexpr bool
422 operator==(const move_iterator& x, const move_sentinel<S>& y); // Since C++20
423 template<sized_sentinel_for<Iterator> S>
424 friend constexpr iter_difference_t<Iterator>
425 operator-(const move_sentinel<S>& x, const move_iterator& y); // Since C++20
426 template<sized_sentinel_for<Iterator> S>
427 friend constexpr iter_difference_t<Iterator>
428 operator-(const move_iterator& x, const move_sentinel<S>& y); // Since C++20
429 friend constexpr iter_rvalue_reference_t<Iterator>
430 iter_move(const move_iterator& i)
431 noexcept(noexcept(ranges::iter_move(i.current))); // Since C++20
432 template<indirectly_swappable<Iterator> Iterator2>
433 friend constexpr void
434 iter_swap(const move_iterator& x, const move_iterator<Iterator2>& y)
435 noexcept(noexcept(ranges::iter_swap(x.current, y.current))); // Since C++20
436
366private:437private:
367 Iterator current; // exposition only438 Iterator current; // exposition only
368};439};
...@@ -404,6 +475,23 @@ constexpr move_iterator<Iterator> operator+( // constexpr in C++17...@@ -404,6 +475,23 @@ constexpr move_iterator<Iterator> operator+( // constexpr in C++17
404template <class Iterator> // constexpr in C++17475template <class Iterator> // constexpr in C++17
405constexpr move_iterator<Iterator> make_move_iterator(const Iterator& i);476constexpr move_iterator<Iterator> make_move_iterator(const Iterator& i);
406477
478template<semiregular S>
479class move_sentinel {
480public:
481 constexpr move_sentinel();
482 constexpr explicit move_sentinel(S s);
483 template<class S2>
484 requires convertible_to<const S2&, S>
485 constexpr move_sentinel(const move_sentinel<S2>& s);
486 template<class S2>
487 requires assignable_from<S&, const S2&>
488 constexpr move_sentinel& operator=(const move_sentinel<S2>& s);
489
490 constexpr S base() const;
491private:
492 S last; // exposition only
493};
494
407// [default.sentinel], default sentinel495// [default.sentinel], default sentinel
408struct default_sentinel_t;496struct default_sentinel_t;
409inline constexpr default_sentinel_t default_sentinel{};497inline constexpr default_sentinel_t default_sentinel{};
...@@ -434,7 +522,8 @@ public:...@@ -434,7 +522,8 @@ public:
434 typedef traits traits_type;522 typedef traits traits_type;
435 typedef basic_istream<charT, traits> istream_type;523 typedef basic_istream<charT, traits> istream_type;
436524
437 constexpr istream_iterator();525 istream_iterator(); // constexpr since C++11
526 constexpr istream_iterator(default_sentinel_t); // since C++20
438 istream_iterator(istream_type& s);527 istream_iterator(istream_type& s);
439 istream_iterator(const istream_iterator& x);528 istream_iterator(const istream_iterator& x);
440 ~istream_iterator();529 ~istream_iterator();
...@@ -443,6 +532,7 @@ public:...@@ -443,6 +532,7 @@ public:
443 const T* operator->() const;532 const T* operator->() const;
444 istream_iterator& operator++();533 istream_iterator& operator++();
445 istream_iterator operator++(int);534 istream_iterator operator++(int);
535 friend bool operator==(const istream_iterator& i, default_sentinel_t); // since C++20
446};536};
447537
448template <class T, class charT, class traits, class Distance>538template <class T, class charT, class traits, class Distance>
...@@ -450,7 +540,7 @@ bool operator==(const istream_iterator<T,charT,traits,Distance>& x,...@@ -450,7 +540,7 @@ bool operator==(const istream_iterator<T,charT,traits,Distance>& x,
450 const istream_iterator<T,charT,traits,Distance>& y);540 const istream_iterator<T,charT,traits,Distance>& y);
451template <class T, class charT, class traits, class Distance>541template <class T, class charT, class traits, class Distance>
452bool operator!=(const istream_iterator<T,charT,traits,Distance>& x,542bool operator!=(const istream_iterator<T,charT,traits,Distance>& x,
453 const istream_iterator<T,charT,traits,Distance>& y);543 const istream_iterator<T,charT,traits,Distance>& y); // until C++20
454544
455template <class T, class charT = char, class traits = char_traits<charT> >545template <class T, class charT = char, class traits = char_traits<charT> >
456class ostream_iterator546class ostream_iterator
...@@ -496,7 +586,8 @@ public:...@@ -496,7 +586,8 @@ public:
496 typedef basic_streambuf<charT, traits> streambuf_type;586 typedef basic_streambuf<charT, traits> streambuf_type;
497 typedef basic_istream<charT, traits> istream_type;587 typedef basic_istream<charT, traits> istream_type;
498588
499 istreambuf_iterator() noexcept;589 istreambuf_iterator() noexcept; // constexpr since C++11
590 constexpr istreambuf_iterator(default_sentinel_t) noexcept; // since C++20
500 istreambuf_iterator(istream_type& s) noexcept;591 istreambuf_iterator(istream_type& s) noexcept;
501 istreambuf_iterator(streambuf_type* s) noexcept;592 istreambuf_iterator(streambuf_type* s) noexcept;
502 istreambuf_iterator(a-private-type) noexcept;593 istreambuf_iterator(a-private-type) noexcept;
...@@ -507,6 +598,7 @@ public:...@@ -507,6 +598,7 @@ public:
507 a-private-type operator++(int);598 a-private-type operator++(int);
508599
509 bool equal(const istreambuf_iterator& b) const;600 bool equal(const istreambuf_iterator& b) const;
601 friend bool operator==(const istreambuf_iterator& i, default_sentinel_t s); // since C++20
510};602};
511603
512template <class charT, class traits>604template <class charT, class traits>
...@@ -514,7 +606,7 @@ bool operator==(const istreambuf_iterator<charT,traits>& a,...@@ -514,7 +606,7 @@ bool operator==(const istreambuf_iterator<charT,traits>& a,
514 const istreambuf_iterator<charT,traits>& b);606 const istreambuf_iterator<charT,traits>& b);
515template <class charT, class traits>607template <class charT, class traits>
516bool operator!=(const istreambuf_iterator<charT,traits>& a,608bool operator!=(const istreambuf_iterator<charT,traits>& a,
517 const istreambuf_iterator<charT,traits>& b);609 const istreambuf_iterator<charT,traits>& b); // until C++20
518610
519template <class charT, class traits = char_traits<charT> >611template <class charT, class traits = char_traits<charT> >
520class ostreambuf_iterator612class ostreambuf_iterator
...@@ -582,12 +674,13 @@ template <class E> constexpr const E* data(initializer_list<E> il) noexcept;...@@ -582,12 +674,13 @@ template <class E> constexpr const E* data(initializer_list<E> il) noexcept;
582674
583*/675*/
584676
677#include <__assert> // all public C++ headers provide the assertion handler
585#include <__config>678#include <__config>
586#include <__debug>679#include <__debug>
587#include <__functional_base>
588#include <__iterator/access.h>680#include <__iterator/access.h>
589#include <__iterator/advance.h>681#include <__iterator/advance.h>
590#include <__iterator/back_insert_iterator.h>682#include <__iterator/back_insert_iterator.h>
683#include <__iterator/bounded_iter.h>
591#include <__iterator/common_iterator.h>684#include <__iterator/common_iterator.h>
592#include <__iterator/concepts.h>685#include <__iterator/concepts.h>
593#include <__iterator/counted_iterator.h>686#include <__iterator/counted_iterator.h>
...@@ -606,21 +699,24 @@ template <class E> constexpr const E* data(initializer_list<E> il) noexcept;...@@ -606,21 +699,24 @@ template <class E> constexpr const E* data(initializer_list<E> il) noexcept;
606#include <__iterator/iter_swap.h>699#include <__iterator/iter_swap.h>
607#include <__iterator/iterator.h>700#include <__iterator/iterator.h>
608#include <__iterator/iterator_traits.h>701#include <__iterator/iterator_traits.h>
702#include <__iterator/mergeable.h>
609#include <__iterator/move_iterator.h>703#include <__iterator/move_iterator.h>
704#include <__iterator/move_sentinel.h>
610#include <__iterator/next.h>705#include <__iterator/next.h>
611#include <__iterator/ostream_iterator.h>706#include <__iterator/ostream_iterator.h>
612#include <__iterator/ostreambuf_iterator.h>707#include <__iterator/ostreambuf_iterator.h>
708#include <__iterator/permutable.h>
613#include <__iterator/prev.h>709#include <__iterator/prev.h>
614#include <__iterator/projected.h>710#include <__iterator/projected.h>
615#include <__iterator/readable_traits.h>711#include <__iterator/readable_traits.h>
616#include <__iterator/reverse_access.h>712#include <__iterator/reverse_access.h>
617#include <__iterator/reverse_iterator.h>713#include <__iterator/reverse_iterator.h>
618#include <__iterator/size.h>714#include <__iterator/size.h>
715#include <__iterator/sortable.h>
619#include <__iterator/unreachable_sentinel.h>716#include <__iterator/unreachable_sentinel.h>
620#include <__iterator/wrap_iter.h>717#include <__iterator/wrap_iter.h>
621#include <__memory/addressof.h>718#include <__memory/addressof.h>
622#include <__memory/pointer_traits.h>719#include <__memory/pointer_traits.h>
623#include <__utility/forward.h>
624#include <compare>720#include <compare>
625#include <concepts> // Mandated by the Standard.721#include <concepts> // Mandated by the Standard.
626#include <cstddef>722#include <cstddef>
...@@ -628,8 +724,15 @@ template <class E> constexpr const E* data(initializer_list<E> il) noexcept;...@@ -628,8 +724,15 @@ template <class E> constexpr const E* data(initializer_list<E> il) noexcept;
628#include <type_traits>724#include <type_traits>
629#include <version>725#include <version>
630726
727#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
728# include <exception>
729# include <new>
730# include <typeinfo>
731# include <utility>
732#endif
733
631#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)734#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
632#pragma GCC system_header735# pragma GCC system_header
633#endif736#endif
634737
635#endif // _LIBCPP_ITERATOR738#endif // _LIBCPP_ITERATOR
lib/libcxx/include/latch+6-5
...@@ -40,17 +40,19 @@ namespace std...@@ -40,17 +40,19 @@ namespace std
4040
41*/41*/
4242
43#include <__assert> // all public C++ headers provide the assertion handler
43#include <__availability>44#include <__availability>
44#include <__config>45#include <__config>
45#include <atomic>46#include <atomic>
47#include <limits>
46#include <version>48#include <version>
4749
48#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)50#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
49#pragma GCC system_header51# pragma GCC system_header
50#endif52#endif
5153
52#ifdef _LIBCPP_HAS_NO_THREADS54#ifdef _LIBCPP_HAS_NO_THREADS
53# error <latch> is not supported on this single threaded system55# error "<latch> is not supported since libc++ has been configured without support for threads."
54#endif56#endif
5557
56_LIBCPP_PUSH_MACROS58_LIBCPP_PUSH_MACROS
...@@ -91,10 +93,9 @@ public:...@@ -91,10 +93,9 @@ public:
91 inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY93 inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
92 void wait() const94 void wait() const
93 {95 {
94 auto const __test_fn = [=]() -> bool {96 __cxx_atomic_wait(&__a.__a_, [&]() -> bool {
95 return try_wait();97 return try_wait();
96 };98 });
97 __cxx_atomic_wait(&__a.__a_, __test_fn);
98 }99 }
99 inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY100 inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
100 void arrive_and_wait(ptrdiff_t __update = 1)101 void arrive_and_wait(ptrdiff_t __update = 1)
lib/libcxx/include/limits+15-5
...@@ -101,6 +101,8 @@ template<> class numeric_limits<cv long double>;...@@ -101,6 +101,8 @@ template<> class numeric_limits<cv long double>;
101} // std101} // std
102102
103*/103*/
104
105#include <__assert> // all public C++ headers provide the assertion handler
104#include <__config>106#include <__config>
105#include <type_traits>107#include <type_traits>
106108
...@@ -108,12 +110,8 @@ template<> class numeric_limits<cv long double>;...@@ -108,12 +110,8 @@ template<> class numeric_limits<cv long double>;
108#include "__support/win32/limits_msvc_win32.h"110#include "__support/win32/limits_msvc_win32.h"
109#endif // _LIBCPP_MSVCRT111#endif // _LIBCPP_MSVCRT
110112
111#if defined(__IBMCPP__)
112#include "__support/ibm/limits.h"
113#endif // __IBMCPP__
114
115#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)113#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
116#pragma GCC system_header114# pragma GCC system_header
117#endif115#endif
118116
119_LIBCPP_PUSH_MACROS117_LIBCPP_PUSH_MACROS
...@@ -339,7 +337,11 @@ protected:...@@ -339,7 +337,11 @@ protected:
339 static _LIBCPP_CONSTEXPR const bool is_modulo = false;337 static _LIBCPP_CONSTEXPR const bool is_modulo = false;
340338
341 static _LIBCPP_CONSTEXPR const bool traps = false;339 static _LIBCPP_CONSTEXPR const bool traps = false;
340#if (defined(__arm__) || defined(__aarch64__))
341 static _LIBCPP_CONSTEXPR const bool tinyness_before = true;
342#else
342 static _LIBCPP_CONSTEXPR const bool tinyness_before = false;343 static _LIBCPP_CONSTEXPR const bool tinyness_before = false;
344#endif
343 static _LIBCPP_CONSTEXPR const float_round_style round_style = round_to_nearest;345 static _LIBCPP_CONSTEXPR const float_round_style round_style = round_to_nearest;
344};346};
345347
...@@ -385,7 +387,11 @@ protected:...@@ -385,7 +387,11 @@ protected:
385 static _LIBCPP_CONSTEXPR const bool is_modulo = false;387 static _LIBCPP_CONSTEXPR const bool is_modulo = false;
386388
387 static _LIBCPP_CONSTEXPR const bool traps = false;389 static _LIBCPP_CONSTEXPR const bool traps = false;
390#if (defined(__arm__) || defined(__aarch64__))
391 static _LIBCPP_CONSTEXPR const bool tinyness_before = true;
392#else
388 static _LIBCPP_CONSTEXPR const bool tinyness_before = false;393 static _LIBCPP_CONSTEXPR const bool tinyness_before = false;
394#endif
389 static _LIBCPP_CONSTEXPR const float_round_style round_style = round_to_nearest;395 static _LIBCPP_CONSTEXPR const float_round_style round_style = round_to_nearest;
390};396};
391397
...@@ -435,7 +441,11 @@ protected:...@@ -435,7 +441,11 @@ protected:
435 static _LIBCPP_CONSTEXPR const bool is_modulo = false;441 static _LIBCPP_CONSTEXPR const bool is_modulo = false;
436442
437 static _LIBCPP_CONSTEXPR const bool traps = false;443 static _LIBCPP_CONSTEXPR const bool traps = false;
444#if (defined(__arm__) || defined(__aarch64__))
445 static _LIBCPP_CONSTEXPR const bool tinyness_before = true;
446#else
438 static _LIBCPP_CONSTEXPR const bool tinyness_before = false;447 static _LIBCPP_CONSTEXPR const bool tinyness_before = false;
448#endif
439 static _LIBCPP_CONSTEXPR const float_round_style round_style = round_to_nearest;449 static _LIBCPP_CONSTEXPR const float_round_style round_style = round_to_nearest;
440};450};
441451
lib/libcxx/include/limits.h+1-1
...@@ -40,7 +40,7 @@ Macros:...@@ -40,7 +40,7 @@ Macros:
40#include <__config>40#include <__config>
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
44#endif44#endif
4545
46#ifndef __GNUC__46#ifndef __GNUC__
lib/libcxx/include/list+97-148
...@@ -180,19 +180,50 @@ template <class T, class Allocator, class Predicate>...@@ -180,19 +180,50 @@ template <class T, class Allocator, class Predicate>
180180
181*/181*/
182182
183#include <__algorithm/comp.h>
184#include <__algorithm/equal.h>
185#include <__algorithm/lexicographical_compare.h>
186#include <__algorithm/min.h>
187#include <__assert> // all public C++ headers provide the assertion handler
183#include <__config>188#include <__config>
184#include <__debug>189#include <__debug>
190#include <__format/enable_insertable.h>
191#include <__iterator/distance.h>
192#include <__iterator/iterator_traits.h>
193#include <__iterator/move_iterator.h>
194#include <__iterator/next.h>
195#include <__iterator/prev.h>
196#include <__iterator/reverse_iterator.h>
197#include <__memory/swap_allocator.h>
185#include <__utility/forward.h>198#include <__utility/forward.h>
186#include <algorithm>199#include <__utility/move.h>
187#include <initializer_list>200#include <__utility/swap.h>
188#include <iterator>
189#include <limits>201#include <limits>
190#include <memory>202#include <memory>
191#include <type_traits>203#include <type_traits>
192#include <version>204#include <version>
193205
206#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
207# include <algorithm>
208# include <functional>
209# include <iterator>
210#endif
211
212// standard-mandated includes
213
214// [iterator.range]
215#include <__iterator/access.h>
216#include <__iterator/data.h>
217#include <__iterator/empty.h>
218#include <__iterator/reverse_access.h>
219#include <__iterator/size.h>
220
221// [list.syn]
222#include <compare>
223#include <initializer_list>
224
194#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)225#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
195#pragma GCC system_header226# pragma GCC system_header
196#endif227#endif
197228
198_LIBCPP_PUSH_MACROS229_LIBCPP_PUSH_MACROS
...@@ -292,19 +323,15 @@ class _LIBCPP_TEMPLATE_VIS __list_iterator...@@ -292,19 +323,15 @@ class _LIBCPP_TEMPLATE_VIS __list_iterator
292323
293 __link_pointer __ptr_;324 __link_pointer __ptr_;
294325
295#if _LIBCPP_DEBUG_LEVEL == 2
296 _LIBCPP_INLINE_VISIBILITY326 _LIBCPP_INLINE_VISIBILITY
297 explicit __list_iterator(__link_pointer __p, const void* __c) _NOEXCEPT327 explicit __list_iterator(__link_pointer __p, const void* __c) _NOEXCEPT
298 : __ptr_(__p)328 : __ptr_(__p)
299 {329 {
330 (void)__c;
331#ifdef _LIBCPP_ENABLE_DEBUG_MODE
300 __get_db()->__insert_ic(this, __c);332 __get_db()->__insert_ic(this, __c);
301 }
302#else
303 _LIBCPP_INLINE_VISIBILITY
304 explicit __list_iterator(__link_pointer __p) _NOEXCEPT : __ptr_(__p) {}
305#endif333#endif
306334 }
307
308335
309 template<class, class> friend class list;336 template<class, class> friend class list;
310 template<class, class> friend class __list_imp;337 template<class, class> friend class __list_imp;
...@@ -322,7 +349,7 @@ public:...@@ -322,7 +349,7 @@ public:
322 _VSTD::__debug_db_insert_i(this);349 _VSTD::__debug_db_insert_i(this);
323 }350 }
324351
325#if _LIBCPP_DEBUG_LEVEL == 2352#ifdef _LIBCPP_ENABLE_DEBUG_MODE
326353
327 _LIBCPP_INLINE_VISIBILITY354 _LIBCPP_INLINE_VISIBILITY
328 __list_iterator(const __list_iterator& __p)355 __list_iterator(const __list_iterator& __p)
...@@ -348,7 +375,7 @@ public:...@@ -348,7 +375,7 @@ public:
348 return *this;375 return *this;
349 }376 }
350377
351#endif // _LIBCPP_DEBUG_LEVEL == 2378#endif // _LIBCPP_ENABLE_DEBUG_MODE
352379
353 _LIBCPP_INLINE_VISIBILITY380 _LIBCPP_INLINE_VISIBILITY
354 reference operator*() const381 reference operator*() const
...@@ -405,17 +432,15 @@ class _LIBCPP_TEMPLATE_VIS __list_const_iterator...@@ -405,17 +432,15 @@ class _LIBCPP_TEMPLATE_VIS __list_const_iterator
405432
406 __link_pointer __ptr_;433 __link_pointer __ptr_;
407434
408#if _LIBCPP_DEBUG_LEVEL == 2
409 _LIBCPP_INLINE_VISIBILITY435 _LIBCPP_INLINE_VISIBILITY
410 explicit __list_const_iterator(__link_pointer __p, const void* __c) _NOEXCEPT436 explicit __list_const_iterator(__link_pointer __p, const void* __c) _NOEXCEPT
411 : __ptr_(__p)437 : __ptr_(__p)
412 {438 {
439 (void)__c;
440#ifdef _LIBCPP_ENABLE_DEBUG_MODE
413 __get_db()->__insert_ic(this, __c);441 __get_db()->__insert_ic(this, __c);
414 }
415#else
416 _LIBCPP_INLINE_VISIBILITY
417 explicit __list_const_iterator(__link_pointer __p) _NOEXCEPT : __ptr_(__p) {}
418#endif442#endif
443 }
419444
420 template<class, class> friend class list;445 template<class, class> friend class list;
421 template<class, class> friend class __list_imp;446 template<class, class> friend class __list_imp;
...@@ -435,12 +460,12 @@ public:...@@ -435,12 +460,12 @@ public:
435 __list_const_iterator(const __list_iterator<_Tp, _VoidPtr>& __p) _NOEXCEPT460 __list_const_iterator(const __list_iterator<_Tp, _VoidPtr>& __p) _NOEXCEPT
436 : __ptr_(__p.__ptr_)461 : __ptr_(__p.__ptr_)
437 {462 {
438#if _LIBCPP_DEBUG_LEVEL == 2463#ifdef _LIBCPP_ENABLE_DEBUG_MODE
439 __get_db()->__iterator_copy(this, _VSTD::addressof(__p));464 __get_db()->__iterator_copy(this, _VSTD::addressof(__p));
440#endif465#endif
441 }466 }
442467
443#if _LIBCPP_DEBUG_LEVEL == 2468#ifdef _LIBCPP_ENABLE_DEBUG_MODE
444469
445 _LIBCPP_INLINE_VISIBILITY470 _LIBCPP_INLINE_VISIBILITY
446 __list_const_iterator(const __list_const_iterator& __p)471 __list_const_iterator(const __list_const_iterator& __p)
...@@ -466,7 +491,7 @@ public:...@@ -466,7 +491,7 @@ public:
466 return *this;491 return *this;
467 }492 }
468493
469#endif // _LIBCPP_DEBUG_LEVEL == 2494#endif // _LIBCPP_ENABLE_DEBUG_MODE
470 _LIBCPP_INLINE_VISIBILITY495 _LIBCPP_INLINE_VISIBILITY
471 reference operator*() const496 reference operator*() const
472 {497 {
...@@ -593,38 +618,22 @@ protected:...@@ -593,38 +618,22 @@ protected:
593 _LIBCPP_INLINE_VISIBILITY618 _LIBCPP_INLINE_VISIBILITY
594 iterator begin() _NOEXCEPT619 iterator begin() _NOEXCEPT
595 {620 {
596#if _LIBCPP_DEBUG_LEVEL == 2
597 return iterator(__end_.__next_, this);621 return iterator(__end_.__next_, this);
598#else
599 return iterator(__end_.__next_);
600#endif
601 }622 }
602 _LIBCPP_INLINE_VISIBILITY623 _LIBCPP_INLINE_VISIBILITY
603 const_iterator begin() const _NOEXCEPT624 const_iterator begin() const _NOEXCEPT
604 {625 {
605#if _LIBCPP_DEBUG_LEVEL == 2
606 return const_iterator(__end_.__next_, this);626 return const_iterator(__end_.__next_, this);
607#else
608 return const_iterator(__end_.__next_);
609#endif
610 }627 }
611 _LIBCPP_INLINE_VISIBILITY628 _LIBCPP_INLINE_VISIBILITY
612 iterator end() _NOEXCEPT629 iterator end() _NOEXCEPT
613 {630 {
614#if _LIBCPP_DEBUG_LEVEL == 2
615 return iterator(__end_as_link(), this);631 return iterator(__end_as_link(), this);
616#else
617 return iterator(__end_as_link());
618#endif
619 }632 }
620 _LIBCPP_INLINE_VISIBILITY633 _LIBCPP_INLINE_VISIBILITY
621 const_iterator end() const _NOEXCEPT634 const_iterator end() const _NOEXCEPT
622 {635 {
623#if _LIBCPP_DEBUG_LEVEL == 2
624 return const_iterator(__end_as_link(), this);636 return const_iterator(__end_as_link(), this);
625#else
626 return const_iterator(__end_as_link());
627#endif
628 }637 }
629638
630 void swap(__list_imp& __c)639 void swap(__list_imp& __c)
...@@ -672,13 +681,6 @@ private:...@@ -672,13 +681,6 @@ private:
672 void __move_assign_alloc(__list_imp&, false_type)681 void __move_assign_alloc(__list_imp&, false_type)
673 _NOEXCEPT682 _NOEXCEPT
674 {}683 {}
675
676 _LIBCPP_INLINE_VISIBILITY
677 void __invalidate_all_iterators() {
678#if _LIBCPP_DEBUG_LEVEL == 2
679 __get_db()->__invalidate_all(this);
680#endif
681 }
682};684};
683685
684// Unlink nodes [__f, __l]686// Unlink nodes [__f, __l]
...@@ -720,9 +722,7 @@ inline __list_imp<_Tp, _Alloc>::__list_imp(__node_allocator&& __a) _NOEXCEPT...@@ -720,9 +722,7 @@ inline __list_imp<_Tp, _Alloc>::__list_imp(__node_allocator&& __a) _NOEXCEPT
720template <class _Tp, class _Alloc>722template <class _Tp, class _Alloc>
721__list_imp<_Tp, _Alloc>::~__list_imp() {723__list_imp<_Tp, _Alloc>::~__list_imp() {
722 clear();724 clear();
723#if _LIBCPP_DEBUG_LEVEL == 2725 std::__debug_db_erase_c(this);
724 __get_db()->__erase_c(this);
725#endif
726}726}
727727
728template <class _Tp, class _Alloc>728template <class _Tp, class _Alloc>
...@@ -743,7 +743,7 @@ __list_imp<_Tp, _Alloc>::clear() _NOEXCEPT...@@ -743,7 +743,7 @@ __list_imp<_Tp, _Alloc>::clear() _NOEXCEPT
743 __node_alloc_traits::destroy(__na, _VSTD::addressof(__np->__value_));743 __node_alloc_traits::destroy(__na, _VSTD::addressof(__np->__value_));
744 __node_alloc_traits::deallocate(__na, __np, 1);744 __node_alloc_traits::deallocate(__na, __np, 1);
745 }745 }
746 __invalidate_all_iterators();746 std::__debug_db_invalidate_all(this);
747 }747 }
748}748}
749749
...@@ -774,7 +774,7 @@ __list_imp<_Tp, _Alloc>::swap(__list_imp& __c)...@@ -774,7 +774,7 @@ __list_imp<_Tp, _Alloc>::swap(__list_imp& __c)
774 else774 else
775 __c.__end_.__prev_->__next_ = __c.__end_.__next_->__prev_ = __c.__end_as_link();775 __c.__end_.__prev_->__next_ = __c.__end_.__next_->__prev_ = __c.__end_as_link();
776776
777#if _LIBCPP_DEBUG_LEVEL == 2777#ifdef _LIBCPP_ENABLE_DEBUG_MODE
778 __libcpp_db* __db = __get_db();778 __libcpp_db* __db = __get_db();
779 __c_node* __cn1 = __db->__find_c_and_lock(this);779 __c_node* __cn1 = __db->__find_c_and_lock(this);
780 __c_node* __cn2 = __db->__find_c(_VSTD::addressof(__c));780 __c_node* __cn2 = __db->__find_c(_VSTD::addressof(__c));
...@@ -871,13 +871,13 @@ public:...@@ -871,13 +871,13 @@ public:
871871
872 template <class _InpIter>872 template <class _InpIter>
873 list(_InpIter __f, _InpIter __l,873 list(_InpIter __f, _InpIter __l,
874 typename enable_if<__is_cpp17_input_iterator<_InpIter>::value>::type* = 0);874 __enable_if_t<__is_cpp17_input_iterator<_InpIter>::value>* = 0);
875 template <class _InpIter>875 template <class _InpIter>
876 list(_InpIter __f, _InpIter __l, const allocator_type& __a,876 list(_InpIter __f, _InpIter __l, const allocator_type& __a,
877 typename enable_if<__is_cpp17_input_iterator<_InpIter>::value>::type* = 0);877 __enable_if_t<__is_cpp17_input_iterator<_InpIter>::value>* = 0);
878878
879 list(const list& __c);879 list(const list& __c);
880 list(const list& __c, const __identity_t<allocator_type>& __a);880 list(const list& __c, const __type_identity_t<allocator_type>& __a);
881 _LIBCPP_INLINE_VISIBILITY881 _LIBCPP_INLINE_VISIBILITY
882 list& operator=(const list& __c);882 list& operator=(const list& __c);
883#ifndef _LIBCPP_CXX03_LANG883#ifndef _LIBCPP_CXX03_LANG
...@@ -888,7 +888,7 @@ public:...@@ -888,7 +888,7 @@ public:
888 list(list&& __c)888 list(list&& __c)
889 _NOEXCEPT_(is_nothrow_move_constructible<__node_allocator>::value);889 _NOEXCEPT_(is_nothrow_move_constructible<__node_allocator>::value);
890 _LIBCPP_INLINE_VISIBILITY890 _LIBCPP_INLINE_VISIBILITY
891 list(list&& __c, const __identity_t<allocator_type>& __a);891 list(list&& __c, const __type_identity_t<allocator_type>& __a);
892 _LIBCPP_INLINE_VISIBILITY892 _LIBCPP_INLINE_VISIBILITY
893 list& operator=(list&& __c)893 list& operator=(list&& __c)
894 _NOEXCEPT_(894 _NOEXCEPT_(
...@@ -906,7 +906,7 @@ public:...@@ -906,7 +906,7 @@ public:
906906
907 template <class _InpIter>907 template <class _InpIter>
908 void assign(_InpIter __f, _InpIter __l,908 void assign(_InpIter __f, _InpIter __l,
909 typename enable_if<__is_cpp17_input_iterator<_InpIter>::value>::type* = 0);909 __enable_if_t<__is_cpp17_input_iterator<_InpIter>::value>* = 0);
910 void assign(size_type __n, const value_type& __x);910 void assign(size_type __n, const value_type& __x);
911911
912 _LIBCPP_INLINE_VISIBILITY912 _LIBCPP_INLINE_VISIBILITY
...@@ -1023,7 +1023,7 @@ public:...@@ -1023,7 +1023,7 @@ public:
1023 iterator insert(const_iterator __p, size_type __n, const value_type& __x);1023 iterator insert(const_iterator __p, size_type __n, const value_type& __x);
1024 template <class _InpIter>1024 template <class _InpIter>
1025 iterator insert(const_iterator __p, _InpIter __f, _InpIter __l,1025 iterator insert(const_iterator __p, _InpIter __f, _InpIter __l,
1026 typename enable_if<__is_cpp17_input_iterator<_InpIter>::value>::type* = 0);1026 __enable_if_t<__is_cpp17_input_iterator<_InpIter>::value>* = 0);
10271027
1028 _LIBCPP_INLINE_VISIBILITY1028 _LIBCPP_INLINE_VISIBILITY
1029 void swap(list& __c)1029 void swap(list& __c)
...@@ -1099,14 +1099,14 @@ public:...@@ -1099,14 +1099,14 @@ public:
1099 return __hold_pointer(__p, __node_destructor(__na, 1));1099 return __hold_pointer(__p, __node_destructor(__na, 1));
1100 }1100 }
11011101
1102#if _LIBCPP_DEBUG_LEVEL == 21102#ifdef _LIBCPP_ENABLE_DEBUG_MODE
11031103
1104 bool __dereferenceable(const const_iterator* __i) const;1104 bool __dereferenceable(const const_iterator* __i) const;
1105 bool __decrementable(const const_iterator* __i) const;1105 bool __decrementable(const const_iterator* __i) const;
1106 bool __addable(const const_iterator* __i, ptrdiff_t __n) const;1106 bool __addable(const const_iterator* __i, ptrdiff_t __n) const;
1107 bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const;1107 bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const;
11081108
1109#endif // _LIBCPP_DEBUG_LEVEL == 21109#endif // _LIBCPP_ENABLE_DEBUG_MODE
11101110
1111private:1111private:
1112 _LIBCPP_INLINE_VISIBILITY1112 _LIBCPP_INLINE_VISIBILITY
...@@ -1221,7 +1221,7 @@ list<_Tp, _Alloc>::list(size_type __n, const value_type& __x)...@@ -1221,7 +1221,7 @@ list<_Tp, _Alloc>::list(size_type __n, const value_type& __x)
1221template <class _Tp, class _Alloc>1221template <class _Tp, class _Alloc>
1222template <class _InpIter>1222template <class _InpIter>
1223list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l,1223list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l,
1224 typename enable_if<__is_cpp17_input_iterator<_InpIter>::value>::type*)1224 __enable_if_t<__is_cpp17_input_iterator<_InpIter>::value>*)
1225{1225{
1226 _VSTD::__debug_db_insert_c(this);1226 _VSTD::__debug_db_insert_c(this);
1227 for (; __f != __l; ++__f)1227 for (; __f != __l; ++__f)
...@@ -1231,7 +1231,7 @@ list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l,...@@ -1231,7 +1231,7 @@ list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l,
1231template <class _Tp, class _Alloc>1231template <class _Tp, class _Alloc>
1232template <class _InpIter>1232template <class _InpIter>
1233list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l, const allocator_type& __a,1233list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l, const allocator_type& __a,
1234 typename enable_if<__is_cpp17_input_iterator<_InpIter>::value>::type*)1234 __enable_if_t<__is_cpp17_input_iterator<_InpIter>::value>*)
1235 : base(__a)1235 : base(__a)
1236{1236{
1237 _VSTD::__debug_db_insert_c(this);1237 _VSTD::__debug_db_insert_c(this);
...@@ -1249,7 +1249,7 @@ list<_Tp, _Alloc>::list(const list& __c)...@@ -1249,7 +1249,7 @@ list<_Tp, _Alloc>::list(const list& __c)
1249}1249}
12501250
1251template <class _Tp, class _Alloc>1251template <class _Tp, class _Alloc>
1252list<_Tp, _Alloc>::list(const list& __c, const __identity_t<allocator_type>& __a)1252list<_Tp, _Alloc>::list(const list& __c, const __type_identity_t<allocator_type>& __a)
1253 : base(__a)1253 : base(__a)
1254{1254{
1255 _VSTD::__debug_db_insert_c(this);1255 _VSTD::__debug_db_insert_c(this);
...@@ -1288,7 +1288,7 @@ inline list<_Tp, _Alloc>::list(list&& __c)...@@ -1288,7 +1288,7 @@ inline list<_Tp, _Alloc>::list(list&& __c)
12881288
1289template <class _Tp, class _Alloc>1289template <class _Tp, class _Alloc>
1290inline1290inline
1291list<_Tp, _Alloc>::list(list&& __c, const __identity_t<allocator_type>& __a)1291list<_Tp, _Alloc>::list(list&& __c, const __type_identity_t<allocator_type>& __a)
1292 : base(__a)1292 : base(__a)
1293{1293{
1294 _VSTD::__debug_db_insert_c(this);1294 _VSTD::__debug_db_insert_c(this);
...@@ -1356,7 +1356,7 @@ template <class _Tp, class _Alloc>...@@ -1356,7 +1356,7 @@ template <class _Tp, class _Alloc>
1356template <class _InpIter>1356template <class _InpIter>
1357void1357void
1358list<_Tp, _Alloc>::assign(_InpIter __f, _InpIter __l,1358list<_Tp, _Alloc>::assign(_InpIter __f, _InpIter __l,
1359 typename enable_if<__is_cpp17_input_iterator<_InpIter>::value>::type*)1359 __enable_if_t<__is_cpp17_input_iterator<_InpIter>::value>*)
1360{1360{
1361 iterator __i = begin();1361 iterator __i = begin();
1362 iterator __e = end();1362 iterator __e = end();
...@@ -1366,9 +1366,7 @@ list<_Tp, _Alloc>::assign(_InpIter __f, _InpIter __l,...@@ -1366,9 +1366,7 @@ list<_Tp, _Alloc>::assign(_InpIter __f, _InpIter __l,
1366 insert(__e, __f, __l);1366 insert(__e, __f, __l);
1367 else1367 else
1368 erase(__i, __e);1368 erase(__i, __e);
1369#if _LIBCPP_DEBUG_LEVEL == 21369 std::__debug_db_invalidate_all(this);
1370 __get_db()->__invalidate_all(this);
1371#endif
1372}1370}
13731371
1374template <class _Tp, class _Alloc>1372template <class _Tp, class _Alloc>
...@@ -1383,9 +1381,7 @@ list<_Tp, _Alloc>::assign(size_type __n, const value_type& __x)...@@ -1383,9 +1381,7 @@ list<_Tp, _Alloc>::assign(size_type __n, const value_type& __x)
1383 insert(__e, __n, __x);1381 insert(__e, __n, __x);
1384 else1382 else
1385 erase(__i, __e);1383 erase(__i, __e);
1386#if _LIBCPP_DEBUG_LEVEL == 21384 std::__debug_db_invalidate_all(this);
1387 __get_db()->__invalidate_all(this);
1388#endif
1389}1385}
13901386
1391template <class _Tp, class _Alloc>1387template <class _Tp, class _Alloc>
...@@ -1407,11 +1403,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, const value_type& __x)...@@ -1407,11 +1403,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, const value_type& __x)
1407 __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);1403 __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
1408 __link_nodes(__p.__ptr_, __hold->__as_link(), __hold->__as_link());1404 __link_nodes(__p.__ptr_, __hold->__as_link(), __hold->__as_link());
1409 ++base::__sz();1405 ++base::__sz();
1410#if _LIBCPP_DEBUG_LEVEL == 2
1411 return iterator(__hold.release()->__as_link(), this);1406 return iterator(__hold.release()->__as_link(), this);
1412#else
1413 return iterator(__hold.release()->__as_link());
1414#endif
1415}1407}
14161408
1417template <class _Tp, class _Alloc>1409template <class _Tp, class _Alloc>
...@@ -1420,11 +1412,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _...@@ -1420,11 +1412,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _
1420{1412{
1421 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this,1413 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this,
1422 "list::insert(iterator, n, x) called with an iterator not referring to this list");1414 "list::insert(iterator, n, x) called with an iterator not referring to this list");
1423#if _LIBCPP_DEBUG_LEVEL == 2
1424 iterator __r(__p.__ptr_, this);1415 iterator __r(__p.__ptr_, this);
1425#else
1426 iterator __r(__p.__ptr_);
1427#endif
1428 if (__n > 0)1416 if (__n > 0)
1429 {1417 {
1430 size_type __ds = 0;1418 size_type __ds = 0;
...@@ -1432,11 +1420,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _...@@ -1432,11 +1420,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _
1432 __hold_pointer __hold = __allocate_node(__na);1420 __hold_pointer __hold = __allocate_node(__na);
1433 __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);1421 __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
1434 ++__ds;1422 ++__ds;
1435#if _LIBCPP_DEBUG_LEVEL == 2
1436 __r = iterator(__hold->__as_link(), this);1423 __r = iterator(__hold->__as_link(), this);
1437#else
1438 __r = iterator(__hold->__as_link());
1439#endif
1440 __hold.release();1424 __hold.release();
1441 iterator __e = __r;1425 iterator __e = __r;
1442#ifndef _LIBCPP_NO_EXCEPTIONS1426#ifndef _LIBCPP_NO_EXCEPTIONS
...@@ -1462,11 +1446,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _...@@ -1462,11 +1446,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _
1462 __node_alloc_traits::deallocate(__na, __e.__ptr_->__as_node(), 1);1446 __node_alloc_traits::deallocate(__na, __e.__ptr_->__as_node(), 1);
1463 if (__prev == 0)1447 if (__prev == 0)
1464 break;1448 break;
1465#if _LIBCPP_DEBUG_LEVEL == 2
1466 __e = iterator(__prev, this);1449 __e = iterator(__prev, this);
1467#else
1468 __e = iterator(__prev);
1469#endif
1470 }1450 }
1471 throw;1451 throw;
1472 }1452 }
...@@ -1481,15 +1461,11 @@ template <class _Tp, class _Alloc>...@@ -1481,15 +1461,11 @@ template <class _Tp, class _Alloc>
1481template <class _InpIter>1461template <class _InpIter>
1482typename list<_Tp, _Alloc>::iterator1462typename list<_Tp, _Alloc>::iterator
1483list<_Tp, _Alloc>::insert(const_iterator __p, _InpIter __f, _InpIter __l,1463list<_Tp, _Alloc>::insert(const_iterator __p, _InpIter __f, _InpIter __l,
1484 typename enable_if<__is_cpp17_input_iterator<_InpIter>::value>::type*)1464 __enable_if_t<__is_cpp17_input_iterator<_InpIter>::value>*)
1485{1465{
1486 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this,1466 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this,
1487 "list::insert(iterator, range) called with an iterator not referring to this list");1467 "list::insert(iterator, range) called with an iterator not referring to this list");
1488#if _LIBCPP_DEBUG_LEVEL == 2
1489 iterator __r(__p.__ptr_, this);1468 iterator __r(__p.__ptr_, this);
1490#else
1491 iterator __r(__p.__ptr_);
1492#endif
1493 if (__f != __l)1469 if (__f != __l)
1494 {1470 {
1495 size_type __ds = 0;1471 size_type __ds = 0;
...@@ -1497,11 +1473,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, _InpIter __f, _InpIter __l,...@@ -1497,11 +1473,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, _InpIter __f, _InpIter __l,
1497 __hold_pointer __hold = __allocate_node(__na);1473 __hold_pointer __hold = __allocate_node(__na);
1498 __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), *__f);1474 __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), *__f);
1499 ++__ds;1475 ++__ds;
1500#if _LIBCPP_DEBUG_LEVEL == 2
1501 __r = iterator(__hold.get()->__as_link(), this);1476 __r = iterator(__hold.get()->__as_link(), this);
1502#else
1503 __r = iterator(__hold.get()->__as_link());
1504#endif
1505 __hold.release();1477 __hold.release();
1506 iterator __e = __r;1478 iterator __e = __r;
1507#ifndef _LIBCPP_NO_EXCEPTIONS1479#ifndef _LIBCPP_NO_EXCEPTIONS
...@@ -1527,11 +1499,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, _InpIter __f, _InpIter __l,...@@ -1527,11 +1499,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, _InpIter __f, _InpIter __l,
1527 __node_alloc_traits::deallocate(__na, __e.__ptr_->__as_node(), 1);1499 __node_alloc_traits::deallocate(__na, __e.__ptr_->__as_node(), 1);
1528 if (__prev == 0)1500 if (__prev == 0)
1529 break;1501 break;
1530#if _LIBCPP_DEBUG_LEVEL == 2
1531 __e = iterator(__prev, this);1502 __e = iterator(__prev, this);
1532#else
1533 __e = iterator(__prev);
1534#endif
1535 }1503 }
1536 throw;1504 throw;
1537 }1505 }
...@@ -1650,11 +1618,7 @@ list<_Tp, _Alloc>::emplace(const_iterator __p, _Args&&... __args)...@@ -1650,11 +1618,7 @@ list<_Tp, _Alloc>::emplace(const_iterator __p, _Args&&... __args)
1650 __link_nodes(__p.__ptr_, __nl, __nl);1618 __link_nodes(__p.__ptr_, __nl, __nl);
1651 ++base::__sz();1619 ++base::__sz();
1652 __hold.release();1620 __hold.release();
1653#if _LIBCPP_DEBUG_LEVEL == 2
1654 return iterator(__nl, this);1621 return iterator(__nl, this);
1655#else
1656 return iterator(__nl);
1657#endif
1658}1622}
16591623
1660template <class _Tp, class _Alloc>1624template <class _Tp, class _Alloc>
...@@ -1670,11 +1634,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, value_type&& __x)...@@ -1670,11 +1634,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, value_type&& __x)
1670 __link_nodes(__p.__ptr_, __nl, __nl);1634 __link_nodes(__p.__ptr_, __nl, __nl);
1671 ++base::__sz();1635 ++base::__sz();
1672 __hold.release();1636 __hold.release();
1673#if _LIBCPP_DEBUG_LEVEL == 2
1674 return iterator(__nl, this);1637 return iterator(__nl, this);
1675#else
1676 return iterator(__nl);
1677#endif
1678}1638}
16791639
1680#endif // _LIBCPP_CXX03_LANG1640#endif // _LIBCPP_CXX03_LANG
...@@ -1688,7 +1648,7 @@ list<_Tp, _Alloc>::pop_front()...@@ -1688,7 +1648,7 @@ list<_Tp, _Alloc>::pop_front()
1688 __link_pointer __n = base::__end_.__next_;1648 __link_pointer __n = base::__end_.__next_;
1689 base::__unlink_nodes(__n, __n);1649 base::__unlink_nodes(__n, __n);
1690 --base::__sz();1650 --base::__sz();
1691#if _LIBCPP_DEBUG_LEVEL == 21651#ifdef _LIBCPP_ENABLE_DEBUG_MODE
1692 __c_node* __c = __get_db()->__find_c_and_lock(this);1652 __c_node* __c = __get_db()->__find_c_and_lock(this);
1693 for (__i_node** __p = __c->end_; __p != __c->beg_; )1653 for (__i_node** __p = __c->end_; __p != __c->beg_; )
1694 {1654 {
...@@ -1717,7 +1677,7 @@ list<_Tp, _Alloc>::pop_back()...@@ -1717,7 +1677,7 @@ list<_Tp, _Alloc>::pop_back()
1717 __link_pointer __n = base::__end_.__prev_;1677 __link_pointer __n = base::__end_.__prev_;
1718 base::__unlink_nodes(__n, __n);1678 base::__unlink_nodes(__n, __n);
1719 --base::__sz();1679 --base::__sz();
1720#if _LIBCPP_DEBUG_LEVEL == 21680#ifdef _LIBCPP_ENABLE_DEBUG_MODE
1721 __c_node* __c = __get_db()->__find_c_and_lock(this);1681 __c_node* __c = __get_db()->__find_c_and_lock(this);
1722 for (__i_node** __p = __c->end_; __p != __c->beg_; )1682 for (__i_node** __p = __c->end_; __p != __c->beg_; )
1723 {1683 {
...@@ -1750,7 +1710,7 @@ list<_Tp, _Alloc>::erase(const_iterator __p)...@@ -1750,7 +1710,7 @@ list<_Tp, _Alloc>::erase(const_iterator __p)
1750 __link_pointer __r = __n->__next_;1710 __link_pointer __r = __n->__next_;
1751 base::__unlink_nodes(__n, __n);1711 base::__unlink_nodes(__n, __n);
1752 --base::__sz();1712 --base::__sz();
1753#if _LIBCPP_DEBUG_LEVEL == 21713#ifdef _LIBCPP_ENABLE_DEBUG_MODE
1754 __c_node* __c = __get_db()->__find_c_and_lock(this);1714 __c_node* __c = __get_db()->__find_c_and_lock(this);
1755 for (__i_node** __ip = __c->end_; __ip != __c->beg_; )1715 for (__i_node** __ip = __c->end_; __ip != __c->beg_; )
1756 {1716 {
...@@ -1768,11 +1728,7 @@ list<_Tp, _Alloc>::erase(const_iterator __p)...@@ -1768,11 +1728,7 @@ list<_Tp, _Alloc>::erase(const_iterator __p)
1768 __node_pointer __np = __n->__as_node();1728 __node_pointer __np = __n->__as_node();
1769 __node_alloc_traits::destroy(__na, _VSTD::addressof(__np->__value_));1729 __node_alloc_traits::destroy(__na, _VSTD::addressof(__np->__value_));
1770 __node_alloc_traits::deallocate(__na, __np, 1);1730 __node_alloc_traits::deallocate(__na, __np, 1);
1771#if _LIBCPP_DEBUG_LEVEL == 2
1772 return iterator(__r, this);1731 return iterator(__r, this);
1773#else
1774 return iterator(__r);
1775#endif
1776}1732}
17771733
1778template <class _Tp, class _Alloc>1734template <class _Tp, class _Alloc>
...@@ -1792,7 +1748,7 @@ list<_Tp, _Alloc>::erase(const_iterator __f, const_iterator __l)...@@ -1792,7 +1748,7 @@ list<_Tp, _Alloc>::erase(const_iterator __f, const_iterator __l)
1792 __link_pointer __n = __f.__ptr_;1748 __link_pointer __n = __f.__ptr_;
1793 ++__f;1749 ++__f;
1794 --base::__sz();1750 --base::__sz();
1795#if _LIBCPP_DEBUG_LEVEL == 21751#ifdef _LIBCPP_ENABLE_DEBUG_MODE
1796 __c_node* __c = __get_db()->__find_c_and_lock(this);1752 __c_node* __c = __get_db()->__find_c_and_lock(this);
1797 for (__i_node** __p = __c->end_; __p != __c->beg_; )1753 for (__i_node** __p = __c->end_; __p != __c->beg_; )
1798 {1754 {
...@@ -1812,11 +1768,7 @@ list<_Tp, _Alloc>::erase(const_iterator __f, const_iterator __l)...@@ -1812,11 +1768,7 @@ list<_Tp, _Alloc>::erase(const_iterator __f, const_iterator __l)
1812 __node_alloc_traits::deallocate(__na, __np, 1);1768 __node_alloc_traits::deallocate(__na, __np, 1);
1813 }1769 }
1814 }1770 }
1815#if _LIBCPP_DEBUG_LEVEL == 2
1816 return iterator(__l.__ptr_, this);1771 return iterator(__l.__ptr_, this);
1817#else
1818 return iterator(__l.__ptr_);
1819#endif
1820}1772}
18211773
1822template <class _Tp, class _Alloc>1774template <class _Tp, class _Alloc>
...@@ -1833,11 +1785,7 @@ list<_Tp, _Alloc>::resize(size_type __n)...@@ -1833,11 +1785,7 @@ list<_Tp, _Alloc>::resize(size_type __n)
1833 __hold_pointer __hold = __allocate_node(__na);1785 __hold_pointer __hold = __allocate_node(__na);
1834 __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_));1786 __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_));
1835 ++__ds;1787 ++__ds;
1836#if _LIBCPP_DEBUG_LEVEL == 2
1837 iterator __r = iterator(__hold.release()->__as_link(), this);1788 iterator __r = iterator(__hold.release()->__as_link(), this);
1838#else
1839 iterator __r = iterator(__hold.release()->__as_link());
1840#endif
1841 iterator __e = __r;1789 iterator __e = __r;
1842#ifndef _LIBCPP_NO_EXCEPTIONS1790#ifndef _LIBCPP_NO_EXCEPTIONS
1843 try1791 try
...@@ -1862,11 +1810,7 @@ list<_Tp, _Alloc>::resize(size_type __n)...@@ -1862,11 +1810,7 @@ list<_Tp, _Alloc>::resize(size_type __n)
1862 __node_alloc_traits::deallocate(__na, __e.__ptr_->__as_node(), 1);1810 __node_alloc_traits::deallocate(__na, __e.__ptr_->__as_node(), 1);
1863 if (__prev == 0)1811 if (__prev == 0)
1864 break;1812 break;
1865#if _LIBCPP_DEBUG_LEVEL == 2
1866 __e = iterator(__prev, this);1813 __e = iterator(__prev, this);
1867#else
1868 __e = iterator(__prev);
1869#endif
1870 }1814 }
1871 throw;1815 throw;
1872 }1816 }
...@@ -1891,11 +1835,7 @@ list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x)...@@ -1891,11 +1835,7 @@ list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x)
1891 __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);1835 __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
1892 ++__ds;1836 ++__ds;
1893 __link_pointer __nl = __hold.release()->__as_link();1837 __link_pointer __nl = __hold.release()->__as_link();
1894#if _LIBCPP_DEBUG_LEVEL == 2
1895 iterator __r = iterator(__nl, this);1838 iterator __r = iterator(__nl, this);
1896#else
1897 iterator __r = iterator(__nl);
1898#endif
1899 iterator __e = __r;1839 iterator __e = __r;
1900#ifndef _LIBCPP_NO_EXCEPTIONS1840#ifndef _LIBCPP_NO_EXCEPTIONS
1901 try1841 try
...@@ -1920,11 +1860,7 @@ list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x)...@@ -1920,11 +1860,7 @@ list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x)
1920 __node_alloc_traits::deallocate(__na, __e.__ptr_->__as_node(), 1);1860 __node_alloc_traits::deallocate(__na, __e.__ptr_->__as_node(), 1);
1921 if (__prev == 0)1861 if (__prev == 0)
1922 break;1862 break;
1923#if _LIBCPP_DEBUG_LEVEL == 2
1924 __e = iterator(__prev, this);1863 __e = iterator(__prev, this);
1925#else
1926 __e = iterator(__prev);
1927#endif
1928 }1864 }
1929 throw;1865 throw;
1930 }1866 }
...@@ -1950,7 +1886,7 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c)...@@ -1950,7 +1886,7 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c)
1950 __link_nodes(__p.__ptr_, __f, __l);1886 __link_nodes(__p.__ptr_, __f, __l);
1951 base::__sz() += __c.__sz();1887 base::__sz() += __c.__sz();
1952 __c.__sz() = 0;1888 __c.__sz() = 0;
1953#if _LIBCPP_DEBUG_LEVEL == 21889#ifdef _LIBCPP_ENABLE_DEBUG_MODE
1954 if (_VSTD::addressof(__c) != this) {1890 if (_VSTD::addressof(__c) != this) {
1955 __libcpp_db* __db = __get_db();1891 __libcpp_db* __db = __get_db();
1956 __c_node* __cn1 = __db->__find_c_and_lock(this);1892 __c_node* __cn1 = __db->__find_c_and_lock(this);
...@@ -1991,7 +1927,7 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __i)...@@ -1991,7 +1927,7 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __i)
1991 __link_nodes(__p.__ptr_, __f, __f);1927 __link_nodes(__p.__ptr_, __f, __f);
1992 --__c.__sz();1928 --__c.__sz();
1993 ++base::__sz();1929 ++base::__sz();
1994#if _LIBCPP_DEBUG_LEVEL == 21930#ifdef _LIBCPP_ENABLE_DEBUG_MODE
1995 if (_VSTD::addressof(__c) != this) {1931 if (_VSTD::addressof(__c) != this) {
1996 __libcpp_db* __db = __get_db();1932 __libcpp_db* __db = __get_db();
1997 __c_node* __cn1 = __db->__find_c_and_lock(this);1933 __c_node* __cn1 = __db->__find_c_and_lock(this);
...@@ -2014,6 +1950,17 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __i)...@@ -2014,6 +1950,17 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __i)
2014 }1950 }
2015}1951}
20161952
1953template <class _Iterator>
1954_LIBCPP_HIDE_FROM_ABI
1955bool __iterator_in_range(_Iterator __first, _Iterator __last, _Iterator __it) {
1956 for (_Iterator __p = __first; __p != __last; ++__p) {
1957 if (__p == __it) {
1958 return true;
1959 }
1960 }
1961 return false;
1962}
1963
2017template <class _Tp, class _Alloc>1964template <class _Tp, class _Alloc>
2018void1965void
2019list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, const_iterator __l)1966list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, const_iterator __l)
...@@ -2024,16 +1971,10 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, con...@@ -2024,16 +1971,10 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, con
2024 "list::splice(iterator, list, iterator, iterator) called with second iterator not referring to the list argument");1971 "list::splice(iterator, list, iterator, iterator) called with second iterator not referring to the list argument");
2025 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__l)) == _VSTD::addressof(__c),1972 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__l)) == _VSTD::addressof(__c),
2026 "list::splice(iterator, list, iterator, iterator) called with third iterator not referring to the list argument");1973 "list::splice(iterator, list, iterator, iterator) called with third iterator not referring to the list argument");
1974 _LIBCPP_DEBUG_ASSERT(this != std::addressof(__c) || !std::__iterator_in_range(__f, __l, __p),
1975 "list::splice(iterator, list, iterator, iterator)"
1976 " called with the first iterator within the range of the second and third iterators");
20271977
2028#if _LIBCPP_DEBUG_LEVEL == 2
2029 if (this == _VSTD::addressof(__c))
2030 {
2031 for (const_iterator __i = __f; __i != __l; ++__i)
2032 _LIBCPP_DEBUG_ASSERT(__i != __p,
2033 "list::splice(iterator, list, iterator, iterator)"
2034 " called with the first iterator within the range of the second and third iterators");
2035 }
2036#endif
2037 if (__f != __l)1978 if (__f != __l)
2038 {1979 {
2039 __link_pointer __first = __f.__ptr_;1980 __link_pointer __first = __f.__ptr_;
...@@ -2047,7 +1988,7 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, con...@@ -2047,7 +1988,7 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, con
2047 }1988 }
2048 base::__unlink_nodes(__first, __last);1989 base::__unlink_nodes(__first, __last);
2049 __link_nodes(__p.__ptr_, __first, __last);1990 __link_nodes(__p.__ptr_, __first, __last);
2050#if _LIBCPP_DEBUG_LEVEL == 21991#ifdef _LIBCPP_ENABLE_DEBUG_MODE
2051 if (_VSTD::addressof(__c) != this) {1992 if (_VSTD::addressof(__c) != this) {
2052 __libcpp_db* __db = __get_db();1993 __libcpp_db* __db = __get_db();
2053 __c_node* __cn1 = __db->__find_c_and_lock(this);1994 __c_node* __cn1 = __db->__find_c_and_lock(this);
...@@ -2184,7 +2125,7 @@ list<_Tp, _Alloc>::merge(list& __c, _Comp __comp)...@@ -2184,7 +2125,7 @@ list<_Tp, _Alloc>::merge(list& __c, _Comp __comp)
2184 ++__f1;2125 ++__f1;
2185 }2126 }
2186 splice(__e1, __c);2127 splice(__e1, __c);
2187#if _LIBCPP_DEBUG_LEVEL == 22128#ifdef _LIBCPP_ENABLE_DEBUG_MODE
2188 __libcpp_db* __db = __get_db();2129 __libcpp_db* __db = __get_db();
2189 __c_node* __cn1 = __db->__find_c_and_lock(this);2130 __c_node* __cn1 = __db->__find_c_and_lock(this);
2190 __c_node* __cn2 = __db->__find_c(_VSTD::addressof(__c));2131 __c_node* __cn2 = __db->__find_c(_VSTD::addressof(__c));
...@@ -2308,7 +2249,7 @@ list<_Tp, _Alloc>::__invariants() const...@@ -2308,7 +2249,7 @@ list<_Tp, _Alloc>::__invariants() const
2308 return size() == _VSTD::distance(begin(), end());2249 return size() == _VSTD::distance(begin(), end());
2309}2250}
23102251
2311#if _LIBCPP_DEBUG_LEVEL == 22252#ifdef _LIBCPP_ENABLE_DEBUG_MODE
23122253
2313template <class _Tp, class _Alloc>2254template <class _Tp, class _Alloc>
2314bool2255bool
...@@ -2338,7 +2279,7 @@ list<_Tp, _Alloc>::__subscriptable(const const_iterator*, ptrdiff_t) const...@@ -2338,7 +2279,7 @@ list<_Tp, _Alloc>::__subscriptable(const const_iterator*, ptrdiff_t) const
2338 return false;2279 return false;
2339}2280}
23402281
2341#endif // _LIBCPP_DEBUG_LEVEL == 22282#endif // _LIBCPP_ENABLE_DEBUG_MODE
23422283
2343template <class _Tp, class _Alloc>2284template <class _Tp, class _Alloc>
2344inline _LIBCPP_INLINE_VISIBILITY2285inline _LIBCPP_INLINE_VISIBILITY
...@@ -2409,8 +2350,16 @@ inline _LIBCPP_INLINE_VISIBILITY typename list<_Tp, _Allocator>::size_type...@@ -2409,8 +2350,16 @@ inline _LIBCPP_INLINE_VISIBILITY typename list<_Tp, _Allocator>::size_type
2409erase(list<_Tp, _Allocator>& __c, const _Up& __v) {2350erase(list<_Tp, _Allocator>& __c, const _Up& __v) {
2410 return _VSTD::erase_if(__c, [&](auto& __elem) { return __elem == __v; });2351 return _VSTD::erase_if(__c, [&](auto& __elem) { return __elem == __v; });
2411}2352}
2353
2354template <>
2355inline constexpr bool __format::__enable_insertable<std::list<char>> = true;
2356#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
2357template <>
2358inline constexpr bool __format::__enable_insertable<std::list<wchar_t>> = true;
2412#endif2359#endif
24132360
2361#endif // _LIBCPP_STD_VER > 17
2362
2414_LIBCPP_END_NAMESPACE_STD2363_LIBCPP_END_NAMESPACE_STD
24152364
2416_LIBCPP_POP_MACROS2365_LIBCPP_POP_MACROS
lib/libcxx/include/locale+85-55
...@@ -187,26 +187,37 @@ template <class charT> class messages_byname;...@@ -187,26 +187,37 @@ template <class charT> class messages_byname;
187187
188*/188*/
189189
190#include <__algorithm/copy.h>
191#include <__algorithm/equal.h>
192#include <__algorithm/find.h>
193#include <__algorithm/max.h>
194#include <__algorithm/reverse.h>
195#include <__algorithm/unwrap_iter.h>
196#include <__assert> // all public C++ headers provide the assertion handler
190#include <__config>197#include <__config>
191#include <__debug>198#include <__debug>
199#include <__iterator/access.h>
200#include <__iterator/back_insert_iterator.h>
201#include <__iterator/istreambuf_iterator.h>
202#include <__iterator/ostreambuf_iterator.h>
192#include <__locale>203#include <__locale>
193#include <algorithm>204#include <cstdarg> // TODO: Remove this include
194#ifndef __APPLE__
195# include <cstdarg>
196#endif
197#include <cstdio>205#include <cstdio>
198#include <cstdlib>206#include <cstdlib>
199#include <ctime>207#include <ctime>
200#include <ios>208#include <ios>
201#include <iterator>
202#include <limits>209#include <limits>
203#include <memory>210#include <memory>
204#include <streambuf>211#include <streambuf>
205#include <version>212#include <version>
206213
214#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
215# include <iterator>
216#endif
217
207#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))218#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
208// Most unix variants have catopen. These are the specific ones that don't.219// Most unix variants have catopen. These are the specific ones that don't.
209# if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION)220# if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION) && !defined(__EMSCRIPTEN__)
210# define _LIBCPP_HAS_CATOPEN 1221# define _LIBCPP_HAS_CATOPEN 1
211# include <nl_types.h>222# include <nl_types.h>
212# endif223# endif
...@@ -219,7 +230,7 @@ template <class charT> class messages_byname;...@@ -219,7 +230,7 @@ template <class charT> class messages_byname;
219#endif230#endif
220231
221#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)232#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
222#pragma GCC system_header233# pragma GCC system_header
223#endif234#endif
224235
225_LIBCPP_PUSH_MACROS236_LIBCPP_PUSH_MACROS
...@@ -572,9 +583,9 @@ __num_get<_CharT>::__stage2_float_loop(_CharT __ct, bool& __in_units, char& __ex...@@ -572,9 +583,9 @@ __num_get<_CharT>::__stage2_float_loop(_CharT __ct, bool& __in_units, char& __ex
572 return 0;583 return 0;
573}584}
574585
575_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get<char>)586extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get<char>;
576#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS587#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
577_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get<wchar_t>)588extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get<wchar_t>;
578#endif589#endif
579590
580template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >591template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >
...@@ -1112,9 +1123,9 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,...@@ -1112,9 +1123,9 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
1112 return __b;1123 return __b;
1113}1124}
11141125
1115_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get<char>)1126extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get<char>;
1116#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS1127#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
1117_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get<wchar_t>)1128extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get<wchar_t>;
1118#endif1129#endif
11191130
1120struct _LIBCPP_TYPE_VIS __num_put_base1131struct _LIBCPP_TYPE_VIS __num_put_base
...@@ -1264,9 +1275,9 @@ __num_put<_CharT>::__widen_and_group_float(char* __nb, char* __np, char* __ne,...@@ -1264,9 +1275,9 @@ __num_put<_CharT>::__widen_and_group_float(char* __nb, char* __np, char* __ne,
1264 __op = __ob + (__np - __nb);1275 __op = __ob + (__np - __nb);
1265}1276}
12661277
1267_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put<char>)1278extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put<char>;
1268#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS1279#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
1269_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put<wchar_t>)1280extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put<wchar_t>;
1270#endif1281#endif
12711282
1272template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >1283template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >
...@@ -1456,7 +1467,7 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,...@@ -1456,7 +1467,7 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
1456 return do_put(__s, __iob, __fl, (unsigned long)__v);1467 return do_put(__s, __iob, __fl, (unsigned long)__v);
1457 const numpunct<char_type>& __np = use_facet<numpunct<char_type> >(__iob.getloc());1468 const numpunct<char_type>& __np = use_facet<numpunct<char_type> >(__iob.getloc());
1458 typedef typename numpunct<char_type>::string_type string_type;1469 typedef typename numpunct<char_type>::string_type string_type;
1459#if _LIBCPP_DEBUG_LEVEL == 21470#ifdef _LIBCPP_ENABLE_DEBUG_MODE
1460 string_type __tmp(__v ? __np.truename() : __np.falsename());1471 string_type __tmp(__v ? __np.truename() : __np.falsename());
1461 string_type __nm = _VSTD::move(__tmp);1472 string_type __nm = _VSTD::move(__tmp);
1462#else1473#else
...@@ -1486,10 +1497,11 @@ num_put<_CharT, _OutputIterator>::__do_put_integral(iter_type __s, ios_base& __i...@@ -1486,10 +1497,11 @@ num_put<_CharT, _OutputIterator>::__do_put_integral(iter_type __s, ios_base& __i
1486 + ((numeric_limits<_Unsigned>::digits % 3) != 0) // round up1497 + ((numeric_limits<_Unsigned>::digits % 3) != 0) // round up
1487 + 2; // base prefix + terminating null character1498 + 2; // base prefix + terminating null character
1488 char __nar[__nbuf];1499 char __nar[__nbuf];
1489#pragma clang diagnostic push1500 _LIBCPP_DIAGNOSTIC_PUSH
1490#pragma clang diagnostic ignored "-Wformat-nonliteral"1501 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wformat-nonliteral")
1502 _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wformat-nonliteral")
1491 int __nc = __libcpp_snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);1503 int __nc = __libcpp_snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
1492#pragma clang diagnostic pop1504 _LIBCPP_DIAGNOSTIC_POP
1493 char* __ne = __nar + __nc;1505 char* __ne = __nar + __nc;
1494 char* __np = this->__identify_padding(__nar, __ne, __iob);1506 char* __np = this->__identify_padding(__nar, __ne, __iob);
1495 // Stage 2 - Widen __nar while adding thousands separators1507 // Stage 2 - Widen __nar while adding thousands separators
...@@ -1549,8 +1561,9 @@ num_put<_CharT, _OutputIterator>::__do_put_floating_point(iter_type __s, ios_bas...@@ -1549,8 +1561,9 @@ num_put<_CharT, _OutputIterator>::__do_put_floating_point(iter_type __s, ios_bas
1549 char __nar[__nbuf];1561 char __nar[__nbuf];
1550 char* __nb = __nar;1562 char* __nb = __nar;
1551 int __nc;1563 int __nc;
1552#pragma clang diagnostic push1564 _LIBCPP_DIAGNOSTIC_PUSH
1553#pragma clang diagnostic ignored "-Wformat-nonliteral"1565 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wformat-nonliteral")
1566 _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wformat-nonliteral")
1554 if (__specify_precision)1567 if (__specify_precision)
1555 __nc = __libcpp_snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt,1568 __nc = __libcpp_snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt,
1556 (int)__iob.precision(), __v);1569 (int)__iob.precision(), __v);
...@@ -1567,7 +1580,7 @@ num_put<_CharT, _OutputIterator>::__do_put_floating_point(iter_type __s, ios_bas...@@ -1567,7 +1580,7 @@ num_put<_CharT, _OutputIterator>::__do_put_floating_point(iter_type __s, ios_bas
1567 __throw_bad_alloc();1580 __throw_bad_alloc();
1568 __nbh.reset(__nb);1581 __nbh.reset(__nb);
1569 }1582 }
1570#pragma clang diagnostic pop1583 _LIBCPP_DIAGNOSTIC_POP
1571 char* __ne = __nb + __nc;1584 char* __ne = __nb + __nc;
1572 char* __np = this->__identify_padding(__nb, __ne, __iob);1585 char* __np = this->__identify_padding(__nb, __ne, __iob);
1573 // Stage 2 - Widen __nar while adding thousands separators1586 // Stage 2 - Widen __nar while adding thousands separators
...@@ -1633,9 +1646,9 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,...@@ -1633,9 +1646,9 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
1633 return __pad_and_output(__s, __o, __op, __oe, __iob, __fl);1646 return __pad_and_output(__s, __o, __op, __oe, __iob, __fl);
1634}1647}
16351648
1636_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<char>)1649extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<char>;
1637#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS1650#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
1638_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<wchar_t>)1651extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<wchar_t>;
1639#endif1652#endif
16401653
1641template <class _CharT, class _InputIterator>1654template <class _CharT, class _InputIterator>
...@@ -1918,7 +1931,7 @@ time_get<_CharT, _InputIterator>::__get_month(int& __m,...@@ -1918,7 +1931,7 @@ time_get<_CharT, _InputIterator>::__get_month(int& __m,
1918 const ctype<char_type>& __ct) const1931 const ctype<char_type>& __ct) const
1919{1932{
1920 int __t = __get_up_to_n_digits(__b, __e, __err, __ct, 2) - 1;1933 int __t = __get_up_to_n_digits(__b, __e, __err, __ct, 2) - 1;
1921 if (!(__err & ios_base::failbit) && __t <= 11)1934 if (!(__err & ios_base::failbit) && 0 <= __t && __t <= 11)
1922 __m = __t;1935 __m = __t;
1923 else1936 else
1924 __err |= ios_base::failbit;1937 __err |= ios_base::failbit;
...@@ -2323,9 +2336,9 @@ time_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,...@@ -2323,9 +2336,9 @@ time_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
2323 return __b;2336 return __b;
2324}2337}
23252338
2326_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get<char>)2339extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get<char>;
2327#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS2340#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
2328_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get<wchar_t>)2341extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get<wchar_t>;
2329#endif2342#endif
23302343
2331class _LIBCPP_TYPE_VIS __time_get2344class _LIBCPP_TYPE_VIS __time_get
...@@ -2425,9 +2438,9 @@ private:...@@ -2425,9 +2438,9 @@ private:
2425 virtual const string_type& __X() const {return this->__X_;}2438 virtual const string_type& __X() const {return this->__X_;}
2426};2439};
24272440
2428_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<char>)2441extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<char>;
2429#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS2442#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
2430_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<wchar_t>)2443extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<wchar_t>;
2431#endif2444#endif
24322445
2433class _LIBCPP_TYPE_VIS __time_put2446class _LIBCPP_TYPE_VIS __time_put
...@@ -2540,9 +2553,9 @@ time_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base&,...@@ -2540,9 +2553,9 @@ time_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base&,
2540 return _VSTD::copy(__nb, __ne, __s);2553 return _VSTD::copy(__nb, __ne, __s);
2541}2554}
25422555
2543_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put<char>)2556extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put<char>;
2544#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS2557#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
2545_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put<wchar_t>)2558extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put<wchar_t>;
2546#endif2559#endif
25472560
2548template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >2561template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >
...@@ -2563,9 +2576,9 @@ protected:...@@ -2563,9 +2576,9 @@ protected:
2563 ~time_put_byname() {}2576 ~time_put_byname() {}
2564};2577};
25652578
2566_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<char>)2579extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<char>;
2567#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS2580#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
2568_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<wchar_t>)2581extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<wchar_t>;
2569#endif2582#endif
25702583
2571// money_base2584// money_base
...@@ -2632,11 +2645,11 @@ template <class _CharT, bool _International>...@@ -2632,11 +2645,11 @@ template <class _CharT, bool _International>
2632const bool2645const bool
2633moneypunct<_CharT, _International>::intl;2646moneypunct<_CharT, _International>::intl;
26342647
2635_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<char, false>)2648extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<char, false>;
2636_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<char, true>)2649extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<char, true>;
2637#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS2650#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
2638_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<wchar_t, false>)2651extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<wchar_t, false>;
2639_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<wchar_t, true>)2652extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<wchar_t, true>;
2640#endif2653#endif
26412654
2642// moneypunct_byname2655// moneypunct_byname
...@@ -2688,14 +2701,14 @@ private:...@@ -2688,14 +2701,14 @@ private:
26882701
2689template<> _LIBCPP_FUNC_VIS void moneypunct_byname<char, false>::init(const char*);2702template<> _LIBCPP_FUNC_VIS void moneypunct_byname<char, false>::init(const char*);
2690template<> _LIBCPP_FUNC_VIS void moneypunct_byname<char, true>::init(const char*);2703template<> _LIBCPP_FUNC_VIS void moneypunct_byname<char, true>::init(const char*);
2691_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<char, false>)2704extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<char, false>;
2692_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<char, true>)2705extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<char, true>;
26932706
2694#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS2707#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
2695template<> _LIBCPP_FUNC_VIS void moneypunct_byname<wchar_t, false>::init(const char*);2708template<> _LIBCPP_FUNC_VIS void moneypunct_byname<wchar_t, false>::init(const char*);
2696template<> _LIBCPP_FUNC_VIS void moneypunct_byname<wchar_t, true>::init(const char*);2709template<> _LIBCPP_FUNC_VIS void moneypunct_byname<wchar_t, true>::init(const char*);
2697_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<wchar_t, false>)2710extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<wchar_t, false>;
2698_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<wchar_t, true>)2711extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<wchar_t, true>;
2699#endif2712#endif
27002713
2701// money_get2714// money_get
...@@ -2752,9 +2765,9 @@ __money_get<_CharT>::__gather_info(bool __intl, const locale& __loc,...@@ -2752,9 +2765,9 @@ __money_get<_CharT>::__gather_info(bool __intl, const locale& __loc,
2752 }2765 }
2753}2766}
27542767
2755_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get<char>)2768extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get<char>;
2756#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS2769#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
2757_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get<wchar_t>)2770extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get<wchar_t>;
2758#endif2771#endif
27592772
2760template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >2773template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >
...@@ -3121,9 +3134,9 @@ money_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,...@@ -3121,9 +3134,9 @@ money_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
3121 return __b;3134 return __b;
3122}3135}
31233136
3124_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get<char>)3137extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get<char>;
3125#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS3138#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
3126_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get<wchar_t>)3139extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get<wchar_t>;
3127#endif3140#endif
31283141
3129// money_put3142// money_put
...@@ -3214,9 +3227,9 @@ __money_put<_CharT>::__format(char_type* __mb, char_type*& __mi, char_type*& __m...@@ -3214,9 +3227,9 @@ __money_put<_CharT>::__format(char_type* __mb, char_type*& __mi, char_type*& __m
3214 int __fd)3227 int __fd)
3215{3228{
3216 __me = __mb;3229 __me = __mb;
3217 for (unsigned __p = 0; __p < 4; ++__p)3230 for (char __p : __pat.field)
3218 {3231 {
3219 switch (__pat.field[__p])3232 switch (__p)
3220 {3233 {
3221 case money_base::none:3234 case money_base::none:
3222 __mi = __me;3235 __mi = __me;
...@@ -3298,9 +3311,9 @@ __money_put<_CharT>::__format(char_type* __mb, char_type*& __mi, char_type*& __m...@@ -3298,9 +3311,9 @@ __money_put<_CharT>::__format(char_type* __mb, char_type*& __mi, char_type*& __m
3298 __mi = __mb;3311 __mi = __mb;
3299}3312}
33003313
3301_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put<char>)3314extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put<char>;
3302#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS3315#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
3303_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put<wchar_t>)3316extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put<wchar_t>;
3304#endif3317#endif
33053318
3306template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >3319template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >
...@@ -3453,9 +3466,9 @@ money_put<_CharT, _OutputIterator>::do_put(iter_type __s, bool __intl,...@@ -3453,9 +3466,9 @@ money_put<_CharT, _OutputIterator>::do_put(iter_type __s, bool __intl,
3453 return __pad_and_output(__s, __mb, __mi, __me, __iob, __fl);3466 return __pad_and_output(__s, __mb, __mi, __me, __iob, __fl);
3454}3467}
34553468
3456_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<char>)3469extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<char>;
3457#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS3470#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
3458_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<wchar_t>)3471extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<wchar_t>;
3459#endif3472#endif
34603473
3461// messages3474// messages
...@@ -3571,9 +3584,9 @@ messages<_CharT>::do_close(catalog __c) const...@@ -3571,9 +3584,9 @@ messages<_CharT>::do_close(catalog __c) const
3571#endif // _LIBCPP_HAS_CATOPEN3584#endif // _LIBCPP_HAS_CATOPEN
3572}3585}
35733586
3574_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages<char>)3587extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages<char>;
3575#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS3588#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
3576_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages<wchar_t>)3589extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages<wchar_t>;
3577#endif3590#endif
35783591
3579template <class _CharT>3592template <class _CharT>
...@@ -3597,15 +3610,15 @@ protected:...@@ -3597,15 +3610,15 @@ protected:
3597 ~messages_byname() {}3610 ~messages_byname() {}
3598};3611};
35993612
3600_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<char>)3613extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<char>;
3601#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS3614#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
3602_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<wchar_t>)3615extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<wchar_t>;
3603#endif3616#endif
36043617
3605template<class _Codecvt, class _Elem = wchar_t,3618template<class _Codecvt, class _Elem = wchar_t,
3606 class _Wide_alloc = allocator<_Elem>,3619 class _Wide_alloc = allocator<_Elem>,
3607 class _Byte_alloc = allocator<char> >3620 class _Byte_alloc = allocator<char> >
3608class _LIBCPP_TEMPLATE_VIS wstring_convert3621class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 wstring_convert
3609{3622{
3610public:3623public:
3611 typedef basic_string<char, char_traits<char>, _Byte_alloc> byte_string;3624 typedef basic_string<char, char_traits<char>, _Byte_alloc> byte_string;
...@@ -3672,6 +3685,7 @@ public:...@@ -3672,6 +3685,7 @@ public:
3672 state_type state() const {return __cvtstate_;}3685 state_type state() const {return __cvtstate_;}
3673};3686};
36743687
3688_LIBCPP_SUPPRESS_DEPRECATED_PUSH
3675template<class _Codecvt, class _Elem, class _Wide_alloc, class _Byte_alloc>3689template<class _Codecvt, class _Elem, class _Wide_alloc, class _Byte_alloc>
3676inline3690inline
3677wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::3691wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::
...@@ -3679,6 +3693,7 @@ wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::...@@ -3679,6 +3693,7 @@ wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::
3679 : __cvtptr_(__pcvt), __cvtstate_(), __cvtcount_(0)3693 : __cvtptr_(__pcvt), __cvtstate_(), __cvtcount_(0)
3680{3694{
3681}3695}
3696_LIBCPP_SUPPRESS_DEPRECATED_POP
36823697
3683template<class _Codecvt, class _Elem, class _Wide_alloc, class _Byte_alloc>3698template<class _Codecvt, class _Elem, class _Wide_alloc, class _Byte_alloc>
3684inline3699inline
...@@ -3713,6 +3728,7 @@ wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::...@@ -3713,6 +3728,7 @@ wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::
37133728
3714#endif // _LIBCPP_CXX03_LANG3729#endif // _LIBCPP_CXX03_LANG
37153730
3731_LIBCPP_SUPPRESS_DEPRECATED_PUSH
3716template<class _Codecvt, class _Elem, class _Wide_alloc, class _Byte_alloc>3732template<class _Codecvt, class _Elem, class _Wide_alloc, class _Byte_alloc>
3717wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::~wstring_convert()3733wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::~wstring_convert()
3718{3734{
...@@ -3724,6 +3740,7 @@ typename wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::wide_string...@@ -3724,6 +3740,7 @@ typename wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::wide_string
3724wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::3740wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::
3725 from_bytes(const char* __frm, const char* __frm_end)3741 from_bytes(const char* __frm, const char* __frm_end)
3726{3742{
3743_LIBCPP_SUPPRESS_DEPRECATED_POP
3727 __cvtcount_ = 0;3744 __cvtcount_ = 0;
3728 if (__cvtptr_ != nullptr)3745 if (__cvtptr_ != nullptr)
3729 {3746 {
...@@ -3870,7 +3887,7 @@ wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::...@@ -3870,7 +3887,7 @@ wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::
3870}3887}
38713888
3872template <class _Codecvt, class _Elem = wchar_t, class _Tr = char_traits<_Elem> >3889template <class _Codecvt, class _Elem = wchar_t, class _Tr = char_traits<_Elem> >
3873class _LIBCPP_TEMPLATE_VIS wbuffer_convert3890class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 wbuffer_convert
3874 : public basic_streambuf<_Elem, _Tr>3891 : public basic_streambuf<_Elem, _Tr>
3875{3892{
3876public:3893public:
...@@ -3947,6 +3964,7 @@ private:...@@ -3947,6 +3964,7 @@ private:
3947 wbuffer_convert* __close();3964 wbuffer_convert* __close();
3948};3965};
39493966
3967_LIBCPP_SUPPRESS_DEPRECATED_PUSH
3950template <class _Codecvt, class _Elem, class _Tr>3968template <class _Codecvt, class _Elem, class _Tr>
3951wbuffer_convert<_Codecvt, _Elem, _Tr>::3969wbuffer_convert<_Codecvt, _Elem, _Tr>::
3952 wbuffer_convert(streambuf* __bytebuf, _Codecvt* __pcvt, state_type __state)3970 wbuffer_convert(streambuf* __bytebuf, _Codecvt* __pcvt, state_type __state)
...@@ -3982,6 +4000,7 @@ template <class _Codecvt, class _Elem, class _Tr>...@@ -3982,6 +4000,7 @@ template <class _Codecvt, class _Elem, class _Tr>
3982typename wbuffer_convert<_Codecvt, _Elem, _Tr>::int_type4000typename wbuffer_convert<_Codecvt, _Elem, _Tr>::int_type
3983wbuffer_convert<_Codecvt, _Elem, _Tr>::underflow()4001wbuffer_convert<_Codecvt, _Elem, _Tr>::underflow()
3984{4002{
4003_LIBCPP_SUPPRESS_DEPRECATED_POP
3985 if (__cv_ == 0 || __bufptr_ == 0)4004 if (__cv_ == 0 || __bufptr_ == 0)
3986 return traits_type::eof();4005 return traits_type::eof();
3987 bool __initial = __read_mode();4006 bool __initial = __read_mode();
...@@ -4046,10 +4065,12 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::underflow()...@@ -4046,10 +4065,12 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::underflow()
4046 return __c;4065 return __c;
4047}4066}
40484067
4068_LIBCPP_SUPPRESS_DEPRECATED_PUSH
4049template <class _Codecvt, class _Elem, class _Tr>4069template <class _Codecvt, class _Elem, class _Tr>
4050typename wbuffer_convert<_Codecvt, _Elem, _Tr>::int_type4070typename wbuffer_convert<_Codecvt, _Elem, _Tr>::int_type
4051wbuffer_convert<_Codecvt, _Elem, _Tr>::pbackfail(int_type __c)4071wbuffer_convert<_Codecvt, _Elem, _Tr>::pbackfail(int_type __c)
4052{4072{
4073_LIBCPP_SUPPRESS_DEPRECATED_POP
4053 if (__cv_ != 0 && __bufptr_ != 0 && this->eback() < this->gptr())4074 if (__cv_ != 0 && __bufptr_ != 0 && this->eback() < this->gptr())
4054 {4075 {
4055 if (traits_type::eq_int_type(__c, traits_type::eof()))4076 if (traits_type::eq_int_type(__c, traits_type::eof()))
...@@ -4067,10 +4088,12 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::pbackfail(int_type __c)...@@ -4067,10 +4088,12 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::pbackfail(int_type __c)
4067 return traits_type::eof();4088 return traits_type::eof();
4068}4089}
40694090
4091_LIBCPP_SUPPRESS_DEPRECATED_PUSH
4070template <class _Codecvt, class _Elem, class _Tr>4092template <class _Codecvt, class _Elem, class _Tr>
4071typename wbuffer_convert<_Codecvt, _Elem, _Tr>::int_type4093typename wbuffer_convert<_Codecvt, _Elem, _Tr>::int_type
4072wbuffer_convert<_Codecvt, _Elem, _Tr>::overflow(int_type __c)4094wbuffer_convert<_Codecvt, _Elem, _Tr>::overflow(int_type __c)
4073{4095{
4096_LIBCPP_SUPPRESS_DEPRECATED_POP
4074 if (__cv_ == 0 || __bufptr_ == 0)4097 if (__cv_ == 0 || __bufptr_ == 0)
4075 return traits_type::eof();4098 return traits_type::eof();
4076 __write_mode();4099 __write_mode();
...@@ -4129,10 +4152,12 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::overflow(int_type __c)...@@ -4129,10 +4152,12 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::overflow(int_type __c)
4129 return traits_type::not_eof(__c);4152 return traits_type::not_eof(__c);
4130}4153}
41314154
4155_LIBCPP_SUPPRESS_DEPRECATED_PUSH
4132template <class _Codecvt, class _Elem, class _Tr>4156template <class _Codecvt, class _Elem, class _Tr>
4133basic_streambuf<_Elem, _Tr>*4157basic_streambuf<_Elem, _Tr>*
4134wbuffer_convert<_Codecvt, _Elem, _Tr>::setbuf(char_type* __s, streamsize __n)4158wbuffer_convert<_Codecvt, _Elem, _Tr>::setbuf(char_type* __s, streamsize __n)
4135{4159{
4160_LIBCPP_SUPPRESS_DEPRECATED_POP
4136 this->setg(0, 0, 0);4161 this->setg(0, 0, 0);
4137 this->setp(0, 0);4162 this->setp(0, 0);
4138 if (__owns_eb_)4163 if (__owns_eb_)
...@@ -4182,6 +4207,7 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::setbuf(char_type* __s, streamsize __n)...@@ -4182,6 +4207,7 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::setbuf(char_type* __s, streamsize __n)
4182 return this;4207 return this;
4183}4208}
41844209
4210_LIBCPP_SUPPRESS_DEPRECATED_PUSH
4185template <class _Codecvt, class _Elem, class _Tr>4211template <class _Codecvt, class _Elem, class _Tr>
4186typename wbuffer_convert<_Codecvt, _Elem, _Tr>::pos_type4212typename wbuffer_convert<_Codecvt, _Elem, _Tr>::pos_type
4187wbuffer_convert<_Codecvt, _Elem, _Tr>::seekoff(off_type __off, ios_base::seekdir __way,4213wbuffer_convert<_Codecvt, _Elem, _Tr>::seekoff(off_type __off, ios_base::seekdir __way,
...@@ -4213,6 +4239,7 @@ template <class _Codecvt, class _Elem, class _Tr>...@@ -4213,6 +4239,7 @@ template <class _Codecvt, class _Elem, class _Tr>
4213int4239int
4214wbuffer_convert<_Codecvt, _Elem, _Tr>::sync()4240wbuffer_convert<_Codecvt, _Elem, _Tr>::sync()
4215{4241{
4242_LIBCPP_SUPPRESS_DEPRECATED_POP
4216 if (__cv_ == 0 || __bufptr_ == 0)4243 if (__cv_ == 0 || __bufptr_ == 0)
4217 return 0;4244 return 0;
4218 if (__cm_ & ios_base::out)4245 if (__cm_ & ios_base::out)
...@@ -4281,6 +4308,7 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::sync()...@@ -4281,6 +4308,7 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::sync()
4281 return 0;4308 return 0;
4282}4309}
42834310
4311_LIBCPP_SUPPRESS_DEPRECATED_PUSH
4284template <class _Codecvt, class _Elem, class _Tr>4312template <class _Codecvt, class _Elem, class _Tr>
4285bool4313bool
4286wbuffer_convert<_Codecvt, _Elem, _Tr>::__read_mode()4314wbuffer_convert<_Codecvt, _Elem, _Tr>::__read_mode()
...@@ -4335,6 +4363,8 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::__close()...@@ -4335,6 +4363,8 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::__close()
4335 return __rt;4363 return __rt;
4336}4364}
43374365
4366_LIBCPP_SUPPRESS_DEPRECATED_POP
4367
4338_LIBCPP_END_NAMESPACE_STD4368_LIBCPP_END_NAMESPACE_STD
43394369
4340_LIBCPP_POP_MACROS4370_LIBCPP_POP_MACROS
lib/libcxx/include/locale.h+2-2
...@@ -36,11 +36,11 @@ Functions:...@@ -36,11 +36,11 @@ Functions:
36#include <__config>36#include <__config>
3737
38#if defined(_LIBCPP_HAS_NO_LOCALIZATION)38#if defined(_LIBCPP_HAS_NO_LOCALIZATION)
39# error "The Localization library is not supported since libc++ has been configured with LIBCXX_ENABLE_LOCALIZATION disabled"39# error "<locale.h> is not supported since libc++ has been configured without support for localization."
40#endif40#endif
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
44#endif44#endif
4545
46#include_next <locale.h>46#include_next <locale.h>
lib/libcxx/include/map+65-64
...@@ -528,24 +528,45 @@ erase_if(multimap<Key, T, Compare, Allocator>& c, Predicate pred); // C++20...@@ -528,24 +528,45 @@ erase_if(multimap<Key, T, Compare, Allocator>& c, Predicate pred); // C++20
528528
529*/529*/
530530
531#include <__algorithm/equal.h>
532#include <__algorithm/lexicographical_compare.h>
533#include <__assert> // all public C++ headers provide the assertion handler
531#include <__config>534#include <__config>
532#include <__debug>535#include <__functional/binary_function.h>
533#include <__functional/is_transparent.h>536#include <__functional/is_transparent.h>
537#include <__functional/operations.h>
538#include <__iterator/erase_if_container.h>
534#include <__iterator/iterator_traits.h>539#include <__iterator/iterator_traits.h>
540#include <__iterator/reverse_iterator.h>
535#include <__node_handle>541#include <__node_handle>
536#include <__tree>542#include <__tree>
537#include <__utility/forward.h>543#include <__utility/forward.h>
538#include <compare>544#include <__utility/swap.h>
539#include <functional>
540#include <initializer_list>
541#include <iterator> // __libcpp_erase_if_container
542#include <memory>545#include <memory>
543#include <type_traits>546#include <type_traits>
544#include <utility>
545#include <version>547#include <version>
546548
549#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
550# include <functional>
551# include <iterator>
552# include <utility>
553#endif
554
555// standard-mandated includes
556
557// [iterator.range]
558#include <__iterator/access.h>
559#include <__iterator/data.h>
560#include <__iterator/empty.h>
561#include <__iterator/reverse_access.h>
562#include <__iterator/size.h>
563
564// [associative.map.syn]
565#include <compare>
566#include <initializer_list>
567
547#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)568#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
548#pragma GCC system_header569# pragma GCC system_header
549#endif570#endif
550571
551_LIBCPP_BEGIN_NAMESPACE_STD572_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -561,9 +582,9 @@ public:...@@ -561,9 +582,9 @@ public:
561 _NOEXCEPT_(is_nothrow_default_constructible<_Compare>::value)582 _NOEXCEPT_(is_nothrow_default_constructible<_Compare>::value)
562 : _Compare() {}583 : _Compare() {}
563 _LIBCPP_INLINE_VISIBILITY584 _LIBCPP_INLINE_VISIBILITY
564 __map_value_compare(_Compare c)585 __map_value_compare(_Compare __c)
565 _NOEXCEPT_(is_nothrow_copy_constructible<_Compare>::value)586 _NOEXCEPT_(is_nothrow_copy_constructible<_Compare>::value)
566 : _Compare(c) {}587 : _Compare(__c) {}
567 _LIBCPP_INLINE_VISIBILITY588 _LIBCPP_INLINE_VISIBILITY
568 const _Compare& key_comp() const _NOEXCEPT {return *this;}589 const _Compare& key_comp() const _NOEXCEPT {return *this;}
569 _LIBCPP_INLINE_VISIBILITY590 _LIBCPP_INLINE_VISIBILITY
...@@ -606,9 +627,9 @@ public:...@@ -606,9 +627,9 @@ public:
606 _NOEXCEPT_(is_nothrow_default_constructible<_Compare>::value)627 _NOEXCEPT_(is_nothrow_default_constructible<_Compare>::value)
607 : comp() {}628 : comp() {}
608 _LIBCPP_INLINE_VISIBILITY629 _LIBCPP_INLINE_VISIBILITY
609 __map_value_compare(_Compare c)630 __map_value_compare(_Compare __c)
610 _NOEXCEPT_(is_nothrow_copy_constructible<_Compare>::value)631 _NOEXCEPT_(is_nothrow_copy_constructible<_Compare>::value)
611 : comp(c) {}632 : comp(__c) {}
612 _LIBCPP_INLINE_VISIBILITY633 _LIBCPP_INLINE_VISIBILITY
613 const _Compare& key_comp() const _NOEXCEPT {return comp;}634 const _Compare& key_comp() const _NOEXCEPT {return comp;}
614635
...@@ -771,9 +792,7 @@ public:...@@ -771,9 +792,7 @@ public:
771 }792 }
772793
773 template <class _ValueTp,794 template <class _ValueTp,
774 class = typename enable_if<795 class = __enable_if_t<__is_same_uncvref<_ValueTp, value_type>::value>
775 __is_same_uncvref<_ValueTp, value_type>::value
776 >::type
777 >796 >
778 _LIBCPP_INLINE_VISIBILITY797 _LIBCPP_INLINE_VISIBILITY
779 __value_type& operator=(_ValueTp&& __v)798 __value_type& operator=(_ValueTp&& __v)
...@@ -956,32 +975,23 @@ public:...@@ -956,32 +975,23 @@ public:
956 typedef _Key key_type;975 typedef _Key key_type;
957 typedef _Tp mapped_type;976 typedef _Tp mapped_type;
958 typedef pair<const key_type, mapped_type> value_type;977 typedef pair<const key_type, mapped_type> value_type;
959 typedef __identity_t<_Compare> key_compare;978 typedef __type_identity_t<_Compare> key_compare;
960 typedef __identity_t<_Allocator> allocator_type;979 typedef __type_identity_t<_Allocator> allocator_type;
961 typedef value_type& reference;980 typedef value_type& reference;
962 typedef const value_type& const_reference;981 typedef const value_type& const_reference;
963982
964 static_assert((is_same<typename allocator_type::value_type, value_type>::value),983 static_assert((is_same<typename allocator_type::value_type, value_type>::value),
965 "Allocator::value_type must be same type as value_type");984 "Allocator::value_type must be same type as value_type");
966985
967_LIBCPP_SUPPRESS_DEPRECATED_PUSH
968 class _LIBCPP_TEMPLATE_VIS value_compare986 class _LIBCPP_TEMPLATE_VIS value_compare
969#if defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)987 : public __binary_function<value_type, value_type, bool>
970 : public binary_function<value_type, value_type, bool>
971#endif
972 {988 {
973_LIBCPP_SUPPRESS_DEPRECATED_POP
974 friend class map;989 friend class map;
975 protected:990 protected:
976 key_compare comp;991 key_compare comp;
977992
978 _LIBCPP_INLINE_VISIBILITY value_compare(key_compare c) : comp(c) {}993 _LIBCPP_INLINE_VISIBILITY value_compare(key_compare __c) : comp(__c) {}
979 public:994 public:
980#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
981 _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
982 _LIBCPP_DEPRECATED_IN_CXX17 typedef value_type first_argument_type;
983 _LIBCPP_DEPRECATED_IN_CXX17 typedef value_type second_argument_type;
984#endif
985 _LIBCPP_INLINE_VISIBILITY995 _LIBCPP_INLINE_VISIBILITY
986 bool operator()(const value_type& __x, const value_type& __y) const996 bool operator()(const value_type& __x, const value_type& __y) const
987 {return comp(__x.first, __y.first);}997 {return comp(__x.first, __y.first);}
...@@ -1218,13 +1228,13 @@ public:...@@ -1218,13 +1228,13 @@ public:
1218 }1228 }
12191229
1220 template <class _Pp,1230 template <class _Pp,
1221 class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>1231 class = __enable_if_t<is_constructible<value_type, _Pp>::value> >
1222 _LIBCPP_INLINE_VISIBILITY1232 _LIBCPP_INLINE_VISIBILITY
1223 pair<iterator, bool> insert(_Pp&& __p)1233 pair<iterator, bool> insert(_Pp&& __p)
1224 {return __tree_.__insert_unique(_VSTD::forward<_Pp>(__p));}1234 {return __tree_.__insert_unique(_VSTD::forward<_Pp>(__p));}
12251235
1226 template <class _Pp,1236 template <class _Pp,
1227 class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>1237 class = __enable_if_t<is_constructible<value_type, _Pp>::value> >
1228 _LIBCPP_INLINE_VISIBILITY1238 _LIBCPP_INLINE_VISIBILITY
1229 iterator insert(const_iterator __pos, _Pp&& __p)1239 iterator insert(const_iterator __pos, _Pp&& __p)
1230 {return __tree_.__insert_unique(__pos.__i_, _VSTD::forward<_Pp>(__p));}1240 {return __tree_.__insert_unique(__pos.__i_, _VSTD::forward<_Pp>(__p));}
...@@ -1444,11 +1454,11 @@ public:...@@ -1444,11 +1454,11 @@ public:
1444#if _LIBCPP_STD_VER > 111454#if _LIBCPP_STD_VER > 11
1445 template <typename _K2>1455 template <typename _K2>
1446 _LIBCPP_INLINE_VISIBILITY1456 _LIBCPP_INLINE_VISIBILITY
1447 typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type1457 __enable_if_t<__is_transparent<_Compare, _K2>::value, iterator>
1448 find(const _K2& __k) {return __tree_.find(__k);}1458 find(const _K2& __k) {return __tree_.find(__k);}
1449 template <typename _K2>1459 template <typename _K2>
1450 _LIBCPP_INLINE_VISIBILITY1460 _LIBCPP_INLINE_VISIBILITY
1451 typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type1461 __enable_if_t<__is_transparent<_Compare, _K2>::value, const_iterator>
1452 find(const _K2& __k) const {return __tree_.find(__k);}1462 find(const _K2& __k) const {return __tree_.find(__k);}
1453#endif1463#endif
14541464
...@@ -1458,7 +1468,7 @@ public:...@@ -1458,7 +1468,7 @@ public:
1458#if _LIBCPP_STD_VER > 111468#if _LIBCPP_STD_VER > 11
1459 template <typename _K2>1469 template <typename _K2>
1460 _LIBCPP_INLINE_VISIBILITY1470 _LIBCPP_INLINE_VISIBILITY
1461 typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type1471 __enable_if_t<__is_transparent<_Compare, _K2>::value, size_type>
1462 count(const _K2& __k) const {return __tree_.__count_multi(__k);}1472 count(const _K2& __k) const {return __tree_.__count_multi(__k);}
1463#endif1473#endif
14641474
...@@ -1467,7 +1477,7 @@ public:...@@ -1467,7 +1477,7 @@ public:
1467 bool contains(const key_type& __k) const {return find(__k) != end();}1477 bool contains(const key_type& __k) const {return find(__k) != end();}
1468 template <typename _K2>1478 template <typename _K2>
1469 _LIBCPP_INLINE_VISIBILITY1479 _LIBCPP_INLINE_VISIBILITY
1470 typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type1480 __enable_if_t<__is_transparent<_Compare, _K2>::value, bool>
1471 contains(const _K2& __k) const { return find(__k) != end(); }1481 contains(const _K2& __k) const { return find(__k) != end(); }
1472#endif // _LIBCPP_STD_VER > 171482#endif // _LIBCPP_STD_VER > 17
14731483
...@@ -1480,12 +1490,12 @@ public:...@@ -1480,12 +1490,12 @@ public:
1480#if _LIBCPP_STD_VER > 111490#if _LIBCPP_STD_VER > 11
1481 template <typename _K2>1491 template <typename _K2>
1482 _LIBCPP_INLINE_VISIBILITY1492 _LIBCPP_INLINE_VISIBILITY
1483 typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type1493 __enable_if_t<__is_transparent<_Compare, _K2>::value, iterator>
1484 lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);}1494 lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);}
14851495
1486 template <typename _K2>1496 template <typename _K2>
1487 _LIBCPP_INLINE_VISIBILITY1497 _LIBCPP_INLINE_VISIBILITY
1488 typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type1498 __enable_if_t<__is_transparent<_Compare, _K2>::value, const_iterator>
1489 lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);}1499 lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);}
1490#endif1500#endif
14911501
...@@ -1498,11 +1508,11 @@ public:...@@ -1498,11 +1508,11 @@ public:
1498#if _LIBCPP_STD_VER > 111508#if _LIBCPP_STD_VER > 11
1499 template <typename _K2>1509 template <typename _K2>
1500 _LIBCPP_INLINE_VISIBILITY1510 _LIBCPP_INLINE_VISIBILITY
1501 typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type1511 __enable_if_t<__is_transparent<_Compare, _K2>::value, iterator>
1502 upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);}1512 upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);}
1503 template <typename _K2>1513 template <typename _K2>
1504 _LIBCPP_INLINE_VISIBILITY1514 _LIBCPP_INLINE_VISIBILITY
1505 typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type1515 __enable_if_t<__is_transparent<_Compare, _K2>::value, const_iterator>
1506 upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);}1516 upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);}
1507#endif1517#endif
15081518
...@@ -1515,11 +1525,11 @@ public:...@@ -1515,11 +1525,11 @@ public:
1515#if _LIBCPP_STD_VER > 111525#if _LIBCPP_STD_VER > 11
1516 template <typename _K2>1526 template <typename _K2>
1517 _LIBCPP_INLINE_VISIBILITY1527 _LIBCPP_INLINE_VISIBILITY
1518 typename enable_if<__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type1528 __enable_if_t<__is_transparent<_Compare, _K2>::value, pair<iterator,iterator>>
1519 equal_range(const _K2& __k) {return __tree_.__equal_range_multi(__k);}1529 equal_range(const _K2& __k) {return __tree_.__equal_range_multi(__k);}
1520 template <typename _K2>1530 template <typename _K2>
1521 _LIBCPP_INLINE_VISIBILITY1531 _LIBCPP_INLINE_VISIBILITY
1522 typename enable_if<__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type1532 __enable_if_t<__is_transparent<_Compare, _K2>::value, pair<const_iterator,const_iterator>>
1523 equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);}1533 equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);}
1524#endif1534#endif
15251535
...@@ -1741,33 +1751,24 @@ public:...@@ -1741,33 +1751,24 @@ public:
1741 typedef _Key key_type;1751 typedef _Key key_type;
1742 typedef _Tp mapped_type;1752 typedef _Tp mapped_type;
1743 typedef pair<const key_type, mapped_type> value_type;1753 typedef pair<const key_type, mapped_type> value_type;
1744 typedef __identity_t<_Compare> key_compare;1754 typedef __type_identity_t<_Compare> key_compare;
1745 typedef __identity_t<_Allocator> allocator_type;1755 typedef __type_identity_t<_Allocator> allocator_type;
1746 typedef value_type& reference;1756 typedef value_type& reference;
1747 typedef const value_type& const_reference;1757 typedef const value_type& const_reference;
17481758
1749 static_assert((is_same<typename allocator_type::value_type, value_type>::value),1759 static_assert((is_same<typename allocator_type::value_type, value_type>::value),
1750 "Allocator::value_type must be same type as value_type");1760 "Allocator::value_type must be same type as value_type");
17511761
1752_LIBCPP_SUPPRESS_DEPRECATED_PUSH
1753 class _LIBCPP_TEMPLATE_VIS value_compare1762 class _LIBCPP_TEMPLATE_VIS value_compare
1754#if defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)1763 : public __binary_function<value_type, value_type, bool>
1755 : public binary_function<value_type, value_type, bool>
1756#endif
1757 {1764 {
1758_LIBCPP_SUPPRESS_DEPRECATED_POP
1759 friend class multimap;1765 friend class multimap;
1760 protected:1766 protected:
1761 key_compare comp;1767 key_compare comp;
17621768
1763 _LIBCPP_INLINE_VISIBILITY1769 _LIBCPP_INLINE_VISIBILITY
1764 value_compare(key_compare c) : comp(c) {}1770 value_compare(key_compare __c) : comp(__c) {}
1765 public:1771 public:
1766#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
1767 _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
1768 _LIBCPP_DEPRECATED_IN_CXX17 typedef value_type first_argument_type;
1769 _LIBCPP_DEPRECATED_IN_CXX17 typedef value_type second_argument_type;
1770#endif
1771 _LIBCPP_INLINE_VISIBILITY1772 _LIBCPP_INLINE_VISIBILITY
1772 bool operator()(const value_type& __x, const value_type& __y) const1773 bool operator()(const value_type& __x, const value_type& __y) const
1773 {return comp(__x.first, __y.first);}1774 {return comp(__x.first, __y.first);}
...@@ -1997,13 +1998,13 @@ public:...@@ -1997,13 +1998,13 @@ public:
1997 }1998 }
19981999
1999 template <class _Pp,2000 template <class _Pp,
2000 class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>2001 class = __enable_if_t<is_constructible<value_type, _Pp>::value>>
2001 _LIBCPP_INLINE_VISIBILITY2002 _LIBCPP_INLINE_VISIBILITY
2002 iterator insert(_Pp&& __p)2003 iterator insert(_Pp&& __p)
2003 {return __tree_.__insert_multi(_VSTD::forward<_Pp>(__p));}2004 {return __tree_.__insert_multi(_VSTD::forward<_Pp>(__p));}
20042005
2005 template <class _Pp,2006 template <class _Pp,
2006 class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>2007 class = __enable_if_t<is_constructible<value_type, _Pp>::value>>
2007 _LIBCPP_INLINE_VISIBILITY2008 _LIBCPP_INLINE_VISIBILITY
2008 iterator insert(const_iterator __pos, _Pp&& __p)2009 iterator insert(const_iterator __pos, _Pp&& __p)
2009 {return __tree_.__insert_multi(__pos.__i_, _VSTD::forward<_Pp>(__p));}2010 {return __tree_.__insert_multi(__pos.__i_, _VSTD::forward<_Pp>(__p));}
...@@ -2125,11 +2126,11 @@ public:...@@ -2125,11 +2126,11 @@ public:
2125#if _LIBCPP_STD_VER > 112126#if _LIBCPP_STD_VER > 11
2126 template <typename _K2>2127 template <typename _K2>
2127 _LIBCPP_INLINE_VISIBILITY2128 _LIBCPP_INLINE_VISIBILITY
2128 typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type2129 __enable_if_t<__is_transparent<_Compare, _K2>::value, iterator>
2129 find(const _K2& __k) {return __tree_.find(__k);}2130 find(const _K2& __k) {return __tree_.find(__k);}
2130 template <typename _K2>2131 template <typename _K2>
2131 _LIBCPP_INLINE_VISIBILITY2132 _LIBCPP_INLINE_VISIBILITY
2132 typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type2133 __enable_if_t<__is_transparent<_Compare, _K2>::value, const_iterator>
2133 find(const _K2& __k) const {return __tree_.find(__k);}2134 find(const _K2& __k) const {return __tree_.find(__k);}
2134#endif2135#endif
21352136
...@@ -2139,7 +2140,7 @@ public:...@@ -2139,7 +2140,7 @@ public:
2139#if _LIBCPP_STD_VER > 112140#if _LIBCPP_STD_VER > 11
2140 template <typename _K2>2141 template <typename _K2>
2141 _LIBCPP_INLINE_VISIBILITY2142 _LIBCPP_INLINE_VISIBILITY
2142 typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type2143 __enable_if_t<__is_transparent<_Compare, _K2>::value, size_type>
2143 count(const _K2& __k) const {return __tree_.__count_multi(__k);}2144 count(const _K2& __k) const {return __tree_.__count_multi(__k);}
2144#endif2145#endif
21452146
...@@ -2148,7 +2149,7 @@ public:...@@ -2148,7 +2149,7 @@ public:
2148 bool contains(const key_type& __k) const {return find(__k) != end();}2149 bool contains(const key_type& __k) const {return find(__k) != end();}
2149 template <typename _K2>2150 template <typename _K2>
2150 _LIBCPP_INLINE_VISIBILITY2151 _LIBCPP_INLINE_VISIBILITY
2151 typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type2152 __enable_if_t<__is_transparent<_Compare, _K2>::value, bool>
2152 contains(const _K2& __k) const { return find(__k) != end(); }2153 contains(const _K2& __k) const { return find(__k) != end(); }
2153#endif // _LIBCPP_STD_VER > 172154#endif // _LIBCPP_STD_VER > 17
21542155
...@@ -2161,12 +2162,12 @@ public:...@@ -2161,12 +2162,12 @@ public:
2161#if _LIBCPP_STD_VER > 112162#if _LIBCPP_STD_VER > 11
2162 template <typename _K2>2163 template <typename _K2>
2163 _LIBCPP_INLINE_VISIBILITY2164 _LIBCPP_INLINE_VISIBILITY
2164 typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type2165 __enable_if_t<__is_transparent<_Compare, _K2>::value, iterator>
2165 lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);}2166 lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);}
21662167
2167 template <typename _K2>2168 template <typename _K2>
2168 _LIBCPP_INLINE_VISIBILITY2169 _LIBCPP_INLINE_VISIBILITY
2169 typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type2170 __enable_if_t<__is_transparent<_Compare, _K2>::value, const_iterator>
2170 lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);}2171 lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);}
2171#endif2172#endif
21722173
...@@ -2179,11 +2180,11 @@ public:...@@ -2179,11 +2180,11 @@ public:
2179#if _LIBCPP_STD_VER > 112180#if _LIBCPP_STD_VER > 11
2180 template <typename _K2>2181 template <typename _K2>
2181 _LIBCPP_INLINE_VISIBILITY2182 _LIBCPP_INLINE_VISIBILITY
2182 typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type2183 __enable_if_t<__is_transparent<_Compare, _K2>::value, iterator>
2183 upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);}2184 upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);}
2184 template <typename _K2>2185 template <typename _K2>
2185 _LIBCPP_INLINE_VISIBILITY2186 _LIBCPP_INLINE_VISIBILITY
2186 typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type2187 __enable_if_t<__is_transparent<_Compare, _K2>::value, const_iterator>
2187 upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);}2188 upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);}
2188#endif2189#endif
21892190
...@@ -2196,11 +2197,11 @@ public:...@@ -2196,11 +2197,11 @@ public:
2196#if _LIBCPP_STD_VER > 112197#if _LIBCPP_STD_VER > 11
2197 template <typename _K2>2198 template <typename _K2>
2198 _LIBCPP_INLINE_VISIBILITY2199 _LIBCPP_INLINE_VISIBILITY
2199 typename enable_if<__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type2200 __enable_if_t<__is_transparent<_Compare, _K2>::value, pair<iterator,iterator>>
2200 equal_range(const _K2& __k) {return __tree_.__equal_range_multi(__k);}2201 equal_range(const _K2& __k) {return __tree_.__equal_range_multi(__k);}
2201 template <typename _K2>2202 template <typename _K2>
2202 _LIBCPP_INLINE_VISIBILITY2203 _LIBCPP_INLINE_VISIBILITY
2203 typename enable_if<__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type2204 __enable_if_t<__is_transparent<_Compare, _K2>::value, pair<const_iterator,const_iterator>>
2204 equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);}2205 equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);}
2205#endif2206#endif
22062207
lib/libcxx/include/math.h+45-44
...@@ -294,7 +294,7 @@ long double truncl(long double x);...@@ -294,7 +294,7 @@ long double truncl(long double x);
294#include <__config>294#include <__config>
295295
296#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)296#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
297#pragma GCC system_header297# pragma GCC system_header
298#endif298#endif
299299
300#include_next <math.h>300#include_next <math.h>
...@@ -305,6 +305,7 @@ long double truncl(long double x);...@@ -305,6 +305,7 @@ long double truncl(long double x);
305// back to C++ linkage before including these C++ headers.305// back to C++ linkage before including these C++ headers.
306extern "C++" {306extern "C++" {
307307
308#include <__type_traits/promote.h>
308#include <limits>309#include <limits>
309#include <stdlib.h>310#include <stdlib.h>
310#include <type_traits>311#include <type_traits>
...@@ -788,10 +789,10 @@ isunordered(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT...@@ -788,10 +789,10 @@ isunordered(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
788789
789// acos790// acos
790791
791#if !(defined(_AIX) || defined(__sun__))792# if !defined(__sun__)
792inline _LIBCPP_INLINE_VISIBILITY float acos(float __lcpp_x) _NOEXCEPT {return ::acosf(__lcpp_x);}793inline _LIBCPP_INLINE_VISIBILITY float acos(float __lcpp_x) _NOEXCEPT {return ::acosf(__lcpp_x);}
793inline _LIBCPP_INLINE_VISIBILITY long double acos(long double __lcpp_x) _NOEXCEPT {return ::acosl(__lcpp_x);}794inline _LIBCPP_INLINE_VISIBILITY long double acos(long double __lcpp_x) _NOEXCEPT {return ::acosl(__lcpp_x);}
794#endif795# endif
795796
796template <class _A1>797template <class _A1>
797inline _LIBCPP_INLINE_VISIBILITY798inline _LIBCPP_INLINE_VISIBILITY
...@@ -800,10 +801,10 @@ acos(_A1 __lcpp_x) _NOEXCEPT {return ::acos((double)__lcpp_x);}...@@ -800,10 +801,10 @@ acos(_A1 __lcpp_x) _NOEXCEPT {return ::acos((double)__lcpp_x);}
800801
801// asin802// asin
802803
803#if !(defined(_AIX) || defined(__sun__))804# if !defined(__sun__)
804inline _LIBCPP_INLINE_VISIBILITY float asin(float __lcpp_x) _NOEXCEPT {return ::asinf(__lcpp_x);}805inline _LIBCPP_INLINE_VISIBILITY float asin(float __lcpp_x) _NOEXCEPT {return ::asinf(__lcpp_x);}
805inline _LIBCPP_INLINE_VISIBILITY long double asin(long double __lcpp_x) _NOEXCEPT {return ::asinl(__lcpp_x);}806inline _LIBCPP_INLINE_VISIBILITY long double asin(long double __lcpp_x) _NOEXCEPT {return ::asinl(__lcpp_x);}
806#endif807# endif
807808
808template <class _A1>809template <class _A1>
809inline _LIBCPP_INLINE_VISIBILITY810inline _LIBCPP_INLINE_VISIBILITY
...@@ -812,10 +813,10 @@ asin(_A1 __lcpp_x) _NOEXCEPT {return ::asin((double)__lcpp_x);}...@@ -812,10 +813,10 @@ asin(_A1 __lcpp_x) _NOEXCEPT {return ::asin((double)__lcpp_x);}
812813
813// atan814// atan
814815
815#if !(defined(_AIX) || defined(__sun__))816# if !defined(__sun__)
816inline _LIBCPP_INLINE_VISIBILITY float atan(float __lcpp_x) _NOEXCEPT {return ::atanf(__lcpp_x);}817inline _LIBCPP_INLINE_VISIBILITY float atan(float __lcpp_x) _NOEXCEPT {return ::atanf(__lcpp_x);}
817inline _LIBCPP_INLINE_VISIBILITY long double atan(long double __lcpp_x) _NOEXCEPT {return ::atanl(__lcpp_x);}818inline _LIBCPP_INLINE_VISIBILITY long double atan(long double __lcpp_x) _NOEXCEPT {return ::atanl(__lcpp_x);}
818#endif819# endif
819820
820template <class _A1>821template <class _A1>
821inline _LIBCPP_INLINE_VISIBILITY822inline _LIBCPP_INLINE_VISIBILITY
...@@ -824,10 +825,10 @@ atan(_A1 __lcpp_x) _NOEXCEPT {return ::atan((double)__lcpp_x);}...@@ -824,10 +825,10 @@ atan(_A1 __lcpp_x) _NOEXCEPT {return ::atan((double)__lcpp_x);}
824825
825// atan2826// atan2
826827
827#if !(defined(_AIX) || defined(__sun__))828# if !defined(__sun__)
828inline _LIBCPP_INLINE_VISIBILITY float atan2(float __lcpp_y, float __lcpp_x) _NOEXCEPT {return ::atan2f(__lcpp_y, __lcpp_x);}829inline _LIBCPP_INLINE_VISIBILITY float atan2(float __lcpp_y, float __lcpp_x) _NOEXCEPT {return ::atan2f(__lcpp_y, __lcpp_x);}
829inline _LIBCPP_INLINE_VISIBILITY long double atan2(long double __lcpp_y, long double __lcpp_x) _NOEXCEPT {return ::atan2l(__lcpp_y, __lcpp_x);}830inline _LIBCPP_INLINE_VISIBILITY long double atan2(long double __lcpp_y, long double __lcpp_x) _NOEXCEPT {return ::atan2l(__lcpp_y, __lcpp_x);}
830#endif831# endif
831832
832template <class _A1, class _A2>833template <class _A1, class _A2>
833inline _LIBCPP_INLINE_VISIBILITY834inline _LIBCPP_INLINE_VISIBILITY
...@@ -847,10 +848,10 @@ atan2(_A1 __lcpp_y, _A2 __lcpp_x) _NOEXCEPT...@@ -847,10 +848,10 @@ atan2(_A1 __lcpp_y, _A2 __lcpp_x) _NOEXCEPT
847848
848// ceil849// ceil
849850
850#if !(defined(_AIX) || defined(__sun__))851# if !defined(__sun__)
851inline _LIBCPP_INLINE_VISIBILITY float ceil(float __lcpp_x) _NOEXCEPT {return ::ceilf(__lcpp_x);}852inline _LIBCPP_INLINE_VISIBILITY float ceil(float __lcpp_x) _NOEXCEPT {return ::ceilf(__lcpp_x);}
852inline _LIBCPP_INLINE_VISIBILITY long double ceil(long double __lcpp_x) _NOEXCEPT {return ::ceill(__lcpp_x);}853inline _LIBCPP_INLINE_VISIBILITY long double ceil(long double __lcpp_x) _NOEXCEPT {return ::ceill(__lcpp_x);}
853#endif854# endif
854855
855template <class _A1>856template <class _A1>
856inline _LIBCPP_INLINE_VISIBILITY857inline _LIBCPP_INLINE_VISIBILITY
...@@ -859,10 +860,10 @@ ceil(_A1 __lcpp_x) _NOEXCEPT {return ::ceil((double)__lcpp_x);}...@@ -859,10 +860,10 @@ ceil(_A1 __lcpp_x) _NOEXCEPT {return ::ceil((double)__lcpp_x);}
859860
860// cos861// cos
861862
862#if !(defined(_AIX) || defined(__sun__))863# if !defined(__sun__)
863inline _LIBCPP_INLINE_VISIBILITY float cos(float __lcpp_x) _NOEXCEPT {return ::cosf(__lcpp_x);}864inline _LIBCPP_INLINE_VISIBILITY float cos(float __lcpp_x) _NOEXCEPT {return ::cosf(__lcpp_x);}
864inline _LIBCPP_INLINE_VISIBILITY long double cos(long double __lcpp_x) _NOEXCEPT {return ::cosl(__lcpp_x);}865inline _LIBCPP_INLINE_VISIBILITY long double cos(long double __lcpp_x) _NOEXCEPT {return ::cosl(__lcpp_x);}
865#endif866# endif
866867
867template <class _A1>868template <class _A1>
868inline _LIBCPP_INLINE_VISIBILITY869inline _LIBCPP_INLINE_VISIBILITY
...@@ -871,10 +872,10 @@ cos(_A1 __lcpp_x) _NOEXCEPT {return ::cos((double)__lcpp_x);}...@@ -871,10 +872,10 @@ cos(_A1 __lcpp_x) _NOEXCEPT {return ::cos((double)__lcpp_x);}
871872
872// cosh873// cosh
873874
874#if !(defined(_AIX) || defined(__sun__))875# if !defined(__sun__)
875inline _LIBCPP_INLINE_VISIBILITY float cosh(float __lcpp_x) _NOEXCEPT {return ::coshf(__lcpp_x);}876inline _LIBCPP_INLINE_VISIBILITY float cosh(float __lcpp_x) _NOEXCEPT {return ::coshf(__lcpp_x);}
876inline _LIBCPP_INLINE_VISIBILITY long double cosh(long double __lcpp_x) _NOEXCEPT {return ::coshl(__lcpp_x);}877inline _LIBCPP_INLINE_VISIBILITY long double cosh(long double __lcpp_x) _NOEXCEPT {return ::coshl(__lcpp_x);}
877#endif878# endif
878879
879template <class _A1>880template <class _A1>
880inline _LIBCPP_INLINE_VISIBILITY881inline _LIBCPP_INLINE_VISIBILITY
...@@ -883,10 +884,10 @@ cosh(_A1 __lcpp_x) _NOEXCEPT {return ::cosh((double)__lcpp_x);}...@@ -883,10 +884,10 @@ cosh(_A1 __lcpp_x) _NOEXCEPT {return ::cosh((double)__lcpp_x);}
883884
884// exp885// exp
885886
886#if !(defined(_AIX) || defined(__sun__))887# if !defined(__sun__)
887inline _LIBCPP_INLINE_VISIBILITY float exp(float __lcpp_x) _NOEXCEPT {return ::expf(__lcpp_x);}888inline _LIBCPP_INLINE_VISIBILITY float exp(float __lcpp_x) _NOEXCEPT {return ::expf(__lcpp_x);}
888inline _LIBCPP_INLINE_VISIBILITY long double exp(long double __lcpp_x) _NOEXCEPT {return ::expl(__lcpp_x);}889inline _LIBCPP_INLINE_VISIBILITY long double exp(long double __lcpp_x) _NOEXCEPT {return ::expl(__lcpp_x);}
889#endif890# endif
890891
891template <class _A1>892template <class _A1>
892inline _LIBCPP_INLINE_VISIBILITY893inline _LIBCPP_INLINE_VISIBILITY
...@@ -895,10 +896,10 @@ exp(_A1 __lcpp_x) _NOEXCEPT {return ::exp((double)__lcpp_x);}...@@ -895,10 +896,10 @@ exp(_A1 __lcpp_x) _NOEXCEPT {return ::exp((double)__lcpp_x);}
895896
896// fabs897// fabs
897898
898#if !(defined(_AIX) || defined(__sun__))899# if !defined(__sun__)
899inline _LIBCPP_INLINE_VISIBILITY float fabs(float __lcpp_x) _NOEXCEPT {return ::fabsf(__lcpp_x);}900inline _LIBCPP_INLINE_VISIBILITY float fabs(float __lcpp_x) _NOEXCEPT {return ::fabsf(__lcpp_x);}
900inline _LIBCPP_INLINE_VISIBILITY long double fabs(long double __lcpp_x) _NOEXCEPT {return ::fabsl(__lcpp_x);}901inline _LIBCPP_INLINE_VISIBILITY long double fabs(long double __lcpp_x) _NOEXCEPT {return ::fabsl(__lcpp_x);}
901#endif902# endif
902903
903template <class _A1>904template <class _A1>
904inline _LIBCPP_INLINE_VISIBILITY905inline _LIBCPP_INLINE_VISIBILITY
...@@ -907,10 +908,10 @@ fabs(_A1 __lcpp_x) _NOEXCEPT {return ::fabs((double)__lcpp_x);}...@@ -907,10 +908,10 @@ fabs(_A1 __lcpp_x) _NOEXCEPT {return ::fabs((double)__lcpp_x);}
907908
908// floor909// floor
909910
910#if !(defined(_AIX) || defined(__sun__))911# if !defined(__sun__)
911inline _LIBCPP_INLINE_VISIBILITY float floor(float __lcpp_x) _NOEXCEPT {return ::floorf(__lcpp_x);}912inline _LIBCPP_INLINE_VISIBILITY float floor(float __lcpp_x) _NOEXCEPT {return ::floorf(__lcpp_x);}
912inline _LIBCPP_INLINE_VISIBILITY long double floor(long double __lcpp_x) _NOEXCEPT {return ::floorl(__lcpp_x);}913inline _LIBCPP_INLINE_VISIBILITY long double floor(long double __lcpp_x) _NOEXCEPT {return ::floorl(__lcpp_x);}
913#endif914# endif
914915
915template <class _A1>916template <class _A1>
916inline _LIBCPP_INLINE_VISIBILITY917inline _LIBCPP_INLINE_VISIBILITY
...@@ -919,10 +920,10 @@ floor(_A1 __lcpp_x) _NOEXCEPT {return ::floor((double)__lcpp_x);}...@@ -919,10 +920,10 @@ floor(_A1 __lcpp_x) _NOEXCEPT {return ::floor((double)__lcpp_x);}
919920
920// fmod921// fmod
921922
922#if !(defined(_AIX) || defined(__sun__))923# if !defined(__sun__)
923inline _LIBCPP_INLINE_VISIBILITY float fmod(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::fmodf(__lcpp_x, __lcpp_y);}924inline _LIBCPP_INLINE_VISIBILITY float fmod(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::fmodf(__lcpp_x, __lcpp_y);}
924inline _LIBCPP_INLINE_VISIBILITY long double fmod(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::fmodl(__lcpp_x, __lcpp_y);}925inline _LIBCPP_INLINE_VISIBILITY long double fmod(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::fmodl(__lcpp_x, __lcpp_y);}
925#endif926# endif
926927
927template <class _A1, class _A2>928template <class _A1, class _A2>
928inline _LIBCPP_INLINE_VISIBILITY929inline _LIBCPP_INLINE_VISIBILITY
...@@ -942,10 +943,10 @@ fmod(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT...@@ -942,10 +943,10 @@ fmod(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
942943
943// frexp944// frexp
944945
945#if !(defined(_AIX) || defined(__sun__))946# if !defined(__sun__)
946inline _LIBCPP_INLINE_VISIBILITY float frexp(float __lcpp_x, int* __lcpp_e) _NOEXCEPT {return ::frexpf(__lcpp_x, __lcpp_e);}947inline _LIBCPP_INLINE_VISIBILITY float frexp(float __lcpp_x, int* __lcpp_e) _NOEXCEPT {return ::frexpf(__lcpp_x, __lcpp_e);}
947inline _LIBCPP_INLINE_VISIBILITY long double frexp(long double __lcpp_x, int* __lcpp_e) _NOEXCEPT {return ::frexpl(__lcpp_x, __lcpp_e);}948inline _LIBCPP_INLINE_VISIBILITY long double frexp(long double __lcpp_x, int* __lcpp_e) _NOEXCEPT {return ::frexpl(__lcpp_x, __lcpp_e);}
948#endif949# endif
949950
950template <class _A1>951template <class _A1>
951inline _LIBCPP_INLINE_VISIBILITY952inline _LIBCPP_INLINE_VISIBILITY
...@@ -954,10 +955,10 @@ frexp(_A1 __lcpp_x, int* __lcpp_e) _NOEXCEPT {return ::frexp((double)__lcpp_x, _...@@ -954,10 +955,10 @@ frexp(_A1 __lcpp_x, int* __lcpp_e) _NOEXCEPT {return ::frexp((double)__lcpp_x, _
954955
955// ldexp956// ldexp
956957
957#if !(defined(_AIX) || defined(__sun__))958# if !defined(__sun__)
958inline _LIBCPP_INLINE_VISIBILITY float ldexp(float __lcpp_x, int __lcpp_e) _NOEXCEPT {return ::ldexpf(__lcpp_x, __lcpp_e);}959inline _LIBCPP_INLINE_VISIBILITY float ldexp(float __lcpp_x, int __lcpp_e) _NOEXCEPT {return ::ldexpf(__lcpp_x, __lcpp_e);}
959inline _LIBCPP_INLINE_VISIBILITY long double ldexp(long double __lcpp_x, int __lcpp_e) _NOEXCEPT {return ::ldexpl(__lcpp_x, __lcpp_e);}960inline _LIBCPP_INLINE_VISIBILITY long double ldexp(long double __lcpp_x, int __lcpp_e) _NOEXCEPT {return ::ldexpl(__lcpp_x, __lcpp_e);}
960#endif961# endif
961962
962template <class _A1>963template <class _A1>
963inline _LIBCPP_INLINE_VISIBILITY964inline _LIBCPP_INLINE_VISIBILITY
...@@ -966,10 +967,10 @@ ldexp(_A1 __lcpp_x, int __lcpp_e) _NOEXCEPT {return ::ldexp((double)__lcpp_x, __...@@ -966,10 +967,10 @@ ldexp(_A1 __lcpp_x, int __lcpp_e) _NOEXCEPT {return ::ldexp((double)__lcpp_x, __
966967
967// log968// log
968969
969#if !(defined(_AIX) || defined(__sun__))970# if !defined(__sun__)
970inline _LIBCPP_INLINE_VISIBILITY float log(float __lcpp_x) _NOEXCEPT {return ::logf(__lcpp_x);}971inline _LIBCPP_INLINE_VISIBILITY float log(float __lcpp_x) _NOEXCEPT {return ::logf(__lcpp_x);}
971inline _LIBCPP_INLINE_VISIBILITY long double log(long double __lcpp_x) _NOEXCEPT {return ::logl(__lcpp_x);}972inline _LIBCPP_INLINE_VISIBILITY long double log(long double __lcpp_x) _NOEXCEPT {return ::logl(__lcpp_x);}
972#endif973# endif
973974
974template <class _A1>975template <class _A1>
975inline _LIBCPP_INLINE_VISIBILITY976inline _LIBCPP_INLINE_VISIBILITY
...@@ -978,10 +979,10 @@ log(_A1 __lcpp_x) _NOEXCEPT {return ::log((double)__lcpp_x);}...@@ -978,10 +979,10 @@ log(_A1 __lcpp_x) _NOEXCEPT {return ::log((double)__lcpp_x);}
978979
979// log10980// log10
980981
981#if !(defined(_AIX) || defined(__sun__))982# if !defined(__sun__)
982inline _LIBCPP_INLINE_VISIBILITY float log10(float __lcpp_x) _NOEXCEPT {return ::log10f(__lcpp_x);}983inline _LIBCPP_INLINE_VISIBILITY float log10(float __lcpp_x) _NOEXCEPT {return ::log10f(__lcpp_x);}
983inline _LIBCPP_INLINE_VISIBILITY long double log10(long double __lcpp_x) _NOEXCEPT {return ::log10l(__lcpp_x);}984inline _LIBCPP_INLINE_VISIBILITY long double log10(long double __lcpp_x) _NOEXCEPT {return ::log10l(__lcpp_x);}
984#endif985# endif
985986
986template <class _A1>987template <class _A1>
987inline _LIBCPP_INLINE_VISIBILITY988inline _LIBCPP_INLINE_VISIBILITY
...@@ -990,17 +991,17 @@ log10(_A1 __lcpp_x) _NOEXCEPT {return ::log10((double)__lcpp_x);}...@@ -990,17 +991,17 @@ log10(_A1 __lcpp_x) _NOEXCEPT {return ::log10((double)__lcpp_x);}
990991
991// modf992// modf
992993
993#if !(defined(_AIX) || defined(__sun__))994# if !defined(__sun__)
994inline _LIBCPP_INLINE_VISIBILITY float modf(float __lcpp_x, float* __lcpp_y) _NOEXCEPT {return ::modff(__lcpp_x, __lcpp_y);}995inline _LIBCPP_INLINE_VISIBILITY float modf(float __lcpp_x, float* __lcpp_y) _NOEXCEPT {return ::modff(__lcpp_x, __lcpp_y);}
995inline _LIBCPP_INLINE_VISIBILITY long double modf(long double __lcpp_x, long double* __lcpp_y) _NOEXCEPT {return ::modfl(__lcpp_x, __lcpp_y);}996inline _LIBCPP_INLINE_VISIBILITY long double modf(long double __lcpp_x, long double* __lcpp_y) _NOEXCEPT {return ::modfl(__lcpp_x, __lcpp_y);}
996#endif997# endif
997998
998// pow999// pow
9991000
1000#if !(defined(_AIX) || defined(__sun__))1001# if !defined(__sun__)
1001inline _LIBCPP_INLINE_VISIBILITY float pow(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::powf(__lcpp_x, __lcpp_y);}1002inline _LIBCPP_INLINE_VISIBILITY float pow(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::powf(__lcpp_x, __lcpp_y);}
1002inline _LIBCPP_INLINE_VISIBILITY long double pow(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::powl(__lcpp_x, __lcpp_y);}1003inline _LIBCPP_INLINE_VISIBILITY long double pow(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::powl(__lcpp_x, __lcpp_y);}
1003#endif1004# endif
10041005
1005template <class _A1, class _A2>1006template <class _A1, class _A2>
1006inline _LIBCPP_INLINE_VISIBILITY1007inline _LIBCPP_INLINE_VISIBILITY
...@@ -1020,7 +1021,7 @@ pow(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT...@@ -1020,7 +1021,7 @@ pow(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
10201021
1021// sin1022// sin
10221023
1023#if !(defined(_AIX) || defined(__sun__))1024# if !defined(__sun__)
1024inline _LIBCPP_INLINE_VISIBILITY float sin(float __lcpp_x) _NOEXCEPT {return ::sinf(__lcpp_x);}1025inline _LIBCPP_INLINE_VISIBILITY float sin(float __lcpp_x) _NOEXCEPT {return ::sinf(__lcpp_x);}
1025inline _LIBCPP_INLINE_VISIBILITY long double sin(long double __lcpp_x) _NOEXCEPT {return ::sinl(__lcpp_x);}1026inline _LIBCPP_INLINE_VISIBILITY long double sin(long double __lcpp_x) _NOEXCEPT {return ::sinl(__lcpp_x);}
1026#endif1027#endif
...@@ -1032,10 +1033,10 @@ sin(_A1 __lcpp_x) _NOEXCEPT {return ::sin((double)__lcpp_x);}...@@ -1032,10 +1033,10 @@ sin(_A1 __lcpp_x) _NOEXCEPT {return ::sin((double)__lcpp_x);}
10321033
1033// sinh1034// sinh
10341035
1035#if !(defined(_AIX) || defined(__sun__))1036# if !defined(__sun__)
1036inline _LIBCPP_INLINE_VISIBILITY float sinh(float __lcpp_x) _NOEXCEPT {return ::sinhf(__lcpp_x);}1037inline _LIBCPP_INLINE_VISIBILITY float sinh(float __lcpp_x) _NOEXCEPT {return ::sinhf(__lcpp_x);}
1037inline _LIBCPP_INLINE_VISIBILITY long double sinh(long double __lcpp_x) _NOEXCEPT {return ::sinhl(__lcpp_x);}1038inline _LIBCPP_INLINE_VISIBILITY long double sinh(long double __lcpp_x) _NOEXCEPT {return ::sinhl(__lcpp_x);}
1038#endif1039# endif
10391040
1040template <class _A1>1041template <class _A1>
1041inline _LIBCPP_INLINE_VISIBILITY1042inline _LIBCPP_INLINE_VISIBILITY
...@@ -1044,10 +1045,10 @@ sinh(_A1 __lcpp_x) _NOEXCEPT {return ::sinh((double)__lcpp_x);}...@@ -1044,10 +1045,10 @@ sinh(_A1 __lcpp_x) _NOEXCEPT {return ::sinh((double)__lcpp_x);}
10441045
1045// sqrt1046// sqrt
10461047
1047#if !(defined(_AIX) || defined(__sun__))1048# if !defined(__sun__)
1048inline _LIBCPP_INLINE_VISIBILITY float sqrt(float __lcpp_x) _NOEXCEPT {return ::sqrtf(__lcpp_x);}1049inline _LIBCPP_INLINE_VISIBILITY float sqrt(float __lcpp_x) _NOEXCEPT {return ::sqrtf(__lcpp_x);}
1049inline _LIBCPP_INLINE_VISIBILITY long double sqrt(long double __lcpp_x) _NOEXCEPT {return ::sqrtl(__lcpp_x);}1050inline _LIBCPP_INLINE_VISIBILITY long double sqrt(long double __lcpp_x) _NOEXCEPT {return ::sqrtl(__lcpp_x);}
1050#endif1051# endif
10511052
1052template <class _A1>1053template <class _A1>
1053inline _LIBCPP_INLINE_VISIBILITY1054inline _LIBCPP_INLINE_VISIBILITY
...@@ -1056,10 +1057,10 @@ sqrt(_A1 __lcpp_x) _NOEXCEPT {return ::sqrt((double)__lcpp_x);}...@@ -1056,10 +1057,10 @@ sqrt(_A1 __lcpp_x) _NOEXCEPT {return ::sqrt((double)__lcpp_x);}
10561057
1057// tan1058// tan
10581059
1059#if !(defined(_AIX) || defined(__sun__))1060# if !defined(__sun__)
1060inline _LIBCPP_INLINE_VISIBILITY float tan(float __lcpp_x) _NOEXCEPT {return ::tanf(__lcpp_x);}1061inline _LIBCPP_INLINE_VISIBILITY float tan(float __lcpp_x) _NOEXCEPT {return ::tanf(__lcpp_x);}
1061inline _LIBCPP_INLINE_VISIBILITY long double tan(long double __lcpp_x) _NOEXCEPT {return ::tanl(__lcpp_x);}1062inline _LIBCPP_INLINE_VISIBILITY long double tan(long double __lcpp_x) _NOEXCEPT {return ::tanl(__lcpp_x);}
1062#endif1063# endif
10631064
1064template <class _A1>1065template <class _A1>
1065inline _LIBCPP_INLINE_VISIBILITY1066inline _LIBCPP_INLINE_VISIBILITY
...@@ -1068,10 +1069,10 @@ tan(_A1 __lcpp_x) _NOEXCEPT {return ::tan((double)__lcpp_x);}...@@ -1068,10 +1069,10 @@ tan(_A1 __lcpp_x) _NOEXCEPT {return ::tan((double)__lcpp_x);}
10681069
1069// tanh1070// tanh
10701071
1071#if !(defined(_AIX) || defined(__sun__))1072# if !defined(__sun__)
1072inline _LIBCPP_INLINE_VISIBILITY float tanh(float __lcpp_x) _NOEXCEPT {return ::tanhf(__lcpp_x);}1073inline _LIBCPP_INLINE_VISIBILITY float tanh(float __lcpp_x) _NOEXCEPT {return ::tanhf(__lcpp_x);}
1073inline _LIBCPP_INLINE_VISIBILITY long double tanh(long double __lcpp_x) _NOEXCEPT {return ::tanhl(__lcpp_x);}1074inline _LIBCPP_INLINE_VISIBILITY long double tanh(long double __lcpp_x) _NOEXCEPT {return ::tanhl(__lcpp_x);}
1074#endif1075# endif
10751076
1076template <class _A1>1077template <class _A1>
1077inline _LIBCPP_INLINE_VISIBILITY1078inline _LIBCPP_INLINE_VISIBILITY
lib/libcxx/include/memory+68-137
...@@ -98,6 +98,16 @@ struct allocator_traits...@@ -98,6 +98,16 @@ struct allocator_traits
98 static allocator_type select_on_container_copy_construction(const allocator_type& a); // constexpr in C++2098 static allocator_type select_on_container_copy_construction(const allocator_type& a); // constexpr in C++20
99};99};
100100
101template<class Pointer>
102struct allocation_result {
103 Pointer ptr;
104 size_t count;
105}; // since C++23
106
107template<class Allocator>
108[[nodiscard]] constexpr allocation_result<typename allocator_traits<Allocator>::pointer>
109 allocate_at_least(Allocator& a, size_t n); // since C++23
110
101template <>111template <>
102class allocator<void> // removed in C++20112class allocator<void> // removed in C++20
103{113{
...@@ -661,9 +671,29 @@ template<class E, class T, class Y>...@@ -661,9 +671,29 @@ template<class E, class T, class Y>
661template<class D, class T> D* get_deleter(shared_ptr<T> const& p) noexcept;671template<class D, class T> D* get_deleter(shared_ptr<T> const& p) noexcept;
662672
663template<class T, class... Args>673template<class T, class... Args>
664 shared_ptr<T> make_shared(Args&&... args);674 shared_ptr<T> make_shared(Args&&... args); // T is not an array
665template<class T, class A, class... Args>675template<class T, class A, class... Args>
666 shared_ptr<T> allocate_shared(const A& a, Args&&... args);676 shared_ptr<T> allocate_shared(const A& a, Args&&... args); // T is not an array
677
678template<class T>
679 shared_ptr<T> make_shared(size_t N); // T is U[] (since C++20)
680template<class T, class A>
681 shared_ptr<T> allocate_shared(const A& a, size_t N); // T is U[] (since C++20)
682
683template<class T>
684 shared_ptr<T> make_shared(); // T is U[N] (since C++20)
685template<class T, class A>
686 shared_ptr<T> allocate_shared(const A& a); // T is U[N] (since C++20)
687
688template<class T>
689 shared_ptr<T> make_shared(size_t N, const remove_extent_t<T>& u); // T is U[] (since C++20)
690template<class T, class A>
691 shared_ptr<T> allocate_shared(const A& a, size_t N, const remove_extent_t<T>& u); // T is U[] (since C++20)
692
693template<class T> shared_ptr<T>
694 make_shared(const remove_extent_t<T>& u); // T is U[N] (since C++20)
695template<class T, class A>
696 shared_ptr<T> allocate_shared(const A& a, const remove_extent_t<T>& u); // T is U[N] (since C++20)
667697
668template<class T>698template<class T>
669class weak_ptr699class weak_ptr
...@@ -798,19 +828,28 @@ template <class T> struct hash<shared_ptr<T> >;...@@ -798,19 +828,28 @@ template <class T> struct hash<shared_ptr<T> >;
798template <class T, class Alloc>828template <class T, class Alloc>
799 inline constexpr bool uses_allocator_v = uses_allocator<T, Alloc>::value;829 inline constexpr bool uses_allocator_v = uses_allocator<T, Alloc>::value;
800830
831// [ptr.align]
801void* align(size_t alignment, size_t size, void*& ptr, size_t& space);832void* align(size_t alignment, size_t size, void*& ptr, size_t& space);
802833
834template<size_t N, class T>
835[[nodiscard]] constexpr T* assume_aligned(T* ptr); // since C++20
836
803} // std837} // std
804838
805*/839*/
806840
841#include <__algorithm/copy.h>
842#include <__algorithm/move.h>
843#include <__assert> // all public C++ headers provide the assertion handler
807#include <__config>844#include <__config>
808#include <__functional_base>
809#include <__memory/addressof.h>845#include <__memory/addressof.h>
846#include <__memory/allocate_at_least.h>
810#include <__memory/allocation_guard.h>847#include <__memory/allocation_guard.h>
811#include <__memory/allocator.h>848#include <__memory/allocator.h>
812#include <__memory/allocator_arg_t.h>849#include <__memory/allocator_arg_t.h>
813#include <__memory/allocator_traits.h>850#include <__memory/allocator_traits.h>
851#include <__memory/assume_aligned.h>
852#include <__memory/auto_ptr.h>
814#include <__memory/compressed_pair.h>853#include <__memory/compressed_pair.h>
815#include <__memory/concepts.h>854#include <__memory/concepts.h>
816#include <__memory/construct_at.h>855#include <__memory/construct_at.h>
...@@ -823,117 +862,31 @@ void* align(size_t alignment, size_t size, void*& ptr, size_t& space);...@@ -823,117 +862,31 @@ void* align(size_t alignment, size_t size, void*& ptr, size_t& space);
823#include <__memory/uninitialized_algorithms.h>862#include <__memory/uninitialized_algorithms.h>
824#include <__memory/unique_ptr.h>863#include <__memory/unique_ptr.h>
825#include <__memory/uses_allocator.h>864#include <__memory/uses_allocator.h>
826#include <compare>
827#include <cstddef>865#include <cstddef>
828#include <cstdint>866#include <cstdint>
829#include <cstring>867#include <cstring>
830#include <iosfwd>868#include <iosfwd>
831#include <iterator>
832#include <new>869#include <new>
833#include <stdexcept>870#include <stdexcept>
834#include <tuple>871#include <tuple>
835#include <type_traits>872#include <type_traits>
836#include <typeinfo>873#include <typeinfo>
837#include <utility>
838#include <version>874#include <version>
839875
840#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)876#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
841# include <__memory/auto_ptr.h>877# include <iterator>
878# include <utility>
842#endif879#endif
843880
881// standard-mandated includes
882#include <compare>
883
844#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)884#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
845#pragma GCC system_header885# pragma GCC system_header
846#endif886#endif
847887
848_LIBCPP_BEGIN_NAMESPACE_STD888_LIBCPP_BEGIN_NAMESPACE_STD
849889
850template <class _Alloc, class _Ptr>
851_LIBCPP_INLINE_VISIBILITY
852void __construct_forward_with_exception_guarantees(_Alloc& __a, _Ptr __begin1, _Ptr __end1, _Ptr& __begin2) {
853 static_assert(__is_cpp17_move_insertable<_Alloc>::value,
854 "The specified type does not meet the requirements of Cpp17MoveInsertable");
855 typedef allocator_traits<_Alloc> _Traits;
856 for (; __begin1 != __end1; ++__begin1, (void)++__begin2) {
857 _Traits::construct(__a, _VSTD::__to_address(__begin2),
858#ifdef _LIBCPP_NO_EXCEPTIONS
859 _VSTD::move(*__begin1)
860#else
861 _VSTD::move_if_noexcept(*__begin1)
862#endif
863 );
864 }
865}
866
867template <class _Alloc, class _Tp, typename enable_if<
868 (__is_default_allocator<_Alloc>::value || !__has_construct<_Alloc, _Tp*, _Tp>::value) &&
869 is_trivially_move_constructible<_Tp>::value
870>::type>
871_LIBCPP_INLINE_VISIBILITY
872void __construct_forward_with_exception_guarantees(_Alloc&, _Tp* __begin1, _Tp* __end1, _Tp*& __begin2) {
873 ptrdiff_t _Np = __end1 - __begin1;
874 if (_Np > 0) {
875 _VSTD::memcpy(__begin2, __begin1, _Np * sizeof(_Tp));
876 __begin2 += _Np;
877 }
878}
879
880template <class _Alloc, class _Iter, class _Ptr>
881_LIBCPP_INLINE_VISIBILITY
882void __construct_range_forward(_Alloc& __a, _Iter __begin1, _Iter __end1, _Ptr& __begin2) {
883 typedef allocator_traits<_Alloc> _Traits;
884 for (; __begin1 != __end1; ++__begin1, (void) ++__begin2) {
885 _Traits::construct(__a, _VSTD::__to_address(__begin2), *__begin1);
886 }
887}
888
889template <class _Alloc, class _Source, class _Dest,
890 class _RawSource = typename remove_const<_Source>::type,
891 class _RawDest = typename remove_const<_Dest>::type,
892 class =
893 typename enable_if<
894 is_trivially_copy_constructible<_Dest>::value &&
895 is_same<_RawSource, _RawDest>::value &&
896 (__is_default_allocator<_Alloc>::value || !__has_construct<_Alloc, _Dest*, _Source&>::value)
897 >::type>
898_LIBCPP_INLINE_VISIBILITY
899void __construct_range_forward(_Alloc&, _Source* __begin1, _Source* __end1, _Dest*& __begin2) {
900 ptrdiff_t _Np = __end1 - __begin1;
901 if (_Np > 0) {
902 _VSTD::memcpy(const_cast<_RawDest*>(__begin2), __begin1, _Np * sizeof(_Dest));
903 __begin2 += _Np;
904 }
905}
906
907template <class _Alloc, class _Ptr>
908_LIBCPP_INLINE_VISIBILITY
909void __construct_backward_with_exception_guarantees(_Alloc& __a, _Ptr __begin1, _Ptr __end1, _Ptr& __end2) {
910 static_assert(__is_cpp17_move_insertable<_Alloc>::value,
911 "The specified type does not meet the requirements of Cpp17MoveInsertable");
912 typedef allocator_traits<_Alloc> _Traits;
913 while (__end1 != __begin1) {
914 _Traits::construct(__a, _VSTD::__to_address(__end2 - 1),
915#ifdef _LIBCPP_NO_EXCEPTIONS
916 _VSTD::move(*--__end1)
917#else
918 _VSTD::move_if_noexcept(*--__end1)
919#endif
920 );
921 --__end2;
922 }
923}
924
925template <class _Alloc, class _Tp, class = typename enable_if<
926 (__is_default_allocator<_Alloc>::value || !__has_construct<_Alloc, _Tp*, _Tp>::value) &&
927 is_trivially_move_constructible<_Tp>::value
928>::type>
929_LIBCPP_INLINE_VISIBILITY
930void __construct_backward_with_exception_guarantees(_Alloc&, _Tp* __begin1, _Tp* __end1, _Tp*& __end2) {
931 ptrdiff_t _Np = __end1 - __begin1;
932 __end2 -= _Np;
933 if (_Np > 0)
934 _VSTD::memcpy(static_cast<void*>(__end2), static_cast<void const*>(__begin1), _Np * sizeof(_Tp));
935}
936
937struct __destruct_n890struct __destruct_n
938{891{
939private:892private:
...@@ -975,37 +928,6 @@ public:...@@ -975,37 +928,6 @@ public:
975928
976_LIBCPP_FUNC_VIS void* align(size_t __align, size_t __sz, void*& __ptr, size_t& __space);929_LIBCPP_FUNC_VIS void* align(size_t __align, size_t __sz, void*& __ptr, size_t& __space);
977930
978// --- Helper for container swap --
979template <typename _Alloc>
980_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
981void __swap_allocator(_Alloc & __a1, _Alloc & __a2, true_type)
982#if _LIBCPP_STD_VER > 11
983 _NOEXCEPT
984#else
985 _NOEXCEPT_(__is_nothrow_swappable<_Alloc>::value)
986#endif
987{
988 using _VSTD::swap;
989 swap(__a1, __a2);
990}
991
992template <typename _Alloc>
993inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
994void __swap_allocator(_Alloc &, _Alloc &, false_type) _NOEXCEPT {}
995
996template <typename _Alloc>
997inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
998void __swap_allocator(_Alloc & __a1, _Alloc & __a2)
999#if _LIBCPP_STD_VER > 11
1000 _NOEXCEPT
1001#else
1002 _NOEXCEPT_(__is_nothrow_swappable<_Alloc>::value)
1003#endif
1004{
1005 _VSTD::__swap_allocator(__a1, __a2,
1006 integral_constant<bool, allocator_traits<_Alloc>::propagate_on_container_swap::value>());
1007}
1008
1009template <typename _Alloc, typename _Traits=allocator_traits<_Alloc> >931template <typename _Alloc, typename _Traits=allocator_traits<_Alloc> >
1010struct __noexcept_move_assign_container : public integral_constant<bool,932struct __noexcept_move_assign_container : public integral_constant<bool,
1011 _Traits::propagate_on_container_move_assignment::value933 _Traits::propagate_on_container_move_assignment::value
...@@ -1021,21 +943,31 @@ template <class _Tp, class _Alloc>...@@ -1021,21 +943,31 @@ template <class _Tp, class _Alloc>
1021struct __temp_value {943struct __temp_value {
1022 typedef allocator_traits<_Alloc> _Traits;944 typedef allocator_traits<_Alloc> _Traits;
1023945
946#ifdef _LIBCPP_CXX03_LANG
1024 typename aligned_storage<sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp)>::type __v;947 typename aligned_storage<sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp)>::type __v;
948#else
949 union { _Tp __v; };
950#endif
1025 _Alloc &__a;951 _Alloc &__a;
1026952
1027 _Tp *__addr() { return reinterpret_cast<_Tp *>(addressof(__v)); }953 _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp *__addr() {
1028 _Tp & get() { return *__addr(); }954#ifdef _LIBCPP_CXX03_LANG
955 return reinterpret_cast<_Tp*>(std::addressof(__v));
956#else
957 return std::addressof(__v);
958#endif
959 }
960
961 _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp & get() { return *__addr(); }
1029962
1030 template<class... _Args>963 template<class... _Args>
1031 _LIBCPP_NO_CFI964 _LIBCPP_NO_CFI
1032 __temp_value(_Alloc &__alloc, _Args&& ... __args) : __a(__alloc) {965 _LIBCPP_CONSTEXPR_AFTER_CXX17 __temp_value(_Alloc &__alloc, _Args&& ... __args) : __a(__alloc) {
1033 _Traits::construct(__a, reinterpret_cast<_Tp*>(addressof(__v)),966 _Traits::construct(__a, __addr(), std::forward<_Args>(__args)...);
1034 _VSTD::forward<_Args>(__args)...);
1035 }967 }
1036968
1037 ~__temp_value() { _Traits::destroy(__a, __addr()); }969 _LIBCPP_CONSTEXPR_AFTER_CXX17 ~__temp_value() { _Traits::destroy(__a, __addr()); }
1038 };970};
1039971
1040template<typename _Alloc, typename = void, typename = void>972template<typename _Alloc, typename = void, typename = void>
1041struct __is_allocator : false_type {};973struct __is_allocator : false_type {};
...@@ -1058,8 +990,8 @@ struct __builtin_new_allocator {...@@ -1058,8 +990,8 @@ struct __builtin_new_allocator {
1058 _LIBCPP_CONSTEXPR explicit __builtin_new_deleter(size_t __size, size_t __align)990 _LIBCPP_CONSTEXPR explicit __builtin_new_deleter(size_t __size, size_t __align)
1059 : __size_(__size), __align_(__align) {}991 : __size_(__size), __align_(__align) {}
1060992
1061 void operator()(void* p) const _NOEXCEPT {993 void operator()(void* __p) const _NOEXCEPT {
1062 _VSTD::__libcpp_deallocate(p, __size_, __align_);994 _VSTD::__libcpp_deallocate(__p, __size_, __align_);
1063 }995 }
1064996
1065 private:997 private:
...@@ -1092,7 +1024,6 @@ struct __builtin_new_allocator {...@@ -1092,7 +1024,6 @@ struct __builtin_new_allocator {
1092 }1024 }
1093};1025};
10941026
1095
1096_LIBCPP_END_NAMESPACE_STD1027_LIBCPP_END_NAMESPACE_STD
10971028
1098#if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 171029#if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17
lib/libcxx/include/module.modulemap deleted-1092
...@@ -1,1092 +0,0 @@
1// define the module for __config outside of the top level 'std' module
2// since __config may be included from C headers which may create an
3// include cycle.
4module std_config [system] [extern_c] {
5 textual header "__config"
6 textual header "__config_site"
7}
8
9module std [system] {
10 export std_config
11 // FIXME: The standard does not require that each of these submodules
12 // re-exports its imported modules. We should provide an alternative form of
13 // export that issues a warning if a name from the submodule is used, and
14 // use that to provide a 'strict mode' for libc++.
15
16 // Deprecated C-compatibility headers. These can all be included from within
17 // an 'extern "C"' context.
18 module depr [extern_c] {
19 // <assert.h> provided by C library.
20 module ctype_h {
21 header "ctype.h"
22 export *
23 }
24 module errno_h {
25 header "errno.h"
26 export *
27 }
28 module fenv_h {
29 header "fenv.h"
30 export *
31 }
32 // <float.h> provided by compiler or C library.
33 module inttypes_h {
34 header "inttypes.h"
35 export stdint_h
36 export *
37 }
38 // <iso646.h> provided by compiler.
39 // <limits.h> provided by compiler or C library.
40 module locale_h {
41 header "locale.h"
42 export *
43 }
44 module math_h {
45 header "math.h"
46 export *
47 }
48 module setjmp_h {
49 header "setjmp.h"
50 export *
51 }
52 // FIXME: <stdalign.h> is missing.
53 // <signal.h> provided by C library.
54 // <stdarg.h> provided by compiler.
55 // <stdbool.h> provided by compiler.
56 module stddef_h {
57 // <stddef.h>'s __need_* macros require textual inclusion.
58 textual header "stddef.h"
59 }
60 module stdint_h {
61 header "stdint.h"
62 export *
63 // FIXME: This module only exists on OS X and for some reason the
64 // wildcard above doesn't export it.
65 export Darwin.C.stdint
66 }
67 module stdio_h {
68 // <stdio.h>'s __need_* macros require textual inclusion.
69 textual header "stdio.h"
70 export *
71 export Darwin.C.stdio
72 }
73 module stdlib_h {
74 // <stdlib.h>'s __need_* macros require textual inclusion.
75 textual header "stdlib.h"
76 export *
77 }
78 module string_h {
79 header "string.h"
80 export *
81 }
82 // FIXME: <uchar.h> is missing.
83 // <time.h> provided by C library.
84 module wchar_h {
85 // <wchar.h>'s __need_* macros require textual inclusion.
86 textual header "wchar.h"
87 export *
88 }
89 module wctype_h {
90 header "wctype.h"
91 export *
92 }
93 }
94
95 // <complex.h> and <tgmath.h> are not C headers in any real sense, do not
96 // allow their use in extern "C" contexts.
97 module complex_h {
98 header "complex.h"
99 export ccomplex
100 export *
101 }
102 module tgmath_h {
103 header "tgmath.h"
104 export ccomplex
105 export cmath
106 export *
107 }
108
109 // C compatibility headers.
110 module compat {
111 module cassert {
112 // <cassert>'s use of NDEBUG requires textual inclusion.
113 textual header "cassert"
114 }
115 module ccomplex {
116 header "ccomplex"
117 export complex
118 export *
119 }
120 module cctype {
121 header "cctype"
122 export *
123 }
124 module cerrno {
125 header "cerrno"
126 export *
127 }
128 module cfenv {
129 header "cfenv"
130 export *
131 }
132 module cfloat {
133 header "cfloat"
134 export *
135 }
136 module cinttypes {
137 header "cinttypes"
138 export cstdint
139 export *
140 }
141 module ciso646 {
142 header "ciso646"
143 export *
144 }
145 module climits {
146 header "climits"
147 export *
148 }
149 module clocale {
150 header "clocale"
151 export *
152 }
153 module cmath {
154 header "cmath"
155 export *
156 }
157 module csetjmp {
158 header "csetjmp"
159 export *
160 }
161 module csignal {
162 header "csignal"
163 export *
164 }
165 // FIXME: <cstdalign> is missing.
166 module cstdarg {
167 header "cstdarg"
168 export *
169 }
170 module cstdbool {
171 header "cstdbool"
172 export *
173 }
174 module cstddef {
175 header "cstddef"
176 export *
177 }
178 module cstdint {
179 header "cstdint"
180 export depr.stdint_h
181 export *
182 }
183 module cstdio {
184 header "cstdio"
185 export *
186 }
187 module cstdlib {
188 header "cstdlib"
189 export *
190 }
191 module cstring {
192 header "cstring"
193 export *
194 }
195 module ctgmath {
196 header "ctgmath"
197 export ccomplex
198 export cmath
199 export *
200 }
201 module ctime {
202 header "ctime"
203 export *
204 }
205 // FIXME: <cuchar> is missing.
206 module cwchar {
207 header "cwchar"
208 export depr.stdio_h
209 export *
210 }
211 module cwctype {
212 header "cwctype"
213 export *
214 }
215 }
216
217 module algorithm {
218 header "algorithm"
219 export initializer_list
220 export *
221
222 module __algorithm {
223 module adjacent_find { private header "__algorithm/adjacent_find.h" }
224 module all_of { private header "__algorithm/all_of.h" }
225 module any_of { private header "__algorithm/any_of.h" }
226 module binary_search { private header "__algorithm/binary_search.h" }
227 module clamp { private header "__algorithm/clamp.h" }
228 module comp { private header "__algorithm/comp.h" }
229 module comp_ref_type { private header "__algorithm/comp_ref_type.h" }
230 module copy { private header "__algorithm/copy.h" }
231 module copy_backward { private header "__algorithm/copy_backward.h" }
232 module copy_if { private header "__algorithm/copy_if.h" }
233 module copy_n { private header "__algorithm/copy_n.h" }
234 module count { private header "__algorithm/count.h" }
235 module count_if { private header "__algorithm/count_if.h" }
236 module equal { private header "__algorithm/equal.h" }
237 module equal_range { private header "__algorithm/equal_range.h" }
238 module fill { private header "__algorithm/fill.h" }
239 module fill_n { private header "__algorithm/fill_n.h" }
240 module find { private header "__algorithm/find.h" }
241 module find_end { private header "__algorithm/find_end.h" }
242 module find_first_of { private header "__algorithm/find_first_of.h" }
243 module find_if { private header "__algorithm/find_if.h" }
244 module find_if_not { private header "__algorithm/find_if_not.h" }
245 module for_each { private header "__algorithm/for_each.h" }
246 module for_each_n { private header "__algorithm/for_each_n.h" }
247 module generate { private header "__algorithm/generate.h" }
248 module generate_n { private header "__algorithm/generate_n.h" }
249 module half_positive { private header "__algorithm/half_positive.h" }
250 module in_in_out_result { private header "__algorithm/in_in_out_result.h" }
251 module in_in_result { private header "__algorithm/in_in_result.h" }
252 module in_out_result { private header "__algorithm/in_out_result.h" }
253 module includes { private header "__algorithm/includes.h" }
254 module inplace_merge { private header "__algorithm/inplace_merge.h" }
255 module is_heap { private header "__algorithm/is_heap.h" }
256 module is_heap_until { private header "__algorithm/is_heap_until.h" }
257 module is_partitioned { private header "__algorithm/is_partitioned.h" }
258 module is_permutation { private header "__algorithm/is_permutation.h" }
259 module is_sorted { private header "__algorithm/is_sorted.h" }
260 module is_sorted_until { private header "__algorithm/is_sorted_until.h" }
261 module iter_swap { private header "__algorithm/iter_swap.h" }
262 module lexicographical_compare { private header "__algorithm/lexicographical_compare.h" }
263 module lower_bound { private header "__algorithm/lower_bound.h" }
264 module make_heap { private header "__algorithm/make_heap.h" }
265 module max { private header "__algorithm/max.h" }
266 module max_element { private header "__algorithm/max_element.h" }
267 module merge { private header "__algorithm/merge.h" }
268 module min { private header "__algorithm/min.h" }
269 module min_element { private header "__algorithm/min_element.h" }
270 module minmax { private header "__algorithm/minmax.h" }
271 module minmax_element { private header "__algorithm/minmax_element.h" }
272 module mismatch { private header "__algorithm/mismatch.h" }
273 module move { private header "__algorithm/move.h" }
274 module move_backward { private header "__algorithm/move_backward.h" }
275 module next_permutation { private header "__algorithm/next_permutation.h" }
276 module none_of { private header "__algorithm/none_of.h" }
277 module nth_element { private header "__algorithm/nth_element.h" }
278 module partial_sort { private header "__algorithm/partial_sort.h" }
279 module partial_sort_copy { private header "__algorithm/partial_sort_copy.h" }
280 module partition { private header "__algorithm/partition.h" }
281 module partition_copy { private header "__algorithm/partition_copy.h" }
282 module partition_point { private header "__algorithm/partition_point.h" }
283 module pop_heap { private header "__algorithm/pop_heap.h" }
284 module prev_permutation { private header "__algorithm/prev_permutation.h" }
285 module push_heap { private header "__algorithm/push_heap.h" }
286 module remove { private header "__algorithm/remove.h" }
287 module remove_copy { private header "__algorithm/remove_copy.h" }
288 module remove_copy_if { private header "__algorithm/remove_copy_if.h" }
289 module remove_if { private header "__algorithm/remove_if.h" }
290 module replace { private header "__algorithm/replace.h" }
291 module replace_copy { private header "__algorithm/replace_copy.h" }
292 module replace_copy_if { private header "__algorithm/replace_copy_if.h" }
293 module replace_if { private header "__algorithm/replace_if.h" }
294 module reverse { private header "__algorithm/reverse.h" }
295 module reverse_copy { private header "__algorithm/reverse_copy.h" }
296 module rotate { private header "__algorithm/rotate.h" }
297 module rotate_copy { private header "__algorithm/rotate_copy.h" }
298 module sample { private header "__algorithm/sample.h" }
299 module search { private header "__algorithm/search.h" }
300 module search_n { private header "__algorithm/search_n.h" }
301 module set_difference { private header "__algorithm/set_difference.h" }
302 module set_intersection { private header "__algorithm/set_intersection.h" }
303 module set_symmetric_difference { private header "__algorithm/set_symmetric_difference.h" }
304 module set_union { private header "__algorithm/set_union.h" }
305 module shift_left { private header "__algorithm/shift_left.h" }
306 module shift_right { private header "__algorithm/shift_right.h" }
307 module shuffle { private header "__algorithm/shuffle.h" }
308 module sift_down { private header "__algorithm/sift_down.h" }
309 module sort { private header "__algorithm/sort.h" }
310 module sort_heap { private header "__algorithm/sort_heap.h" }
311 module stable_partition { private header "__algorithm/stable_partition.h" }
312 module stable_sort { private header "__algorithm/stable_sort.h" }
313 module swap_ranges { private header "__algorithm/swap_ranges.h" }
314 module transform { private header "__algorithm/transform.h" }
315 module unique { private header "__algorithm/unique.h" }
316 module unique_copy { private header "__algorithm/unique_copy.h" }
317 module unwrap_iter { private header "__algorithm/unwrap_iter.h" }
318 module upper_bound { private header "__algorithm/upper_bound.h" }
319 }
320 }
321 module any {
322 header "any"
323 export *
324 }
325 module array {
326 header "array"
327 export initializer_list
328 export *
329 }
330 module atomic {
331 header "atomic"
332 export *
333 }
334 module barrier {
335 requires cplusplus14
336 header "barrier"
337 export *
338 }
339 module bit {
340 header "bit"
341 export *
342
343 module __bit {
344 module bit_cast { private header "__bit/bit_cast.h" }
345 module byteswap { private header "__bit/byteswap.h" }
346 }
347 }
348 module bitset {
349 header "bitset"
350 export string
351 export iosfwd
352 export *
353 }
354 // No submodule for cassert. It fundamentally needs repeated, textual inclusion.
355 module charconv {
356 header "charconv"
357 export *
358
359 module __charconv {
360 module chars_format { private header "__charconv/chars_format.h" }
361 module from_chars_result { private header "__charconv/from_chars_result.h" }
362 module to_chars_result { private header "__charconv/to_chars_result.h" }
363 }
364
365 }
366 module chrono {
367 header "chrono"
368 export *
369
370 module __chrono {
371 module calendar { private header "__chrono/calendar.h" }
372 module convert_to_timespec { private header "__chrono/convert_to_timespec.h" }
373 module duration { private header "__chrono/duration.h" }
374 module file_clock { private header "__chrono/file_clock.h" }
375 module high_resolution_clock { private header "__chrono/high_resolution_clock.h" }
376 module steady_clock { private header "__chrono/steady_clock.h" }
377 module system_clock { private header "__chrono/system_clock.h" }
378 module time_point { private header "__chrono/time_point.h" }
379 }
380 }
381 module codecvt {
382 header "codecvt"
383 export *
384 }
385 module compare {
386 header "compare"
387 export *
388
389 module __compare {
390 module common_comparison_category { private header "__compare/common_comparison_category.h" }
391 module compare_partial_order_fallback { private header "__compare/compare_partial_order_fallback.h" }
392 module compare_strong_order_fallback { private header "__compare/compare_strong_order_fallback.h" }
393 module compare_three_way { private header "__compare/compare_three_way.h" }
394 module compare_three_way_result { private header "__compare/compare_three_way_result.h" }
395 module compare_weak_order_fallback { private header "__compare/compare_weak_order_fallback.h" }
396 module is_eq { private header "__compare/is_eq.h" }
397 module ordering { private header "__compare/ordering.h" }
398 module partial_order { private header "__compare/partial_order.h" }
399 module strong_order { private header "__compare/strong_order.h" }
400 module synth_three_way { private header "__compare/synth_three_way.h" }
401 module three_way_comparable { private header "__compare/three_way_comparable.h" }
402 module weak_order { private header "__compare/weak_order.h" }
403 }
404 }
405 module complex {
406 header "complex"
407 export *
408 }
409 module concepts {
410 header "concepts"
411 export *
412
413 module __concepts {
414 module arithmetic { private header "__concepts/arithmetic.h" }
415 module assignable { private header "__concepts/assignable.h" }
416 module boolean_testable { private header "__concepts/boolean_testable.h" }
417 module class_or_enum { private header "__concepts/class_or_enum.h" }
418 module common_reference_with { private header "__concepts/common_reference_with.h" }
419 module common_with { private header "__concepts/common_with.h" }
420 module constructible { private header "__concepts/constructible.h" }
421 module convertible_to { private header "__concepts/convertible_to.h" }
422 module copyable { private header "__concepts/copyable.h" }
423 module derived_from { private header "__concepts/derived_from.h" }
424 module destructible { private header "__concepts/destructible.h" }
425 module different_from { private header "__concepts/different_from.h" }
426 module equality_comparable { private header "__concepts/equality_comparable.h" }
427 module invocable { private header "__concepts/invocable.h" }
428 module movable { private header "__concepts/movable.h" }
429 module predicate { private header "__concepts/predicate.h" }
430 module regular { private header "__concepts/regular.h" }
431 module relation { private header "__concepts/relation.h" }
432 module same_as { private header "__concepts/same_as.h" }
433 module semiregular { private header "__concepts/semiregular.h" }
434 module swappable { private header "__concepts/swappable.h" }
435 module totally_ordered { private header "__concepts/totally_ordered.h" }
436 }
437 }
438 module condition_variable {
439 header "condition_variable"
440 export *
441 }
442 module coroutine {
443 requires coroutines
444 header "coroutine"
445 export compare
446 export *
447
448 module __coroutine {
449 module coroutine_handle { private header "__coroutine/coroutine_handle.h" }
450 module coroutine_traits { private header "__coroutine/coroutine_traits.h" }
451 module noop_coroutine_handle { private header "__coroutine/noop_coroutine_handle.h" }
452 module trivial_awaitables { private header "__coroutine/trivial_awaitables.h" }
453 }
454 }
455 module deque {
456 header "deque"
457 export initializer_list
458 export *
459 }
460 module exception {
461 header "exception"
462 export *
463 }
464 module execution {
465 header "execution"
466 export *
467 }
468 module filesystem {
469 header "filesystem"
470 export *
471
472 module __filesystem {
473 module copy_options { private header "__filesystem/copy_options.h" }
474 module directory_entry { private header "__filesystem/directory_entry.h" }
475 module directory_iterator { private header "__filesystem/directory_iterator.h" }
476 module directory_options { private header "__filesystem/directory_options.h" }
477 module file_status { private header "__filesystem/file_status.h" }
478 module file_time_type { private header "__filesystem/file_time_type.h" }
479 module file_type { private header "__filesystem/file_type.h" }
480 module filesystem_error { private header "__filesystem/filesystem_error.h" }
481 module operations { private header "__filesystem/operations.h" }
482 module path { private header "__filesystem/path.h" }
483 module path_iterator { private header "__filesystem/path_iterator.h" }
484 module perm_options { private header "__filesystem/perm_options.h" }
485 module perms { private header "__filesystem/perms.h" }
486 module recursive_directory_iterator { private header "__filesystem/recursive_directory_iterator.h" }
487 module space_info { private header "__filesystem/space_info.h" }
488 module u8path { private header "__filesystem/u8path.h" }
489 }
490 }
491 module format {
492 header "format"
493 export *
494
495 module __format {
496 module format_arg { private header "__format/format_arg.h" }
497 module format_args { private header "__format/format_args.h" }
498 module format_context {
499 private header "__format/format_context.h"
500 export optional
501 export locale
502 }
503 module format_error { private header "__format/format_error.h" }
504 module format_fwd { private header "__format/format_fwd.h" }
505 module format_parse_context { private header "__format/format_parse_context.h" }
506 module format_string { private header "__format/format_string.h" }
507 module format_to_n_result { private header "__format/format_to_n_result.h" }
508 module formatter { private header "__format/formatter.h" }
509 module formatter_bool { private header "__format/formatter_bool.h" }
510 module formatter_char { private header "__format/formatter_char.h" }
511 module formatter_floating_point { private header "__format/formatter_floating_point.h" }
512 module formatter_integer { private header "__format/formatter_integer.h" }
513 module formatter_integral { private header "__format/formatter_integral.h" }
514 module formatter_pointer { private header "__format/formatter_pointer.h" }
515 module formatter_string { private header "__format/formatter_string.h" }
516 module parser_std_format_spec { private header "__format/parser_std_format_spec.h" }
517 }
518 }
519 module forward_list {
520 header "forward_list"
521 export initializer_list
522 export *
523 }
524 module fstream {
525 header "fstream"
526 export *
527 }
528 module functional {
529 header "functional"
530 export *
531
532 module __functional {
533 module binary_function { private header "__functional/binary_function.h" }
534 module binary_negate { private header "__functional/binary_negate.h" }
535 module bind { private header "__functional/bind.h" }
536 module bind_back { private header "__functional/bind_back.h" }
537 module bind_front { private header "__functional/bind_front.h" }
538 module binder1st { private header "__functional/binder1st.h" }
539 module binder2nd { private header "__functional/binder2nd.h" }
540 module compose { private header "__functional/compose.h" }
541 module default_searcher { private header "__functional/default_searcher.h" }
542 module function { private header "__functional/function.h" }
543 module hash { private header "__functional/hash.h" }
544 module identity { private header "__functional/identity.h" }
545 module invoke { private header "__functional/invoke.h" }
546 module is_transparent { private header "__functional/is_transparent.h" }
547 module mem_fn { private header "__functional/mem_fn.h" }
548 module mem_fun_ref { private header "__functional/mem_fun_ref.h" }
549 module not_fn { private header "__functional/not_fn.h" }
550 module operations { private header "__functional/operations.h" }
551 module perfect_forward { private header "__functional/perfect_forward.h" }
552 module pointer_to_binary_function { private header "__functional/pointer_to_binary_function.h" }
553 module pointer_to_unary_function { private header "__functional/pointer_to_unary_function.h" }
554 module ranges_operations { private header "__functional/ranges_operations.h" }
555 module reference_wrapper { private header "__functional/reference_wrapper.h" }
556 module unary_function { private header "__functional/unary_function.h" }
557 module unary_negate { private header "__functional/unary_negate.h" }
558 module unwrap_ref { private header "__functional/unwrap_ref.h" }
559 module weak_result_type { private header "__functional/weak_result_type.h" }
560 }
561 }
562 module future {
563 header "future"
564 export *
565 }
566 module initializer_list {
567 header "initializer_list"
568 export *
569 }
570 module iomanip {
571 header "iomanip"
572 export *
573 }
574 module ios {
575 header "ios"
576 export iosfwd
577 export *
578 }
579 module iosfwd {
580 header "iosfwd"
581 export *
582 }
583 module iostream {
584 header "iostream"
585 export ios
586 export streambuf
587 export istream
588 export ostream
589 export *
590 }
591 module istream {
592 header "istream"
593 // FIXME: should re-export ios, streambuf?
594 export *
595 }
596 module iterator {
597 header "iterator"
598 export *
599
600 module __iterator {
601 module access { private header "__iterator/access.h" }
602 module advance { private header "__iterator/advance.h" }
603 module back_insert_iterator { private header "__iterator/back_insert_iterator.h" }
604 module common_iterator { private header "__iterator/common_iterator.h" }
605 module concepts { private header "__iterator/concepts.h" }
606 module counted_iterator { private header "__iterator/counted_iterator.h" }
607 module data { private header "__iterator/data.h" }
608 module default_sentinel { private header "__iterator/default_sentinel.h" }
609 module distance { private header "__iterator/distance.h" }
610 module empty { private header "__iterator/empty.h" }
611 module erase_if_container { private header "__iterator/erase_if_container.h" }
612 module front_insert_iterator { private header "__iterator/front_insert_iterator.h" }
613 module incrementable_traits { private header "__iterator/incrementable_traits.h" }
614 module indirectly_comparable { private header "__iterator/indirectly_comparable.h" }
615 module insert_iterator { private header "__iterator/insert_iterator.h" }
616 module istream_iterator { private header "__iterator/istream_iterator.h" }
617 module istreambuf_iterator { private header "__iterator/istreambuf_iterator.h" }
618 module iter_move { private header "__iterator/iter_move.h" }
619 module iter_swap { private header "__iterator/iter_swap.h" }
620 module iterator { private header "__iterator/iterator.h" }
621 module iterator_traits { private header "__iterator/iterator_traits.h" }
622 module move_iterator { private header "__iterator/move_iterator.h" }
623 module next { private header "__iterator/next.h" }
624 module ostream_iterator { private header "__iterator/ostream_iterator.h" }
625 module ostreambuf_iterator { private header "__iterator/ostreambuf_iterator.h" }
626 module prev { private header "__iterator/prev.h" }
627 module projected { private header "__iterator/projected.h" }
628 module readable_traits { private header "__iterator/readable_traits.h" }
629 module reverse_access { private header "__iterator/reverse_access.h" }
630 module reverse_iterator { private header "__iterator/reverse_iterator.h" }
631 module size { private header "__iterator/size.h" }
632 module unreachable_sentinel { private header "__iterator/unreachable_sentinel.h" }
633 module wrap_iter { private header "__iterator/wrap_iter.h" }
634 }
635 }
636 module latch {
637 requires cplusplus14
638 header "latch"
639 export *
640 }
641 module limits {
642 header "limits"
643 export *
644 }
645 module list {
646 header "list"
647 export initializer_list
648 export *
649 }
650 module locale {
651 header "locale"
652 export *
653 }
654 module map {
655 header "map"
656 export initializer_list
657 export *
658 }
659 module memory {
660 header "memory"
661 export *
662
663 module __memory {
664 module addressof { private header "__memory/addressof.h" }
665 module allocation_guard { private header "__memory/allocation_guard.h" }
666 module allocator { private header "__memory/allocator.h" }
667 module allocator_arg_t { private header "__memory/allocator_arg_t.h" }
668 module allocator_traits { private header "__memory/allocator_traits.h" }
669 module auto_ptr { private header "__memory/auto_ptr.h" }
670 module compressed_pair { private header "__memory/compressed_pair.h" }
671 module concepts { private header "__memory/concepts.h" }
672 module construct_at { private header "__memory/construct_at.h" }
673 module pointer_traits { private header "__memory/pointer_traits.h" }
674 module ranges_construct_at { private header "__memory/ranges_construct_at.h" }
675 module ranges_uninitialized_algorithms { private header "__memory/ranges_uninitialized_algorithms.h" }
676 module raw_storage_iterator { private header "__memory/raw_storage_iterator.h" }
677 module shared_ptr { private header "__memory/shared_ptr.h" }
678 module temporary_buffer { private header "__memory/temporary_buffer.h" }
679 module uninitialized_algorithms { private header "__memory/uninitialized_algorithms.h" }
680 module unique_ptr { private header "__memory/unique_ptr.h" }
681 module uses_allocator { private header "__memory/uses_allocator.h" }
682 module voidify { private header "__memory/voidify.h" }
683 }
684 }
685 module mutex {
686 header "mutex"
687 export *
688 }
689 module new {
690 header "new"
691 export *
692 }
693 module numbers {
694 header "numbers"
695 export *
696 }
697 module numeric {
698 header "numeric"
699 export *
700
701 module __numeric {
702 module accumulate { private header "__numeric/accumulate.h" }
703 module adjacent_difference { private header "__numeric/adjacent_difference.h" }
704 module exclusive_scan { private header "__numeric/exclusive_scan.h" }
705 module gcd_lcm { private header "__numeric/gcd_lcm.h" }
706 module inclusive_scan { private header "__numeric/inclusive_scan.h" }
707 module inner_product { private header "__numeric/inner_product.h" }
708 module iota { private header "__numeric/iota.h" }
709 module midpoint { private header "__numeric/midpoint.h" }
710 module partial_sum { private header "__numeric/partial_sum.h" }
711 module reduce { private header "__numeric/reduce.h" }
712 module transform_exclusive_scan { private header "__numeric/transform_exclusive_scan.h" }
713 module transform_inclusive_scan { private header "__numeric/transform_inclusive_scan.h" }
714 module transform_reduce { private header "__numeric/transform_reduce.h" }
715 }
716 }
717 module optional {
718 header "optional"
719 export *
720 }
721 module ostream {
722 header "ostream"
723 // FIXME: should re-export ios, streambuf?
724 export *
725 }
726 module queue {
727 header "queue"
728 export initializer_list
729 export *
730 }
731 module random {
732 header "random"
733 export initializer_list
734 export *
735
736 module __random {
737 module bernoulli_distribution { private header "__random/bernoulli_distribution.h" }
738 module binomial_distribution { private header "__random/binomial_distribution.h" }
739 module cauchy_distribution { private header "__random/cauchy_distribution.h" }
740 module chi_squared_distribution { private header "__random/chi_squared_distribution.h" }
741 module clamp_to_integral { private header "__random/clamp_to_integral.h" }
742 module default_random_engine { private header "__random/default_random_engine.h" }
743 module discard_block_engine { private header "__random/discard_block_engine.h" }
744 module discrete_distribution { private header "__random/discrete_distribution.h" }
745 module exponential_distribution { private header "__random/exponential_distribution.h" }
746 module extreme_value_distribution { private header "__random/extreme_value_distribution.h" }
747 module fisher_f_distribution { private header "__random/fisher_f_distribution.h" }
748 module gamma_distribution { private header "__random/gamma_distribution.h" }
749 module generate_canonical { private header "__random/generate_canonical.h" }
750 module geometric_distribution { private header "__random/geometric_distribution.h" }
751 module independent_bits_engine { private header "__random/independent_bits_engine.h" }
752 module is_seed_sequence { private header "__random/is_seed_sequence.h" }
753 module knuth_b { private header "__random/knuth_b.h" }
754 module linear_congruential_engine { private header "__random/linear_congruential_engine.h" }
755 module log2 { private header "__random/log2.h" }
756 module lognormal_distribution { private header "__random/lognormal_distribution.h" }
757 module mersenne_twister_engine { private header "__random/mersenne_twister_engine.h" }
758 module negative_binomial_distribution { private header "__random/negative_binomial_distribution.h" }
759 module normal_distribution { private header "__random/normal_distribution.h" }
760 module piecewise_constant_distribution { private header "__random/piecewise_constant_distribution.h" }
761 module piecewise_linear_distribution { private header "__random/piecewise_linear_distribution.h" }
762 module poisson_distribution { private header "__random/poisson_distribution.h" }
763 module random_device { private header "__random/random_device.h" }
764 module ranlux { private header "__random/ranlux.h" }
765 module seed_seq { private header "__random/seed_seq.h" }
766 module shuffle_order_engine { private header "__random/shuffle_order_engine.h" }
767 module student_t_distribution { private header "__random/student_t_distribution.h" }
768 module subtract_with_carry_engine { private header "__random/subtract_with_carry_engine.h" }
769 module uniform_int_distribution { private header "__random/uniform_int_distribution.h" }
770 module uniform_random_bit_generator { private header "__random/uniform_random_bit_generator.h" }
771 module uniform_real_distribution { private header "__random/uniform_real_distribution.h" }
772 module weibull_distribution { private header "__random/weibull_distribution.h" }
773 }
774 }
775 module ranges {
776 header "ranges"
777 export compare
778 export initializer_list
779 export iterator
780 export *
781
782 module __ranges {
783 module access { private header "__ranges/access.h" }
784 module all {
785 private header "__ranges/all.h"
786 export functional.__functional.compose
787 export functional.__functional.perfect_forward
788 }
789 module common_view { private header "__ranges/common_view.h" }
790 module concepts { private header "__ranges/concepts.h" }
791 module copyable_box { private header "__ranges/copyable_box.h" }
792 module counted {
793 private header "__ranges/counted.h"
794 export span
795 }
796 module dangling { private header "__ranges/dangling.h" }
797 module data { private header "__ranges/data.h" }
798 module drop_view { private header "__ranges/drop_view.h" }
799 module empty { private header "__ranges/empty.h" }
800 module empty_view { private header "__ranges/empty_view.h" }
801 module enable_borrowed_range { private header "__ranges/enable_borrowed_range.h" }
802 module enable_view { private header "__ranges/enable_view.h" }
803 module iota_view { private header "__ranges/iota_view.h" }
804 module join_view { private header "__ranges/join_view.h" }
805 module non_propagating_cache { private header "__ranges/non_propagating_cache.h" }
806 module owning_view { private header "__ranges/owning_view.h" }
807 module range_adaptor { private header "__ranges/range_adaptor.h" }
808 module ref_view { private header "__ranges/ref_view.h" }
809 module reverse_view { private header "__ranges/reverse_view.h" }
810 module single_view { private header "__ranges/single_view.h" }
811 module size { private header "__ranges/size.h" }
812 module subrange { private header "__ranges/subrange.h" }
813 module take_view { private header "__ranges/take_view.h" }
814 module transform_view {
815 private header "__ranges/transform_view.h"
816 export functional.__functional.bind_back
817 export functional.__functional.perfect_forward
818 }
819 module view_interface { private header "__ranges/view_interface.h" }
820 module views { private header "__ranges/views.h" }
821 }
822 }
823 module ratio {
824 header "ratio"
825 export *
826 }
827 module regex {
828 header "regex"
829 export initializer_list
830 export *
831 }
832 module scoped_allocator {
833 header "scoped_allocator"
834 export *
835 }
836 module semaphore {
837 requires cplusplus14
838 header "semaphore"
839 export *
840 }
841 module set {
842 header "set"
843 export initializer_list
844 export *
845 }
846 module shared_mutex {
847 header "shared_mutex"
848 export version
849 }
850 module span {
851 header "span"
852 export ranges.__ranges.enable_borrowed_range
853 export version
854 }
855 module sstream {
856 header "sstream"
857 // FIXME: should re-export istream, ostream, ios, streambuf, string?
858 export *
859 }
860 module stack {
861 header "stack"
862 export initializer_list
863 export *
864 }
865 module stdexcept {
866 header "stdexcept"
867 export *
868 }
869 module streambuf {
870 header "streambuf"
871 export *
872 }
873 module string {
874 header "string"
875 export initializer_list
876 export string_view
877 export __string
878 export *
879 }
880 module string_view {
881 header "string_view"
882 export initializer_list
883 export __string
884 export *
885 }
886 module strstream {
887 header "strstream"
888 export *
889 }
890 module system_error {
891 header "system_error"
892 export *
893 }
894 module thread {
895 header "thread"
896 export *
897
898 module __thread {
899 module poll_with_backoff { private header "__thread/poll_with_backoff.h" }
900 module timed_backoff_policy { private header "__thread/timed_backoff_policy.h" }
901 }
902 }
903 module tuple {
904 header "tuple"
905 export *
906 }
907 module type_traits {
908 header "type_traits"
909 export functional.__functional.unwrap_ref
910 export *
911 }
912 module typeindex {
913 header "typeindex"
914 export *
915 }
916 module typeinfo {
917 header "typeinfo"
918 export *
919 }
920 module unordered_map {
921 header "unordered_map"
922 export initializer_list
923 export *
924 }
925 module unordered_set {
926 header "unordered_set"
927 export initializer_list
928 export *
929 }
930 module utility {
931 header "utility"
932 export initializer_list
933 export *
934
935 module __utility {
936 module as_const { private header "__utility/as_const.h" }
937 module auto_cast { private header "__utility/auto_cast.h" }
938 module cmp { private header "__utility/cmp.h" }
939 module declval { private header "__utility/declval.h" }
940 module exchange { private header "__utility/exchange.h" }
941 module forward { private header "__utility/forward.h" }
942 module in_place { private header "__utility/in_place.h" }
943 module integer_sequence { private header "__utility/integer_sequence.h" }
944 module move { private header "__utility/move.h" }
945 module pair { private header "__utility/pair.h" }
946 module piecewise_construct { private header "__utility/piecewise_construct.h" }
947 module priority_tag { private header "__utility/priority_tag.h" }
948 module rel_ops { private header "__utility/rel_ops.h" }
949 module swap { private header "__utility/swap.h" }
950 module to_underlying { private header "__utility/to_underlying.h" }
951 module transaction { private header "__utility/transaction.h" }
952 }
953 }
954 module valarray {
955 header "valarray"
956 export initializer_list
957 export *
958 }
959 module variant {
960 header "variant"
961 export *
962
963 module __variant {
964 module monostate { private header "__variant/monostate.h" }
965 }
966 }
967 module vector {
968 header "vector"
969 export initializer_list
970 export *
971 }
972 module version {
973 header "version"
974 export *
975 }
976
977 // __config not modularised due to a bug in Clang
978 // FIXME: These should be private.
979 module __availability { private header "__availability" export * }
980 module __bit_reference { private header "__bit_reference" export * }
981 module __bits { private header "__bits" export * }
982 module __debug { header "__debug" export * }
983 module __errc { private header "__errc" export * }
984 module __hash_table { header "__hash_table" export * }
985 module __locale { private header "__locale" export * }
986 module __mbstate_t { private header "__mbstate_t.h" export * }
987 module __mutex_base { private header "__mutex_base" export * }
988 module __node_handle { private header "__node_handle" export * }
989 module __nullptr { header "__nullptr" export * }
990 module __split_buffer { private header "__split_buffer" export * }
991 module __std_stream { private header "__std_stream" export * }
992 module __string { private header "__string" export * }
993 module __threading_support { header "__threading_support" export * }
994 module __tree { header "__tree" export * }
995 module __tuple { private header "__tuple" export * }
996 module __undef_macros { header "__undef_macros" export * }
997
998 module experimental {
999 requires cplusplus11
1000
1001 module algorithm {
1002 header "experimental/algorithm"
1003 export *
1004 }
1005 module coroutine {
1006 requires coroutines
1007 header "experimental/coroutine"
1008 export *
1009 }
1010 module deque {
1011 header "experimental/deque"
1012 export *
1013 }
1014 module filesystem {
1015 header "experimental/filesystem"
1016 export *
1017 }
1018 module forward_list {
1019 header "experimental/forward_list"
1020 export *
1021 }
1022 module functional {
1023 header "experimental/functional"
1024 export *
1025 }
1026 module iterator {
1027 header "experimental/iterator"
1028 export *
1029 }
1030 module list {
1031 header "experimental/list"
1032 export *
1033 }
1034 module map {
1035 header "experimental/map"
1036 export *
1037 }
1038 module memory_resource {
1039 header "experimental/memory_resource"
1040 export *
1041 }
1042 module propagate_const {
1043 header "experimental/propagate_const"
1044 export *
1045 }
1046 module regex {
1047 header "experimental/regex"
1048 export *
1049 }
1050 module simd {
1051 header "experimental/simd"
1052 export *
1053 }
1054 module set {
1055 header "experimental/set"
1056 export *
1057 }
1058 module span {
1059 header "span"
1060 export *
1061 }
1062 module string {
1063 header "experimental/string"
1064 export *
1065 }
1066 module type_traits {
1067 header "experimental/type_traits"
1068 export *
1069 }
1070 module unordered_map {
1071 header "experimental/unordered_map"
1072 export *
1073 }
1074 module unordered_set {
1075 header "experimental/unordered_set"
1076 export *
1077 }
1078 module utility {
1079 header "experimental/utility"
1080 export *
1081 }
1082 module vector {
1083 header "experimental/vector"
1084 export *
1085 }
1086 // FIXME these should be private
1087 module __memory {
1088 header "experimental/__memory"
1089 export *
1090 }
1091 } // end experimental
1092}
lib/libcxx/include/mutex+6-2
...@@ -186,20 +186,24 @@ template<class Callable, class ...Args>...@@ -186,20 +186,24 @@ template<class Callable, class ...Args>
186186
187*/187*/
188188
189#include <__assert> // all public C++ headers provide the assertion handler
189#include <__config>190#include <__config>
190#include <__mutex_base>191#include <__mutex_base>
191#include <__threading_support>192#include <__threading_support>
192#include <__utility/forward.h>193#include <__utility/forward.h>
193#include <cstdint>194#include <cstdint>
194#include <functional>
195#include <memory>195#include <memory>
196#ifndef _LIBCPP_CXX03_LANG196#ifndef _LIBCPP_CXX03_LANG
197# include <tuple>197# include <tuple>
198#endif198#endif
199#include <version>199#include <version>
200200
201#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
202# include <functional>
203#endif
204
201#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)205#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
202#pragma GCC system_header206# pragma GCC system_header
203#endif207#endif
204208
205_LIBCPP_PUSH_MACROS209_LIBCPP_PUSH_MACROS
lib/libcxx/include/new+13-1
...@@ -86,6 +86,7 @@ void operator delete[](void* ptr, void*) noexcept;...@@ -86,6 +86,7 @@ void operator delete[](void* ptr, void*) noexcept;
8686
87*/87*/
8888
89#include <__assert> // all public C++ headers provide the assertion handler
89#include <__availability>90#include <__availability>
90#include <__config>91#include <__config>
91#include <cstddef>92#include <cstddef>
...@@ -99,7 +100,7 @@ void operator delete[](void* ptr, void*) noexcept;...@@ -99,7 +100,7 @@ void operator delete[](void* ptr, void*) noexcept;
99#endif100#endif
100101
101#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)102#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
102#pragma GCC system_header103# pragma GCC system_header
103#endif104#endif
104105
105#if !defined(__cpp_sized_deallocation) || __cpp_sized_deallocation < 201309L106#if !defined(__cpp_sized_deallocation) || __cpp_sized_deallocation < 201309L
...@@ -359,6 +360,17 @@ constexpr _Tp* launder(_Tp* __p) noexcept...@@ -359,6 +360,17 @@ constexpr _Tp* launder(_Tp* __p) noexcept
359}360}
360#endif361#endif
361362
363#if _LIBCPP_STD_VER > 14
364
365#if defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE)
366
367inline constexpr size_t hardware_destructive_interference_size = __GCC_DESTRUCTIVE_SIZE;
368inline constexpr size_t hardware_constructive_interference_size = __GCC_CONSTRUCTIVE_SIZE;
369
370#endif // defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE)
371
372#endif // _LIBCPP_STD_VER > 14
373
362_LIBCPP_END_NAMESPACE_STD374_LIBCPP_END_NAMESPACE_STD
363375
364#endif // _LIBCPP_NEW376#endif // _LIBCPP_NEW
lib/libcxx/include/numbers+4-3
...@@ -58,15 +58,16 @@ namespace std::numbers {...@@ -58,15 +58,16 @@ namespace std::numbers {
58}58}
59*/59*/
6060
61#include <__assert> // all public C++ headers provide the assertion handler
61#include <__config>62#include <__config>
62#include <concepts>63#include <concepts>
63#include <type_traits>64#include <type_traits>
64#include <version>65#include <version>
6566
66#if !defined(_LIBCPP_HAS_NO_CONCEPTS)67#if _LIBCPP_STD_VER > 17
6768
68#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)69#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
69#pragma GCC system_header70# pragma GCC system_header
70#endif71#endif
7172
72_LIBCPP_BEGIN_NAMESPACE_STD73_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -128,6 +129,6 @@ inline constexpr double phi = phi_v<double>;...@@ -128,6 +129,6 @@ inline constexpr double phi = phi_v<double>;
128129
129_LIBCPP_END_NAMESPACE_STD130_LIBCPP_END_NAMESPACE_STD
130131
131#endif //!defined(_LIBCPP_HAS_NO_CONCEPTS)132#endif // _LIBCPP_STD_VER > 17
132133
133#endif // _LIBCPP_NUMBERS134#endif // _LIBCPP_NUMBERS
lib/libcxx/include/numeric+7-3
...@@ -144,10 +144,9 @@ template<class T>...@@ -144,10 +144,9 @@ template<class T>
144144
145*/145*/
146146
147#include <__assert> // all public C++ headers provide the assertion handler
147#include <__config>148#include <__config>
148#include <cmath> // for isnormal149#include <cmath> // for isnormal
149#include <functional>
150#include <iterator>
151#include <version>150#include <version>
152151
153#include <__numeric/accumulate.h>152#include <__numeric/accumulate.h>
...@@ -164,8 +163,13 @@ template<class T>...@@ -164,8 +163,13 @@ template<class T>
164#include <__numeric/transform_inclusive_scan.h>163#include <__numeric/transform_inclusive_scan.h>
165#include <__numeric/transform_reduce.h>164#include <__numeric/transform_reduce.h>
166165
166#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
167# include <functional>
168# include <iterator>
169#endif
170
167#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)171#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
168#pragma GCC system_header172# pragma GCC system_header
169#endif173#endif
170174
171#if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17175#if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17
lib/libcxx/include/optional+42-19
...@@ -93,11 +93,11 @@ namespace std {...@@ -93,11 +93,11 @@ namespace std {
93 template <class U, class... Args>93 template <class U, class... Args>
94 constexpr explicit optional(in_place_t, initializer_list<U>, Args &&...);94 constexpr explicit optional(in_place_t, initializer_list<U>, Args &&...);
95 template <class U = T>95 template <class U = T>
96 constexpr EXPLICIT optional(U &&);96 constexpr explicit(see-below) optional(U &&);
97 template <class U>97 template <class U>
98 EXPLICIT optional(const optional<U> &); // constexpr in C++2098 explicit(see-below) optional(const optional<U> &); // constexpr in C++20
99 template <class U>99 template <class U>
100 EXPLICIT optional(optional<U> &&); // constexpr in C++20100 explicit(see-below) optional(optional<U> &&); // constexpr in C++20
101101
102 // 23.6.3.2, destructor102 // 23.6.3.2, destructor
103 ~optional(); // constexpr in C++20103 ~optional(); // constexpr in C++20
...@@ -158,22 +158,45 @@ template<class T>...@@ -158,22 +158,45 @@ template<class T>
158158
159*/159*/
160160
161#include <__assert> // all public C++ headers provide the assertion handler
161#include <__availability>162#include <__availability>
162#include <__concepts/invocable.h>163#include <__concepts/invocable.h>
163#include <__config>164#include <__config>
164#include <__debug>165#include <__functional/hash.h>
165#include <__functional_base>166#include <__functional/invoke.h>
166#include <compare>167#include <__functional/unary_function.h>
167#include <functional>168#include <__memory/construct_at.h>
169#include <__tuple>
170#include <__utility/forward.h>
171#include <__utility/in_place.h>
172#include <__utility/move.h>
173#include <__utility/swap.h>
168#include <initializer_list>174#include <initializer_list>
169#include <new>175#include <new>
170#include <stdexcept>176#include <stdexcept>
171#include <type_traits>177#include <type_traits>
172#include <utility>
173#include <version>178#include <version>
174179
180#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
181# include <atomic>
182# include <chrono>
183# include <climits>
184# include <concepts>
185# include <ctime>
186# include <iterator>
187# include <memory>
188# include <ratio>
189# include <tuple>
190# include <typeinfo>
191# include <utility>
192# include <variant>
193#endif
194
195// standard-mandated includes
196#include <compare>
197
175#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)198#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
176#pragma GCC system_header199# pragma GCC system_header
177#endif200#endif
178201
179namespace std // purposefully not using versioning namespace202namespace std // purposefully not using versioning namespace
...@@ -382,9 +405,9 @@ struct __optional_storage_base : __optional_destruct_base<_Tp>...@@ -382,9 +405,9 @@ struct __optional_storage_base : __optional_destruct_base<_Tp>
382 }405 }
383};406};
384407
385// optional<T&> is currently required ill-formed, however it may to be in the408// optional<T&> is currently required to be ill-formed. However, it may
386// future. For this reason it has already been implemented to ensure we can409// be allowed in the future. For this reason, it has already been implemented
387// make the change in an ABI compatible manner.410// to ensure we can make the change in an ABI-compatible manner.
388template <class _Tp>411template <class _Tp>
389struct __optional_storage_base<_Tp, true>412struct __optional_storage_base<_Tp, true>
390{413{
...@@ -1039,7 +1062,7 @@ public:...@@ -1039,7 +1062,7 @@ public:
10391062
1040#if _LIBCPP_STD_VER > 201063#if _LIBCPP_STD_VER > 20
1041 template<class _Func>1064 template<class _Func>
1042 _LIBCPP_HIDE_FROM_ABI1065 _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS
1043 constexpr auto and_then(_Func&& __f) & {1066 constexpr auto and_then(_Func&& __f) & {
1044 using _Up = invoke_result_t<_Func, value_type&>;1067 using _Up = invoke_result_t<_Func, value_type&>;
1045 static_assert(__is_std_optional<remove_cvref_t<_Up>>::value,1068 static_assert(__is_std_optional<remove_cvref_t<_Up>>::value,
...@@ -1050,7 +1073,7 @@ public:...@@ -1050,7 +1073,7 @@ public:
1050 }1073 }
10511074
1052 template<class _Func>1075 template<class _Func>
1053 _LIBCPP_HIDE_FROM_ABI1076 _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS
1054 constexpr auto and_then(_Func&& __f) const& {1077 constexpr auto and_then(_Func&& __f) const& {
1055 using _Up = invoke_result_t<_Func, const value_type&>;1078 using _Up = invoke_result_t<_Func, const value_type&>;
1056 static_assert(__is_std_optional<remove_cvref_t<_Up>>::value,1079 static_assert(__is_std_optional<remove_cvref_t<_Up>>::value,
...@@ -1061,7 +1084,7 @@ public:...@@ -1061,7 +1084,7 @@ public:
1061 }1084 }
10621085
1063 template<class _Func>1086 template<class _Func>
1064 _LIBCPP_HIDE_FROM_ABI1087 _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS
1065 constexpr auto and_then(_Func&& __f) && {1088 constexpr auto and_then(_Func&& __f) && {
1066 using _Up = invoke_result_t<_Func, value_type&&>;1089 using _Up = invoke_result_t<_Func, value_type&&>;
1067 static_assert(__is_std_optional<remove_cvref_t<_Up>>::value,1090 static_assert(__is_std_optional<remove_cvref_t<_Up>>::value,
...@@ -1083,7 +1106,7 @@ public:...@@ -1083,7 +1106,7 @@ public:
1083 }1106 }
10841107
1085 template<class _Func>1108 template<class _Func>
1086 _LIBCPP_HIDE_FROM_ABI1109 _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS
1087 constexpr auto transform(_Func&& __f) & {1110 constexpr auto transform(_Func&& __f) & {
1088 using _Up = remove_cv_t<invoke_result_t<_Func, value_type&>>;1111 using _Up = remove_cv_t<invoke_result_t<_Func, value_type&>>;
1089 static_assert(!is_array_v<_Up>, "Result of f(value()) should not be an Array");1112 static_assert(!is_array_v<_Up>, "Result of f(value()) should not be an Array");
...@@ -1098,7 +1121,7 @@ public:...@@ -1098,7 +1121,7 @@ public:
1098 }1121 }
10991122
1100 template<class _Func>1123 template<class _Func>
1101 _LIBCPP_HIDE_FROM_ABI1124 _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS
1102 constexpr auto transform(_Func&& __f) const& {1125 constexpr auto transform(_Func&& __f) const& {
1103 using _Up = remove_cv_t<invoke_result_t<_Func, const value_type&>>;1126 using _Up = remove_cv_t<invoke_result_t<_Func, const value_type&>>;
1104 static_assert(!is_array_v<_Up>, "Result of f(value()) should not be an Array");1127 static_assert(!is_array_v<_Up>, "Result of f(value()) should not be an Array");
...@@ -1113,7 +1136,7 @@ public:...@@ -1113,7 +1136,7 @@ public:
1113 }1136 }
11141137
1115 template<class _Func>1138 template<class _Func>
1116 _LIBCPP_HIDE_FROM_ABI1139 _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS
1117 constexpr auto transform(_Func&& __f) && {1140 constexpr auto transform(_Func&& __f) && {
1118 using _Up = remove_cv_t<invoke_result_t<_Func, value_type&&>>;1141 using _Up = remove_cv_t<invoke_result_t<_Func, value_type&&>>;
1119 static_assert(!is_array_v<_Up>, "Result of f(std::move(value())) should not be an Array");1142 static_assert(!is_array_v<_Up>, "Result of f(std::move(value())) should not be an Array");
...@@ -1128,7 +1151,7 @@ public:...@@ -1128,7 +1151,7 @@ public:
1128 }1151 }
11291152
1130 template<class _Func>1153 template<class _Func>
1131 _LIBCPP_HIDE_FROM_ABI1154 _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS
1132 constexpr auto transform(_Func&& __f) const&& {1155 constexpr auto transform(_Func&& __f) const&& {
1133 using _Up = remove_cvref_t<invoke_result_t<_Func, const value_type&&>>;1156 using _Up = remove_cvref_t<invoke_result_t<_Func, const value_type&&>>;
1134 static_assert(!is_array_v<_Up>, "Result of f(std::move(value())) should not be an Array");1157 static_assert(!is_array_v<_Up>, "Result of f(std::move(value())) should not be an Array");
lib/libcxx/include/ostream+92-4
...@@ -130,20 +130,53 @@ template <class charT, class traits>...@@ -130,20 +130,53 @@ template <class charT, class traits>
130template <class Stream, class T>130template <class Stream, class T>
131 Stream&& operator<<(Stream&& os, const T& x);131 Stream&& operator<<(Stream&& os, const T& x);
132132
133template<class traits>
134basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, wchar_t) = delete; // since C++20
135template<class traits>
136basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, char8_t) = delete; // since C++20
137template<class traits>
138basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, char16_t) = delete; // since C++20
139template<class traits>
140basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, char32_t) = delete; // since C++20
141template<class traits>
142basic_ostream<wchar_t, traits>& operator<<(basic_ostream<wchar_t, traits>&, char8_t) = delete; // since C++20
143template<class traits>
144basic_ostream<wchar_t, traits>& operator<<(basic_ostream<wchar_t, traits>&, char16_t) = delete; // since C++20
145template<class traits>
146basic_ostream<wchar_t, traits>& operator<<(basic_ostream<wchar_t, traits>&, char32_t) = delete; // since C++20
147template<class traits>
148basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, const wchar_t*) = delete; // since C++20
149template<class traits>
150basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, const char8_t*) = delete; // since C++20
151template<class traits>
152basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, const char16_t*) = delete; // since C++20
153template<class traits>
154basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, const char32_t*) = delete; // since C++20
155template<class traits>
156basic_ostream<wchar_t, traits>& operator<<(basic_ostream<wchar_t, traits>&, const char8_t*) = delete; // since C++20
157template<class traits>
158basic_ostream<wchar_t, traits>& operator<<(basic_ostream<wchar_t, traits>&, const char16_t*) = delete; // since C++20
159template<class traits>
160basic_ostream<wchar_t, traits>& operator<<(basic_ostream<wchar_t, traits>&, const char32_t*) = delete; // since C++20
161
133} // std162} // std
134163
135*/164*/
136165
166#include <__assert> // all public C++ headers provide the assertion handler
137#include <__config>167#include <__config>
138#include <bitset>168#include <bitset>
139#include <ios>169#include <ios>
140#include <iterator>
141#include <locale>170#include <locale>
142#include <streambuf>171#include <streambuf>
143#include <version>172#include <version>
144173
174#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
175# include <iterator>
176#endif
177
145#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)178#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
146#pragma GCC system_header179# pragma GCC system_header
147#endif180#endif
148181
149_LIBCPP_BEGIN_NAMESPACE_STD182_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -221,9 +254,13 @@ public:...@@ -221,9 +254,13 @@ public:
221254
222 basic_ostream& operator<<(basic_streambuf<char_type, traits_type>* __sb);255 basic_ostream& operator<<(basic_streambuf<char_type, traits_type>* __sb);
223256
257#if _LIBCPP_STD_VER > 14
258// LWG 2221 - nullptr. This is not backported to older standards modes.
259// See https://reviews.llvm.org/D127033 for more info on the rationale.
224 _LIBCPP_INLINE_VISIBILITY260 _LIBCPP_INLINE_VISIBILITY
225 basic_ostream& operator<<(nullptr_t)261 basic_ostream& operator<<(nullptr_t)
226 { return *this << "nullptr"; }262 { return *this << "nullptr"; }
263#endif
227264
228 // 27.7.2.7 Unformatted output:265 // 27.7.2.7 Unformatted output:
229 basic_ostream& put(char_type __c);266 basic_ostream& put(char_type __c);
...@@ -1094,9 +1131,60 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Size>& __x)...@@ -1094,9 +1131,60 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Size>& __x)
1094 use_facet<ctype<_CharT> >(__os.getloc()).widen('1'));1131 use_facet<ctype<_CharT> >(__os.getloc()).widen('1'));
1095}1132}
10961133
1097_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<char>)1134#if _LIBCPP_STD_VER > 17
1135
1136#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
1137template <class _Traits>
1138basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, wchar_t) = delete;
1139
1140template <class _Traits>
1141basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, const wchar_t*) = delete;
1142
1143template <class _Traits>
1144basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, char16_t) = delete;
1145
1146template <class _Traits>
1147basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, char32_t) = delete;
1148
1149template <class _Traits>
1150basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, const char16_t*) = delete;
1151
1152template <class _Traits>
1153basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, const char32_t*) = delete;
1154
1155#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
1156
1157#ifndef _LIBCPP_HAS_NO_CHAR8_T
1158template <class _Traits>
1159basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, char8_t) = delete;
1160
1161template <class _Traits>
1162basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, char8_t) = delete;
1163
1164template <class _Traits>
1165basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, const char8_t*) = delete;
1166
1167template <class _Traits>
1168basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, const char8_t*) = delete;
1169#endif
1170
1171template <class _Traits>
1172basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, char16_t) = delete;
1173
1174template <class _Traits>
1175basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, char32_t) = delete;
1176
1177template <class _Traits>
1178basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, const char16_t*) = delete;
1179
1180template <class _Traits>
1181basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, const char32_t*) = delete;
1182
1183#endif // _LIBCPP_STD_VER > 17
1184
1185extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<char>;
1098#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS1186#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
1099_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<wchar_t>)1187extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<wchar_t>;
1100#endif1188#endif
11011189
1102_LIBCPP_END_NAMESPACE_STD1190_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/queue+14-4
...@@ -217,20 +217,30 @@ template <class T, class Container, class Compare>...@@ -217,20 +217,30 @@ template <class T, class Container, class Compare>
217217
218*/218*/
219219
220#include <__algorithm/make_heap.h>
221#include <__algorithm/pop_heap.h>
222#include <__algorithm/push_heap.h>
223#include <__assert> // all public C++ headers provide the assertion handler
220#include <__config>224#include <__config>
225#include <__functional/operations.h>
221#include <__iterator/iterator_traits.h>226#include <__iterator/iterator_traits.h>
222#include <__memory/uses_allocator.h>227#include <__memory/uses_allocator.h>
223#include <__utility/forward.h>228#include <__utility/forward.h>
224#include <algorithm>
225#include <compare>
226#include <deque>229#include <deque>
227#include <functional>
228#include <type_traits>230#include <type_traits>
229#include <vector>231#include <vector>
230#include <version>232#include <version>
231233
234#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
235# include <functional>
236#endif
237
238// standard-mandated includes
239#include <compare>
240#include <initializer_list>
241
232#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)242#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
233#pragma GCC system_header243# pragma GCC system_header
234#endif244#endif
235245
236_LIBCPP_BEGIN_NAMESPACE_STD246_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/random+10-3
...@@ -1677,6 +1677,7 @@ class piecewise_linear_distribution...@@ -1677,6 +1677,7 @@ class piecewise_linear_distribution
1677} // std1677} // std
1678*/1678*/
16791679
1680#include <__assert> // all public C++ headers provide the assertion handler
1680#include <__config>1681#include <__config>
1681#include <__random/bernoulli_distribution.h>1682#include <__random/bernoulli_distribution.h>
1682#include <__random/binomial_distribution.h>1683#include <__random/binomial_distribution.h>
...@@ -1694,6 +1695,7 @@ class piecewise_linear_distribution...@@ -1694,6 +1695,7 @@ class piecewise_linear_distribution
1694#include <__random/geometric_distribution.h>1695#include <__random/geometric_distribution.h>
1695#include <__random/independent_bits_engine.h>1696#include <__random/independent_bits_engine.h>
1696#include <__random/is_seed_sequence.h>1697#include <__random/is_seed_sequence.h>
1698#include <__random/is_valid.h>
1697#include <__random/knuth_b.h>1699#include <__random/knuth_b.h>
1698#include <__random/linear_congruential_engine.h>1700#include <__random/linear_congruential_engine.h>
1699#include <__random/log2.h>1701#include <__random/log2.h>
...@@ -1714,10 +1716,15 @@ class piecewise_linear_distribution...@@ -1714,10 +1716,15 @@ class piecewise_linear_distribution
1714#include <__random/uniform_random_bit_generator.h>1716#include <__random/uniform_random_bit_generator.h>
1715#include <__random/uniform_real_distribution.h>1717#include <__random/uniform_real_distribution.h>
1716#include <__random/weibull_distribution.h>1718#include <__random/weibull_distribution.h>
1717#include <initializer_list>
1718#include <version>1719#include <version>
17191720
1720#include <algorithm> // for backward compatibility; TODO remove it1721#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
1722# include <algorithm>
1723#endif
1724
1725// standard-mandated includes
1726#include <initializer_list>
1727
1721#include <cmath> // for backward compatibility; TODO remove it1728#include <cmath> // for backward compatibility; TODO remove it
1722#include <cstddef> // for backward compatibility; TODO remove it1729#include <cstddef> // for backward compatibility; TODO remove it
1723#include <cstdint> // for backward compatibility; TODO remove it1730#include <cstdint> // for backward compatibility; TODO remove it
...@@ -1729,7 +1736,7 @@ class piecewise_linear_distribution...@@ -1729,7 +1736,7 @@ class piecewise_linear_distribution
1729#include <vector> // for backward compatibility; TODO remove it1736#include <vector> // for backward compatibility; TODO remove it
17301737
1731#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)1738#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1732#pragma GCC system_header1739# pragma GCC system_header
1733#endif1740#endif
17341741
1735#endif // _LIBCPP_RANDOM1742#endif // _LIBCPP_RANDOM
lib/libcxx/include/ranges+80-1
...@@ -120,6 +120,14 @@ namespace std::ranges {...@@ -120,6 +120,14 @@ namespace std::ranges {
120 requires is_object_v<T>120 requires is_object_v<T>
121 class empty_view;121 class empty_view;
122122
123 template<class T>
124 inline constexpr bool enable_borrowed_range<empty_view<T>> = true;
125
126 namespace views {
127 template<class T>
128 inline constexpr empty_view<T> empty{};
129 }
130
123 // [range.all], all view131 // [range.all], all view
124 namespace views {132 namespace views {
125 inline constexpr unspecified all = unspecified;133 inline constexpr unspecified all = unspecified;
...@@ -142,6 +150,15 @@ namespace std::ranges {...@@ -142,6 +150,15 @@ namespace std::ranges {
142 template<class T>150 template<class T>
143 inline constexpr bool enable_borrowed_range<owning_view<T>> = enable_borrowed_range<T>;151 inline constexpr bool enable_borrowed_range<owning_view<T>> = enable_borrowed_range<T>;
144152
153 // [range.filter], filter view
154 template<input_range V, indirect_unary_predicate<iterator_t<V>> Pred>
155 requires view<V> && is_object_v<Pred>
156 class filter_view;
157
158 namespace views {
159 inline constexpr unspecified filter = unspecified;
160 }
161
145 // [range.drop], drop view162 // [range.drop], drop view
146 template<view V>163 template<view V>
147 class drop_view;164 class drop_view;
...@@ -196,10 +213,66 @@ namespace std::ranges {...@@ -196,10 +213,66 @@ namespace std::ranges {
196 template<input_range V>213 template<input_range V>
197 requires view<V> && input_range<range_reference_t<V>>214 requires view<V> && input_range<range_reference_t<V>>
198 class join_view;215 class join_view;
216
217 // [range.lazy.split], lazy split view
218 template<class R>
219 concept tiny-range = see below; // exposition only
220
221 template<input_range V, forward_range Pattern>
222 requires view<V> && view<Pattern> &&
223 indirectly_comparable<iterator_t<V>, iterator_t<Pattern>, ranges::equal_to> &&
224 (forward_range<V> || tiny-range<Pattern>)
225 class lazy_split_view;
226
227 namespace views {
228 inline constexpr unspecified lazy_split = unspecified;
229 }
230
231 // [range.zip], zip view
232 template<input_range... Views>
233 requires (view<Views> && ...) && (sizeof...(Views) > 0)
234 class zip_view; // C++2b
235
236 template<class... Views>
237 inline constexpr bool enable_borrowed_range<zip_view<Views...>> = // C++2b
238 (enable_borrowed_range<Views> && ...);
239
240 namespace views { inline constexpr unspecified zip = unspecified; } // C++2b
199}241}
200242
243namespace std {
244 namespace views = ranges::views;
245
246 template<class T> struct tuple_size;
247 template<size_t I, class T> struct tuple_element;
248
249 template<class I, class S, ranges::subrange_kind K>
250 struct tuple_size<ranges::subrange<I, S, K>>
251 : integral_constant<size_t, 2> {};
252
253 template<class I, class S, ranges::subrange_kind K>
254 struct tuple_element<0, ranges::subrange<I, S, K>> {
255 using type = I;
256 };
257
258 template<class I, class S, ranges::subrange_kind K>
259 struct tuple_element<1, ranges::subrange<I, S, K>> {
260 using type = S;
261 };
262
263 template<class I, class S, ranges::subrange_kind K>
264 struct tuple_element<0, const ranges::subrange<I, S, K>> {
265 using type = I;
266 };
267
268 template<class I, class S, ranges::subrange_kind K>
269 struct tuple_element<1, const ranges::subrange<I, S, K>> {
270 using type = S;
271 };
272}
201*/273*/
202274
275#include <__assert> // all public C++ headers provide the assertion handler
203#include <__config>276#include <__config>
204#include <__ranges/access.h>277#include <__ranges/access.h>
205#include <__ranges/all.h>278#include <__ranges/all.h>
...@@ -213,9 +286,13 @@ namespace std::ranges {...@@ -213,9 +286,13 @@ namespace std::ranges {
213#include <__ranges/empty_view.h>286#include <__ranges/empty_view.h>
214#include <__ranges/enable_borrowed_range.h>287#include <__ranges/enable_borrowed_range.h>
215#include <__ranges/enable_view.h>288#include <__ranges/enable_view.h>
289#include <__ranges/filter_view.h>
216#include <__ranges/iota_view.h>290#include <__ranges/iota_view.h>
217#include <__ranges/join_view.h>291#include <__ranges/join_view.h>
292#include <__ranges/lazy_split_view.h>
293#include <__ranges/rbegin.h>
218#include <__ranges/ref_view.h>294#include <__ranges/ref_view.h>
295#include <__ranges/rend.h>
219#include <__ranges/reverse_view.h>296#include <__ranges/reverse_view.h>
220#include <__ranges/single_view.h>297#include <__ranges/single_view.h>
221#include <__ranges/size.h>298#include <__ranges/size.h>
...@@ -224,6 +301,8 @@ namespace std::ranges {...@@ -224,6 +301,8 @@ namespace std::ranges {
224#include <__ranges/transform_view.h>301#include <__ranges/transform_view.h>
225#include <__ranges/view_interface.h>302#include <__ranges/view_interface.h>
226#include <__ranges/views.h>303#include <__ranges/views.h>
304#include <__ranges/zip_view.h>
305#include <__tuple> // TODO: <ranges> has to export std::tuple_size. Replace this, once <tuple> is granularized.
227#include <compare> // Required by the standard.306#include <compare> // Required by the standard.
228#include <initializer_list> // Required by the standard.307#include <initializer_list> // Required by the standard.
229#include <iterator> // Required by the standard.308#include <iterator> // Required by the standard.
...@@ -231,7 +310,7 @@ namespace std::ranges {...@@ -231,7 +310,7 @@ namespace std::ranges {
231#include <version>310#include <version>
232311
233#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)312#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
234#pragma GCC system_header313# pragma GCC system_header
235#endif314#endif
236315
237#endif // _LIBCPP_RANGES316#endif // _LIBCPP_RANGES
lib/libcxx/include/ratio+8-7
...@@ -77,6 +77,7 @@ typedef ratio<1000000000000000000000000, 1> yotta; // not supported...@@ -77,6 +77,7 @@ typedef ratio<1000000000000000000000000, 1> yotta; // not supported
77}77}
78*/78*/
7979
80#include <__assert> // all public C++ headers provide the assertion handler
80#include <__config>81#include <__config>
81#include <climits>82#include <climits>
82#include <cstdint>83#include <cstdint>
...@@ -84,7 +85,7 @@ typedef ratio<1000000000000000000000000, 1> yotta; // not supported...@@ -84,7 +85,7 @@ typedef ratio<1000000000000000000000000, 1> yotta; // not supported
84#include <version>85#include <version>
8586
86#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)87#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
87#pragma GCC system_header88# pragma GCC system_header
88#endif89#endif
8990
90_LIBCPP_PUSH_MACROS91_LIBCPP_PUSH_MACROS
...@@ -416,11 +417,11 @@ struct _LIBCPP_TEMPLATE_VIS ratio_subtract...@@ -416,11 +417,11 @@ struct _LIBCPP_TEMPLATE_VIS ratio_subtract
416417
417template <class _R1, class _R2>418template <class _R1, class _R2>
418struct _LIBCPP_TEMPLATE_VIS ratio_equal419struct _LIBCPP_TEMPLATE_VIS ratio_equal
419 : public _LIBCPP_BOOL_CONSTANT((_R1::num == _R2::num && _R1::den == _R2::den)) {};420 : _BoolConstant<(_R1::num == _R2::num && _R1::den == _R2::den)> {};
420421
421template <class _R1, class _R2>422template <class _R1, class _R2>
422struct _LIBCPP_TEMPLATE_VIS ratio_not_equal423struct _LIBCPP_TEMPLATE_VIS ratio_not_equal
423 : public _LIBCPP_BOOL_CONSTANT((!ratio_equal<_R1, _R2>::value)) {};424 : _BoolConstant<!ratio_equal<_R1, _R2>::value> {};
424425
425// ratio_less426// ratio_less
426427
...@@ -479,19 +480,19 @@ struct __ratio_less<_R1, _R2, -1LL, -1LL>...@@ -479,19 +480,19 @@ struct __ratio_less<_R1, _R2, -1LL, -1LL>
479480
480template <class _R1, class _R2>481template <class _R1, class _R2>
481struct _LIBCPP_TEMPLATE_VIS ratio_less482struct _LIBCPP_TEMPLATE_VIS ratio_less
482 : public _LIBCPP_BOOL_CONSTANT((__ratio_less<_R1, _R2>::value)) {};483 : _BoolConstant<__ratio_less<_R1, _R2>::value> {};
483484
484template <class _R1, class _R2>485template <class _R1, class _R2>
485struct _LIBCPP_TEMPLATE_VIS ratio_less_equal486struct _LIBCPP_TEMPLATE_VIS ratio_less_equal
486 : public _LIBCPP_BOOL_CONSTANT((!ratio_less<_R2, _R1>::value)) {};487 : _BoolConstant<!ratio_less<_R2, _R1>::value> {};
487488
488template <class _R1, class _R2>489template <class _R1, class _R2>
489struct _LIBCPP_TEMPLATE_VIS ratio_greater490struct _LIBCPP_TEMPLATE_VIS ratio_greater
490 : public _LIBCPP_BOOL_CONSTANT((ratio_less<_R2, _R1>::value)) {};491 : _BoolConstant<ratio_less<_R2, _R1>::value> {};
491492
492template <class _R1, class _R2>493template <class _R1, class _R2>
493struct _LIBCPP_TEMPLATE_VIS ratio_greater_equal494struct _LIBCPP_TEMPLATE_VIS ratio_greater_equal
494 : public _LIBCPP_BOOL_CONSTANT((!ratio_less<_R1, _R2>::value)) {};495 : _BoolConstant<!ratio_less<_R1, _R2>::value> {};
495496
496template <class _R1, class _R2>497template <class _R1, class _R2>
497struct __ratio_gcd498struct __ratio_gcd
lib/libcxx/include/regex+40-26
...@@ -762,23 +762,42 @@ typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;...@@ -762,23 +762,42 @@ typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;
762} // std762} // std
763*/763*/
764764
765#include <__algorithm/find.h>
766#include <__algorithm/search.h>
767#include <__assert> // all public C++ headers provide the assertion handler
765#include <__config>768#include <__config>
766#include <__debug>769#include <__iterator/back_insert_iterator.h>
767#include <__iterator/wrap_iter.h>770#include <__iterator/wrap_iter.h>
768#include <__locale>771#include <__locale>
769#include <compare>772#include <__utility/move.h>
773#include <__utility/swap.h>
770#include <deque>774#include <deque>
771#include <initializer_list>
772#include <iterator>
773#include <memory>775#include <memory>
774#include <stdexcept>776#include <stdexcept>
775#include <string>777#include <string>
776#include <utility>
777#include <vector>778#include <vector>
778#include <version>779#include <version>
779780
781#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
782# include <iterator>
783# include <utility>
784#endif
785
786// standard-mandated includes
787
788// [iterator.range]
789#include <__iterator/access.h>
790#include <__iterator/data.h>
791#include <__iterator/empty.h>
792#include <__iterator/reverse_access.h>
793#include <__iterator/size.h>
794
795// [re.syn]
796#include <compare>
797#include <initializer_list>
798
780#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)799#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
781#pragma GCC system_header800# pragma GCC system_header
782#endif801#endif
783802
784_LIBCPP_PUSH_MACROS803_LIBCPP_PUSH_MACROS
...@@ -1311,9 +1330,9 @@ regex_traits<_CharT>::isctype(char_type __c, char_class_type __m) const...@@ -1311,9 +1330,9 @@ regex_traits<_CharT>::isctype(char_type __c, char_class_type __m) const
1311}1330}
13121331
1313inline _LIBCPP_INLINE_VISIBILITY1332inline _LIBCPP_INLINE_VISIBILITY
1314bool __is_07(unsigned char c)1333bool __is_07(unsigned char __c)
1315{1334{
1316 return (c & 0xF8u) ==1335 return (__c & 0xF8u) ==
1317#if defined(__MVS__) && !defined(__NATIVE_ASCII_F)1336#if defined(__MVS__) && !defined(__NATIVE_ASCII_F)
1318 0xF0;1337 0xF0;
1319#else1338#else
...@@ -1322,9 +1341,9 @@ bool __is_07(unsigned char c)...@@ -1322,9 +1341,9 @@ bool __is_07(unsigned char c)
1322}1341}
13231342
1324inline _LIBCPP_INLINE_VISIBILITY1343inline _LIBCPP_INLINE_VISIBILITY
1325bool __is_89(unsigned char c)1344bool __is_89(unsigned char __c)
1326{1345{
1327 return (c & 0xFEu) ==1346 return (__c & 0xFEu) ==
1328#if defined(__MVS__) && !defined(__NATIVE_ASCII_F)1347#if defined(__MVS__) && !defined(__NATIVE_ASCII_F)
1329 0xF8;1348 0xF8;
1330#else1349#else
...@@ -1333,12 +1352,12 @@ bool __is_89(unsigned char c)...@@ -1333,12 +1352,12 @@ bool __is_89(unsigned char c)
1333}1352}
13341353
1335inline _LIBCPP_INLINE_VISIBILITY1354inline _LIBCPP_INLINE_VISIBILITY
1336unsigned char __to_lower(unsigned char c)1355unsigned char __to_lower(unsigned char __c)
1337{1356{
1338#if defined(__MVS__) && !defined(__NATIVE_ASCII_F)1357#if defined(__MVS__) && !defined(__NATIVE_ASCII_F)
1339 return c & 0xBF;1358 return c & 0xBF;
1340#else1359#else
1341 return c | 0x20;1360 return __c | 0x20;
1342#endif1361#endif
1343}1362}
13441363
...@@ -2038,9 +2057,9 @@ __word_boundary<_CharT, _Traits>::__exec(__state& __s) const...@@ -2038,9 +2057,9 @@ __word_boundary<_CharT, _Traits>::__exec(__state& __s) const
20382057
2039template <class _CharT>2058template <class _CharT>
2040_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR2059_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
2041bool __is_eol(_CharT c)2060bool __is_eol(_CharT __c)
2042{2061{
2043 return c == '\r' || c == '\n';2062 return __c == '\r' || __c == '\n';
2044}2063}
20452064
2046template <class _CharT>2065template <class _CharT>
...@@ -2093,14 +2112,14 @@ class __r_anchor_multiline...@@ -2093,14 +2112,14 @@ class __r_anchor_multiline
2093{2112{
2094 typedef __owns_one_state<_CharT> base;2113 typedef __owns_one_state<_CharT> base;
20952114
2096 bool __multiline;2115 bool __multiline_;
20972116
2098public:2117public:
2099 typedef _VSTD::__state<_CharT> __state;2118 typedef _VSTD::__state<_CharT> __state;
21002119
2101 _LIBCPP_INLINE_VISIBILITY2120 _LIBCPP_INLINE_VISIBILITY
2102 __r_anchor_multiline(bool __multiline, __node<_CharT>* __s)2121 __r_anchor_multiline(bool __multiline, __node<_CharT>* __s)
2103 : base(__s), __multiline(__multiline) {}2122 : base(__s), __multiline_(__multiline) {}
21042123
2105 virtual void __exec(__state&) const;2124 virtual void __exec(__state&) const;
2106};2125};
...@@ -2115,7 +2134,7 @@ __r_anchor_multiline<_CharT>::__exec(__state& __s) const...@@ -2115,7 +2134,7 @@ __r_anchor_multiline<_CharT>::__exec(__state& __s) const
2115 __s.__do_ = __state::__accept_but_not_consume;2134 __s.__do_ = __state::__accept_but_not_consume;
2116 __s.__node_ = this->first();2135 __s.__node_ = this->first();
2117 }2136 }
2118 else if (__multiline && __is_eol(*__s.__current_))2137 else if (__multiline_ && __is_eol(*__s.__current_))
2119 {2138 {
2120 __s.__do_ = __state::__accept_but_not_consume;2139 __s.__do_ = __state::__accept_but_not_consume;
2121 __s.__node_ = this->first();2140 __s.__node_ = this->first();
...@@ -2729,12 +2748,7 @@ public:...@@ -2729,12 +2748,7 @@ public:
27292748
2730 template <class _InputIterator>2749 template <class _InputIterator>
2731 _LIBCPP_INLINE_VISIBILITY2750 _LIBCPP_INLINE_VISIBILITY
2732 typename enable_if2751 typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value, basic_regex&>::type
2733 <
2734 __is_cpp17_input_iterator <_InputIterator>::value &&
2735 !__is_cpp17_forward_iterator<_InputIterator>::value,
2736 basic_regex&
2737 >::type
2738 assign(_InputIterator __first, _InputIterator __last,2752 assign(_InputIterator __first, _InputIterator __last,
2739 flag_type __f = regex_constants::ECMAScript)2753 flag_type __f = regex_constants::ECMAScript)
2740 {2754 {
...@@ -2949,7 +2963,7 @@ private:...@@ -2949,7 +2963,7 @@ private:
2949 __parse_awk_escape(_ForwardIterator __first, _ForwardIterator __last,2963 __parse_awk_escape(_ForwardIterator __first, _ForwardIterator __last,
2950 basic_string<_CharT>* __str = nullptr);2964 basic_string<_CharT>* __str = nullptr);
29512965
2952 bool __test_back_ref(_CharT c);2966 bool __test_back_ref(_CharT);
29532967
2954 _LIBCPP_INLINE_VISIBILITY2968 _LIBCPP_INLINE_VISIBILITY
2955 void __push_l_anchor();2969 void __push_l_anchor();
...@@ -4768,9 +4782,9 @@ basic_regex<_CharT, _Traits>::__parse_egrep(_ForwardIterator __first,...@@ -4768,9 +4782,9 @@ basic_regex<_CharT, _Traits>::__parse_egrep(_ForwardIterator __first,
47684782
4769template <class _CharT, class _Traits>4783template <class _CharT, class _Traits>
4770bool4784bool
4771basic_regex<_CharT, _Traits>::__test_back_ref(_CharT c)4785basic_regex<_CharT, _Traits>::__test_back_ref(_CharT __c)
4772{4786{
4773 unsigned __val = __traits_.value(c, 10);4787 unsigned __val = __traits_.value(__c, 10);
4774 if (__val >= 1 && __val <= 9)4788 if (__val >= 1 && __val <= 9)
4775 {4789 {
4776 if (__val > mark_count())4790 if (__val > mark_count())
lib/libcxx/include/scoped_allocator+11-10
...@@ -109,13 +109,14 @@ template <class OuterA1, class OuterA2, class... InnerAllocs>...@@ -109,13 +109,14 @@ template <class OuterA1, class OuterA2, class... InnerAllocs>
109109
110*/110*/
111111
112#include <__assert> // all public C++ headers provide the assertion handler
112#include <__config>113#include <__config>
113#include <__utility/forward.h>114#include <__utility/forward.h>
114#include <memory>115#include <memory>
115#include <version>116#include <version>
116117
117#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)118#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
118#pragma GCC system_header119# pragma GCC system_header
119#endif120#endif
120121
121_LIBCPP_BEGIN_NAMESPACE_STD122_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -218,10 +219,10 @@ protected:...@@ -218,10 +219,10 @@ protected:
218 is_constructible<outer_allocator_type, _OuterA2>::value219 is_constructible<outer_allocator_type, _OuterA2>::value
219 >::type>220 >::type>
220 _LIBCPP_INLINE_VISIBILITY221 _LIBCPP_INLINE_VISIBILITY
221 __scoped_allocator_storage(_OuterA2&& __outerAlloc,222 __scoped_allocator_storage(_OuterA2&& __outer_alloc,
222 const _InnerAllocs& ...__innerAllocs) _NOEXCEPT223 const _InnerAllocs& ...__inner_allocs) _NOEXCEPT
223 : outer_allocator_type(_VSTD::forward<_OuterA2>(__outerAlloc)),224 : outer_allocator_type(_VSTD::forward<_OuterA2>(__outer_alloc)),
224 __inner_(__innerAllocs...) {}225 __inner_(__inner_allocs...) {}
225226
226 template <class _OuterA2,227 template <class _OuterA2,
227 class = typename enable_if<228 class = typename enable_if<
...@@ -299,8 +300,8 @@ protected:...@@ -299,8 +300,8 @@ protected:
299 is_constructible<outer_allocator_type, _OuterA2>::value300 is_constructible<outer_allocator_type, _OuterA2>::value
300 >::type>301 >::type>
301 _LIBCPP_INLINE_VISIBILITY302 _LIBCPP_INLINE_VISIBILITY
302 __scoped_allocator_storage(_OuterA2&& __outerAlloc) _NOEXCEPT303 __scoped_allocator_storage(_OuterA2&& __outer_alloc) _NOEXCEPT
303 : outer_allocator_type(_VSTD::forward<_OuterA2>(__outerAlloc)) {}304 : outer_allocator_type(_VSTD::forward<_OuterA2>(__outer_alloc)) {}
304305
305 template <class _OuterA2,306 template <class _OuterA2,
306 class = typename enable_if<307 class = typename enable_if<
...@@ -443,9 +444,9 @@ public:...@@ -443,9 +444,9 @@ public:
443 is_constructible<outer_allocator_type, _OuterA2>::value444 is_constructible<outer_allocator_type, _OuterA2>::value
444 >::type>445 >::type>
445 _LIBCPP_INLINE_VISIBILITY446 _LIBCPP_INLINE_VISIBILITY
446 scoped_allocator_adaptor(_OuterA2&& __outerAlloc,447 scoped_allocator_adaptor(_OuterA2&& __outer_alloc,
447 const _InnerAllocs& ...__innerAllocs) _NOEXCEPT448 const _InnerAllocs& ...__inner_allocs) _NOEXCEPT
448 : base(_VSTD::forward<_OuterA2>(__outerAlloc), __innerAllocs...) {}449 : base(_VSTD::forward<_OuterA2>(__outer_alloc), __inner_allocs...) {}
449 // scoped_allocator_adaptor(const scoped_allocator_adaptor& __other) = default;450 // scoped_allocator_adaptor(const scoped_allocator_adaptor& __other) = default;
450 template <class _OuterA2,451 template <class _OuterA2,
451 class = typename enable_if<452 class = typename enable_if<
lib/libcxx/include/semaphore+5-2
...@@ -45,19 +45,22 @@ using binary_semaphore = counting_semaphore<1>;...@@ -45,19 +45,22 @@ using binary_semaphore = counting_semaphore<1>;
4545
46*/46*/
4747
48#include <__assert> // all public C++ headers provide the assertion handler
48#include <__availability>49#include <__availability>
50#include <__chrono/time_point.h>
49#include <__config>51#include <__config>
50#include <__thread/timed_backoff_policy.h>52#include <__thread/timed_backoff_policy.h>
51#include <__threading_support>53#include <__threading_support>
52#include <atomic>54#include <atomic>
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#ifdef _LIBCPP_HAS_NO_THREADS62#ifdef _LIBCPP_HAS_NO_THREADS
60# error <semaphore> is not supported on this single threaded system63# error "<semaphore> is not supported since libc++ has been configured without support for threads."
61#endif64#endif
6265
63_LIBCPP_PUSH_MACROS66_LIBCPP_PUSH_MACROS
lib/libcxx/include/set+28-9
...@@ -471,21 +471,40 @@ erase_if(multiset<Key, Compare, Allocator>& c, Predicate pred); // C++20...@@ -471,21 +471,40 @@ erase_if(multiset<Key, Compare, Allocator>& c, Predicate pred); // C++20
471471
472*/472*/
473473
474#include <__algorithm/equal.h>
475#include <__algorithm/lexicographical_compare.h>
476#include <__assert> // all public C++ headers provide the assertion handler
474#include <__config>477#include <__config>
475#include <__debug>
476#include <__functional/is_transparent.h>478#include <__functional/is_transparent.h>
479#include <__functional/operations.h>
480#include <__iterator/erase_if_container.h>
477#include <__iterator/iterator_traits.h>481#include <__iterator/iterator_traits.h>
482#include <__iterator/reverse_iterator.h>
478#include <__node_handle>483#include <__node_handle>
479#include <__tree>484#include <__tree>
480#include <__utility/forward.h>485#include <__utility/forward.h>
486#include <version>
487
488#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
489# include <functional>
490# include <iterator>
491#endif
492
493// standard-mandated includes
494
495// [iterator.range]
496#include <__iterator/access.h>
497#include <__iterator/data.h>
498#include <__iterator/empty.h>
499#include <__iterator/reverse_access.h>
500#include <__iterator/size.h>
501
502// [associative.set.syn]
481#include <compare>503#include <compare>
482#include <functional>
483#include <initializer_list>504#include <initializer_list>
484#include <iterator> // __libcpp_erase_if_container
485#include <version>
486505
487#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)506#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
488#pragma GCC system_header507# pragma GCC system_header
489#endif508#endif
490509
491_LIBCPP_BEGIN_NAMESPACE_STD510_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -501,9 +520,9 @@ public:...@@ -501,9 +520,9 @@ public:
501 // types:520 // types:
502 typedef _Key key_type;521 typedef _Key key_type;
503 typedef key_type value_type;522 typedef key_type value_type;
504 typedef __identity_t<_Compare> key_compare;523 typedef __type_identity_t<_Compare> key_compare;
505 typedef key_compare value_compare;524 typedef key_compare value_compare;
506 typedef __identity_t<_Allocator> allocator_type;525 typedef __type_identity_t<_Allocator> allocator_type;
507 typedef value_type& reference;526 typedef value_type& reference;
508 typedef const value_type& const_reference;527 typedef const value_type& const_reference;
509528
...@@ -1034,9 +1053,9 @@ public:...@@ -1034,9 +1053,9 @@ public:
1034 // types:1053 // types:
1035 typedef _Key key_type;1054 typedef _Key key_type;
1036 typedef key_type value_type;1055 typedef key_type value_type;
1037 typedef __identity_t<_Compare> key_compare;1056 typedef __type_identity_t<_Compare> key_compare;
1038 typedef key_compare value_compare;1057 typedef key_compare value_compare;
1039 typedef __identity_t<_Allocator> allocator_type;1058 typedef __type_identity_t<_Allocator> allocator_type;
1040 typedef value_type& reference;1059 typedef value_type& reference;
1041 typedef const value_type& const_reference;1060 typedef const value_type& const_reference;
10421061
lib/libcxx/include/setjmp.h+1-1
...@@ -28,7 +28,7 @@ void longjmp(jmp_buf env, int val);...@@ -28,7 +28,7 @@ void longjmp(jmp_buf env, int val);
28#include <__config>28#include <__config>
2929
30#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)30#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
31#pragma GCC system_header31# pragma GCC system_header
32#endif32#endif
3333
34#include_next <setjmp.h>34#include_next <setjmp.h>
lib/libcxx/include/shared_mutex+6-7
...@@ -122,6 +122,7 @@ template <class Mutex>...@@ -122,6 +122,7 @@ template <class Mutex>
122122
123*/123*/
124124
125#include <__assert> // all public C++ headers provide the assertion handler
125#include <__availability>126#include <__availability>
126#include <__config>127#include <__config>
127#include <version>128#include <version>
...@@ -135,12 +136,12 @@ _LIBCPP_PUSH_MACROS...@@ -135,12 +136,12 @@ _LIBCPP_PUSH_MACROS
135#include <__mutex_base>136#include <__mutex_base>
136137
137#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)138#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
138#pragma GCC system_header139# pragma GCC system_header
139#endif140#endif
140141
141#ifdef _LIBCPP_HAS_NO_THREADS142#ifdef _LIBCPP_HAS_NO_THREADS
142#error <shared_mutex> is not supported on this single threaded system143# error "<shared_mutex> is not supported since libc++ has been configured without support for threads."
143#else // !_LIBCPP_HAS_NO_THREADS144#endif
144145
145_LIBCPP_BEGIN_NAMESPACE_STD146_LIBCPP_BEGIN_NAMESPACE_STD
146147
...@@ -399,9 +400,9 @@ public:...@@ -399,9 +400,9 @@ public:
399 void lock();400 void lock();
400 bool try_lock();401 bool try_lock();
401 template <class Rep, class Period>402 template <class Rep, class Period>
402 bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);403 bool try_lock_for(const chrono::duration<Rep, Period>& __rel_time);
403 template <class Clock, class Duration>404 template <class Clock, class Duration>
404 bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);405 bool try_lock_until(const chrono::time_point<Clock, Duration>& __abs_time);
405 void unlock();406 void unlock();
406407
407 // Setters408 // Setters
...@@ -500,8 +501,6 @@ swap(shared_lock<_Mutex>& __x, shared_lock<_Mutex>& __y) _NOEXCEPT...@@ -500,8 +501,6 @@ swap(shared_lock<_Mutex>& __x, shared_lock<_Mutex>& __y) _NOEXCEPT
500501
501_LIBCPP_END_NAMESPACE_STD502_LIBCPP_END_NAMESPACE_STD
502503
503#endif // !_LIBCPP_HAS_NO_THREADS
504
505#endif // _LIBCPP_STD_VER > 11504#endif // _LIBCPP_STD_VER > 11
506505
507_LIBCPP_POP_MACROS506_LIBCPP_POP_MACROS
lib/libcxx/include/span+129-123
...@@ -127,24 +127,43 @@ template<class R>...@@ -127,24 +127,43 @@ template<class R>
127127
128*/128*/
129129
130#include <__assert> // all public C++ headers provide the assertion handler
130#include <__config>131#include <__config>
131#include <__debug>132#include <__debug>
133#include <__fwd/span.h>
134#include <__iterator/bounded_iter.h>
132#include <__iterator/concepts.h>135#include <__iterator/concepts.h>
136#include <__iterator/iterator_traits.h>
133#include <__iterator/wrap_iter.h>137#include <__iterator/wrap_iter.h>
138#include <__memory/pointer_traits.h>
134#include <__ranges/concepts.h>139#include <__ranges/concepts.h>
135#include <__ranges/data.h>140#include <__ranges/data.h>
136#include <__ranges/enable_borrowed_range.h>141#include <__ranges/enable_borrowed_range.h>
137#include <__ranges/enable_view.h>142#include <__ranges/enable_view.h>
138#include <__ranges/size.h>143#include <__ranges/size.h>
144#include <__utility/forward.h>
139#include <array> // for array145#include <array> // for array
140#include <cstddef> // for byte146#include <cstddef> // for byte
141#include <iterator> // for iterators
142#include <limits>147#include <limits>
143#include <type_traits> // for remove_cv, etc148#include <type_traits> // for remove_cv, etc
144#include <version>149#include <version>
145150
151#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
152# include <functional>
153# include <iterator>
154#endif
155
156// standard-mandated includes
157
158// [iterator.range]
159#include <__iterator/access.h>
160#include <__iterator/data.h>
161#include <__iterator/empty.h>
162#include <__iterator/reverse_access.h>
163#include <__iterator/size.h>
164
146#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)165#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
147#pragma GCC system_header166# pragma GCC system_header
148#endif167#endif
149168
150_LIBCPP_PUSH_MACROS169_LIBCPP_PUSH_MACROS
...@@ -154,10 +173,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -154,10 +173,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD
154173
155#if _LIBCPP_STD_VER > 17174#if _LIBCPP_STD_VER > 17
156175
157inline constexpr size_t dynamic_extent = numeric_limits<size_t>::max();
158template <typename _Tp, size_t _Extent = dynamic_extent> class span;
159
160
161template <class _Tp>176template <class _Tp>
162struct __is_std_array : false_type {};177struct __is_std_array : false_type {};
163178
...@@ -170,24 +185,22 @@ struct __is_std_span : false_type {};...@@ -170,24 +185,22 @@ struct __is_std_span : false_type {};
170template <class _Tp, size_t _Sz>185template <class _Tp, size_t _Sz>
171struct __is_std_span<span<_Tp, _Sz>> : true_type {};186struct __is_std_span<span<_Tp, _Sz>> : true_type {};
172187
173#if defined(_LIBCPP_HAS_NO_CONCEPTS) || defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)188#if defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
174// This is a temporary workaround until we ship <ranges> -- we've unfortunately been189// This is a temporary workaround until we ship <ranges> -- we've unfortunately been
175// shipping <span> before its API was finalized, and we used to provide a constructor190// shipping <span> before its API was finalized, and we used to provide a constructor
176// from container types that had the requirements below. To avoid breaking code that191// from container types that had the requirements below. To avoid breaking code that
177// has started relying on the range-based constructor until we ship all of <ranges>,192// has started relying on the range-based constructor until we ship all of <ranges>,
178// we emulate the constructor requirements like this.193// we emulate the constructor requirements like this.
179template <class _Range, class _ElementType, class = void>
180struct __span_compatible_range : false_type { };
181
182template <class _Range, class _ElementType>194template <class _Range, class _ElementType>
183struct __span_compatible_range<_Range, _ElementType, void_t<195concept __span_compatible_range =
184 enable_if_t<!__is_std_span<remove_cvref_t<_Range>>::value>,196 !__is_std_span<remove_cvref_t<_Range>>::value &&
185 enable_if_t<!__is_std_array<remove_cvref_t<_Range>>::value>,197 !__is_std_array<remove_cvref_t<_Range>>::value &&
186 enable_if_t<!is_array_v<remove_cvref_t<_Range>>>,198 !is_array_v<remove_cvref_t<_Range>> &&
187 decltype(data(declval<_Range>())),199 requires (_Range&& __r) {
188 decltype(size(declval<_Range>())),200 data(std::forward<_Range>(__r));
189 enable_if_t<is_convertible_v<remove_pointer_t<decltype(data(declval<_Range&>()))>(*)[], _ElementType(*)[]>>201 size(std::forward<_Range>(__r));
190>> : true_type { };202 } &&
203 is_convertible_v<remove_reference_t<ranges::range_reference_t<_Range>>(*)[], _ElementType(*)[]>;
191#else204#else
192template <class _Range, class _ElementType>205template <class _Range, class _ElementType>
193concept __span_compatible_range =206concept __span_compatible_range =
...@@ -198,7 +211,16 @@ concept __span_compatible_range =...@@ -198,7 +211,16 @@ concept __span_compatible_range =
198 !__is_std_array<remove_cvref_t<_Range>>::value &&211 !__is_std_array<remove_cvref_t<_Range>>::value &&
199 !is_array_v<remove_cvref_t<_Range>> &&212 !is_array_v<remove_cvref_t<_Range>> &&
200 is_convertible_v<remove_reference_t<ranges::range_reference_t<_Range>>(*)[], _ElementType(*)[]>;213 is_convertible_v<remove_reference_t<ranges::range_reference_t<_Range>>(*)[], _ElementType(*)[]>;
201#endif214#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
215
216template <class _From, class _To>
217concept __span_array_convertible = is_convertible_v<_From(*)[], _To(*)[]>;
218
219template <class _It, class _Tp>
220concept __span_compatible_iterator = contiguous_iterator<_It> && __span_array_convertible<remove_reference_t<iter_reference_t<_It>>, _Tp>;
221
222template <class _Sentinel, class _It>
223concept __span_compatible_sentinel_for = sized_sentinel_for<_Sentinel, _It> && !is_convertible_v<_Sentinel, size_t>;
202224
203template <typename _Tp, size_t _Extent>225template <typename _Tp, size_t _Extent>
204class _LIBCPP_TEMPLATE_VIS span {226class _LIBCPP_TEMPLATE_VIS span {
...@@ -212,8 +234,8 @@ public:...@@ -212,8 +234,8 @@ public:
212 using const_pointer = const _Tp *;234 using const_pointer = const _Tp *;
213 using reference = _Tp &;235 using reference = _Tp &;
214 using const_reference = const _Tp &;236 using const_reference = const _Tp &;
215#if (_LIBCPP_DEBUG_LEVEL == 2) || defined(_LIBCPP_ABI_SPAN_POINTER_ITERATORS)237#ifdef _LIBCPP_ENABLE_DEBUG_MODE
216 using iterator = pointer;238 using iterator = __bounded_iter<pointer>;
217#else239#else
218 using iterator = __wrap_iter<pointer>;240 using iterator = __wrap_iter<pointer>;
219#endif241#endif
...@@ -222,17 +244,13 @@ public:...@@ -222,17 +244,13 @@ public:
222 static constexpr size_type extent = _Extent;244 static constexpr size_type extent = _Extent;
223245
224// [span.cons], span constructors, copy, assignment, and destructor246// [span.cons], span constructors, copy, assignment, and destructor
225 template <size_t _Sz = _Extent, enable_if_t<_Sz == 0, nullptr_t> = nullptr>247 template <size_t _Sz = _Extent> requires(_Sz == 0)
226 _LIBCPP_INLINE_VISIBILITY constexpr span() noexcept : __data{nullptr} {}248 _LIBCPP_INLINE_VISIBILITY constexpr span() noexcept : __data{nullptr} {}
227249
228 constexpr span (const span&) noexcept = default;250 constexpr span (const span&) noexcept = default;
229 constexpr span& operator=(const span&) noexcept = default;251 constexpr span& operator=(const span&) noexcept = default;
230252
231#if !defined(_LIBCPP_HAS_NO_CONCEPTS)253 template <__span_compatible_iterator<element_type> _It>
232 template <class _It,
233 enable_if_t<contiguous_iterator<_It> &&
234 is_convertible_v<remove_reference_t<iter_reference_t<_It>>(*)[], element_type (*)[]>,
235 nullptr_t> = nullptr>
236 _LIBCPP_INLINE_VISIBILITY254 _LIBCPP_INLINE_VISIBILITY
237 constexpr explicit span(_It __first, size_type __count)255 constexpr explicit span(_It __first, size_type __count)
238 : __data{_VSTD::to_address(__first)} {256 : __data{_VSTD::to_address(__first)} {
...@@ -240,11 +258,7 @@ public:...@@ -240,11 +258,7 @@ public:
240 _LIBCPP_ASSERT(_Extent == __count, "size mismatch in span's constructor (iterator, len)");258 _LIBCPP_ASSERT(_Extent == __count, "size mismatch in span's constructor (iterator, len)");
241 }259 }
242260
243 template <261 template <__span_compatible_iterator<element_type> _It, __span_compatible_sentinel_for<_It> _End>
244 class _It, class _End,
245 enable_if_t<is_convertible_v<remove_reference_t<iter_reference_t<_It> > (*)[], element_type (*)[]> &&
246 contiguous_iterator<_It> && sized_sentinel_for<_End, _It> && !is_convertible_v<_End, size_t>,
247 nullptr_t> = nullptr>
248 _LIBCPP_INLINE_VISIBILITY262 _LIBCPP_INLINE_VISIBILITY
249 constexpr explicit span(_It __first, _End __last) : __data{_VSTD::to_address(__first)} {263 constexpr explicit span(_It __first, _End __last) : __data{_VSTD::to_address(__first)} {
250 (void)__last;264 (void)__last;
...@@ -252,31 +266,27 @@ public:...@@ -252,31 +266,27 @@ public:
252 _LIBCPP_ASSERT(__last - __first == _Extent,266 _LIBCPP_ASSERT(__last - __first == _Extent,
253 "invalid range in span's constructor (iterator, sentinel): last - first != extent");267 "invalid range in span's constructor (iterator, sentinel): last - first != extent");
254 }268 }
255#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
256269
257 _LIBCPP_INLINE_VISIBILITY constexpr span(type_identity_t<element_type> (&__arr)[_Extent]) noexcept : __data{__arr} {}270 _LIBCPP_INLINE_VISIBILITY constexpr span(type_identity_t<element_type> (&__arr)[_Extent]) noexcept : __data{__arr} {}
258271
259 template <class _OtherElementType,272 template <__span_array_convertible<element_type> _OtherElementType>
260 enable_if_t<is_convertible_v<_OtherElementType(*)[], element_type (*)[]>, nullptr_t> = nullptr>
261 _LIBCPP_INLINE_VISIBILITY273 _LIBCPP_INLINE_VISIBILITY
262 constexpr span(array<_OtherElementType, _Extent>& __arr) noexcept : __data{__arr.data()} {}274 constexpr span(array<_OtherElementType, _Extent>& __arr) noexcept : __data{__arr.data()} {}
263275
264 template <class _OtherElementType,276 template <class _OtherElementType>
265 enable_if_t<is_convertible_v<const _OtherElementType(*)[], element_type (*)[]>, nullptr_t> = nullptr>277 requires __span_array_convertible<const _OtherElementType, element_type>
266 _LIBCPP_INLINE_VISIBILITY278 _LIBCPP_INLINE_VISIBILITY
267 constexpr span(const array<_OtherElementType, _Extent>& __arr) noexcept : __data{__arr.data()} {}279 constexpr span(const array<_OtherElementType, _Extent>& __arr) noexcept : __data{__arr.data()} {}
268280
269#if defined(_LIBCPP_HAS_NO_CONCEPTS) || defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)281#if defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
270 template <class _Container, class = enable_if_t<282 template <class _Container>
271 __span_compatible_range<_Container, element_type>::value283 requires __span_compatible_range<_Container, element_type>
272 >>
273 _LIBCPP_INLINE_VISIBILITY284 _LIBCPP_INLINE_VISIBILITY
274 constexpr explicit span(_Container& __c) : __data{std::data(__c)} {285 constexpr explicit span(_Container& __c) : __data{std::data(__c)} {
275 _LIBCPP_ASSERT(std::size(__c) == _Extent, "size mismatch in span's constructor (range)");286 _LIBCPP_ASSERT(std::size(__c) == _Extent, "size mismatch in span's constructor (range)");
276 }287 }
277 template <class _Container, class = enable_if_t<288 template <class _Container>
278 __span_compatible_range<const _Container, element_type>::value289 requires __span_compatible_range<const _Container, element_type>
279 >>
280 _LIBCPP_INLINE_VISIBILITY290 _LIBCPP_INLINE_VISIBILITY
281 constexpr explicit span(const _Container& __c) : __data{std::data(__c)} {291 constexpr explicit span(const _Container& __c) : __data{std::data(__c)} {
282 _LIBCPP_ASSERT(std::size(__c) == _Extent, "size mismatch in span's constructor (range)");292 _LIBCPP_ASSERT(std::size(__c) == _Extent, "size mismatch in span's constructor (range)");
...@@ -287,22 +297,16 @@ public:...@@ -287,22 +297,16 @@ public:
287 constexpr explicit span(_Range&& __r) : __data{ranges::data(__r)} {297 constexpr explicit span(_Range&& __r) : __data{ranges::data(__r)} {
288 _LIBCPP_ASSERT(ranges::size(__r) == _Extent, "size mismatch in span's constructor (range)");298 _LIBCPP_ASSERT(ranges::size(__r) == _Extent, "size mismatch in span's constructor (range)");
289 }299 }
290#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)300#endif
291301
292 template <class _OtherElementType>302 template <__span_array_convertible<element_type> _OtherElementType>
293 _LIBCPP_INLINE_VISIBILITY303 _LIBCPP_INLINE_VISIBILITY
294 constexpr span(const span<_OtherElementType, _Extent>& __other,304 constexpr span(const span<_OtherElementType, _Extent>& __other)
295 enable_if_t<
296 is_convertible_v<_OtherElementType(*)[], element_type (*)[]>,
297 nullptr_t> = nullptr)
298 : __data{__other.data()} {}305 : __data{__other.data()} {}
299306
300 template <class _OtherElementType>307 template <__span_array_convertible<element_type> _OtherElementType>
301 _LIBCPP_INLINE_VISIBILITY308 _LIBCPP_INLINE_VISIBILITY
302 constexpr explicit span(const span<_OtherElementType, dynamic_extent>& __other,309 constexpr explicit span(const span<_OtherElementType, dynamic_extent>& __other) noexcept
303 enable_if_t<
304 is_convertible_v<_OtherElementType(*)[], element_type (*)[]>,
305 nullptr_t> = nullptr) noexcept
306 : __data{__other.data()} { _LIBCPP_ASSERT(_Extent == __other.size(), "size mismatch in span's constructor (other span)"); }310 : __data{__other.data()} { _LIBCPP_ASSERT(_Extent == __other.size(), "size mismatch in span's constructor (other span)"); }
307311
308312
...@@ -312,7 +316,7 @@ public:...@@ -312,7 +316,7 @@ public:
312 _LIBCPP_INLINE_VISIBILITY316 _LIBCPP_INLINE_VISIBILITY
313 constexpr span<element_type, _Count> first() const noexcept317 constexpr span<element_type, _Count> first() const noexcept
314 {318 {
315 static_assert(_Count <= _Extent, "Count out of range in span::first()");319 static_assert(_Count <= _Extent, "span<T, N>::first<Count>(): Count out of range");
316 return span<element_type, _Count>{data(), _Count};320 return span<element_type, _Count>{data(), _Count};
317 }321 }
318322
...@@ -320,21 +324,21 @@ public:...@@ -320,21 +324,21 @@ public:
320 _LIBCPP_INLINE_VISIBILITY324 _LIBCPP_INLINE_VISIBILITY
321 constexpr span<element_type, _Count> last() const noexcept325 constexpr span<element_type, _Count> last() const noexcept
322 {326 {
323 static_assert(_Count <= _Extent, "Count out of range in span::last()");327 static_assert(_Count <= _Extent, "span<T, N>::last<Count>(): Count out of range");
324 return span<element_type, _Count>{data() + size() - _Count, _Count};328 return span<element_type, _Count>{data() + size() - _Count, _Count};
325 }329 }
326330
327 _LIBCPP_INLINE_VISIBILITY331 _LIBCPP_INLINE_VISIBILITY
328 constexpr span<element_type, dynamic_extent> first(size_type __count) const noexcept332 constexpr span<element_type, dynamic_extent> first(size_type __count) const noexcept
329 {333 {
330 _LIBCPP_ASSERT(__count <= size(), "Count out of range in span::first(count)");334 _LIBCPP_ASSERT(__count <= size(), "span<T, N>::first(count): count out of range");
331 return {data(), __count};335 return {data(), __count};
332 }336 }
333337
334 _LIBCPP_INLINE_VISIBILITY338 _LIBCPP_INLINE_VISIBILITY
335 constexpr span<element_type, dynamic_extent> last(size_type __count) const noexcept339 constexpr span<element_type, dynamic_extent> last(size_type __count) const noexcept
336 {340 {
337 _LIBCPP_ASSERT(__count <= size(), "Count out of range in span::last(count)");341 _LIBCPP_ASSERT(__count <= size(), "span<T, N>::last(count): count out of range");
338 return {data() + size() - __count, __count};342 return {data() + size() - __count, __count};
339 }343 }
340344
...@@ -343,8 +347,8 @@ public:...@@ -343,8 +347,8 @@ public:
343 constexpr auto subspan() const noexcept347 constexpr auto subspan() const noexcept
344 -> span<element_type, _Count != dynamic_extent ? _Count : _Extent - _Offset>348 -> span<element_type, _Count != dynamic_extent ? _Count : _Extent - _Offset>
345 {349 {
346 static_assert(_Offset <= _Extent, "Offset out of range in span::subspan()");350 static_assert(_Offset <= _Extent, "span<T, N>::subspan<Offset, Count>(): Offset out of range");
347 static_assert(_Count == dynamic_extent || _Count <= _Extent - _Offset, "Offset + count out of range in span::subspan()");351 static_assert(_Count == dynamic_extent || _Count <= _Extent - _Offset, "span<T, N>::subspan<Offset, Count>(): Offset + Count out of range");
348352
349 using _ReturnType = span<element_type, _Count != dynamic_extent ? _Count : _Extent - _Offset>;353 using _ReturnType = span<element_type, _Count != dynamic_extent ? _Count : _Extent - _Offset>;
350 return _ReturnType{data() + _Offset, _Count == dynamic_extent ? size() - _Offset : _Count};354 return _ReturnType{data() + _Offset, _Count == dynamic_extent ? size() - _Offset : _Count};
...@@ -355,11 +359,11 @@ public:...@@ -355,11 +359,11 @@ public:
355 constexpr span<element_type, dynamic_extent>359 constexpr span<element_type, dynamic_extent>
356 subspan(size_type __offset, size_type __count = dynamic_extent) const noexcept360 subspan(size_type __offset, size_type __count = dynamic_extent) const noexcept
357 {361 {
358 _LIBCPP_ASSERT(__offset <= size(), "Offset out of range in span::subspan(offset, count)");362 _LIBCPP_ASSERT(__offset <= size(), "span<T, N>::subspan(offset, count): offset out of range");
359 _LIBCPP_ASSERT(__count <= size() || __count == dynamic_extent, "Count out of range in span::subspan(offset, count)");363 _LIBCPP_ASSERT(__count <= size() || __count == dynamic_extent, "span<T, N>::subspan(offset, count): count out of range");
360 if (__count == dynamic_extent)364 if (__count == dynamic_extent)
361 return {data() + __offset, size() - __offset};365 return {data() + __offset, size() - __offset};
362 _LIBCPP_ASSERT(__count <= size() - __offset, "Offset + count out of range in span::subspan(offset, count)");366 _LIBCPP_ASSERT(__count <= size() - __offset, "span<T, N>::subspan(offset, count): offset + count out of range");
363 return {data() + __offset, __count};367 return {data() + __offset, __count};
364 }368 }
365369
...@@ -369,7 +373,7 @@ public:...@@ -369,7 +373,7 @@ public:
369373
370 _LIBCPP_INLINE_VISIBILITY constexpr reference operator[](size_type __idx) const noexcept374 _LIBCPP_INLINE_VISIBILITY constexpr reference operator[](size_type __idx) const noexcept
371 {375 {
372 _LIBCPP_ASSERT(__idx < size(), "span<T,N>[] index out of bounds");376 _LIBCPP_ASSERT(__idx < size(), "span<T, N>::operator[](index): index out of range");
373 return __data[__idx];377 return __data[__idx];
374 }378 }
375379
...@@ -388,8 +392,20 @@ public:...@@ -388,8 +392,20 @@ public:
388 _LIBCPP_INLINE_VISIBILITY constexpr pointer data() const noexcept { return __data; }392 _LIBCPP_INLINE_VISIBILITY constexpr pointer data() const noexcept { return __data; }
389393
390// [span.iter], span iterator support394// [span.iter], span iterator support
391 _LIBCPP_INLINE_VISIBILITY constexpr iterator begin() const noexcept { return iterator(data()); }395 _LIBCPP_INLINE_VISIBILITY constexpr iterator begin() const noexcept {
392 _LIBCPP_INLINE_VISIBILITY constexpr iterator end() const noexcept { return iterator(data() + size()); }396#ifdef _LIBCPP_ENABLE_DEBUG_MODE
397 return std::__make_bounded_iter(data(), data(), data() + size());
398#else
399 return iterator(this, data());
400#endif
401 }
402 _LIBCPP_INLINE_VISIBILITY constexpr iterator end() const noexcept {
403#ifdef _LIBCPP_ENABLE_DEBUG_MODE
404 return std::__make_bounded_iter(data() + size(), data(), data() + size());
405#else
406 return iterator(this, data() + size());
407#endif
408 }
393 _LIBCPP_INLINE_VISIBILITY constexpr reverse_iterator rbegin() const noexcept { return reverse_iterator(end()); }409 _LIBCPP_INLINE_VISIBILITY constexpr reverse_iterator rbegin() const noexcept { return reverse_iterator(end()); }
394 _LIBCPP_INLINE_VISIBILITY constexpr reverse_iterator rend() const noexcept { return reverse_iterator(begin()); }410 _LIBCPP_INLINE_VISIBILITY constexpr reverse_iterator rend() const noexcept { return reverse_iterator(begin()); }
395411
...@@ -401,14 +417,11 @@ public:...@@ -401,14 +417,11 @@ public:
401417
402private:418private:
403 pointer __data;419 pointer __data;
404
405};420};
406421
407422
408template <typename _Tp>423template <typename _Tp>
409class _LIBCPP_TEMPLATE_VIS span<_Tp, dynamic_extent> {424class _LIBCPP_TEMPLATE_VIS span<_Tp, dynamic_extent> {
410private:
411
412public:425public:
413// constants and types426// constants and types
414 using element_type = _Tp;427 using element_type = _Tp;
...@@ -419,8 +432,8 @@ public:...@@ -419,8 +432,8 @@ public:
419 using const_pointer = const _Tp *;432 using const_pointer = const _Tp *;
420 using reference = _Tp &;433 using reference = _Tp &;
421 using const_reference = const _Tp &;434 using const_reference = const _Tp &;
422#if (_LIBCPP_DEBUG_LEVEL == 2) || defined(_LIBCPP_ABI_SPAN_POINTER_ITERATORS)435#ifdef _LIBCPP_ENABLE_DEBUG_MODE
423 using iterator = pointer;436 using iterator = __bounded_iter<pointer>;
424#else437#else
425 using iterator = __wrap_iter<pointer>;438 using iterator = __wrap_iter<pointer>;
426#endif439#endif
...@@ -434,62 +447,47 @@ public:...@@ -434,62 +447,47 @@ public:
434 constexpr span (const span&) noexcept = default;447 constexpr span (const span&) noexcept = default;
435 constexpr span& operator=(const span&) noexcept = default;448 constexpr span& operator=(const span&) noexcept = default;
436449
437#if !defined(_LIBCPP_HAS_NO_CONCEPTS)450 template <__span_compatible_iterator<element_type> _It>
438 template <class _It,
439 enable_if_t<contiguous_iterator<_It> &&
440 is_convertible_v<remove_reference_t<iter_reference_t<_It> > (*)[], element_type (*)[]>,
441 nullptr_t> = nullptr>
442 _LIBCPP_INLINE_VISIBILITY451 _LIBCPP_INLINE_VISIBILITY
443 constexpr span(_It __first, size_type __count)452 constexpr span(_It __first, size_type __count)
444 : __data{_VSTD::to_address(__first)}, __size{__count} {}453 : __data{_VSTD::to_address(__first)}, __size{__count} {}
445454
446 template <455 template <__span_compatible_iterator<element_type> _It, __span_compatible_sentinel_for<_It> _End>
447 class _It, class _End,
448 enable_if_t<is_convertible_v<remove_reference_t<iter_reference_t<_It> > (*)[], element_type (*)[]> &&
449 contiguous_iterator<_It> && sized_sentinel_for<_End, _It> && !is_convertible_v<_End, size_t>,
450 nullptr_t> = nullptr>
451 _LIBCPP_INLINE_VISIBILITY456 _LIBCPP_INLINE_VISIBILITY
452 constexpr span(_It __first, _End __last)457 constexpr span(_It __first, _End __last)
453 : __data(_VSTD::to_address(__first)), __size(__last - __first) {}458 : __data(_VSTD::to_address(__first)), __size(__last - __first) {}
454#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
455459
456 template <size_t _Sz>460 template <size_t _Sz>
457 _LIBCPP_INLINE_VISIBILITY461 _LIBCPP_INLINE_VISIBILITY
458 constexpr span(type_identity_t<element_type> (&__arr)[_Sz]) noexcept : __data{__arr}, __size{_Sz} {}462 constexpr span(type_identity_t<element_type> (&__arr)[_Sz]) noexcept : __data{__arr}, __size{_Sz} {}
459463
460 template <class _OtherElementType, size_t _Sz,464 template <__span_array_convertible<element_type> _OtherElementType, size_t _Sz>
461 enable_if_t<is_convertible_v<_OtherElementType(*)[], element_type (*)[]>, nullptr_t> = nullptr>
462 _LIBCPP_INLINE_VISIBILITY465 _LIBCPP_INLINE_VISIBILITY
463 constexpr span(array<_OtherElementType, _Sz>& __arr) noexcept : __data{__arr.data()}, __size{_Sz} {}466 constexpr span(array<_OtherElementType, _Sz>& __arr) noexcept : __data{__arr.data()}, __size{_Sz} {}
464467
465 template <class _OtherElementType, size_t _Sz,468 template <class _OtherElementType, size_t _Sz>
466 enable_if_t<is_convertible_v<const _OtherElementType(*)[], element_type (*)[]>, nullptr_t> = nullptr>469 requires __span_array_convertible<const _OtherElementType, element_type>
467 _LIBCPP_INLINE_VISIBILITY470 _LIBCPP_INLINE_VISIBILITY
468 constexpr span(const array<_OtherElementType, _Sz>& __arr) noexcept : __data{__arr.data()}, __size{_Sz} {}471 constexpr span(const array<_OtherElementType, _Sz>& __arr) noexcept : __data{__arr.data()}, __size{_Sz} {}
469472
470#if defined(_LIBCPP_HAS_NO_CONCEPTS) || defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)473#if defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
471 template <class _Container, class = enable_if_t<474 template <class _Container>
472 __span_compatible_range<_Container, element_type>::value475 requires __span_compatible_range<_Container, element_type>
473 >>
474 _LIBCPP_INLINE_VISIBILITY476 _LIBCPP_INLINE_VISIBILITY
475 constexpr span(_Container& __c) : __data(std::data(__c)), __size{std::size(__c)} {}477 constexpr span(_Container& __c) : __data(std::data(__c)), __size{std::size(__c)} {}
476 template <class _Container, class = enable_if_t<478 template <class _Container>
477 __span_compatible_range<const _Container, element_type>::value479 requires __span_compatible_range<const _Container, element_type>
478 >>
479 _LIBCPP_INLINE_VISIBILITY480 _LIBCPP_INLINE_VISIBILITY
480 constexpr span(const _Container& __c) : __data(std::data(__c)), __size{std::size(__c)} {}481 constexpr span(const _Container& __c) : __data(std::data(__c)), __size{std::size(__c)} {}
481#else482#else
482 template <__span_compatible_range<element_type> _Range>483 template <__span_compatible_range<element_type> _Range>
483 _LIBCPP_INLINE_VISIBILITY484 _LIBCPP_INLINE_VISIBILITY
484 constexpr span(_Range&& __r) : __data(ranges::data(__r)), __size{ranges::size(__r)} {}485 constexpr span(_Range&& __r) : __data(ranges::data(__r)), __size{ranges::size(__r)} {}
485#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)486#endif
486487
487 template <class _OtherElementType, size_t _OtherExtent>488 template <__span_array_convertible<element_type> _OtherElementType, size_t _OtherExtent>
488 _LIBCPP_INLINE_VISIBILITY489 _LIBCPP_INLINE_VISIBILITY
489 constexpr span(const span<_OtherElementType, _OtherExtent>& __other,490 constexpr span(const span<_OtherElementType, _OtherExtent>& __other) noexcept
490 enable_if_t<
491 is_convertible_v<_OtherElementType(*)[], element_type (*)[]>,
492 nullptr_t> = nullptr) noexcept
493 : __data{__other.data()}, __size{__other.size()} {}491 : __data{__other.data()}, __size{__other.size()} {}
494492
495// ~span() noexcept = default;493// ~span() noexcept = default;
...@@ -498,7 +496,7 @@ public:...@@ -498,7 +496,7 @@ public:
498 _LIBCPP_INLINE_VISIBILITY496 _LIBCPP_INLINE_VISIBILITY
499 constexpr span<element_type, _Count> first() const noexcept497 constexpr span<element_type, _Count> first() const noexcept
500 {498 {
501 _LIBCPP_ASSERT(_Count <= size(), "Count out of range in span::first()");499 _LIBCPP_ASSERT(_Count <= size(), "span<T>::first<Count>(): Count out of range");
502 return span<element_type, _Count>{data(), _Count};500 return span<element_type, _Count>{data(), _Count};
503 }501 }
504502
...@@ -506,21 +504,21 @@ public:...@@ -506,21 +504,21 @@ public:
506 _LIBCPP_INLINE_VISIBILITY504 _LIBCPP_INLINE_VISIBILITY
507 constexpr span<element_type, _Count> last() const noexcept505 constexpr span<element_type, _Count> last() const noexcept
508 {506 {
509 _LIBCPP_ASSERT(_Count <= size(), "Count out of range in span::last()");507 _LIBCPP_ASSERT(_Count <= size(), "span<T>::last<Count>(): Count out of range");
510 return span<element_type, _Count>{data() + size() - _Count, _Count};508 return span<element_type, _Count>{data() + size() - _Count, _Count};
511 }509 }
512510
513 _LIBCPP_INLINE_VISIBILITY511 _LIBCPP_INLINE_VISIBILITY
514 constexpr span<element_type, dynamic_extent> first(size_type __count) const noexcept512 constexpr span<element_type, dynamic_extent> first(size_type __count) const noexcept
515 {513 {
516 _LIBCPP_ASSERT(__count <= size(), "Count out of range in span::first(count)");514 _LIBCPP_ASSERT(__count <= size(), "span<T>::first(count): count out of range");
517 return {data(), __count};515 return {data(), __count};
518 }516 }
519517
520 _LIBCPP_INLINE_VISIBILITY518 _LIBCPP_INLINE_VISIBILITY
521 constexpr span<element_type, dynamic_extent> last (size_type __count) const noexcept519 constexpr span<element_type, dynamic_extent> last (size_type __count) const noexcept
522 {520 {
523 _LIBCPP_ASSERT(__count <= size(), "Count out of range in span::last(count)");521 _LIBCPP_ASSERT(__count <= size(), "span<T>::last(count): count out of range");
524 return {data() + size() - __count, __count};522 return {data() + size() - __count, __count};
525 }523 }
526524
...@@ -528,8 +526,8 @@ public:...@@ -528,8 +526,8 @@ public:
528 _LIBCPP_INLINE_VISIBILITY526 _LIBCPP_INLINE_VISIBILITY
529 constexpr span<element_type, _Count> subspan() const noexcept527 constexpr span<element_type, _Count> subspan() const noexcept
530 {528 {
531 _LIBCPP_ASSERT(_Offset <= size(), "Offset out of range in span::subspan()");529 _LIBCPP_ASSERT(_Offset <= size(), "span<T>::subspan<Offset, Count>(): Offset out of range");
532 _LIBCPP_ASSERT(_Count == dynamic_extent || _Count <= size() - _Offset, "Offset + count out of range in span::subspan()");530 _LIBCPP_ASSERT(_Count == dynamic_extent || _Count <= size() - _Offset, "span<T>::subspan<Offset, Count>(): Offset + Count out of range");
533 return span<element_type, _Count>{data() + _Offset, _Count == dynamic_extent ? size() - _Offset : _Count};531 return span<element_type, _Count>{data() + _Offset, _Count == dynamic_extent ? size() - _Offset : _Count};
534 }532 }
535533
...@@ -537,11 +535,11 @@ public:...@@ -537,11 +535,11 @@ public:
537 _LIBCPP_INLINE_VISIBILITY535 _LIBCPP_INLINE_VISIBILITY
538 subspan(size_type __offset, size_type __count = dynamic_extent) const noexcept536 subspan(size_type __offset, size_type __count = dynamic_extent) const noexcept
539 {537 {
540 _LIBCPP_ASSERT(__offset <= size(), "Offset out of range in span::subspan(offset, count)");538 _LIBCPP_ASSERT(__offset <= size(), "span<T>::subspan(offset, count): offset out of range");
541 _LIBCPP_ASSERT(__count <= size() || __count == dynamic_extent, "count out of range in span::subspan(offset, count)");539 _LIBCPP_ASSERT(__count <= size() || __count == dynamic_extent, "span<T>::subspan(offset, count): count out of range");
542 if (__count == dynamic_extent)540 if (__count == dynamic_extent)
543 return {data() + __offset, size() - __offset};541 return {data() + __offset, size() - __offset};
544 _LIBCPP_ASSERT(__count <= size() - __offset, "Offset + count out of range in span::subspan(offset, count)");542 _LIBCPP_ASSERT(__count <= size() - __offset, "span<T>::subspan(offset, count): offset + count out of range");
545 return {data() + __offset, __count};543 return {data() + __offset, __count};
546 }544 }
547545
...@@ -551,19 +549,19 @@ public:...@@ -551,19 +549,19 @@ public:
551549
552 _LIBCPP_INLINE_VISIBILITY constexpr reference operator[](size_type __idx) const noexcept550 _LIBCPP_INLINE_VISIBILITY constexpr reference operator[](size_type __idx) const noexcept
553 {551 {
554 _LIBCPP_ASSERT(__idx < size(), "span<T>[] index out of bounds");552 _LIBCPP_ASSERT(__idx < size(), "span<T>::operator[](index): index out of range");
555 return __data[__idx];553 return __data[__idx];
556 }554 }
557555
558 _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept556 _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept
559 {557 {
560 _LIBCPP_ASSERT(!empty(), "span<T>[].front() on empty span");558 _LIBCPP_ASSERT(!empty(), "span<T>::front() on empty span");
561 return __data[0];559 return __data[0];
562 }560 }
563561
564 _LIBCPP_INLINE_VISIBILITY constexpr reference back() const noexcept562 _LIBCPP_INLINE_VISIBILITY constexpr reference back() const noexcept
565 {563 {
566 _LIBCPP_ASSERT(!empty(), "span<T>[].back() on empty span");564 _LIBCPP_ASSERT(!empty(), "span<T>::back() on empty span");
567 return __data[size()-1];565 return __data[size()-1];
568 }566 }
569567
...@@ -571,8 +569,20 @@ public:...@@ -571,8 +569,20 @@ public:
571 _LIBCPP_INLINE_VISIBILITY constexpr pointer data() const noexcept { return __data; }569 _LIBCPP_INLINE_VISIBILITY constexpr pointer data() const noexcept { return __data; }
572570
573// [span.iter], span iterator support571// [span.iter], span iterator support
574 _LIBCPP_INLINE_VISIBILITY constexpr iterator begin() const noexcept { return iterator(data()); }572 _LIBCPP_INLINE_VISIBILITY constexpr iterator begin() const noexcept {
575 _LIBCPP_INLINE_VISIBILITY constexpr iterator end() const noexcept { return iterator(data() + size()); }573#ifdef _LIBCPP_ENABLE_DEBUG_MODE
574 return std::__make_bounded_iter(data(), data(), data() + size());
575#else
576 return iterator(this, data());
577#endif
578 }
579 _LIBCPP_INLINE_VISIBILITY constexpr iterator end() const noexcept {
580#ifdef _LIBCPP_ENABLE_DEBUG_MODE
581 return std::__make_bounded_iter(data() + size(), data(), data() + size());
582#else
583 return iterator(this, data() + size());
584#endif
585 }
576 _LIBCPP_INLINE_VISIBILITY constexpr reverse_iterator rbegin() const noexcept { return reverse_iterator(end()); }586 _LIBCPP_INLINE_VISIBILITY constexpr reverse_iterator rbegin() const noexcept { return reverse_iterator(end()); }
577 _LIBCPP_INLINE_VISIBILITY constexpr reverse_iterator rend() const noexcept { return reverse_iterator(begin()); }587 _LIBCPP_INLINE_VISIBILITY constexpr reverse_iterator rend() const noexcept { return reverse_iterator(begin()); }
578588
...@@ -587,31 +597,27 @@ private:...@@ -587,31 +597,27 @@ private:
587 size_type __size;597 size_type __size;
588};598};
589599
590#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
591template <class _Tp, size_t _Extent>600template <class _Tp, size_t _Extent>
592inline constexpr bool ranges::enable_borrowed_range<span<_Tp, _Extent> > = true;601inline constexpr bool ranges::enable_borrowed_range<span<_Tp, _Extent> > = true;
593602
594template <class _ElementType, size_t _Extent>603template <class _ElementType, size_t _Extent>
595inline constexpr bool ranges::enable_view<span<_ElementType, _Extent>> = true;604inline constexpr bool ranges::enable_view<span<_ElementType, _Extent>> = true;
596#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
597605
598// as_bytes & as_writable_bytes606// as_bytes & as_writable_bytes
599template <class _Tp, size_t _Extent>607template <class _Tp, size_t _Extent>
600_LIBCPP_INLINE_VISIBILITY608_LIBCPP_INLINE_VISIBILITY
601auto as_bytes(span<_Tp, _Extent> __s) noexcept609auto as_bytes(span<_Tp, _Extent> __s) noexcept
602-> decltype(__s.__as_bytes())610{ return __s.__as_bytes(); }
603{ return __s.__as_bytes(); }
604611
605template <class _Tp, size_t _Extent>612template <class _Tp, size_t _Extent> requires(!is_const_v<_Tp>)
606_LIBCPP_INLINE_VISIBILITY613_LIBCPP_INLINE_VISIBILITY
607auto as_writable_bytes(span<_Tp, _Extent> __s) noexcept614auto as_writable_bytes(span<_Tp, _Extent> __s) noexcept
608-> enable_if_t<!is_const_v<_Tp>, decltype(__s.__as_writable_bytes())>
609{ return __s.__as_writable_bytes(); }615{ return __s.__as_writable_bytes(); }
610616
611#if !defined(_LIBCPP_HAS_NO_CONCEPTS)617#if _LIBCPP_STD_VER > 17
612template<contiguous_iterator _It, class _EndOrSize>618template<contiguous_iterator _It, class _EndOrSize>
613 span(_It, _EndOrSize) -> span<remove_reference_t<iter_reference_t<_It>>>;619 span(_It, _EndOrSize) -> span<remove_reference_t<iter_reference_t<_It>>>;
614#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)620#endif // _LIBCPP_STD_VER > 17
615621
616template<class _Tp, size_t _Sz>622template<class _Tp, size_t _Sz>
617 span(_Tp (&)[_Sz]) -> span<_Tp, _Sz>;623 span(_Tp (&)[_Sz]) -> span<_Tp, _Sz>;
...@@ -622,7 +628,7 @@ template<class _Tp, size_t _Sz>...@@ -622,7 +628,7 @@ template<class _Tp, size_t _Sz>
622template<class _Tp, size_t _Sz>628template<class _Tp, size_t _Sz>
623 span(const array<_Tp, _Sz>&) -> span<const _Tp, _Sz>;629 span(const array<_Tp, _Sz>&) -> span<const _Tp, _Sz>;
624630
625#if defined(_LIBCPP_HAS_NO_CONCEPTS) || defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)631#if defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
626template<class _Container>632template<class _Container>
627 span(_Container&) -> span<typename _Container::value_type>;633 span(_Container&) -> span<typename _Container::value_type>;
628634
lib/libcxx/include/sstream+7-5
...@@ -180,14 +180,16 @@ typedef basic_stringstream<wchar_t> wstringstream;...@@ -180,14 +180,16 @@ typedef basic_stringstream<wchar_t> wstringstream;
180180
181*/181*/
182182
183#include <__assert> // all public C++ headers provide the assertion handler
183#include <__config>184#include <__config>
185#include <__utility/swap.h>
184#include <istream>186#include <istream>
185#include <ostream>187#include <ostream>
186#include <string>188#include <string>
187#include <version>189#include <version>
188190
189#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)191#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
190#pragma GCC system_header192# pragma GCC system_header
191#endif193#endif
192194
193_LIBCPP_PUSH_MACROS195_LIBCPP_PUSH_MACROS
...@@ -859,10 +861,10 @@ swap(basic_stringstream<_CharT, _Traits, _Allocator>& __x,...@@ -859,10 +861,10 @@ swap(basic_stringstream<_CharT, _Traits, _Allocator>& __x,
859}861}
860862
861#if defined(_LIBCPP_ABI_ENABLE_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1)863#if defined(_LIBCPP_ABI_ENABLE_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1)
862_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_stringbuf<char>)864extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_stringbuf<char>;
863_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_stringstream<char>)865extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_stringstream<char>;
864_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostringstream<char>)866extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostringstream<char>;
865_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istringstream<char>)867extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istringstream<char>;
866#endif868#endif
867869
868_LIBCPP_END_NAMESPACE_STD870_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/stack+10-1
...@@ -98,6 +98,7 @@ template <class T, class Container>...@@ -98,6 +98,7 @@ template <class T, class Container>
9898
99*/99*/
100100
101#include <__assert> // all public C++ headers provide the assertion handler
101#include <__config>102#include <__config>
102#include <__iterator/iterator_traits.h>103#include <__iterator/iterator_traits.h>
103#include <__memory/uses_allocator.h>104#include <__memory/uses_allocator.h>
...@@ -106,8 +107,16 @@ template <class T, class Container>...@@ -106,8 +107,16 @@ template <class T, class Container>
106#include <type_traits>107#include <type_traits>
107#include <version>108#include <version>
108109
110#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
111# include <functional>
112#endif
113
114// standard-mandated includes
115#include <compare>
116#include <initializer_list>
117
109#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)118#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
110#pragma GCC system_header119# pragma GCC system_header
111#endif120#endif
112121
113_LIBCPP_BEGIN_NAMESPACE_STD122_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/stdatomic.h created+235
...@@ -0,0 +1,235 @@
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_STDATOMIC_H
11#define _LIBCPP_STDATOMIC_H
12
13/*
14 stdatomic.h synopsis
15
16template<class T>
17 using std-atomic = std::atomic<T>; // exposition only
18
19#define _Atomic(T) std-atomic<T>
20
21#define ATOMIC_BOOL_LOCK_FREE see below
22#define ATOMIC_CHAR_LOCK_FREE see below
23#define ATOMIC_CHAR16_T_LOCK_FREE see below
24#define ATOMIC_CHAR32_T_LOCK_FREE see below
25#define ATOMIC_WCHAR_T_LOCK_FREE see below
26#define ATOMIC_SHORT_LOCK_FREE see below
27#define ATOMIC_INT_LOCK_FREE see below
28#define ATOMIC_LONG_LOCK_FREE see below
29#define ATOMIC_LLONG_LOCK_FREE see below
30#define ATOMIC_POINTER_LOCK_FREE see below
31
32using std::memory_order // see below
33using std::memory_order_relaxed // see below
34using std::memory_order_consume // see below
35using std::memory_order_acquire // see below
36using std::memory_order_release // see below
37using std::memory_order_acq_rel // see below
38using std::memory_order_seq_cst // see below
39
40using std::atomic_flag // see below
41
42using std::atomic_bool // see below
43using std::atomic_char // see below
44using std::atomic_schar // see below
45using std::atomic_uchar // see below
46using std::atomic_short // see below
47using std::atomic_ushort // see below
48using std::atomic_int // see below
49using std::atomic_uint // see below
50using std::atomic_long // see below
51using std::atomic_ulong // see below
52using std::atomic_llong // see below
53using std::atomic_ullong // see below
54using std::atomic_char8_t // see below
55using std::atomic_char16_t // see below
56using std::atomic_char32_t // see below
57using std::atomic_wchar_t // see below
58using std::atomic_int8_t // see below
59using std::atomic_uint8_t // see below
60using std::atomic_int16_t // see below
61using std::atomic_uint16_t // see below
62using std::atomic_int32_t // see below
63using std::atomic_uint32_t // see below
64using std::atomic_int64_t // see below
65using std::atomic_uint64_t // see below
66using std::atomic_int_least8_t // see below
67using std::atomic_uint_least8_t // see below
68using std::atomic_int_least16_t // see below
69using std::atomic_uint_least16_t // see below
70using std::atomic_int_least32_t // see below
71using std::atomic_uint_least32_t // see below
72using std::atomic_int_least64_t // see below
73using std::atomic_uint_least64_t // see below
74using std::atomic_int_fast8_t // see below
75using std::atomic_uint_fast8_t // see below
76using std::atomic_int_fast16_t // see below
77using std::atomic_uint_fast16_t // see below
78using std::atomic_int_fast32_t // see below
79using std::atomic_uint_fast32_t // see below
80using std::atomic_int_fast64_t // see below
81using std::atomic_uint_fast64_t // see below
82using std::atomic_intptr_t // see below
83using std::atomic_uintptr_t // see below
84using std::atomic_size_t // see below
85using std::atomic_ptrdiff_t // see below
86using std::atomic_intmax_t // see below
87using std::atomic_uintmax_t // see below
88
89using std::atomic_is_lock_free // see below
90using std::atomic_load // see below
91using std::atomic_load_explicit // see below
92using std::atomic_store // see below
93using std::atomic_store_explicit // see below
94using std::atomic_exchange // see below
95using std::atomic_exchange_explicit // see below
96using std::atomic_compare_exchange_strong // see below
97using std::atomic_compare_exchange_strong_explicit // see below
98using std::atomic_compare_exchange_weak // see below
99using std::atomic_compare_exchange_weak_explicit // see below
100using std::atomic_fetch_add // see below
101using std::atomic_fetch_add_explicit // see below
102using std::atomic_fetch_sub // see below
103using std::atomic_fetch_sub_explicit // see below
104using std::atomic_fetch_or // see below
105using std::atomic_fetch_or_explicit // see below
106using std::atomic_fetch_and // see below
107using std::atomic_fetch_and_explicit // see below
108using std::atomic_flag_test_and_set // see below
109using std::atomic_flag_test_and_set_explicit // see below
110using std::atomic_flag_clear // see below
111using std::atomic_flag_clear_explicit // see below
112
113using std::atomic_thread_fence // see below
114using std::atomic_signal_fence // see below
115
116*/
117
118#include <__config>
119
120#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
121# pragma GCC system_header
122#endif
123
124#if _LIBCPP_STD_VER > 20
125
126#include <atomic>
127#include <version>
128
129#ifdef _Atomic
130# undef _Atomic
131#endif
132
133#define _Atomic(_Tp) ::std::atomic<_Tp>
134
135using std::memory_order _LIBCPP_USING_IF_EXISTS;
136using std::memory_order_relaxed _LIBCPP_USING_IF_EXISTS;
137using std::memory_order_consume _LIBCPP_USING_IF_EXISTS;
138using std::memory_order_acquire _LIBCPP_USING_IF_EXISTS;
139using std::memory_order_release _LIBCPP_USING_IF_EXISTS;
140using std::memory_order_acq_rel _LIBCPP_USING_IF_EXISTS;
141using std::memory_order_seq_cst _LIBCPP_USING_IF_EXISTS;
142
143using std::atomic_flag _LIBCPP_USING_IF_EXISTS;
144
145using std::atomic_bool _LIBCPP_USING_IF_EXISTS;
146using std::atomic_char _LIBCPP_USING_IF_EXISTS;
147using std::atomic_schar _LIBCPP_USING_IF_EXISTS;
148using std::atomic_uchar _LIBCPP_USING_IF_EXISTS;
149using std::atomic_short _LIBCPP_USING_IF_EXISTS;
150using std::atomic_ushort _LIBCPP_USING_IF_EXISTS;
151using std::atomic_int _LIBCPP_USING_IF_EXISTS;
152using std::atomic_uint _LIBCPP_USING_IF_EXISTS;
153using std::atomic_long _LIBCPP_USING_IF_EXISTS;
154using std::atomic_ulong _LIBCPP_USING_IF_EXISTS;
155using std::atomic_llong _LIBCPP_USING_IF_EXISTS;
156using std::atomic_ullong _LIBCPP_USING_IF_EXISTS;
157using std::atomic_char8_t _LIBCPP_USING_IF_EXISTS;
158using std::atomic_char16_t _LIBCPP_USING_IF_EXISTS;
159using std::atomic_char32_t _LIBCPP_USING_IF_EXISTS;
160using std::atomic_wchar_t _LIBCPP_USING_IF_EXISTS;
161
162using std::atomic_int8_t _LIBCPP_USING_IF_EXISTS;
163using std::atomic_uint8_t _LIBCPP_USING_IF_EXISTS;
164using std::atomic_int16_t _LIBCPP_USING_IF_EXISTS;
165using std::atomic_uint16_t _LIBCPP_USING_IF_EXISTS;
166using std::atomic_int32_t _LIBCPP_USING_IF_EXISTS;
167using std::atomic_uint32_t _LIBCPP_USING_IF_EXISTS;
168using std::atomic_int64_t _LIBCPP_USING_IF_EXISTS;
169using std::atomic_uint64_t _LIBCPP_USING_IF_EXISTS;
170
171using std::atomic_int_least8_t _LIBCPP_USING_IF_EXISTS;
172using std::atomic_uint_least8_t _LIBCPP_USING_IF_EXISTS;
173using std::atomic_int_least16_t _LIBCPP_USING_IF_EXISTS;
174using std::atomic_uint_least16_t _LIBCPP_USING_IF_EXISTS;
175using std::atomic_int_least32_t _LIBCPP_USING_IF_EXISTS;
176using std::atomic_uint_least32_t _LIBCPP_USING_IF_EXISTS;
177using std::atomic_int_least64_t _LIBCPP_USING_IF_EXISTS;
178using std::atomic_uint_least64_t _LIBCPP_USING_IF_EXISTS;
179
180using std::atomic_int_fast8_t _LIBCPP_USING_IF_EXISTS;
181using std::atomic_uint_fast8_t _LIBCPP_USING_IF_EXISTS;
182using std::atomic_int_fast16_t _LIBCPP_USING_IF_EXISTS;
183using std::atomic_uint_fast16_t _LIBCPP_USING_IF_EXISTS;
184using std::atomic_int_fast32_t _LIBCPP_USING_IF_EXISTS;
185using std::atomic_uint_fast32_t _LIBCPP_USING_IF_EXISTS;
186using std::atomic_int_fast64_t _LIBCPP_USING_IF_EXISTS;
187using std::atomic_uint_fast64_t _LIBCPP_USING_IF_EXISTS;
188
189using std::atomic_intptr_t _LIBCPP_USING_IF_EXISTS;
190using std::atomic_uintptr_t _LIBCPP_USING_IF_EXISTS;
191using std::atomic_size_t _LIBCPP_USING_IF_EXISTS;
192using std::atomic_ptrdiff_t _LIBCPP_USING_IF_EXISTS;
193using std::atomic_intmax_t _LIBCPP_USING_IF_EXISTS;
194using std::atomic_uintmax_t _LIBCPP_USING_IF_EXISTS;
195
196using std::atomic_compare_exchange_strong _LIBCPP_USING_IF_EXISTS;
197using std::atomic_compare_exchange_strong_explicit _LIBCPP_USING_IF_EXISTS;
198using std::atomic_compare_exchange_weak _LIBCPP_USING_IF_EXISTS;
199using std::atomic_compare_exchange_weak_explicit _LIBCPP_USING_IF_EXISTS;
200using std::atomic_exchange _LIBCPP_USING_IF_EXISTS;
201using std::atomic_exchange_explicit _LIBCPP_USING_IF_EXISTS;
202using std::atomic_fetch_add _LIBCPP_USING_IF_EXISTS;
203using std::atomic_fetch_add_explicit _LIBCPP_USING_IF_EXISTS;
204using std::atomic_fetch_and _LIBCPP_USING_IF_EXISTS;
205using std::atomic_fetch_and_explicit _LIBCPP_USING_IF_EXISTS;
206using std::atomic_fetch_or _LIBCPP_USING_IF_EXISTS;
207using std::atomic_fetch_or_explicit _LIBCPP_USING_IF_EXISTS;
208using std::atomic_fetch_sub _LIBCPP_USING_IF_EXISTS;
209using std::atomic_fetch_sub_explicit _LIBCPP_USING_IF_EXISTS;
210using std::atomic_flag_clear _LIBCPP_USING_IF_EXISTS;
211using std::atomic_flag_clear_explicit _LIBCPP_USING_IF_EXISTS;
212using std::atomic_flag_test_and_set _LIBCPP_USING_IF_EXISTS;
213using std::atomic_flag_test_and_set_explicit _LIBCPP_USING_IF_EXISTS;
214using std::atomic_is_lock_free _LIBCPP_USING_IF_EXISTS;
215using std::atomic_load _LIBCPP_USING_IF_EXISTS;
216using std::atomic_load_explicit _LIBCPP_USING_IF_EXISTS;
217using std::atomic_store _LIBCPP_USING_IF_EXISTS;
218using std::atomic_store_explicit _LIBCPP_USING_IF_EXISTS;
219
220using std::atomic_signal_fence _LIBCPP_USING_IF_EXISTS;
221using std::atomic_thread_fence _LIBCPP_USING_IF_EXISTS;
222
223#elif defined(_LIBCPP_COMPILER_CLANG_BASED)
224
225// 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>
227// header that would be available in all Standard modes, and we don't want to
228// break that use case.
229# if __has_include_next(<stdatomic.h>)
230# include_next <stdatomic.h>
231# endif
232
233#endif // _LIBCPP_STD_VER > 20
234
235#endif // _LIBCPP_STDATOMIC_H
lib/libcxx/include/stdbool.h+1-2
...@@ -9,7 +9,6 @@...@@ -9,7 +9,6 @@
9#ifndef _LIBCPP_STDBOOL_H9#ifndef _LIBCPP_STDBOOL_H
10#define _LIBCPP_STDBOOL_H10#define _LIBCPP_STDBOOL_H
1111
12
13/*12/*
14 stdbool.h synopsis13 stdbool.h synopsis
1514
...@@ -22,7 +21,7 @@ Macros:...@@ -22,7 +21,7 @@ Macros:
22#include <__config>21#include <__config>
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
26#endif25#endif
2726
28#include_next <stdbool.h>27#include_next <stdbool.h>
lib/libcxx/include/stddef.h+3-8
...@@ -11,7 +11,7 @@...@@ -11,7 +11,7 @@
11 defined(__need_wchar_t) || defined(__need_NULL) || defined(__need_wint_t)11 defined(__need_wchar_t) || defined(__need_NULL) || defined(__need_wint_t)
1212
13#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)13#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
14#pragma GCC system_header14# pragma GCC system_header
15#endif15#endif
1616
17#include_next <stddef.h>17#include_next <stddef.h>
...@@ -39,18 +39,13 @@ Types:...@@ -39,18 +39,13 @@ Types:
39#include <__config>39#include <__config>
4040
41#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)41#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
42#pragma GCC system_header42# pragma GCC system_header
43#endif43#endif
4444
45#include_next <stddef.h>45#include_next <stddef.h>
4646
47#ifdef __cplusplus47#ifdef __cplusplus
4848 typedef decltype(nullptr) nullptr_t;
49extern "C++" {
50#include <__nullptr>
51using std::nullptr_t;
52}
53
54#endif49#endif
5550
56#endif // _LIBCPP_STDDEF_H51#endif // _LIBCPP_STDDEF_H
lib/libcxx/include/stdexcept+2-1
...@@ -41,13 +41,14 @@ public:...@@ -41,13 +41,14 @@ public:
4141
42*/42*/
4343
44#include <__assert> // all public C++ headers provide the assertion handler
44#include <__config>45#include <__config>
45#include <cstdlib>46#include <cstdlib>
46#include <exception>47#include <exception>
47#include <iosfwd> // for string forward decl48#include <iosfwd> // for string forward decl
4849
49#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)50#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
50#pragma GCC system_header51# pragma GCC system_header
51#endif52#endif
5253
53_LIBCPP_BEGIN_NAMESPACE_STD54_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/stdint.h+1-1
...@@ -106,7 +106,7 @@ Macros:...@@ -106,7 +106,7 @@ Macros:
106#include <__config>106#include <__config>
107107
108#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)108#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
109#pragma GCC system_header109# pragma GCC system_header
110#endif110#endif
111111
112/* C99 stdlib (e.g. glibc < 2.18) does not provide macros needed112/* C99 stdlib (e.g. glibc < 2.18) does not provide macros needed
lib/libcxx/include/stdio.h+2-2
...@@ -10,7 +10,7 @@...@@ -10,7 +10,7 @@
10#if defined(__need_FILE) || defined(__need___FILE)10#if defined(__need_FILE) || defined(__need___FILE)
1111
12#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)12#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
13#pragma GCC system_header13# pragma GCC system_header
14#endif14#endif
1515
16#include_next <stdio.h>16#include_next <stdio.h>
...@@ -101,7 +101,7 @@ void perror(const char* s);...@@ -101,7 +101,7 @@ void perror(const char* s);
101#include <__config>101#include <__config>
102102
103#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)103#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
104#pragma GCC system_header104# pragma GCC system_header
105#endif105#endif
106106
107#include_next <stdio.h>107#include_next <stdio.h>
lib/libcxx/include/stdlib.h+2-2
...@@ -10,7 +10,7 @@...@@ -10,7 +10,7 @@
10#if defined(__need_malloc_and_calloc)10#if defined(__need_malloc_and_calloc)
1111
12#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)12#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
13#pragma GCC system_header13# pragma GCC system_header
14#endif14#endif
1515
16#include_next <stdlib.h>16#include_next <stdlib.h>
...@@ -87,7 +87,7 @@ void *aligned_alloc(size_t alignment, size_t size); // C11...@@ -87,7 +87,7 @@ void *aligned_alloc(size_t alignment, size_t size); // C11
87#include <__config>87#include <__config>
8888
89#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)89#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
90#pragma GCC system_header90# pragma GCC system_header
91#endif91#endif
9292
93#include_next <stdlib.h>93#include_next <stdlib.h>
lib/libcxx/include/streambuf+6-5
...@@ -107,6 +107,7 @@ protected:...@@ -107,6 +107,7 @@ protected:
107107
108*/108*/
109109
110#include <__assert> // all public C++ headers provide the assertion handler
110#include <__config>111#include <__config>
111#include <cstdint>112#include <cstdint>
112#include <ios>113#include <ios>
...@@ -114,7 +115,7 @@ protected:...@@ -114,7 +115,7 @@ protected:
114#include <version>115#include <version>
115116
116#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)117#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
117#pragma GCC system_header118# pragma GCC system_header
118#endif119#endif
119120
120_LIBCPP_PUSH_MACROS121_LIBCPP_PUSH_MACROS
...@@ -487,11 +488,11 @@ basic_streambuf<_CharT, _Traits>::overflow(int_type)...@@ -487,11 +488,11 @@ basic_streambuf<_CharT, _Traits>::overflow(int_type)
487 return traits_type::eof();488 return traits_type::eof();
488}489}
489490
490_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<char>)491extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<char>;
491_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<wchar_t>)492extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<wchar_t>;
492493
493_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<char>)494extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<char>;
494_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<wchar_t>)495extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<wchar_t>;
495496
496_LIBCPP_END_NAMESPACE_STD497_LIBCPP_END_NAMESPACE_STD
497498
lib/libcxx/include/string+1145-942
...@@ -95,248 +95,246 @@ public:...@@ -95,248 +95,246 @@ public:
95 static const size_type npos = -1;95 static const size_type npos = -1;
9696
97 basic_string()97 basic_string()
98 noexcept(is_nothrow_default_constructible<allocator_type>::value);98 noexcept(is_nothrow_default_constructible<allocator_type>::value); // constexpr since C++20
99 explicit basic_string(const allocator_type& a);99 explicit basic_string(const allocator_type& a); // constexpr since C++20
100 basic_string(const basic_string& str);100 basic_string(const basic_string& str); // constexpr since C++20
101 basic_string(basic_string&& str)101 basic_string(basic_string&& str)
102 noexcept(is_nothrow_move_constructible<allocator_type>::value);102 noexcept(is_nothrow_move_constructible<allocator_type>::value); // constexpr since C++20
103 basic_string(const basic_string& str, size_type pos,103 basic_string(const basic_string& str, size_type pos,
104 const allocator_type& a = allocator_type());104 const allocator_type& a = allocator_type()); // constexpr since C++20
105 basic_string(const basic_string& str, size_type pos, size_type n,105 basic_string(const basic_string& str, size_type pos, size_type n,
106 const Allocator& a = Allocator());106 const Allocator& a = Allocator()); // constexpr since C++20
107 template<class T>107 template<class T>
108 basic_string(const T& t, size_type pos, size_type n, const Allocator& a = Allocator()); // C++17108 basic_string(const T& t, size_type pos, size_type n, const Allocator& a = Allocator()); // C++17, constexpr since C++20
109 template <class T>109 template <class T>
110 explicit basic_string(const T& t, const Allocator& a = Allocator()); // C++17110 explicit basic_string(const T& t, const Allocator& a = Allocator()); // C++17, constexpr since C++20
111 basic_string(const value_type* s, const allocator_type& a = allocator_type());111 basic_string(const value_type* s, const allocator_type& a = allocator_type()); // constexpr since C++20
112 basic_string(const value_type* s, size_type n, const allocator_type& a = allocator_type());112 basic_string(const value_type* s, size_type n, const allocator_type& a = allocator_type()); // constexpr since C++20
113 basic_string(nullptr_t) = delete; // C++2b113 basic_string(nullptr_t) = delete; // C++2b
114 basic_string(size_type n, value_type c, const allocator_type& a = allocator_type());114 basic_string(size_type n, value_type c, const allocator_type& a = allocator_type()); // constexpr since C++20
115 template<class InputIterator>115 template<class InputIterator>
116 basic_string(InputIterator begin, InputIterator end,116 basic_string(InputIterator begin, InputIterator end,
117 const allocator_type& a = allocator_type());117 const allocator_type& a = allocator_type()); // constexpr since C++20
118 basic_string(initializer_list<value_type>, const Allocator& = Allocator());118 basic_string(initializer_list<value_type>, const Allocator& = Allocator()); // constexpr since C++20
119 basic_string(const basic_string&, const Allocator&);119 basic_string(const basic_string&, const Allocator&); // constexpr since C++20
120 basic_string(basic_string&&, const Allocator&);120 basic_string(basic_string&&, const Allocator&); // constexpr since C++20
121121
122 ~basic_string();122 ~basic_string(); // constexpr since C++20
123123
124 operator basic_string_view<charT, traits>() const noexcept;124 operator basic_string_view<charT, traits>() const noexcept; // constexpr since C++20
125125
126 basic_string& operator=(const basic_string& str);126 basic_string& operator=(const basic_string& str); // constexpr since C++20
127 template <class T>127 template <class T>
128 basic_string& operator=(const T& t); // C++17128 basic_string& operator=(const T& t); // C++17, constexpr since C++20
129 basic_string& operator=(basic_string&& str)129 basic_string& operator=(basic_string&& str)
130 noexcept(130 noexcept(
131 allocator_type::propagate_on_container_move_assignment::value ||131 allocator_type::propagate_on_container_move_assignment::value ||
132 allocator_type::is_always_equal::value ); // C++17132 allocator_type::is_always_equal::value ); // C++17, constexpr since C++20
133 basic_string& operator=(const value_type* s);133 basic_string& operator=(const value_type* s); // constexpr since C++20
134 basic_string& operator=(nullptr_t) = delete; // C++2b134 basic_string& operator=(nullptr_t) = delete; // C++2b
135 basic_string& operator=(value_type c);135 basic_string& operator=(value_type c); // constexpr since C++20
136 basic_string& operator=(initializer_list<value_type>);136 basic_string& operator=(initializer_list<value_type>); // constexpr since C++20
137137
138 iterator begin() noexcept;138 iterator begin() noexcept; // constexpr since C++20
139 const_iterator begin() const noexcept;139 const_iterator begin() const noexcept; // constexpr since C++20
140 iterator end() noexcept;140 iterator end() noexcept; // constexpr since C++20
141 const_iterator end() const noexcept;141 const_iterator end() const noexcept; // constexpr since C++20
142142
143 reverse_iterator rbegin() noexcept;143 reverse_iterator rbegin() noexcept; // constexpr since C++20
144 const_reverse_iterator rbegin() const noexcept;144 const_reverse_iterator rbegin() const noexcept; // constexpr since C++20
145 reverse_iterator rend() noexcept;145 reverse_iterator rend() noexcept; // constexpr since C++20
146 const_reverse_iterator rend() const noexcept;146 const_reverse_iterator rend() const noexcept; // constexpr since C++20
147147
148 const_iterator cbegin() const noexcept;148 const_iterator cbegin() const noexcept; // constexpr since C++20
149 const_iterator cend() const noexcept;149 const_iterator cend() const noexcept; // constexpr since C++20
150 const_reverse_iterator crbegin() const noexcept;150 const_reverse_iterator crbegin() const noexcept; // constexpr since C++20
151 const_reverse_iterator crend() const noexcept;151 const_reverse_iterator crend() const noexcept; // constexpr since C++20
152152
153 size_type size() const noexcept;153 size_type size() const noexcept; // constexpr since C++20
154 size_type length() const noexcept;154 size_type length() const noexcept; // constexpr since C++20
155 size_type max_size() const noexcept;155 size_type max_size() const noexcept; // constexpr since C++20
156 size_type capacity() const noexcept;156 size_type capacity() const noexcept; // constexpr since C++20
157157
158 void resize(size_type n, value_type c);158 void resize(size_type n, value_type c); // constexpr since C++20
159 void resize(size_type n);159 void resize(size_type n); // constexpr since C++20
160160
161 template<class Operation>161 template<class Operation>
162 constexpr void resize_and_overwrite(size_type n, Operation op); // since C++23162 constexpr void resize_and_overwrite(size_type n, Operation op); // since C++23
163163
164 void reserve(size_type res_arg);164 void reserve(size_type res_arg); // constexpr since C++20
165 void reserve(); // deprecated in C++20165 void reserve(); // deprecated in C++20
166 void shrink_to_fit();166 void shrink_to_fit(); // constexpr since C++20
167 void clear() noexcept;167 void clear() noexcept; // constexpr since C++20
168 bool empty() const noexcept;168 bool empty() const noexcept; // constexpr since C++20
169169
170 const_reference operator[](size_type pos) const;170 const_reference operator[](size_type pos) const; // constexpr since C++20
171 reference operator[](size_type pos);171 reference operator[](size_type pos); // constexpr since C++20
172172
173 const_reference at(size_type n) const;173 const_reference at(size_type n) const; // constexpr since C++20
174 reference at(size_type n);174 reference at(size_type n); // constexpr since C++20
175175
176 basic_string& operator+=(const basic_string& str);176 basic_string& operator+=(const basic_string& str); // constexpr since C++20
177 template <class T>177 template <class T>
178 basic_string& operator+=(const T& t); // C++17178 basic_string& operator+=(const T& t); // C++17, constexpr since C++20
179 basic_string& operator+=(const value_type* s);179 basic_string& operator+=(const value_type* s); // constexpr since C++20
180 basic_string& operator+=(value_type c);180 basic_string& operator+=(value_type c); // constexpr since C++20
181 basic_string& operator+=(initializer_list<value_type>);181 basic_string& operator+=(initializer_list<value_type>); // constexpr since C++20
182182
183 basic_string& append(const basic_string& str);183 basic_string& append(const basic_string& str); // constexpr since C++20
184 template <class T>184 template <class T>
185 basic_string& append(const T& t); // C++17185 basic_string& append(const T& t); // C++17, constexpr since C++20
186 basic_string& append(const basic_string& str, size_type pos, size_type n=npos); //C++14186 basic_string& append(const basic_string& str, size_type pos, size_type n=npos); // C++14, constexpr since C++20
187 template <class T>187 template <class T>
188 basic_string& append(const T& t, size_type pos, size_type n=npos); // C++17188 basic_string& append(const T& t, size_type pos, size_type n=npos); // C++17, constexpr since C++20
189 basic_string& append(const value_type* s, size_type n);189 basic_string& append(const value_type* s, size_type n); // constexpr since C++20
190 basic_string& append(const value_type* s);190 basic_string& append(const value_type* s); // constexpr since C++20
191 basic_string& append(size_type n, value_type c);191 basic_string& append(size_type n, value_type c); // constexpr since C++20
192 template<class InputIterator>192 template<class InputIterator>
193 basic_string& append(InputIterator first, InputIterator last);193 basic_string& append(InputIterator first, InputIterator last); // constexpr since C++20
194 basic_string& append(initializer_list<value_type>);194 basic_string& append(initializer_list<value_type>); // constexpr since C++20
195195
196 void push_back(value_type c);196 void push_back(value_type c); // constexpr since C++20
197 void pop_back();197 void pop_back(); // constexpr since C++20
198 reference front();198 reference front(); // constexpr since C++20
199 const_reference front() const;199 const_reference front() const; // constexpr since C++20
200 reference back();200 reference back(); // constexpr since C++20
201 const_reference back() const;201 const_reference back() const; // constexpr since C++20
202202
203 basic_string& assign(const basic_string& str);203 basic_string& assign(const basic_string& str); // constexpr since C++20
204 template <class T>204 template <class T>
205 basic_string& assign(const T& t); // C++17205 basic_string& assign(const T& t); // C++17, constexpr since C++20
206 basic_string& assign(basic_string&& str);206 basic_string& assign(basic_string&& str); // constexpr since C++20
207 basic_string& assign(const basic_string& str, size_type pos, size_type n=npos); // C++14207 basic_string& assign(const basic_string& str, size_type pos, size_type n=npos); // C++14, constexpr since C++20
208 template <class T>208 template <class T>
209 basic_string& assign(const T& t, size_type pos, size_type n=npos); // C++17209 basic_string& assign(const T& t, size_type pos, size_type n=npos); // C++17, constexpr since C++20
210 basic_string& assign(const value_type* s, size_type n);210 basic_string& assign(const value_type* s, size_type n); // constexpr since C++20
211 basic_string& assign(const value_type* s);211 basic_string& assign(const value_type* s); // constexpr since C++20
212 basic_string& assign(size_type n, value_type c);212 basic_string& assign(size_type n, value_type c); // constexpr since C++20
213 template<class InputIterator>213 template<class InputIterator>
214 basic_string& assign(InputIterator first, InputIterator last);214 basic_string& assign(InputIterator first, InputIterator last); // constexpr since C++20
215 basic_string& assign(initializer_list<value_type>);215 basic_string& assign(initializer_list<value_type>); // constexpr since C++20
216216
217 basic_string& insert(size_type pos1, const basic_string& str);217 basic_string& insert(size_type pos1, const basic_string& str); // constexpr since C++20
218 template <class T>218 template <class T>
219 basic_string& insert(size_type pos1, const T& t);219 basic_string& insert(size_type pos1, const T& t); // constexpr since C++20
220 basic_string& insert(size_type pos1, const basic_string& str,220 basic_string& insert(size_type pos1, const basic_string& str,
221 size_type pos2, size_type n);221 size_type pos2, size_type n); // constexpr since C++20
222 template <class T>222 template <class T>
223 basic_string& insert(size_type pos1, const T& t, size_type pos2, size_type n); // C++17223 basic_string& insert(size_type pos1, const T& t, size_type pos2, size_type n); // C++17, constexpr since C++20
224 basic_string& insert(size_type pos, const value_type* s, size_type n=npos); //C++14224 basic_string& insert(size_type pos, const value_type* s, size_type n=npos); // C++14, constexpr since C++20
225 basic_string& insert(size_type pos, const value_type* s);225 basic_string& insert(size_type pos, const value_type* s); // constexpr since C++20
226 basic_string& insert(size_type pos, size_type n, value_type c);226 basic_string& insert(size_type pos, size_type n, value_type c); // constexpr since C++20
227 iterator insert(const_iterator p, value_type c);227 iterator insert(const_iterator p, value_type c); // constexpr since C++20
228 iterator insert(const_iterator p, size_type n, value_type c);228 iterator insert(const_iterator p, size_type n, value_type c); // constexpr since C++20
229 template<class InputIterator>229 template<class InputIterator>
230 iterator insert(const_iterator p, InputIterator first, InputIterator last);230 iterator insert(const_iterator p, InputIterator first, InputIterator last); // constexpr since C++20
231 iterator insert(const_iterator p, initializer_list<value_type>);231 iterator insert(const_iterator p, initializer_list<value_type>); // constexpr since C++20
232232
233 basic_string& erase(size_type pos = 0, size_type n = npos);233 basic_string& erase(size_type pos = 0, size_type n = npos); // constexpr since C++20
234 iterator erase(const_iterator position);234 iterator erase(const_iterator position); // constexpr since C++20
235 iterator erase(const_iterator first, const_iterator last);235 iterator erase(const_iterator first, const_iterator last); // constexpr since C++20
236236
237 basic_string& replace(size_type pos1, size_type n1, const basic_string& str);237 basic_string& replace(size_type pos1, size_type n1, const basic_string& str); // constexpr since C++20
238 template <class T>238 template <class T>
239 basic_string& replace(size_type pos1, size_type n1, const T& t); // C++17239 basic_string& replace(size_type pos1, size_type n1, const T& t); // C++17, constexpr since C++20
240 basic_string& replace(size_type pos1, size_type n1, const basic_string& str,240 basic_string& replace(size_type pos1, size_type n1, const basic_string& str,
241 size_type pos2, size_type n2=npos); // C++14241 size_type pos2, size_type n2=npos); // C++14, constexpr since C++20
242 template <class T>242 template <class T>
243 basic_string& replace(size_type pos1, size_type n1, const T& t,243 basic_string& replace(size_type pos1, size_type n1, const T& t,
244 size_type pos2, size_type n); // C++17244 size_type pos2, size_type n); // C++17, constexpr since C++20
245 basic_string& replace(size_type pos, size_type n1, const value_type* s, size_type n2);245 basic_string& replace(size_type pos, size_type n1, const value_type* s, size_type n2); // constexpr since C++20
246 basic_string& replace(size_type pos, size_type n1, const value_type* s);246 basic_string& replace(size_type pos, size_type n1, const value_type* s); // constexpr since C++20
247 basic_string& replace(size_type pos, size_type n1, size_type n2, value_type c);247 basic_string& replace(size_type pos, size_type n1, size_type n2, value_type c); // constexpr since C++20
248 basic_string& replace(const_iterator i1, const_iterator i2, const basic_string& str);248 basic_string& replace(const_iterator i1, const_iterator i2, const basic_string& str); // constexpr since C++20
249 template <class T>249 template <class T>
250 basic_string& replace(const_iterator i1, const_iterator i2, const T& t); // C++17250 basic_string& replace(const_iterator i1, const_iterator i2, const T& t); // C++17, constexpr since C++20
251 basic_string& replace(const_iterator i1, const_iterator i2, const value_type* s, size_type n);251 basic_string& replace(const_iterator i1, const_iterator i2, const value_type* s, size_type n); // constexpr since C++20
252 basic_string& replace(const_iterator i1, const_iterator i2, const value_type* s);252 basic_string& replace(const_iterator i1, const_iterator i2, const value_type* s); // constexpr since C++20
253 basic_string& replace(const_iterator i1, const_iterator i2, size_type n, value_type c);253 basic_string& replace(const_iterator i1, const_iterator i2, size_type n, value_type c); // constexpr since C++20
254 template<class InputIterator>254 template<class InputIterator>
255 basic_string& replace(const_iterator i1, const_iterator i2, InputIterator j1, InputIterator j2);255 basic_string& replace(const_iterator i1, const_iterator i2, InputIterator j1, InputIterator j2); // constexpr since C++20
256 basic_string& replace(const_iterator i1, const_iterator i2, initializer_list<value_type>);256 basic_string& replace(const_iterator i1, const_iterator i2, initializer_list<value_type>); // constexpr since C++20
257257
258 size_type copy(value_type* s, size_type n, size_type pos = 0) const;258 size_type copy(value_type* s, size_type n, size_type pos = 0) const; // constexpr since C++20
259 basic_string substr(size_type pos = 0, size_type n = npos) const;259 basic_string substr(size_type pos = 0, size_type n = npos) const; // constexpr since C++20
260260
261 void swap(basic_string& str)261 void swap(basic_string& str)
262 noexcept(allocator_traits<allocator_type>::propagate_on_container_swap::value ||262 noexcept(allocator_traits<allocator_type>::propagate_on_container_swap::value ||
263 allocator_traits<allocator_type>::is_always_equal::value); // C++17263 allocator_traits<allocator_type>::is_always_equal::value); // C++17, constexpr since C++20
264264
265 const value_type* c_str() const noexcept;265 const value_type* c_str() const noexcept; // constexpr since C++20
266 const value_type* data() const noexcept;266 const value_type* data() const noexcept; // constexpr since C++20
267 value_type* data() noexcept; // C++17267 value_type* data() noexcept; // C++17, constexpr since C++20
268268
269 allocator_type get_allocator() const noexcept;269 allocator_type get_allocator() const noexcept; // constexpr since C++20
270270
271 size_type find(const basic_string& str, size_type pos = 0) const noexcept;271 size_type find(const basic_string& str, size_type pos = 0) const noexcept; // constexpr since C++20
272 template <class T>272 template <class T>
273 size_type find(const T& t, size_type pos = 0) const noexcept; // C++17, noexcept as an extension273 size_type find(const T& t, size_type pos = 0) const noexcept; // C++17, noexcept as an extension, constexpr since C++20
274 size_type find(const value_type* s, size_type pos, size_type n) const noexcept;274 size_type find(const value_type* s, size_type pos, size_type n) const noexcept; // constexpr since C++20
275 size_type find(const value_type* s, size_type pos = 0) const noexcept;275 size_type find(const value_type* s, size_type pos = 0) const noexcept; // constexpr since C++20
276 size_type find(value_type c, size_type pos = 0) const noexcept;276 size_type find(value_type c, size_type pos = 0) const noexcept; // constexpr since C++20
277277
278 size_type rfind(const basic_string& str, size_type pos = npos) const noexcept;278 size_type rfind(const basic_string& str, size_type pos = npos) const noexcept; // constexpr since C++20
279 template <class T>279 template <class T>
280 size_type rfind(const T& t, size_type pos = npos) const noexcept; // C++17, noexcept as an extension280 size_type rfind(const T& t, size_type pos = npos) const noexcept; // C++17, noexcept as an extension, constexpr since C++20
281 size_type rfind(const value_type* s, size_type pos, size_type n) const noexcept;281 size_type rfind(const value_type* s, size_type pos, size_type n) const noexcept; // constexpr since C++20
282 size_type rfind(const value_type* s, size_type pos = npos) const noexcept;282 size_type rfind(const value_type* s, size_type pos = npos) const noexcept; // constexpr since C++20
283 size_type rfind(value_type c, size_type pos = npos) const noexcept;283 size_type rfind(value_type c, size_type pos = npos) const noexcept; // constexpr since C++20
284284
285 size_type find_first_of(const basic_string& str, size_type pos = 0) const noexcept;285 size_type find_first_of(const basic_string& str, size_type pos = 0) const noexcept; // constexpr since C++20
286 template <class T>286 template <class T>
287 size_type find_first_of(const T& t, size_type pos = 0) const noexcept; // C++17, noexcept as an extension287 size_type find_first_of(const T& t, size_type pos = 0) const noexcept; // C++17, noexcept as an extension, constexpr since C++20
288 size_type find_first_of(const value_type* s, size_type pos, size_type n) const noexcept;288 size_type find_first_of(const value_type* s, size_type pos, size_type n) const noexcept; // constexpr since C++20
289 size_type find_first_of(const value_type* s, size_type pos = 0) const noexcept;289 size_type find_first_of(const value_type* s, size_type pos = 0) const noexcept; // constexpr since C++20
290 size_type find_first_of(value_type c, size_type pos = 0) const noexcept;290 size_type find_first_of(value_type c, size_type pos = 0) const noexcept; // constexpr since C++20
291291
292 size_type find_last_of(const basic_string& str, size_type pos = npos) const noexcept;292 size_type find_last_of(const basic_string& str, size_type pos = npos) const noexcept; // constexpr since C++20
293 template <class T>293 template <class T>
294 size_type find_last_of(const T& t, size_type pos = npos) const noexcept noexcept; // C++17, noexcept as an extension294 size_type find_last_of(const T& t, size_type pos = npos) const noexcept noexcept; // C++17, noexcept as an extension, constexpr since C++20
295 size_type find_last_of(const value_type* s, size_type pos, size_type n) const noexcept;295 size_type find_last_of(const value_type* s, size_type pos, size_type n) const noexcept; // constexpr since C++20
296 size_type find_last_of(const value_type* s, size_type pos = npos) const noexcept;296 size_type find_last_of(const value_type* s, size_type pos = npos) const noexcept; // constexpr since C++20
297 size_type find_last_of(value_type c, size_type pos = npos) const noexcept;297 size_type find_last_of(value_type c, size_type pos = npos) const noexcept; // constexpr since C++20
298298
299 size_type find_first_not_of(const basic_string& str, size_type pos = 0) const noexcept;299 size_type find_first_not_of(const basic_string& str, size_type pos = 0) const noexcept; // constexpr since C++20
300 template <class T>300 template <class T>
301 size_type find_first_not_of(const T& t, size_type pos = 0) const noexcept; // C++17, noexcept as an extension301 size_type find_first_not_of(const T& t, size_type pos = 0) const noexcept; // C++17, noexcept as an extension, constexpr since C++20
302 size_type find_first_not_of(const value_type* s, size_type pos, size_type n) const noexcept;302 size_type find_first_not_of(const value_type* s, size_type pos, size_type n) const noexcept; // constexpr since C++20
303 size_type find_first_not_of(const value_type* s, size_type pos = 0) const noexcept;303 size_type find_first_not_of(const value_type* s, size_type pos = 0) const noexcept; // constexpr since C++20
304 size_type find_first_not_of(value_type c, size_type pos = 0) const noexcept;304 size_type find_first_not_of(value_type c, size_type pos = 0) const noexcept; // constexpr since C++20
305305
306 size_type find_last_not_of(const basic_string& str, size_type pos = npos) const noexcept;306 size_type find_last_not_of(const basic_string& str, size_type pos = npos) const noexcept; // constexpr since C++20
307 template <class T>307 template <class T>
308 size_type find_last_not_of(const T& t, size_type pos = npos) const noexcept; // C++17, noexcept as an extension308 size_type find_last_not_of(const T& t, size_type pos = npos) const noexcept; // C++17, noexcept as an extension, constexpr since C++20
309 size_type find_last_not_of(const value_type* s, size_type pos, size_type n) const noexcept;309 size_type find_last_not_of(const value_type* s, size_type pos, size_type n) const noexcept; // constexpr since C++20
310 size_type find_last_not_of(const value_type* s, size_type pos = npos) const noexcept;310 size_type find_last_not_of(const value_type* s, size_type pos = npos) const noexcept; // constexpr since C++20
311 size_type find_last_not_of(value_type c, size_type pos = npos) const noexcept;311 size_type find_last_not_of(value_type c, size_type pos = npos) const noexcept; // constexpr since C++20
312312
313 int compare(const basic_string& str) const noexcept;313 int compare(const basic_string& str) const noexcept; // constexpr since C++20
314 template <class T>314 template <class T>
315 int compare(const T& t) const noexcept; // C++17, noexcept as an extension315 int compare(const T& t) const noexcept; // C++17, noexcept as an extension, constexpr since C++20
316 int compare(size_type pos1, size_type n1, const basic_string& str) const;316 int compare(size_type pos1, size_type n1, const basic_string& str) const; // constexpr since C++20
317 template <class T>317 template <class T>
318 int compare(size_type pos1, size_type n1, const T& t) const; // C++17318 int compare(size_type pos1, size_type n1, const T& t) const; // C++17, constexpr since C++20
319 int compare(size_type pos1, size_type n1, const basic_string& str,319 int compare(size_type pos1, size_type n1, const basic_string& str,
320 size_type pos2, size_type n2=npos) const; // C++14320 size_type pos2, size_type n2=npos) const; // C++14, constexpr since C++20
321 template <class T>321 template <class T>
322 int compare(size_type pos1, size_type n1, const T& t,322 int compare(size_type pos1, size_type n1, const T& t,
323 size_type pos2, size_type n2=npos) const; // C++17323 size_type pos2, size_type n2=npos) const; // C++17, constexpr since C++20
324 int compare(const value_type* s) const noexcept;324 int compare(const value_type* s) const noexcept; // constexpr since C++20
325 int compare(size_type pos1, size_type n1, const value_type* s) const;325 int compare(size_type pos1, size_type n1, const value_type* s) const; // constexpr since C++20
326 int compare(size_type pos1, size_type n1, const value_type* s, size_type n2) const;326 int compare(size_type pos1, size_type n1, const value_type* s, size_type n2) const; // constexpr since C++20
327327
328 bool starts_with(basic_string_view<charT, traits> sv) const noexcept; // C++20328 constexpr bool starts_with(basic_string_view<charT, traits> sv) const noexcept; // C++20
329 bool starts_with(charT c) const noexcept; // C++20329 constexpr bool starts_with(charT c) const noexcept; // C++20
330 bool starts_with(const charT* s) const; // C++20330 constexpr bool starts_with(const charT* s) const; // C++20
331 bool ends_with(basic_string_view<charT, traits> sv) const noexcept; // C++20331 constexpr bool ends_with(basic_string_view<charT, traits> sv) const noexcept; // C++20
332 bool ends_with(charT c) const noexcept; // C++20332 constexpr bool ends_with(charT c) const noexcept; // C++20
333 bool ends_with(const charT* s) const; // C++20333 constexpr bool ends_with(const charT* s) const; // C++20
334334
335 constexpr bool contains(basic_string_view<charT, traits> sv) const noexcept; // C++2b335 constexpr bool contains(basic_string_view<charT, traits> sv) const noexcept; // C++2b
336 constexpr bool contains(charT c) const noexcept; // C++2b336 constexpr bool contains(charT c) const noexcept; // C++2b
337 constexpr bool contains(const charT* s) const; // C++2b337 constexpr bool contains(const charT* s) const; // C++2b
338
339 bool __invariants() const;
340};338};
341339
342template<class InputIterator,340template<class InputIterator,
...@@ -349,88 +347,88 @@ basic_string(InputIterator, InputIterator, Allocator = Allocator())...@@ -349,88 +347,88 @@ basic_string(InputIterator, InputIterator, Allocator = Allocator())
349template<class charT, class traits, class Allocator>347template<class charT, class traits, class Allocator>
350basic_string<charT, traits, Allocator>348basic_string<charT, traits, Allocator>
351operator+(const basic_string<charT, traits, Allocator>& lhs,349operator+(const basic_string<charT, traits, Allocator>& lhs,
352 const basic_string<charT, traits, Allocator>& rhs);350 const basic_string<charT, traits, Allocator>& rhs); // constexpr since C++20
353351
354template<class charT, class traits, class Allocator>352template<class charT, class traits, class Allocator>
355basic_string<charT, traits, Allocator>353basic_string<charT, traits, Allocator>
356operator+(const charT* lhs , const basic_string<charT,traits,Allocator>&rhs);354operator+(const charT* lhs , const basic_string<charT,traits,Allocator>&rhs); // constexpr since C++20
357355
358template<class charT, class traits, class Allocator>356template<class charT, class traits, class Allocator>
359basic_string<charT, traits, Allocator>357basic_string<charT, traits, Allocator>
360operator+(charT lhs, const basic_string<charT,traits,Allocator>& rhs);358operator+(charT lhs, const basic_string<charT,traits,Allocator>& rhs); // constexpr since C++20
361359
362template<class charT, class traits, class Allocator>360template<class charT, class traits, class Allocator>
363basic_string<charT, traits, Allocator>361basic_string<charT, traits, Allocator>
364operator+(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs);362operator+(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs); // constexpr since C++20
365363
366template<class charT, class traits, class Allocator>364template<class charT, class traits, class Allocator>
367basic_string<charT, traits, Allocator>365basic_string<charT, traits, Allocator>
368operator+(const basic_string<charT, traits, Allocator>& lhs, charT rhs);366operator+(const basic_string<charT, traits, Allocator>& lhs, charT rhs); // constexpr since C++20
369367
370template<class charT, class traits, class Allocator>368template<class charT, class traits, class Allocator>
371bool operator==(const basic_string<charT, traits, Allocator>& lhs,369bool operator==(const basic_string<charT, traits, Allocator>& lhs,
372 const basic_string<charT, traits, Allocator>& rhs) noexcept;370 const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20
373371
374template<class charT, class traits, class Allocator>372template<class charT, class traits, class Allocator>
375bool operator==(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept;373bool operator==(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20
376374
377template<class charT, class traits, class Allocator>375template<class charT, class traits, class Allocator>
378bool operator==(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs) noexcept;376bool operator==(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs) noexcept; // constexpr since C++20
379377
380template<class charT, class traits, class Allocator>378template<class charT, class traits, class Allocator>
381bool operator!=(const basic_string<charT,traits,Allocator>& lhs,379bool operator!=(const basic_string<charT,traits,Allocator>& lhs,
382 const basic_string<charT, traits, Allocator>& rhs) noexcept;380 const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20
383381
384template<class charT, class traits, class Allocator>382template<class charT, class traits, class Allocator>
385bool operator!=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept;383bool operator!=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20
386384
387template<class charT, class traits, class Allocator>385template<class charT, class traits, class Allocator>
388bool operator!=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept;386bool operator!=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; // constexpr since C++20
389387
390template<class charT, class traits, class Allocator>388template<class charT, class traits, class Allocator>
391bool operator< (const basic_string<charT, traits, Allocator>& lhs,389bool operator< (const basic_string<charT, traits, Allocator>& lhs,
392 const basic_string<charT, traits, Allocator>& rhs) noexcept;390 const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20
393391
394template<class charT, class traits, class Allocator>392template<class charT, class traits, class Allocator>
395bool operator< (const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept;393bool operator< (const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; // constexpr since C++20
396394
397template<class charT, class traits, class Allocator>395template<class charT, class traits, class Allocator>
398bool operator< (const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept;396bool operator< (const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20
399397
400template<class charT, class traits, class Allocator>398template<class charT, class traits, class Allocator>
401bool operator> (const basic_string<charT, traits, Allocator>& lhs,399bool operator> (const basic_string<charT, traits, Allocator>& lhs,
402 const basic_string<charT, traits, Allocator>& rhs) noexcept;400 const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20
403401
404template<class charT, class traits, class Allocator>402template<class charT, class traits, class Allocator>
405bool operator> (const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept;403bool operator> (const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; // constexpr since C++20
406404
407template<class charT, class traits, class Allocator>405template<class charT, class traits, class Allocator>
408bool operator> (const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept;406bool operator> (const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20
409407
410template<class charT, class traits, class Allocator>408template<class charT, class traits, class Allocator>
411bool operator<=(const basic_string<charT, traits, Allocator>& lhs,409bool operator<=(const basic_string<charT, traits, Allocator>& lhs,
412 const basic_string<charT, traits, Allocator>& rhs) noexcept;410 const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20
413411
414template<class charT, class traits, class Allocator>412template<class charT, class traits, class Allocator>
415bool operator<=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept;413bool operator<=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; // constexpr since C++20
416414
417template<class charT, class traits, class Allocator>415template<class charT, class traits, class Allocator>
418bool operator<=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept;416bool operator<=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20
419417
420template<class charT, class traits, class Allocator>418template<class charT, class traits, class Allocator>
421bool operator>=(const basic_string<charT, traits, Allocator>& lhs,419bool operator>=(const basic_string<charT, traits, Allocator>& lhs,
422 const basic_string<charT, traits, Allocator>& rhs) noexcept;420 const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20
423421
424template<class charT, class traits, class Allocator>422template<class charT, class traits, class Allocator>
425bool operator>=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept;423bool operator>=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; // constexpr since C++20
426424
427template<class charT, class traits, class Allocator>425template<class charT, class traits, class Allocator>
428bool operator>=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept;426bool operator>=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20
429427
430template<class charT, class traits, class Allocator>428template<class charT, class traits, class Allocator>
431void swap(basic_string<charT, traits, Allocator>& lhs,429void swap(basic_string<charT, traits, Allocator>& lhs,
432 basic_string<charT, traits, Allocator>& rhs)430 basic_string<charT, traits, Allocator>& rhs)
433 noexcept(noexcept(lhs.swap(rhs)));431 noexcept(noexcept(lhs.swap(rhs))); // constexpr since C++20
434432
435template<class charT, class traits, class Allocator>433template<class charT, class traits, class Allocator>
436basic_istream<charT, traits>&434basic_istream<charT, traits>&
...@@ -508,45 +506,81 @@ template <> struct hash<u16string>;...@@ -508,45 +506,81 @@ template <> struct hash<u16string>;
508template <> struct hash<u32string>;506template <> struct hash<u32string>;
509template <> struct hash<wstring>;507template <> struct hash<wstring>;
510508
511basic_string<char> operator "" s( const char *str, size_t len ); // C++14509basic_string<char> operator "" s( const char *str, size_t len ); // C++14, constexpr since C++20
512basic_string<wchar_t> operator "" s( const wchar_t *str, size_t len ); // C++14510basic_string<wchar_t> operator "" s( const wchar_t *str, size_t len ); // C++14, constexpr since C++20
513basic_string<char8_t> operator "" s( const char8_t *str, size_t len ); // C++20511constexpr basic_string<char8_t> operator "" s( const char8_t *str, size_t len ); // C++20
514basic_string<char16_t> operator "" s( const char16_t *str, size_t len ); // C++14512basic_string<char16_t> operator "" s( const char16_t *str, size_t len ); // C++14, constexpr since C++20
515basic_string<char32_t> operator "" s( const char32_t *str, size_t len ); // C++14513basic_string<char32_t> operator "" s( const char32_t *str, size_t len ); // C++14, constexpr since C++20
516514
517} // std515} // std
518516
519*/517*/
520518
519#include <__algorithm/max.h>
520#include <__algorithm/min.h>
521#include <__algorithm/remove.h>
522#include <__algorithm/remove_if.h>
523#include <__assert> // all public C++ headers provide the assertion handler
521#include <__config>524#include <__config>
522#include <__debug>525#include <__debug>
523#include <__functional_base>526#include <__format/enable_insertable.h>
527#include <__functional/hash.h>
528#include <__functional/unary_function.h>
529#include <__ios/fpos.h>
530#include <__iterator/distance.h>
531#include <__iterator/iterator_traits.h>
532#include <__iterator/reverse_iterator.h>
524#include <__iterator/wrap_iter.h>533#include <__iterator/wrap_iter.h>
525#include <algorithm>534#include <__memory/allocate_at_least.h>
526#include <compare>535#include <__memory/swap_allocator.h>
536#include <__string/char_traits.h>
537#include <__string/extern_template_lists.h>
538#include <__utility/auto_cast.h>
539#include <__utility/move.h>
540#include <__utility/swap.h>
541#include <__utility/unreachable.h>
542#include <climits>
543#include <cstdint>
527#include <cstdio> // EOF544#include <cstdio> // EOF
528#include <cstdlib>545#include <cstdlib>
529#include <cstring>546#include <cstring>
530#include <initializer_list>
531#include <iosfwd>547#include <iosfwd>
532#include <iterator>548#include <limits>
533#include <memory>549#include <memory>
534#include <stdexcept>550#include <stdexcept>
535#include <string_view>551#include <string_view>
536#include <type_traits>552#include <type_traits>
537#include <utility>
538#include <version>553#include <version>
539554
540#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS555#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
541# include <cwchar>556# include <cwchar>
542#endif557#endif
543558
544#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS559#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
545# include <cstdint>560# include <algorithm>
561# include <functional>
562# include <iterator>
563# include <new>
564# include <typeinfo>
565# include <utility>
566# include <vector>
546#endif567#endif
547568
569// standard-mandated includes
570
571// [iterator.range]
572#include <__iterator/access.h>
573#include <__iterator/data.h>
574#include <__iterator/empty.h>
575#include <__iterator/reverse_access.h>
576#include <__iterator/size.h>
577
578// [string.syn]
579#include <compare>
580#include <initializer_list>
581
548#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)582#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
549#pragma GCC system_header583# pragma GCC system_header
550#endif584#endif
551585
552_LIBCPP_PUSH_MACROS586_LIBCPP_PUSH_MACROS
...@@ -555,68 +589,35 @@ _LIBCPP_PUSH_MACROS...@@ -555,68 +589,35 @@ _LIBCPP_PUSH_MACROS
555589
556_LIBCPP_BEGIN_NAMESPACE_STD590_LIBCPP_BEGIN_NAMESPACE_STD
557591
558// fpos
559
560template <class _StateT>
561class _LIBCPP_TEMPLATE_VIS fpos
562{
563private:
564 _StateT __st_;
565 streamoff __off_;
566public:
567 _LIBCPP_INLINE_VISIBILITY fpos(streamoff __off = streamoff()) : __st_(), __off_(__off) {}
568
569 _LIBCPP_INLINE_VISIBILITY operator streamoff() const {return __off_;}
570
571 _LIBCPP_INLINE_VISIBILITY _StateT state() const {return __st_;}
572 _LIBCPP_INLINE_VISIBILITY void state(_StateT __st) {__st_ = __st;}
573
574 _LIBCPP_INLINE_VISIBILITY fpos& operator+=(streamoff __off) {__off_ += __off; return *this;}
575 _LIBCPP_INLINE_VISIBILITY fpos operator+ (streamoff __off) const {fpos __t(*this); __t += __off; return __t;}
576 _LIBCPP_INLINE_VISIBILITY fpos& operator-=(streamoff __off) {__off_ -= __off; return *this;}
577 _LIBCPP_INLINE_VISIBILITY fpos operator- (streamoff __off) const {fpos __t(*this); __t -= __off; return __t;}
578};
579
580template <class _StateT>
581inline _LIBCPP_INLINE_VISIBILITY
582streamoff operator-(const fpos<_StateT>& __x, const fpos<_StateT>& __y)
583 {return streamoff(__x) - streamoff(__y);}
584
585template <class _StateT>
586inline _LIBCPP_INLINE_VISIBILITY
587bool operator==(const fpos<_StateT>& __x, const fpos<_StateT>& __y)
588 {return streamoff(__x) == streamoff(__y);}
589
590template <class _StateT>
591inline _LIBCPP_INLINE_VISIBILITY
592bool operator!=(const fpos<_StateT>& __x, const fpos<_StateT>& __y)
593 {return streamoff(__x) != streamoff(__y);}
594
595// basic_string592// basic_string
596593
597template<class _CharT, class _Traits, class _Allocator>594template<class _CharT, class _Traits, class _Allocator>
598basic_string<_CharT, _Traits, _Allocator>595basic_string<_CharT, _Traits, _Allocator>
596_LIBCPP_CONSTEXPR_AFTER_CXX17
599operator+(const basic_string<_CharT, _Traits, _Allocator>& __x,597operator+(const basic_string<_CharT, _Traits, _Allocator>& __x,
600 const basic_string<_CharT, _Traits, _Allocator>& __y);598 const basic_string<_CharT, _Traits, _Allocator>& __y);
601599
602template<class _CharT, class _Traits, class _Allocator>600template<class _CharT, class _Traits, class _Allocator>
601_LIBCPP_CONSTEXPR_AFTER_CXX17
603basic_string<_CharT, _Traits, _Allocator>602basic_string<_CharT, _Traits, _Allocator>
604operator+(const _CharT* __x, const basic_string<_CharT,_Traits,_Allocator>& __y);603operator+(const _CharT* __x, const basic_string<_CharT,_Traits,_Allocator>& __y);
605604
606template<class _CharT, class _Traits, class _Allocator>605template<class _CharT, class _Traits, class _Allocator>
606_LIBCPP_CONSTEXPR_AFTER_CXX17
607basic_string<_CharT, _Traits, _Allocator>607basic_string<_CharT, _Traits, _Allocator>
608operator+(_CharT __x, const basic_string<_CharT,_Traits,_Allocator>& __y);608operator+(_CharT __x, const basic_string<_CharT,_Traits,_Allocator>& __y);
609609
610template<class _CharT, class _Traits, class _Allocator>610template<class _CharT, class _Traits, class _Allocator>
611inline _LIBCPP_INLINE_VISIBILITY611inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
612basic_string<_CharT, _Traits, _Allocator>612basic_string<_CharT, _Traits, _Allocator>
613operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, const _CharT* __y);613operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, const _CharT* __y);
614614
615template<class _CharT, class _Traits, class _Allocator>615template<class _CharT, class _Traits, class _Allocator>
616_LIBCPP_CONSTEXPR_AFTER_CXX17
616basic_string<_CharT, _Traits, _Allocator>617basic_string<_CharT, _Traits, _Allocator>
617operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, _CharT __y);618operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, _CharT __y);
618619
619_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS string operator+<char, char_traits<char>, allocator<char> >(char const*, string const&))620extern template _LIBCPP_FUNC_VIS string operator+<char, char_traits<char>, allocator<char> >(char const*, string const&);
620621
621template <class _Iter>622template <class _Iter>
622struct __string_is_trivial_iterator : public false_type {};623struct __string_is_trivial_iterator : public false_type {};
...@@ -635,29 +636,13 @@ struct __can_be_converted_to_string_view : public _BoolConstant<...@@ -635,29 +636,13 @@ struct __can_be_converted_to_string_view : public _BoolConstant<
635 !is_convertible<const _Tp&, const _CharT*>::value636 !is_convertible<const _Tp&, const _CharT*>::value
636 > {};637 > {};
637638
638#ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
639
640template <class _CharT, size_t = sizeof(_CharT)>
641struct __padding
642{
643 unsigned char __xx[sizeof(_CharT)-1];
644};
645
646template <class _CharT>
647struct __padding<_CharT, 1>
648{
649};
650
651#endif // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
652
653#ifndef _LIBCPP_HAS_NO_CHAR8_T639#ifndef _LIBCPP_HAS_NO_CHAR8_T
654typedef basic_string<char8_t> u8string;640typedef basic_string<char8_t> u8string;
655#endif641#endif
656
657#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
658typedef basic_string<char16_t> u16string;642typedef basic_string<char16_t> u16string;
659typedef basic_string<char32_t> u32string;643typedef basic_string<char32_t> u32string;
660#endif644
645struct __uninitialized_size_tag {};
661646
662template<class _CharT, class _Traits, class _Allocator>647template<class _CharT, class _Traits, class _Allocator>
663class648class
...@@ -665,10 +650,8 @@ class...@@ -665,10 +650,8 @@ class
665#ifndef _LIBCPP_HAS_NO_CHAR8_T650#ifndef _LIBCPP_HAS_NO_CHAR8_T
666 _LIBCPP_PREFERRED_NAME(u8string)651 _LIBCPP_PREFERRED_NAME(u8string)
667#endif652#endif
668#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
669 _LIBCPP_PREFERRED_NAME(u16string)653 _LIBCPP_PREFERRED_NAME(u16string)
670 _LIBCPP_PREFERRED_NAME(u32string)654 _LIBCPP_PREFERRED_NAME(u32string)
671#endif
672 basic_string655 basic_string
673{656{
674public:657public:
...@@ -695,10 +678,11 @@ public:...@@ -695,10 +678,11 @@ public:
695678
696 typedef __wrap_iter<pointer> iterator;679 typedef __wrap_iter<pointer> iterator;
697 typedef __wrap_iter<const_pointer> const_iterator;680 typedef __wrap_iter<const_pointer> const_iterator;
698 typedef _VSTD::reverse_iterator<iterator> reverse_iterator;681 typedef std::reverse_iterator<iterator> reverse_iterator;
699 typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;682 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
700683
701private:684private:
685 static_assert(CHAR_BIT == 8, "This implementation assumes that one byte contains 8 bits");
702686
703#ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT687#ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
704688
...@@ -706,62 +690,79 @@ private:...@@ -706,62 +690,79 @@ private:
706 {690 {
707 pointer __data_;691 pointer __data_;
708 size_type __size_;692 size_type __size_;
709 size_type __cap_;693 size_type __cap_ : sizeof(size_type) * CHAR_BIT - 1;
694 size_type __is_long_ : 1;
710 };695 };
711696
712#ifdef _LIBCPP_BIG_ENDIAN
713 static const size_type __short_mask = 0x01;
714 static const size_type __long_mask = 0x1ul;
715#else // _LIBCPP_BIG_ENDIAN
716 static const size_type __short_mask = 0x80;
717 static const size_type __long_mask = ~(size_type(~0) >> 1);
718#endif // _LIBCPP_BIG_ENDIAN
719
720 enum {__min_cap = (sizeof(__long) - 1)/sizeof(value_type) > 2 ?697 enum {__min_cap = (sizeof(__long) - 1)/sizeof(value_type) > 2 ?
721 (sizeof(__long) - 1)/sizeof(value_type) : 2};698 (sizeof(__long) - 1)/sizeof(value_type) : 2};
722699
723 struct __short700 struct __short
724 {701 {
725 value_type __data_[__min_cap];702 value_type __data_[__min_cap];
726 struct703 unsigned char __padding_[sizeof(value_type) - 1];
727 : __padding<value_type>704 unsigned char __size_ : 7;
728 {705 unsigned char __is_long_ : 1;
729 unsigned char __size_;
730 };
731 };706 };
732707
708// The __endian_factor is required because the field we use to store the size
709// has one fewer bit than it would if it were not a bitfield.
710//
711// If the LSB is used to store the short-flag in the short string representation,
712// we have to multiply the size by two when it is stored and divide it by two when
713// it is loaded to make sure that we always store an even number. In the long string
714// representation, we can ignore this because we can assume that we always allocate
715// an even amount of value_types.
716//
717// If the MSB is used for the short-flag, the max_size() is numeric_limits<size_type>::max() / 2.
718// This does not impact the short string representation, since we never need the MSB
719// for representing the size of a short string anyway.
720
721#ifdef _LIBCPP_BIG_ENDIAN
722 static const size_type __endian_factor = 2;
733#else723#else
724 static const size_type __endian_factor = 1;
725#endif
734726
727#else // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
728
729#ifdef _LIBCPP_BIG_ENDIAN
730 static const size_type __endian_factor = 1;
731#else
732 static const size_type __endian_factor = 2;
733#endif
734
735 // Attribute 'packed' is used to keep the layout compatible with the
736 // previous definition that did not use bit fields. This is because on
737 // some platforms bit fields have a default size rather than the actual
738 // size used, e.g., it is 4 bytes on AIX. See D128285 for details.
735 struct __long739 struct __long
736 {740 {
737 size_type __cap_;741 struct _LIBCPP_PACKED {
742 size_type __is_long_ : 1;
743 size_type __cap_ : sizeof(size_type) * CHAR_BIT - 1;
744 };
738 size_type __size_;745 size_type __size_;
739 pointer __data_;746 pointer __data_;
740 };747 };
741748
742#ifdef _LIBCPP_BIG_ENDIAN
743 static const size_type __short_mask = 0x80;
744 static const size_type __long_mask = ~(size_type(~0) >> 1);
745#else // _LIBCPP_BIG_ENDIAN
746 static const size_type __short_mask = 0x01;
747 static const size_type __long_mask = 0x1ul;
748#endif // _LIBCPP_BIG_ENDIAN
749
750 enum {__min_cap = (sizeof(__long) - 1)/sizeof(value_type) > 2 ?749 enum {__min_cap = (sizeof(__long) - 1)/sizeof(value_type) > 2 ?
751 (sizeof(__long) - 1)/sizeof(value_type) : 2};750 (sizeof(__long) - 1)/sizeof(value_type) : 2};
752751
753 struct __short752 struct __short
754 {753 {
755 union754 struct _LIBCPP_PACKED {
756 {755 unsigned char __is_long_ : 1;
757 unsigned char __size_;756 unsigned char __size_ : 7;
758 value_type __lx;
759 };757 };
758 char __padding_[sizeof(value_type) - 1];
760 value_type __data_[__min_cap];759 value_type __data_[__min_cap];
761 };760 };
762761
763#endif // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT762#endif // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
764763
764 static_assert(sizeof(__short) == (sizeof(value_type) * (__min_cap + 1)), "__short has an unexpected size.");
765
765 union __ulx{__long __lx; __short __lxx;};766 union __ulx{__long __lx; __short __lxx;};
766767
767 enum {__n_words = sizeof(__ulx) / sizeof(size_type)};768 enum {__n_words = sizeof(__ulx) / sizeof(size_type)};
...@@ -783,25 +784,47 @@ private:...@@ -783,25 +784,47 @@ private:
783784
784 __compressed_pair<__rep, allocator_type> __r_;785 __compressed_pair<__rep, allocator_type> __r_;
785786
787 // Construct a string with the given allocator and enough storage to hold `__size` characters, but
788 // don't initialize the characters. The contents of the string, including the null terminator, must be
789 // initialized separately.
790 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
791 explicit basic_string(__uninitialized_size_tag, size_type __size, const allocator_type& __a)
792 : __r_(__default_init_tag(), __a) {
793 if (__size > max_size())
794 __throw_length_error();
795 if (__fits_in_sso(__size)) {
796 __zero();
797 __set_short_size(__size);
798 } else {
799 auto __capacity = __recommend(__size) + 1;
800 auto __allocation = __alloc_traits::allocate(__alloc(), __capacity);
801 __begin_lifetime(__allocation, __capacity);
802 __set_long_cap(__capacity);
803 __set_long_pointer(__allocation);
804 __set_long_size(__size);
805 }
806 std::__debug_db_insert_c(this);
807 }
808
786public:809public:
787 _LIBCPP_TEMPLATE_DATA_VIS810 _LIBCPP_TEMPLATE_DATA_VIS
788 static const size_type npos = -1;811 static const size_type npos = -1;
789812
790 _LIBCPP_INLINE_VISIBILITY basic_string()813 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string()
791 _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);814 _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);
792815
793 _LIBCPP_INLINE_VISIBILITY explicit basic_string(const allocator_type& __a)816 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit basic_string(const allocator_type& __a)
794#if _LIBCPP_STD_VER <= 14817#if _LIBCPP_STD_VER <= 14
795 _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value);818 _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value);
796#else819#else
797 _NOEXCEPT;820 _NOEXCEPT;
798#endif821#endif
799822
800 basic_string(const basic_string& __str);823 _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string(const basic_string& __str);
801 basic_string(const basic_string& __str, const allocator_type& __a);824 _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string(const basic_string& __str, const allocator_type& __a);
802825
803#ifndef _LIBCPP_CXX03_LANG826#ifndef _LIBCPP_CXX03_LANG
804 _LIBCPP_INLINE_VISIBILITY827 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
805 basic_string(basic_string&& __str)828 basic_string(basic_string&& __str)
806#if _LIBCPP_STD_VER <= 14829#if _LIBCPP_STD_VER <= 14
807 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);830 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
...@@ -809,218 +832,221 @@ public:...@@ -809,218 +832,221 @@ public:
809 _NOEXCEPT;832 _NOEXCEPT;
810#endif833#endif
811834
812 _LIBCPP_INLINE_VISIBILITY835 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
813 basic_string(basic_string&& __str, const allocator_type& __a);836 basic_string(basic_string&& __str, const allocator_type& __a);
814#endif // _LIBCPP_CXX03_LANG837#endif // _LIBCPP_CXX03_LANG
815838
816 template <class = __enable_if_t<__is_allocator<_Allocator>::value, nullptr_t> >839 template <class = __enable_if_t<__is_allocator<_Allocator>::value, nullptr_t> >
817 _LIBCPP_INLINE_VISIBILITY840 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
818 basic_string(const _CharT* __s) : __r_(__default_init_tag(), __default_init_tag()) {841 basic_string(const _CharT* __s) : __r_(__default_init_tag(), __default_init_tag()) {
819 _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*) detected nullptr");842 _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*) detected nullptr");
820 __init(__s, traits_type::length(__s));843 __init(__s, traits_type::length(__s));
821 _VSTD::__debug_db_insert_c(this);844 std::__debug_db_insert_c(this);
822 }845 }
823846
824 template <class = __enable_if_t<__is_allocator<_Allocator>::value, nullptr_t> >847 template <class = __enable_if_t<__is_allocator<_Allocator>::value, nullptr_t> >
825 _LIBCPP_INLINE_VISIBILITY848 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
826 basic_string(const _CharT* __s, const _Allocator& __a);849 basic_string(const _CharT* __s, const _Allocator& __a);
827850
828#if _LIBCPP_STD_VER > 20851#if _LIBCPP_STD_VER > 20
829 basic_string(nullptr_t) = delete;852 basic_string(nullptr_t) = delete;
830#endif853#endif
831854
832 _LIBCPP_INLINE_VISIBILITY855 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
833 basic_string(const _CharT* __s, size_type __n);856 basic_string(const _CharT* __s, size_type __n);
834 _LIBCPP_INLINE_VISIBILITY857 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
835 basic_string(const _CharT* __s, size_type __n, const _Allocator& __a);858 basic_string(const _CharT* __s, size_type __n, const _Allocator& __a);
836 _LIBCPP_INLINE_VISIBILITY859 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
837 basic_string(size_type __n, _CharT __c);860 basic_string(size_type __n, _CharT __c);
838861
839 template <class = __enable_if_t<__is_allocator<_Allocator>::value, nullptr_t> >862 template <class = __enable_if_t<__is_allocator<_Allocator>::value, nullptr_t> >
840 _LIBCPP_INLINE_VISIBILITY863 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
841 basic_string(size_type __n, _CharT __c, const _Allocator& __a);864 basic_string(size_type __n, _CharT __c, const _Allocator& __a);
842865
866 _LIBCPP_CONSTEXPR_AFTER_CXX17
843 basic_string(const basic_string& __str, size_type __pos, size_type __n,867 basic_string(const basic_string& __str, size_type __pos, size_type __n,
844 const _Allocator& __a = _Allocator());868 const _Allocator& __a = _Allocator());
845 _LIBCPP_INLINE_VISIBILITY869 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
846 basic_string(const basic_string& __str, size_type __pos,870 basic_string(const basic_string& __str, size_type __pos,
847 const _Allocator& __a = _Allocator());871 const _Allocator& __a = _Allocator());
848872
849 template<class _Tp, class = __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value> >873 template<class _Tp, class = __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value> >
850 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS874 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
851 basic_string(const _Tp& __t, size_type __pos, size_type __n,875 basic_string(const _Tp& __t, size_type __pos, size_type __n,
852 const allocator_type& __a = allocator_type());876 const allocator_type& __a = allocator_type());
853877
854 template<class _Tp, class = __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&878 template<class _Tp, class = __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&
855 !__is_same_uncvref<_Tp, basic_string>::value> >879 !__is_same_uncvref<_Tp, basic_string>::value> >
856 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS880 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
857 explicit basic_string(const _Tp& __t);881 explicit basic_string(const _Tp& __t);
858882
859 template<class _Tp, class = __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value> >883 template<class _Tp, class = __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value> >
860 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS884 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
861 explicit basic_string(const _Tp& __t, const allocator_type& __a);885 explicit basic_string(const _Tp& __t, const allocator_type& __a);
862886
863 template<class _InputIterator, class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value> >887 template<class _InputIterator, class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value> >
864 _LIBCPP_INLINE_VISIBILITY888 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
865 basic_string(_InputIterator __first, _InputIterator __last);889 basic_string(_InputIterator __first, _InputIterator __last);
866 template<class _InputIterator, class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value> >890 template<class _InputIterator, class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value> >
867 _LIBCPP_INLINE_VISIBILITY891 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
868 basic_string(_InputIterator __first, _InputIterator __last, const allocator_type& __a);892 basic_string(_InputIterator __first, _InputIterator __last, const allocator_type& __a);
869#ifndef _LIBCPP_CXX03_LANG893#ifndef _LIBCPP_CXX03_LANG
870 _LIBCPP_INLINE_VISIBILITY894 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
871 basic_string(initializer_list<_CharT> __il);895 basic_string(initializer_list<_CharT> __il);
872 _LIBCPP_INLINE_VISIBILITY896 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
873 basic_string(initializer_list<_CharT> __il, const _Allocator& __a);897 basic_string(initializer_list<_CharT> __il, const _Allocator& __a);
874#endif // _LIBCPP_CXX03_LANG898#endif // _LIBCPP_CXX03_LANG
875899
876 inline ~basic_string();900 inline _LIBCPP_CONSTEXPR_AFTER_CXX17 ~basic_string();
877901
878 _LIBCPP_INLINE_VISIBILITY902 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
879 operator __self_view() const _NOEXCEPT { return __self_view(data(), size()); }903 operator __self_view() const _NOEXCEPT { return __self_view(data(), size()); }
880904
881 basic_string& operator=(const basic_string& __str);905 _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& operator=(const basic_string& __str);
882906
883 template <class _Tp, class = __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value> >907 template <class _Tp, class = __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&
884 basic_string& operator=(const _Tp& __t)908 !__is_same_uncvref<_Tp, basic_string>::value> >
885 {__self_view __sv = __t; return assign(__sv);}909 _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& operator=(const _Tp& __t) {
910 __self_view __sv = __t;
911 return assign(__sv);
912 }
886913
887#ifndef _LIBCPP_CXX03_LANG914#ifndef _LIBCPP_CXX03_LANG
888 _LIBCPP_INLINE_VISIBILITY915 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
889 basic_string& operator=(basic_string&& __str)916 basic_string& operator=(basic_string&& __str)
890 _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value));917 _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value));
891 _LIBCPP_INLINE_VISIBILITY918 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
892 basic_string& operator=(initializer_list<value_type> __il) {return assign(__il.begin(), __il.size());}919 basic_string& operator=(initializer_list<value_type> __il) {return assign(__il.begin(), __il.size());}
893#endif920#endif
894 _LIBCPP_INLINE_VISIBILITY basic_string& operator=(const value_type* __s) {return assign(__s);}921 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
922 basic_string& operator=(const value_type* __s) {return assign(__s);}
895#if _LIBCPP_STD_VER > 20923#if _LIBCPP_STD_VER > 20
896 basic_string& operator=(nullptr_t) = delete;924 basic_string& operator=(nullptr_t) = delete;
897#endif925#endif
898 basic_string& operator=(value_type __c);926 _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& operator=(value_type __c);
899927
900#if _LIBCPP_DEBUG_LEVEL == 2928 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
901 _LIBCPP_INLINE_VISIBILITY
902 iterator begin() _NOEXCEPT929 iterator begin() _NOEXCEPT
903 {return iterator(this, __get_pointer());}930 {return iterator(this, __get_pointer());}
904 _LIBCPP_INLINE_VISIBILITY931 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
905 const_iterator begin() const _NOEXCEPT932 const_iterator begin() const _NOEXCEPT
906 {return const_iterator(this, __get_pointer());}933 {return const_iterator(this, __get_pointer());}
907 _LIBCPP_INLINE_VISIBILITY934 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
908 iterator end() _NOEXCEPT935 iterator end() _NOEXCEPT
909 {return iterator(this, __get_pointer() + size());}936 {return iterator(this, __get_pointer() + size());}
910 _LIBCPP_INLINE_VISIBILITY937 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
911 const_iterator end() const _NOEXCEPT938 const_iterator end() const _NOEXCEPT
912 {return const_iterator(this, __get_pointer() + size());}939 {return const_iterator(this, __get_pointer() + size());}
913#else940
914 _LIBCPP_INLINE_VISIBILITY941 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
915 iterator begin() _NOEXCEPT
916 {return iterator(__get_pointer());}
917 _LIBCPP_INLINE_VISIBILITY
918 const_iterator begin() const _NOEXCEPT
919 {return const_iterator(__get_pointer());}
920 _LIBCPP_INLINE_VISIBILITY
921 iterator end() _NOEXCEPT
922 {return iterator(__get_pointer() + size());}
923 _LIBCPP_INLINE_VISIBILITY
924 const_iterator end() const _NOEXCEPT
925 {return const_iterator(__get_pointer() + size());}
926#endif // _LIBCPP_DEBUG_LEVEL == 2
927 _LIBCPP_INLINE_VISIBILITY
928 reverse_iterator rbegin() _NOEXCEPT942 reverse_iterator rbegin() _NOEXCEPT
929 {return reverse_iterator(end());}943 {return reverse_iterator(end());}
930 _LIBCPP_INLINE_VISIBILITY944 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
931 const_reverse_iterator rbegin() const _NOEXCEPT945 const_reverse_iterator rbegin() const _NOEXCEPT
932 {return const_reverse_iterator(end());}946 {return const_reverse_iterator(end());}
933 _LIBCPP_INLINE_VISIBILITY947 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
934 reverse_iterator rend() _NOEXCEPT948 reverse_iterator rend() _NOEXCEPT
935 {return reverse_iterator(begin());}949 {return reverse_iterator(begin());}
936 _LIBCPP_INLINE_VISIBILITY950 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
937 const_reverse_iterator rend() const _NOEXCEPT951 const_reverse_iterator rend() const _NOEXCEPT
938 {return const_reverse_iterator(begin());}952 {return const_reverse_iterator(begin());}
939953
940 _LIBCPP_INLINE_VISIBILITY954 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
941 const_iterator cbegin() const _NOEXCEPT955 const_iterator cbegin() const _NOEXCEPT
942 {return begin();}956 {return begin();}
943 _LIBCPP_INLINE_VISIBILITY957 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
944 const_iterator cend() const _NOEXCEPT958 const_iterator cend() const _NOEXCEPT
945 {return end();}959 {return end();}
946 _LIBCPP_INLINE_VISIBILITY960 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
947 const_reverse_iterator crbegin() const _NOEXCEPT961 const_reverse_iterator crbegin() const _NOEXCEPT
948 {return rbegin();}962 {return rbegin();}
949 _LIBCPP_INLINE_VISIBILITY963 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
950 const_reverse_iterator crend() const _NOEXCEPT964 const_reverse_iterator crend() const _NOEXCEPT
951 {return rend();}965 {return rend();}
952966
953 _LIBCPP_INLINE_VISIBILITY size_type size() const _NOEXCEPT967 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type size() const _NOEXCEPT
954 {return __is_long() ? __get_long_size() : __get_short_size();}968 {return __is_long() ? __get_long_size() : __get_short_size();}
955 _LIBCPP_INLINE_VISIBILITY size_type length() const _NOEXCEPT {return size();}969 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type length() const _NOEXCEPT {return size();}
956 _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT;970 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type max_size() const _NOEXCEPT;
957 _LIBCPP_INLINE_VISIBILITY size_type capacity() const _NOEXCEPT971 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type capacity() const _NOEXCEPT {
958 {return (__is_long() ? __get_long_cap()972 return (__is_long() ? __get_long_cap() : static_cast<size_type>(__min_cap)) - 1;
959 : static_cast<size_type>(__min_cap)) - 1;}973 }
960974
961 void resize(size_type __n, value_type __c);975 _LIBCPP_CONSTEXPR_AFTER_CXX17 void resize(size_type __n, value_type __c);
962 _LIBCPP_INLINE_VISIBILITY void resize(size_type __n) {resize(__n, value_type());}976 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void resize(size_type __n) { resize(__n, value_type()); }
963977
964 void reserve(size_type __requested_capacity);978 _LIBCPP_CONSTEXPR_AFTER_CXX17 void reserve(size_type __requested_capacity);
965979
966#if _LIBCPP_STD_VER > 20980#if _LIBCPP_STD_VER > 20
967 template <class _Op>981 template <class _Op>
968 _LIBCPP_HIDE_FROM_ABI constexpr982 _LIBCPP_HIDE_FROM_ABI constexpr
969 void resize_and_overwrite(size_type __n, _Op __op) {983 void resize_and_overwrite(size_type __n, _Op __op) {
970 __resize_default_init(__n);984 __resize_default_init(__n);
971 __erase_to_end(_VSTD::move(__op)(data(), _LIBCPP_AUTO_CAST(__n)));985 __erase_to_end(std::move(__op)(data(), _LIBCPP_AUTO_CAST(__n)));
972 }986 }
973#endif987#endif
974988
975 _LIBCPP_INLINE_VISIBILITY void __resize_default_init(size_type __n);989 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __resize_default_init(size_type __n);
976990
977 _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_INLINE_VISIBILITY991 _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI void reserve() _NOEXCEPT { shrink_to_fit(); }
978 void reserve() _NOEXCEPT {shrink_to_fit();}992 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void shrink_to_fit() _NOEXCEPT;
979 _LIBCPP_INLINE_VISIBILITY993 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void clear() _NOEXCEPT;
980 void shrink_to_fit() _NOEXCEPT;994
981 _LIBCPP_INLINE_VISIBILITY995 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
982 void clear() _NOEXCEPT;
983 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
984 bool empty() const _NOEXCEPT {return size() == 0;}996 bool empty() const _NOEXCEPT {return size() == 0;}
985997
986 _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __pos) const _NOEXCEPT;998 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
987 _LIBCPP_INLINE_VISIBILITY reference operator[](size_type __pos) _NOEXCEPT;999 const_reference operator[](size_type __pos) const _NOEXCEPT;
1000 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 reference operator[](size_type __pos) _NOEXCEPT;
9881001
989 const_reference at(size_type __n) const;1002 _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference at(size_type __n) const;
990 reference at(size_type __n);1003 _LIBCPP_CONSTEXPR_AFTER_CXX17 reference at(size_type __n);
9911004
992 _LIBCPP_INLINE_VISIBILITY basic_string& operator+=(const basic_string& __str) {return append(__str);}1005 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& operator+=(const basic_string& __str) {
1006 return append(__str);
1007 }
9931008
994 template <class _Tp>1009 template <class _Tp>
995 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS1010 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
996 __enable_if_t1011 __enable_if_t
997 <1012 <
998 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value1013 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value
999 && !__is_same_uncvref<_Tp, basic_string >::value,1014 && !__is_same_uncvref<_Tp, basic_string >::value,
1000 basic_string&1015 basic_string&
1001 >1016 >
1002 operator+=(const _Tp& __t) {__self_view __sv = __t; return append(__sv);}1017 operator+=(const _Tp& __t) {
1003 _LIBCPP_INLINE_VISIBILITY basic_string& operator+=(const value_type* __s) {return append(__s);}1018 __self_view __sv = __t; return append(__sv);
1004 _LIBCPP_INLINE_VISIBILITY basic_string& operator+=(value_type __c) {push_back(__c); return *this;}1019 }
1020
1021 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& operator+=(const value_type* __s) {
1022 return append(__s);
1023 }
1024
1025 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& operator+=(value_type __c) {
1026 push_back(__c);
1027 return *this;
1028 }
1029
1005#ifndef _LIBCPP_CXX03_LANG1030#ifndef _LIBCPP_CXX03_LANG
1006 _LIBCPP_INLINE_VISIBILITY basic_string& operator+=(initializer_list<value_type> __il) {return append(__il);}1031 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1032 basic_string& operator+=(initializer_list<value_type> __il) { return append(__il); }
1007#endif // _LIBCPP_CXX03_LANG1033#endif // _LIBCPP_CXX03_LANG
10081034
1009 _LIBCPP_INLINE_VISIBILITY1035 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1010 basic_string& append(const basic_string& __str);1036 basic_string& append(const basic_string& __str);
10111037
1012 template <class _Tp>1038 template <class _Tp>
1013 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS1039 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
1014 __enable_if_t<1040 __enable_if_t<
1015 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value1041 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value
1016 && !__is_same_uncvref<_Tp, basic_string>::value,1042 && !__is_same_uncvref<_Tp, basic_string>::value,
1017 basic_string&1043 basic_string&
1018 >1044 >
1019 append(const _Tp& __t) { __self_view __sv = __t; return append(__sv.data(), __sv.size()); }1045 append(const _Tp& __t) { __self_view __sv = __t; return append(__sv.data(), __sv.size()); }
1020 basic_string& append(const basic_string& __str, size_type __pos, size_type __n=npos);1046 _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& append(const basic_string& __str, size_type __pos, size_type __n=npos);
10211047
1022 template <class _Tp>1048 template <class _Tp>
1023 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS1049 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
1024 __enable_if_t1050 __enable_if_t
1025 <1051 <
1026 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value1052 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value
...@@ -1028,11 +1054,11 @@ public:...@@ -1028,11 +1054,11 @@ public:
1028 basic_string&1054 basic_string&
1029 >1055 >
1030 append(const _Tp& __t, size_type __pos, size_type __n=npos);1056 append(const _Tp& __t, size_type __pos, size_type __n=npos);
1031 basic_string& append(const value_type* __s, size_type __n);1057 _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& append(const value_type* __s, size_type __n);
1032 basic_string& append(const value_type* __s);1058 _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& append(const value_type* __s);
1033 basic_string& append(size_type __n, value_type __c);1059 _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& append(size_type __n, value_type __c);
10341060
1035 _LIBCPP_INLINE_VISIBILITY1061 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1036 void __append_default_init(size_type __n);1062 void __append_default_init(size_type __n);
10371063
1038 template<class _InputIterator>1064 template<class _InputIterator>
...@@ -1042,7 +1068,7 @@ public:...@@ -1042,7 +1068,7 @@ public:
1042 __is_exactly_cpp17_input_iterator<_InputIterator>::value,1068 __is_exactly_cpp17_input_iterator<_InputIterator>::value,
1043 basic_string&1069 basic_string&
1044 >1070 >
1045 _LIBCPP_INLINE_VISIBILITY1071 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1046 append(_InputIterator __first, _InputIterator __last) {1072 append(_InputIterator __first, _InputIterator __last) {
1047 const basic_string __temp(__first, __last, __alloc());1073 const basic_string __temp(__first, __last, __alloc());
1048 append(__temp.data(), __temp.size());1074 append(__temp.data(), __temp.size());
...@@ -1055,41 +1081,40 @@ public:...@@ -1055,41 +1081,40 @@ public:
1055 __is_cpp17_forward_iterator<_ForwardIterator>::value,1081 __is_cpp17_forward_iterator<_ForwardIterator>::value,
1056 basic_string&1082 basic_string&
1057 >1083 >
1058 _LIBCPP_INLINE_VISIBILITY1084 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1059 append(_ForwardIterator __first, _ForwardIterator __last);1085 append(_ForwardIterator __first, _ForwardIterator __last);
10601086
1061#ifndef _LIBCPP_CXX03_LANG1087#ifndef _LIBCPP_CXX03_LANG
1062 _LIBCPP_INLINE_VISIBILITY1088 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1063 basic_string& append(initializer_list<value_type> __il) {return append(__il.begin(), __il.size());}1089 basic_string& append(initializer_list<value_type> __il) {return append(__il.begin(), __il.size());}
1064#endif // _LIBCPP_CXX03_LANG1090#endif // _LIBCPP_CXX03_LANG
10651091
1066 void push_back(value_type __c);1092 _LIBCPP_CONSTEXPR_AFTER_CXX17 void push_back(value_type __c);
1067 _LIBCPP_INLINE_VISIBILITY1093 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void pop_back();
1068 void pop_back();1094 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 reference front() _NOEXCEPT;
1069 _LIBCPP_INLINE_VISIBILITY reference front() _NOEXCEPT;1095 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference front() const _NOEXCEPT;
1070 _LIBCPP_INLINE_VISIBILITY const_reference front() const _NOEXCEPT;1096 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 reference back() _NOEXCEPT;
1071 _LIBCPP_INLINE_VISIBILITY reference back() _NOEXCEPT;1097 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference back() const _NOEXCEPT;
1072 _LIBCPP_INLINE_VISIBILITY const_reference back() const _NOEXCEPT;
10731098
1074 template <class _Tp>1099 template <class _Tp>
1075 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS1100 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
1076 __enable_if_t1101 __enable_if_t
1077 <1102 <
1078 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,1103 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
1079 basic_string&1104 basic_string&
1080 >1105 >
1081 assign(const _Tp & __t) { __self_view __sv = __t; return assign(__sv.data(), __sv.size()); }1106 assign(const _Tp & __t) { __self_view __sv = __t; return assign(__sv.data(), __sv.size()); }
1082 _LIBCPP_INLINE_VISIBILITY1107 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1083 basic_string& assign(const basic_string& __str) { return *this = __str; }1108 basic_string& assign(const basic_string& __str) { return *this = __str; }
1084#ifndef _LIBCPP_CXX03_LANG1109#ifndef _LIBCPP_CXX03_LANG
1085 _LIBCPP_INLINE_VISIBILITY1110 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1086 basic_string& assign(basic_string&& __str)1111 basic_string& assign(basic_string&& __str)
1087 _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value))1112 _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value))
1088 {*this = _VSTD::move(__str); return *this;}1113 {*this = std::move(__str); return *this;}
1089#endif1114#endif
1090 basic_string& assign(const basic_string& __str, size_type __pos, size_type __n=npos);1115 _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& assign(const basic_string& __str, size_type __pos, size_type __n=npos);
1091 template <class _Tp>1116 template <class _Tp>
1092 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS1117 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
1093 __enable_if_t1118 __enable_if_t
1094 <1119 <
1095 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value1120 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value
...@@ -1097,11 +1122,11 @@ public:...@@ -1097,11 +1122,11 @@ public:
1097 basic_string&1122 basic_string&
1098 >1123 >
1099 assign(const _Tp & __t, size_type __pos, size_type __n=npos);1124 assign(const _Tp & __t, size_type __pos, size_type __n=npos);
1100 basic_string& assign(const value_type* __s, size_type __n);1125 _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& assign(const value_type* __s, size_type __n);
1101 basic_string& assign(const value_type* __s);1126 _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& assign(const value_type* __s);
1102 basic_string& assign(size_type __n, value_type __c);1127 _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& assign(size_type __n, value_type __c);
1103 template<class _InputIterator>1128 template<class _InputIterator>
1104 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS1129 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
1105 __enable_if_t1130 __enable_if_t
1106 <1131 <
1107 __is_exactly_cpp17_input_iterator<_InputIterator>::value,1132 __is_exactly_cpp17_input_iterator<_InputIterator>::value,
...@@ -1109,7 +1134,7 @@ public:...@@ -1109,7 +1134,7 @@ public:
1109 >1134 >
1110 assign(_InputIterator __first, _InputIterator __last);1135 assign(_InputIterator __first, _InputIterator __last);
1111 template<class _ForwardIterator>1136 template<class _ForwardIterator>
1112 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS1137 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
1113 __enable_if_t1138 __enable_if_t
1114 <1139 <
1115 __is_cpp17_forward_iterator<_ForwardIterator>::value,1140 __is_cpp17_forward_iterator<_ForwardIterator>::value,
...@@ -1117,15 +1142,15 @@ public:...@@ -1117,15 +1142,15 @@ public:
1117 >1142 >
1118 assign(_ForwardIterator __first, _ForwardIterator __last);1143 assign(_ForwardIterator __first, _ForwardIterator __last);
1119#ifndef _LIBCPP_CXX03_LANG1144#ifndef _LIBCPP_CXX03_LANG
1120 _LIBCPP_INLINE_VISIBILITY1145 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1121 basic_string& assign(initializer_list<value_type> __il) {return assign(__il.begin(), __il.size());}1146 basic_string& assign(initializer_list<value_type> __il) {return assign(__il.begin(), __il.size());}
1122#endif // _LIBCPP_CXX03_LANG1147#endif // _LIBCPP_CXX03_LANG
11231148
1124 _LIBCPP_INLINE_VISIBILITY1149 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1125 basic_string& insert(size_type __pos1, const basic_string& __str);1150 basic_string& insert(size_type __pos1, const basic_string& __str);
11261151
1127 template <class _Tp>1152 template <class _Tp>
1128 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS1153 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
1129 __enable_if_t1154 __enable_if_t
1130 <1155 <
1131 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,1156 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
...@@ -1135,22 +1160,23 @@ public:...@@ -1135,22 +1160,23 @@ public:
1135 { __self_view __sv = __t; return insert(__pos1, __sv.data(), __sv.size()); }1160 { __self_view __sv = __t; return insert(__pos1, __sv.data(), __sv.size()); }
11361161
1137 template <class _Tp>1162 template <class _Tp>
1138 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS1163 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
1139 __enable_if_t1164 __enable_if_t
1140 <1165 <
1141 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value,1166 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value,
1142 basic_string&1167 basic_string&
1143 >1168 >
1144 insert(size_type __pos1, const _Tp& __t, size_type __pos2, size_type __n=npos);1169 insert(size_type __pos1, const _Tp& __t, size_type __pos2, size_type __n=npos);
1170 _LIBCPP_CONSTEXPR_AFTER_CXX17
1145 basic_string& insert(size_type __pos1, const basic_string& __str, size_type __pos2, size_type __n=npos);1171 basic_string& insert(size_type __pos1, const basic_string& __str, size_type __pos2, size_type __n=npos);
1146 basic_string& insert(size_type __pos, const value_type* __s, size_type __n);1172 _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& insert(size_type __pos, const value_type* __s, size_type __n);
1147 basic_string& insert(size_type __pos, const value_type* __s);1173 _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& insert(size_type __pos, const value_type* __s);
1148 basic_string& insert(size_type __pos, size_type __n, value_type __c);1174 _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& insert(size_type __pos, size_type __n, value_type __c);
1149 iterator insert(const_iterator __pos, value_type __c);1175 _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator insert(const_iterator __pos, value_type __c);
1150 _LIBCPP_INLINE_VISIBILITY1176 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1151 iterator insert(const_iterator __pos, size_type __n, value_type __c);1177 iterator insert(const_iterator __pos, size_type __n, value_type __c);
1152 template<class _InputIterator>1178 template<class _InputIterator>
1153 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS1179 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
1154 __enable_if_t1180 __enable_if_t
1155 <1181 <
1156 __is_exactly_cpp17_input_iterator<_InputIterator>::value,1182 __is_exactly_cpp17_input_iterator<_InputIterator>::value,
...@@ -1158,7 +1184,7 @@ public:...@@ -1158,7 +1184,7 @@ public:
1158 >1184 >
1159 insert(const_iterator __pos, _InputIterator __first, _InputIterator __last);1185 insert(const_iterator __pos, _InputIterator __first, _InputIterator __last);
1160 template<class _ForwardIterator>1186 template<class _ForwardIterator>
1161 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS1187 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
1162 __enable_if_t1188 __enable_if_t
1163 <1189 <
1164 __is_cpp17_forward_iterator<_ForwardIterator>::value,1190 __is_cpp17_forward_iterator<_ForwardIterator>::value,
...@@ -1166,45 +1192,47 @@ public:...@@ -1166,45 +1192,47 @@ public:
1166 >1192 >
1167 insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last);1193 insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last);
1168#ifndef _LIBCPP_CXX03_LANG1194#ifndef _LIBCPP_CXX03_LANG
1169 _LIBCPP_INLINE_VISIBILITY1195 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1170 iterator insert(const_iterator __pos, initializer_list<value_type> __il)1196 iterator insert(const_iterator __pos, initializer_list<value_type> __il)
1171 {return insert(__pos, __il.begin(), __il.end());}1197 {return insert(__pos, __il.begin(), __il.end());}
1172#endif // _LIBCPP_CXX03_LANG1198#endif // _LIBCPP_CXX03_LANG
11731199
1174 basic_string& erase(size_type __pos = 0, size_type __n = npos);1200 _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& erase(size_type __pos = 0, size_type __n = npos);
1175 _LIBCPP_INLINE_VISIBILITY1201 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1176 iterator erase(const_iterator __pos);1202 iterator erase(const_iterator __pos);
1177 _LIBCPP_INLINE_VISIBILITY1203 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1178 iterator erase(const_iterator __first, const_iterator __last);1204 iterator erase(const_iterator __first, const_iterator __last);
11791205
1180 _LIBCPP_INLINE_VISIBILITY1206 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1181 basic_string& replace(size_type __pos1, size_type __n1, const basic_string& __str);1207 basic_string& replace(size_type __pos1, size_type __n1, const basic_string& __str);
11821208
1183 template <class _Tp>1209 template <class _Tp>
1184 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS1210 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
1185 __enable_if_t1211 __enable_if_t
1186 <1212 <
1187 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,1213 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
1188 basic_string&1214 basic_string&
1189 >1215 >
1190 replace(size_type __pos1, size_type __n1, const _Tp& __t) { __self_view __sv = __t; return replace(__pos1, __n1, __sv.data(), __sv.size()); }1216 replace(size_type __pos1, size_type __n1, const _Tp& __t) { __self_view __sv = __t; return replace(__pos1, __n1, __sv.data(), __sv.size()); }
1217 _LIBCPP_CONSTEXPR_AFTER_CXX17
1191 basic_string& replace(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2=npos);1218 basic_string& replace(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2=npos);
1192 template <class _Tp>1219 template <class _Tp>
1193 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS1220 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
1194 __enable_if_t1221 __enable_if_t
1195 <1222 <
1196 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value,1223 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value,
1197 basic_string&1224 basic_string&
1198 >1225 >
1199 replace(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2=npos);1226 replace(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2=npos);
1227 _LIBCPP_CONSTEXPR_AFTER_CXX17
1200 basic_string& replace(size_type __pos, size_type __n1, const value_type* __s, size_type __n2);1228 basic_string& replace(size_type __pos, size_type __n1, const value_type* __s, size_type __n2);
1201 basic_string& replace(size_type __pos, size_type __n1, const value_type* __s);1229 _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& replace(size_type __pos, size_type __n1, const value_type* __s);
1202 basic_string& replace(size_type __pos, size_type __n1, size_type __n2, value_type __c);1230 _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& replace(size_type __pos, size_type __n1, size_type __n2, value_type __c);
1203 _LIBCPP_INLINE_VISIBILITY1231 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1204 basic_string& replace(const_iterator __i1, const_iterator __i2, const basic_string& __str);1232 basic_string& replace(const_iterator __i1, const_iterator __i2, const basic_string& __str);
12051233
1206 template <class _Tp>1234 template <class _Tp>
1207 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS1235 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
1208 __enable_if_t1236 __enable_if_t
1209 <1237 <
1210 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,1238 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
...@@ -1212,14 +1240,14 @@ public:...@@ -1212,14 +1240,14 @@ public:
1212 >1240 >
1213 replace(const_iterator __i1, const_iterator __i2, const _Tp& __t) { __self_view __sv = __t; return replace(__i1 - begin(), __i2 - __i1, __sv); }1241 replace(const_iterator __i1, const_iterator __i2, const _Tp& __t) { __self_view __sv = __t; return replace(__i1 - begin(), __i2 - __i1, __sv); }
12141242
1215 _LIBCPP_INLINE_VISIBILITY1243 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1216 basic_string& replace(const_iterator __i1, const_iterator __i2, const value_type* __s, size_type __n);1244 basic_string& replace(const_iterator __i1, const_iterator __i2, const value_type* __s, size_type __n);
1217 _LIBCPP_INLINE_VISIBILITY1245 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1218 basic_string& replace(const_iterator __i1, const_iterator __i2, const value_type* __s);1246 basic_string& replace(const_iterator __i1, const_iterator __i2, const value_type* __s);
1219 _LIBCPP_INLINE_VISIBILITY1247 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1220 basic_string& replace(const_iterator __i1, const_iterator __i2, size_type __n, value_type __c);1248 basic_string& replace(const_iterator __i1, const_iterator __i2, size_type __n, value_type __c);
1221 template<class _InputIterator>1249 template<class _InputIterator>
1222 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS1250 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
1223 __enable_if_t1251 __enable_if_t
1224 <1252 <
1225 __is_cpp17_input_iterator<_InputIterator>::value,1253 __is_cpp17_input_iterator<_InputIterator>::value,
...@@ -1227,16 +1255,16 @@ public:...@@ -1227,16 +1255,16 @@ public:
1227 >1255 >
1228 replace(const_iterator __i1, const_iterator __i2, _InputIterator __j1, _InputIterator __j2);1256 replace(const_iterator __i1, const_iterator __i2, _InputIterator __j1, _InputIterator __j2);
1229#ifndef _LIBCPP_CXX03_LANG1257#ifndef _LIBCPP_CXX03_LANG
1230 _LIBCPP_INLINE_VISIBILITY1258 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1231 basic_string& replace(const_iterator __i1, const_iterator __i2, initializer_list<value_type> __il)1259 basic_string& replace(const_iterator __i1, const_iterator __i2, initializer_list<value_type> __il)
1232 {return replace(__i1, __i2, __il.begin(), __il.end());}1260 {return replace(__i1, __i2, __il.begin(), __il.end());}
1233#endif // _LIBCPP_CXX03_LANG1261#endif // _LIBCPP_CXX03_LANG
12341262
1235 size_type copy(value_type* __s, size_type __n, size_type __pos = 0) const;1263 _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type copy(value_type* __s, size_type __n, size_type __pos = 0) const;
1236 _LIBCPP_INLINE_VISIBILITY1264 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1237 basic_string substr(size_type __pos = 0, size_type __n = npos) const;1265 basic_string substr(size_type __pos = 0, size_type __n = npos) const;
12381266
1239 _LIBCPP_INLINE_VISIBILITY1267 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1240 void swap(basic_string& __str)1268 void swap(basic_string& __str)
1241#if _LIBCPP_STD_VER >= 141269#if _LIBCPP_STD_VER >= 14
1242 _NOEXCEPT;1270 _NOEXCEPT;
...@@ -1245,123 +1273,129 @@ public:...@@ -1245,123 +1273,129 @@ public:
1245 __is_nothrow_swappable<allocator_type>::value);1273 __is_nothrow_swappable<allocator_type>::value);
1246#endif1274#endif
12471275
1248 _LIBCPP_INLINE_VISIBILITY1276 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1249 const value_type* c_str() const _NOEXCEPT {return data();}1277 const value_type* c_str() const _NOEXCEPT {return data();}
1250 _LIBCPP_INLINE_VISIBILITY1278 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1251 const value_type* data() const _NOEXCEPT {return _VSTD::__to_address(__get_pointer());}1279 const value_type* data() const _NOEXCEPT {return std::__to_address(__get_pointer());}
1252#if _LIBCPP_STD_VER > 14 || defined(_LIBCPP_BUILDING_LIBRARY)1280#if _LIBCPP_STD_VER > 14 || defined(_LIBCPP_BUILDING_LIBRARY)
1253 _LIBCPP_INLINE_VISIBILITY1281 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1254 value_type* data() _NOEXCEPT {return _VSTD::__to_address(__get_pointer());}1282 value_type* data() _NOEXCEPT {return std::__to_address(__get_pointer());}
1255#endif1283#endif
12561284
1257 _LIBCPP_INLINE_VISIBILITY1285 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1258 allocator_type get_allocator() const _NOEXCEPT {return __alloc();}1286 allocator_type get_allocator() const _NOEXCEPT {return __alloc();}
12591287
1260 _LIBCPP_INLINE_VISIBILITY1288 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1261 size_type find(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT;1289 size_type find(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT;
12621290
1263 template <class _Tp>1291 template <class _Tp>
1264 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS1292 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
1265 __enable_if_t1293 __enable_if_t
1266 <1294 <
1267 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,1295 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
1268 size_type1296 size_type
1269 >1297 >
1270 find(const _Tp& __t, size_type __pos = 0) const _NOEXCEPT;1298 find(const _Tp& __t, size_type __pos = 0) const _NOEXCEPT;
1299 _LIBCPP_CONSTEXPR_AFTER_CXX17
1271 size_type find(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;1300 size_type find(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
1272 _LIBCPP_INLINE_VISIBILITY1301 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1273 size_type find(const value_type* __s, size_type __pos = 0) const _NOEXCEPT;1302 size_type find(const value_type* __s, size_type __pos = 0) const _NOEXCEPT;
1274 size_type find(value_type __c, size_type __pos = 0) const _NOEXCEPT;1303 _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type find(value_type __c, size_type __pos = 0) const _NOEXCEPT;
12751304
1276 _LIBCPP_INLINE_VISIBILITY1305 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1277 size_type rfind(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT;1306 size_type rfind(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT;
12781307
1279 template <class _Tp>1308 template <class _Tp>
1280 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS1309 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
1281 __enable_if_t1310 __enable_if_t
1282 <1311 <
1283 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,1312 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
1284 size_type1313 size_type
1285 >1314 >
1286 rfind(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT;1315 rfind(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT;
1316 _LIBCPP_CONSTEXPR_AFTER_CXX17
1287 size_type rfind(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;1317 size_type rfind(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
1288 _LIBCPP_INLINE_VISIBILITY1318 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1289 size_type rfind(const value_type* __s, size_type __pos = npos) const _NOEXCEPT;1319 size_type rfind(const value_type* __s, size_type __pos = npos) const _NOEXCEPT;
1290 size_type rfind(value_type __c, size_type __pos = npos) const _NOEXCEPT;1320 _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type rfind(value_type __c, size_type __pos = npos) const _NOEXCEPT;
12911321
1292 _LIBCPP_INLINE_VISIBILITY1322 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1293 size_type find_first_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT;1323 size_type find_first_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT;
12941324
1295 template <class _Tp>1325 template <class _Tp>
1296 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS1326 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
1297 __enable_if_t1327 __enable_if_t
1298 <1328 <
1299 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,1329 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
1300 size_type1330 size_type
1301 >1331 >
1302 find_first_of(const _Tp& __t, size_type __pos = 0) const _NOEXCEPT;1332 find_first_of(const _Tp& __t, size_type __pos = 0) const _NOEXCEPT;
1333 _LIBCPP_CONSTEXPR_AFTER_CXX17
1303 size_type find_first_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;1334 size_type find_first_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
1304 _LIBCPP_INLINE_VISIBILITY1335 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1305 size_type find_first_of(const value_type* __s, size_type __pos = 0) const _NOEXCEPT;1336 size_type find_first_of(const value_type* __s, size_type __pos = 0) const _NOEXCEPT;
1306 _LIBCPP_INLINE_VISIBILITY1337 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1307 size_type find_first_of(value_type __c, size_type __pos = 0) const _NOEXCEPT;1338 size_type find_first_of(value_type __c, size_type __pos = 0) const _NOEXCEPT;
13081339
1309 _LIBCPP_INLINE_VISIBILITY1340 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1310 size_type find_last_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT;1341 size_type find_last_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT;
13111342
1312 template <class _Tp>1343 template <class _Tp>
1313 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS1344 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
1314 __enable_if_t1345 __enable_if_t
1315 <1346 <
1316 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,1347 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
1317 size_type1348 size_type
1318 >1349 >
1319 find_last_of(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT;1350 find_last_of(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT;
1351 _LIBCPP_CONSTEXPR_AFTER_CXX17
1320 size_type find_last_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;1352 size_type find_last_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
1321 _LIBCPP_INLINE_VISIBILITY1353 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1322 size_type find_last_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT;1354 size_type find_last_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT;
1323 _LIBCPP_INLINE_VISIBILITY1355 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1324 size_type find_last_of(value_type __c, size_type __pos = npos) const _NOEXCEPT;1356 size_type find_last_of(value_type __c, size_type __pos = npos) const _NOEXCEPT;
13251357
1326 _LIBCPP_INLINE_VISIBILITY1358 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1327 size_type find_first_not_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT;1359 size_type find_first_not_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT;
13281360
1329 template <class _Tp>1361 template <class _Tp>
1330 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS1362 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
1331 __enable_if_t1363 __enable_if_t
1332 <1364 <
1333 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,1365 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
1334 size_type1366 size_type
1335 >1367 >
1336 find_first_not_of(const _Tp &__t, size_type __pos = 0) const _NOEXCEPT;1368 find_first_not_of(const _Tp &__t, size_type __pos = 0) const _NOEXCEPT;
1369 _LIBCPP_CONSTEXPR_AFTER_CXX17
1337 size_type find_first_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;1370 size_type find_first_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
1338 _LIBCPP_INLINE_VISIBILITY1371 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1339 size_type find_first_not_of(const value_type* __s, size_type __pos = 0) const _NOEXCEPT;1372 size_type find_first_not_of(const value_type* __s, size_type __pos = 0) const _NOEXCEPT;
1340 _LIBCPP_INLINE_VISIBILITY1373 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1341 size_type find_first_not_of(value_type __c, size_type __pos = 0) const _NOEXCEPT;1374 size_type find_first_not_of(value_type __c, size_type __pos = 0) const _NOEXCEPT;
13421375
1343 _LIBCPP_INLINE_VISIBILITY1376 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1344 size_type find_last_not_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT;1377 size_type find_last_not_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT;
13451378
1346 template <class _Tp>1379 template <class _Tp>
1347 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS1380 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
1348 __enable_if_t1381 __enable_if_t
1349 <1382 <
1350 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,1383 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
1351 size_type1384 size_type
1352 >1385 >
1353 find_last_not_of(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT;1386 find_last_not_of(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT;
1387 _LIBCPP_CONSTEXPR_AFTER_CXX17
1354 size_type find_last_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;1388 size_type find_last_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
1355 _LIBCPP_INLINE_VISIBILITY1389 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1356 size_type find_last_not_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT;1390 size_type find_last_not_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT;
1357 _LIBCPP_INLINE_VISIBILITY1391 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1358 size_type find_last_not_of(value_type __c, size_type __pos = npos) const _NOEXCEPT;1392 size_type find_last_not_of(value_type __c, size_type __pos = npos) const _NOEXCEPT;
13591393
1360 _LIBCPP_INLINE_VISIBILITY1394 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1361 int compare(const basic_string& __str) const _NOEXCEPT;1395 int compare(const basic_string& __str) const _NOEXCEPT;
13621396
1363 template <class _Tp>1397 template <class _Tp>
1364 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS1398 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
1365 __enable_if_t1399 __enable_if_t
1366 <1400 <
1367 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,1401 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
...@@ -1370,7 +1404,7 @@ public:...@@ -1370,7 +1404,7 @@ public:
1370 compare(const _Tp &__t) const _NOEXCEPT;1404 compare(const _Tp &__t) const _NOEXCEPT;
13711405
1372 template <class _Tp>1406 template <class _Tp>
1373 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS1407 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
1374 __enable_if_t1408 __enable_if_t
1375 <1409 <
1376 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,1410 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
...@@ -1378,199 +1412,243 @@ public:...@@ -1378,199 +1412,243 @@ public:
1378 >1412 >
1379 compare(size_type __pos1, size_type __n1, const _Tp& __t) const;1413 compare(size_type __pos1, size_type __n1, const _Tp& __t) const;
13801414
1381 _LIBCPP_INLINE_VISIBILITY1415 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1382 int compare(size_type __pos1, size_type __n1, const basic_string& __str) const;1416 int compare(size_type __pos1, size_type __n1, const basic_string& __str) const;
1383 int compare(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2=npos) const;1417 _LIBCPP_CONSTEXPR_AFTER_CXX17
1418 int compare(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2,
1419 size_type __n2 = npos) const;
13841420
1385 template <class _Tp>1421 template <class _Tp>
1386 inline _LIBCPP_INLINE_VISIBILITY1422 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1387 __enable_if_t1423 __enable_if_t
1388 <1424 <
1389 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value,1425 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value,
1390 int1426 int
1391 >1427 >
1392 compare(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2=npos) const;1428 compare(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2=npos) const;
1393 int compare(const value_type* __s) const _NOEXCEPT;1429 _LIBCPP_CONSTEXPR_AFTER_CXX17 int compare(const value_type* __s) const _NOEXCEPT;
1394 int compare(size_type __pos1, size_type __n1, const value_type* __s) const;1430 _LIBCPP_CONSTEXPR_AFTER_CXX17 int compare(size_type __pos1, size_type __n1, const value_type* __s) const;
1431 _LIBCPP_CONSTEXPR_AFTER_CXX17
1395 int compare(size_type __pos1, size_type __n1, const value_type* __s, size_type __n2) const;1432 int compare(size_type __pos1, size_type __n1, const value_type* __s, size_type __n2) const;
13961433
1397#if _LIBCPP_STD_VER > 171434#if _LIBCPP_STD_VER > 17
1398 constexpr _LIBCPP_INLINE_VISIBILITY1435 constexpr _LIBCPP_HIDE_FROM_ABI
1399 bool starts_with(__self_view __sv) const noexcept1436 bool starts_with(__self_view __sv) const noexcept
1400 { return __self_view(data(), size()).starts_with(__sv); }1437 { return __self_view(data(), size()).starts_with(__sv); }
14011438
1402 constexpr _LIBCPP_INLINE_VISIBILITY1439 constexpr _LIBCPP_HIDE_FROM_ABI
1403 bool starts_with(value_type __c) const noexcept1440 bool starts_with(value_type __c) const noexcept
1404 { return !empty() && _Traits::eq(front(), __c); }1441 { return !empty() && _Traits::eq(front(), __c); }
14051442
1406 constexpr _LIBCPP_INLINE_VISIBILITY1443 constexpr _LIBCPP_HIDE_FROM_ABI
1407 bool starts_with(const value_type* __s) const noexcept1444 bool starts_with(const value_type* __s) const noexcept
1408 { return starts_with(__self_view(__s)); }1445 { return starts_with(__self_view(__s)); }
14091446
1410 constexpr _LIBCPP_INLINE_VISIBILITY1447 constexpr _LIBCPP_HIDE_FROM_ABI
1411 bool ends_with(__self_view __sv) const noexcept1448 bool ends_with(__self_view __sv) const noexcept
1412 { return __self_view(data(), size()).ends_with( __sv); }1449 { return __self_view(data(), size()).ends_with( __sv); }
14131450
1414 constexpr _LIBCPP_INLINE_VISIBILITY1451 constexpr _LIBCPP_HIDE_FROM_ABI
1415 bool ends_with(value_type __c) const noexcept1452 bool ends_with(value_type __c) const noexcept
1416 { return !empty() && _Traits::eq(back(), __c); }1453 { return !empty() && _Traits::eq(back(), __c); }
14171454
1418 constexpr _LIBCPP_INLINE_VISIBILITY1455 constexpr _LIBCPP_HIDE_FROM_ABI
1419 bool ends_with(const value_type* __s) const noexcept1456 bool ends_with(const value_type* __s) const noexcept
1420 { return ends_with(__self_view(__s)); }1457 { return ends_with(__self_view(__s)); }
1421#endif1458#endif
14221459
1423#if _LIBCPP_STD_VER > 201460#if _LIBCPP_STD_VER > 20
1424 constexpr _LIBCPP_INLINE_VISIBILITY1461 constexpr _LIBCPP_HIDE_FROM_ABI
1425 bool contains(__self_view __sv) const noexcept1462 bool contains(__self_view __sv) const noexcept
1426 { return __self_view(data(), size()).contains(__sv); }1463 { return __self_view(data(), size()).contains(__sv); }
14271464
1428 constexpr _LIBCPP_INLINE_VISIBILITY1465 constexpr _LIBCPP_HIDE_FROM_ABI
1429 bool contains(value_type __c) const noexcept1466 bool contains(value_type __c) const noexcept
1430 { return __self_view(data(), size()).contains(__c); }1467 { return __self_view(data(), size()).contains(__c); }
14311468
1432 constexpr _LIBCPP_INLINE_VISIBILITY1469 constexpr _LIBCPP_HIDE_FROM_ABI
1433 bool contains(const value_type* __s) const1470 bool contains(const value_type* __s) const
1434 { return __self_view(data(), size()).contains(__s); }1471 { return __self_view(data(), size()).contains(__s); }
1435#endif1472#endif
14361473
1437 _LIBCPP_INLINE_VISIBILITY bool __invariants() const;1474 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool __invariants() const;
1438
1439 _LIBCPP_INLINE_VISIBILITY void __clear_and_shrink() _NOEXCEPT;
1440
1441 _LIBCPP_INLINE_VISIBILITY void __shrink_or_extend(size_type __target_capacity);
14421475
1443 _LIBCPP_INLINE_VISIBILITY1476 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __clear_and_shrink() _NOEXCEPT;
1444 bool __is_long() const _NOEXCEPT
1445 {return bool(__r_.first().__s.__size_ & __short_mask);}
14461477
1447#if _LIBCPP_DEBUG_LEVEL == 21478#ifdef _LIBCPP_ENABLE_DEBUG_MODE
14481479
1449 bool __dereferenceable(const const_iterator* __i) const;1480 bool __dereferenceable(const const_iterator* __i) const;
1450 bool __decrementable(const const_iterator* __i) const;1481 bool __decrementable(const const_iterator* __i) const;
1451 bool __addable(const const_iterator* __i, ptrdiff_t __n) const;1482 bool __addable(const const_iterator* __i, ptrdiff_t __n) const;
1452 bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const;1483 bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const;
14531484
1454#endif // _LIBCPP_DEBUG_LEVEL == 21485#endif // _LIBCPP_ENABLE_DEBUG_MODE
14551486
1456private:1487private:
1457 _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI static bool __fits_in_sso(size_type __sz) {1488 template<class _Alloc>
1458 // SSO is disabled during constant evaluation because `__is_long` isn't constexpr friendly1489 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1459 return !__libcpp_is_constant_evaluated() && (__sz < __min_cap);1490 bool friend operator==(const basic_string<char, char_traits<char>, _Alloc>& __lhs,
1491 const basic_string<char, char_traits<char>, _Alloc>& __rhs) _NOEXCEPT;
1492
1493 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __shrink_or_extend(size_type __target_capacity);
1494
1495 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1496 bool __is_long() const _NOEXCEPT {
1497 if (__libcpp_is_constant_evaluated())
1498 return true;
1499 return __r_.first().__s.__is_long_;
1460 }1500 }
14611501
1462 _LIBCPP_INLINE_VISIBILITY1502 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __begin_lifetime(pointer __begin, size_type __n) {
1463 allocator_type& __alloc() _NOEXCEPT1503#if _LIBCPP_STD_VER > 17
1464 {return __r_.second();}1504 if (__libcpp_is_constant_evaluated()) {
1465 _LIBCPP_INLINE_VISIBILITY1505 for (size_type __i = 0; __i != __n; ++__i)
1466 const allocator_type& __alloc() const _NOEXCEPT1506 std::construct_at(std::addressof(__begin[__i]));
1467 {return __r_.second();}1507 }
1508#else
1509 (void)__begin;
1510 (void)__n;
1511#endif // _LIBCPP_STD_VER > 17
1512 }
14681513
1469#ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT1514 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __default_init() {
1515 __zero();
1516 if (__libcpp_is_constant_evaluated()) {
1517 size_type __sz = __recommend(0) + 1;
1518 pointer __ptr = __alloc_traits::allocate(__alloc(), __sz);
1519 __begin_lifetime(__ptr, __sz);
1520 __set_long_pointer(__ptr);
1521 __set_long_cap(__sz);
1522 __set_long_size(0);
1523 }
1524 }
14701525
1471 _LIBCPP_INLINE_VISIBILITY1526 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __deallocate_constexpr() {
1472 void __set_short_size(size_type __s) _NOEXCEPT1527 if (__libcpp_is_constant_evaluated() && __get_pointer() != nullptr)
1473# ifdef _LIBCPP_BIG_ENDIAN1528 __alloc_traits::deallocate(__alloc(), __get_pointer(), __get_long_cap());
1474 {__r_.first().__s.__size_ = (unsigned char)(__s << 1);}1529 }
1475# else
1476 {__r_.first().__s.__size_ = (unsigned char)(__s);}
1477# endif
14781530
1479 _LIBCPP_INLINE_VISIBILITY1531 _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI static bool __fits_in_sso(size_type __sz) {
1480 size_type __get_short_size() const _NOEXCEPT1532 // SSO is disabled during constant evaluation because `__is_long` isn't constexpr friendly
1481# ifdef _LIBCPP_BIG_ENDIAN1533 return !__libcpp_is_constant_evaluated() && (__sz < __min_cap);
1482 {return __r_.first().__s.__size_ >> 1;}1534 }
1483# else1535
1484 {return __r_.first().__s.__size_;}1536 template <class _ForwardIterator>
1485# endif1537 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
1538 iterator __insert_from_safe_copy(size_type __n, size_type __ip, _ForwardIterator __first, _ForwardIterator __last) {
1539 size_type __sz = size();
1540 size_type __cap = capacity();
1541 value_type* __p;
1542 if (__cap - __sz >= __n)
1543 {
1544 __p = std::__to_address(__get_pointer());
1545 size_type __n_move = __sz - __ip;
1546 if (__n_move != 0)
1547 traits_type::move(__p + __ip + __n, __p + __ip, __n_move);
1548 }
1549 else
1550 {
1551 __grow_by(__cap, __sz + __n - __cap, __sz, __ip, 0, __n);
1552 __p = std::__to_address(__get_long_pointer());
1553 }
1554 __sz += __n;
1555 __set_size(__sz);
1556 traits_type::assign(__p[__sz], value_type());
1557 for (__p += __ip; __first != __last; ++__p, ++__first)
1558 traits_type::assign(*__p, *__first);
14861559
1487#else // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT1560 return begin() + __ip;
1561 }
14881562
1489 _LIBCPP_INLINE_VISIBILITY1563 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 allocator_type& __alloc() _NOEXCEPT { return __r_.second(); }
1490 void __set_short_size(size_type __s) _NOEXCEPT1564 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const allocator_type& __alloc() const _NOEXCEPT { return __r_.second(); }
1491# ifdef _LIBCPP_BIG_ENDIAN
1492 {__r_.first().__s.__size_ = (unsigned char)(__s);}
1493# else
1494 {__r_.first().__s.__size_ = (unsigned char)(__s << 1);}
1495# endif
14961565
1497 _LIBCPP_INLINE_VISIBILITY1566 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1498 size_type __get_short_size() const _NOEXCEPT1567 void __set_short_size(size_type __s) _NOEXCEPT {
1499# ifdef _LIBCPP_BIG_ENDIAN1568 _LIBCPP_ASSERT(__s < __min_cap, "__s should never be greater than or equal to the short string capacity");
1500 {return __r_.first().__s.__size_;}1569 __r_.first().__s.__size_ = __s;
1501# else1570 __r_.first().__s.__is_long_ = false;
1502 {return __r_.first().__s.__size_ >> 1;}1571 }
1503# endif
15041572
1505#endif // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT1573 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1574 size_type __get_short_size() const _NOEXCEPT {
1575 _LIBCPP_ASSERT(!__r_.first().__s.__is_long_, "String has to be short when trying to get the short size");
1576 return __r_.first().__s.__size_;
1577 }
15061578
1507 _LIBCPP_INLINE_VISIBILITY1579 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1508 void __set_long_size(size_type __s) _NOEXCEPT1580 void __set_long_size(size_type __s) _NOEXCEPT
1509 {__r_.first().__l.__size_ = __s;}1581 {__r_.first().__l.__size_ = __s;}
1510 _LIBCPP_INLINE_VISIBILITY1582 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1511 size_type __get_long_size() const _NOEXCEPT1583 size_type __get_long_size() const _NOEXCEPT
1512 {return __r_.first().__l.__size_;}1584 {return __r_.first().__l.__size_;}
1513 _LIBCPP_INLINE_VISIBILITY1585 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1514 void __set_size(size_type __s) _NOEXCEPT1586 void __set_size(size_type __s) _NOEXCEPT
1515 {if (__is_long()) __set_long_size(__s); else __set_short_size(__s);}1587 {if (__is_long()) __set_long_size(__s); else __set_short_size(__s);}
15161588
1517 _LIBCPP_INLINE_VISIBILITY1589 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1518 void __set_long_cap(size_type __s) _NOEXCEPT1590 void __set_long_cap(size_type __s) _NOEXCEPT {
1519 {__r_.first().__l.__cap_ = __long_mask | __s;}1591 __r_.first().__l.__cap_ = __s / __endian_factor;
1520 _LIBCPP_INLINE_VISIBILITY1592 __r_.first().__l.__is_long_ = true;
1521 size_type __get_long_cap() const _NOEXCEPT1593 }
1522 {return __r_.first().__l.__cap_ & size_type(~__long_mask);}
15231594
1524 _LIBCPP_INLINE_VISIBILITY1595 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1596 size_type __get_long_cap() const _NOEXCEPT {
1597 return __r_.first().__l.__cap_ * __endian_factor;
1598 }
1599
1600 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1525 void __set_long_pointer(pointer __p) _NOEXCEPT1601 void __set_long_pointer(pointer __p) _NOEXCEPT
1526 {__r_.first().__l.__data_ = __p;}1602 {__r_.first().__l.__data_ = __p;}
1527 _LIBCPP_INLINE_VISIBILITY1603 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1528 pointer __get_long_pointer() _NOEXCEPT1604 pointer __get_long_pointer() _NOEXCEPT
1529 {return __r_.first().__l.__data_;}1605 {return __r_.first().__l.__data_;}
1530 _LIBCPP_INLINE_VISIBILITY1606 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1531 const_pointer __get_long_pointer() const _NOEXCEPT1607 const_pointer __get_long_pointer() const _NOEXCEPT
1532 {return __r_.first().__l.__data_;}1608 {return __r_.first().__l.__data_;}
1533 _LIBCPP_INLINE_VISIBILITY1609 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1534 pointer __get_short_pointer() _NOEXCEPT1610 pointer __get_short_pointer() _NOEXCEPT
1535 {return pointer_traits<pointer>::pointer_to(__r_.first().__s.__data_[0]);}1611 {return pointer_traits<pointer>::pointer_to(__r_.first().__s.__data_[0]);}
1536 _LIBCPP_INLINE_VISIBILITY1612 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1537 const_pointer __get_short_pointer() const _NOEXCEPT1613 const_pointer __get_short_pointer() const _NOEXCEPT
1538 {return pointer_traits<const_pointer>::pointer_to(__r_.first().__s.__data_[0]);}1614 {return pointer_traits<const_pointer>::pointer_to(__r_.first().__s.__data_[0]);}
1539 _LIBCPP_INLINE_VISIBILITY1615 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1540 pointer __get_pointer() _NOEXCEPT1616 pointer __get_pointer() _NOEXCEPT
1541 {return __is_long() ? __get_long_pointer() : __get_short_pointer();}1617 {return __is_long() ? __get_long_pointer() : __get_short_pointer();}
1542 _LIBCPP_INLINE_VISIBILITY1618 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1543 const_pointer __get_pointer() const _NOEXCEPT1619 const_pointer __get_pointer() const _NOEXCEPT
1544 {return __is_long() ? __get_long_pointer() : __get_short_pointer();}1620 {return __is_long() ? __get_long_pointer() : __get_short_pointer();}
15451621
1546 _LIBCPP_INLINE_VISIBILITY1622 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1547 void __zero() _NOEXCEPT1623 void __zero() _NOEXCEPT {
1548 {1624 __r_.first() = __rep();
1549 size_type (&__a)[__n_words] = __r_.first().__r.__words;1625 }
1550 for (unsigned __i = 0; __i < __n_words; ++__i)
1551 __a[__i] = 0;
1552 }
15531626
1554 template <size_type __a> static1627 template <size_type __a> static
1555 _LIBCPP_INLINE_VISIBILITY1628 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1556 size_type __align_it(size_type __s) _NOEXCEPT1629 size_type __align_it(size_type __s) _NOEXCEPT
1557 {return (__s + (__a-1)) & ~(__a-1);}1630 {return (__s + (__a-1)) & ~(__a-1);}
1558 enum {__alignment = 16};1631 enum {__alignment = 16};
1559 static _LIBCPP_INLINE_VISIBILITY1632 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1560 size_type __recommend(size_type __s) _NOEXCEPT1633 size_type __recommend(size_type __s) _NOEXCEPT
1561 {1634 {
1562 if (__s < __min_cap) return static_cast<size_type>(__min_cap) - 1;1635 if (__s < __min_cap) {
1636 if (__libcpp_is_constant_evaluated())
1637 return static_cast<size_type>(__min_cap);
1638 else
1639 return static_cast<size_type>(__min_cap) - 1;
1640 }
1563 size_type __guess = __align_it<sizeof(value_type) < __alignment ?1641 size_type __guess = __align_it<sizeof(value_type) < __alignment ?
1564 __alignment/sizeof(value_type) : 1 > (__s+1) - 1;1642 __alignment/sizeof(value_type) : 1 > (__s+1) - 1;
1565 if (__guess == __min_cap) ++__guess;1643 if (__guess == __min_cap) ++__guess;
1566 return __guess;1644 return __guess;
1567 }1645 }
15681646
1569 inline1647 inline _LIBCPP_CONSTEXPR_AFTER_CXX17
1570 void __init(const value_type* __s, size_type __sz, size_type __reserve);1648 void __init(const value_type* __s, size_type __sz, size_type __reserve);
1571 inline1649 inline _LIBCPP_CONSTEXPR_AFTER_CXX17
1572 void __init(const value_type* __s, size_type __sz);1650 void __init(const value_type* __s, size_type __sz);
1573 inline1651 inline _LIBCPP_CONSTEXPR_AFTER_CXX17
1574 void __init(size_type __n, value_type __c);1652 void __init(size_type __n, value_type __c);
15751653
1576 // Slow path for the (inlined) copy constructor for 'long' strings.1654 // Slow path for the (inlined) copy constructor for 'long' strings.
...@@ -1581,10 +1659,10 @@ private:...@@ -1581,10 +1659,10 @@ private:
1581 // to call the __init() functions as those are marked as inline which may1659 // to call the __init() functions as those are marked as inline which may
1582 // result in over-aggressive inlining by the compiler, where our aim is1660 // result in over-aggressive inlining by the compiler, where our aim is
1583 // to only inline the fast path code directly in the ctor.1661 // to only inline the fast path code directly in the ctor.
1584 void __init_copy_ctor_external(const value_type* __s, size_type __sz);1662 _LIBCPP_CONSTEXPR_AFTER_CXX17 void __init_copy_ctor_external(const value_type* __s, size_type __sz);
15851663
1586 template <class _InputIterator>1664 template <class _InputIterator>
1587 inline1665 inline _LIBCPP_CONSTEXPR_AFTER_CXX17
1588 __enable_if_t1666 __enable_if_t
1589 <1667 <
1590 __is_exactly_cpp17_input_iterator<_InputIterator>::value1668 __is_exactly_cpp17_input_iterator<_InputIterator>::value
...@@ -1592,15 +1670,17 @@ private:...@@ -1592,15 +1670,17 @@ private:
1592 __init(_InputIterator __first, _InputIterator __last);1670 __init(_InputIterator __first, _InputIterator __last);
15931671
1594 template <class _ForwardIterator>1672 template <class _ForwardIterator>
1595 inline1673 inline _LIBCPP_CONSTEXPR_AFTER_CXX17
1596 __enable_if_t1674 __enable_if_t
1597 <1675 <
1598 __is_cpp17_forward_iterator<_ForwardIterator>::value1676 __is_cpp17_forward_iterator<_ForwardIterator>::value
1599 >1677 >
1600 __init(_ForwardIterator __first, _ForwardIterator __last);1678 __init(_ForwardIterator __first, _ForwardIterator __last);
16011679
1680 _LIBCPP_CONSTEXPR_AFTER_CXX17
1602 void __grow_by(size_type __old_cap, size_type __delta_cap, size_type __old_sz,1681 void __grow_by(size_type __old_cap, size_type __delta_cap, size_type __old_sz,
1603 size_type __n_copy, size_type __n_del, size_type __n_add = 0);1682 size_type __n_copy, size_type __n_del, size_type __n_add = 0);
1683 _LIBCPP_CONSTEXPR_AFTER_CXX17
1604 void __grow_by_and_replace(size_type __old_cap, size_type __delta_cap, size_type __old_sz,1684 void __grow_by_and_replace(size_type __old_cap, size_type __delta_cap, size_type __old_sz,
1605 size_type __n_copy, size_type __n_del,1685 size_type __n_copy, size_type __n_del,
1606 size_type __n_add, const value_type* __p_new_stuff);1686 size_type __n_add, const value_type* __p_new_stuff);
...@@ -1609,21 +1689,21 @@ private:...@@ -1609,21 +1689,21 @@ private:
1609 // have proof that the input does not alias the current instance.1689 // have proof that the input does not alias the current instance.
1610 // For example, operator=(basic_string) performs a 'self' check.1690 // For example, operator=(basic_string) performs a 'self' check.
1611 template <bool __is_short>1691 template <bool __is_short>
1612 basic_string& __assign_no_alias(const value_type* __s, size_type __n);1692 _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& __assign_no_alias(const value_type* __s, size_type __n);
16131693
1614 _LIBCPP_INLINE_VISIBILITY1694 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1615 void __erase_to_end(size_type __pos);1695 void __erase_to_end(size_type __pos);
16161696
1617 // __erase_external_with_move is invoked for erase() invocations where1697 // __erase_external_with_move is invoked for erase() invocations where
1618 // `n ~= npos`, likely requiring memory moves on the string data.1698 // `n ~= npos`, likely requiring memory moves on the string data.
1619 void __erase_external_with_move(size_type __pos, size_type __n);1699 _LIBCPP_CONSTEXPR_AFTER_CXX17 void __erase_external_with_move(size_type __pos, size_type __n);
16201700
1621 _LIBCPP_INLINE_VISIBILITY1701 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1622 void __copy_assign_alloc(const basic_string& __str)1702 void __copy_assign_alloc(const basic_string& __str)
1623 {__copy_assign_alloc(__str, integral_constant<bool,1703 {__copy_assign_alloc(__str, integral_constant<bool,
1624 __alloc_traits::propagate_on_container_copy_assignment::value>());}1704 __alloc_traits::propagate_on_container_copy_assignment::value>());}
16251705
1626 _LIBCPP_INLINE_VISIBILITY1706 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1627 void __copy_assign_alloc(const basic_string& __str, true_type)1707 void __copy_assign_alloc(const basic_string& __str, true_type)
1628 {1708 {
1629 if (__alloc() == __str.__alloc())1709 if (__alloc() == __str.__alloc())
...@@ -1638,25 +1718,26 @@ private:...@@ -1638,25 +1718,26 @@ private:
1638 else1718 else
1639 {1719 {
1640 allocator_type __a = __str.__alloc();1720 allocator_type __a = __str.__alloc();
1641 pointer __p = __alloc_traits::allocate(__a, __str.__get_long_cap());1721 auto __allocation = std::__allocate_at_least(__a, __str.__get_long_cap());
1722 __begin_lifetime(__allocation.ptr, __allocation.count);
1642 __clear_and_shrink();1723 __clear_and_shrink();
1643 __alloc() = _VSTD::move(__a);1724 __alloc() = std::move(__a);
1644 __set_long_pointer(__p);1725 __set_long_pointer(__allocation.ptr);
1645 __set_long_cap(__str.__get_long_cap());1726 __set_long_cap(__allocation.count);
1646 __set_long_size(__str.size());1727 __set_long_size(__str.size());
1647 }1728 }
1648 }1729 }
1649 }1730 }
16501731
1651 _LIBCPP_INLINE_VISIBILITY1732 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1652 void __copy_assign_alloc(const basic_string&, false_type) _NOEXCEPT1733 void __copy_assign_alloc(const basic_string&, false_type) _NOEXCEPT
1653 {}1734 {}
16541735
1655#ifndef _LIBCPP_CXX03_LANG1736#ifndef _LIBCPP_CXX03_LANG
1656 _LIBCPP_INLINE_VISIBILITY1737 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1657 void __move_assign(basic_string& __str, false_type)1738 void __move_assign(basic_string& __str, false_type)
1658 _NOEXCEPT_(__alloc_traits::is_always_equal::value);1739 _NOEXCEPT_(__alloc_traits::is_always_equal::value);
1659 _LIBCPP_INLINE_VISIBILITY1740 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1660 void __move_assign(basic_string& __str, true_type)1741 void __move_assign(basic_string& __str, true_type)
1661#if _LIBCPP_STD_VER > 141742#if _LIBCPP_STD_VER > 14
1662 _NOEXCEPT;1743 _NOEXCEPT;
...@@ -1665,7 +1746,7 @@ private:...@@ -1665,7 +1746,7 @@ private:
1665#endif1746#endif
1666#endif1747#endif
16671748
1668 _LIBCPP_INLINE_VISIBILITY1749 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1669 void1750 void
1670 __move_assign_alloc(basic_string& __str)1751 __move_assign_alloc(basic_string& __str)
1671 _NOEXCEPT_(1752 _NOEXCEPT_(
...@@ -1674,78 +1755,83 @@ private:...@@ -1674,78 +1755,83 @@ private:
1674 {__move_assign_alloc(__str, integral_constant<bool,1755 {__move_assign_alloc(__str, integral_constant<bool,
1675 __alloc_traits::propagate_on_container_move_assignment::value>());}1756 __alloc_traits::propagate_on_container_move_assignment::value>());}
16761757
1677 _LIBCPP_INLINE_VISIBILITY1758 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1678 void __move_assign_alloc(basic_string& __c, true_type)1759 void __move_assign_alloc(basic_string& __c, true_type)
1679 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)1760 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
1680 {1761 {
1681 __alloc() = _VSTD::move(__c.__alloc());1762 __alloc() = std::move(__c.__alloc());
1682 }1763 }
16831764
1684 _LIBCPP_INLINE_VISIBILITY1765 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1685 void __move_assign_alloc(basic_string&, false_type)1766 void __move_assign_alloc(basic_string&, false_type)
1686 _NOEXCEPT1767 _NOEXCEPT
1687 {}1768 {}
16881769
1689 basic_string& __assign_external(const value_type* __s);1770 _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& __assign_external(const value_type* __s);
1690 basic_string& __assign_external(const value_type* __s, size_type __n);1771 _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& __assign_external(const value_type* __s, size_type __n);
16911772
1692 // Assigns the value in __s, guaranteed to be __n < __min_cap in length.1773 // Assigns the value in __s, guaranteed to be __n < __min_cap in length.
1693 inline basic_string& __assign_short(const value_type* __s, size_type __n) {1774 inline basic_string& __assign_short(const value_type* __s, size_type __n) {
1694 pointer __p = __is_long()1775 pointer __p = __is_long()
1695 ? (__set_long_size(__n), __get_long_pointer())1776 ? (__set_long_size(__n), __get_long_pointer())
1696 : (__set_short_size(__n), __get_short_pointer());1777 : (__set_short_size(__n), __get_short_pointer());
1697 traits_type::move(_VSTD::__to_address(__p), __s, __n);1778 traits_type::move(std::__to_address(__p), __s, __n);
1698 traits_type::assign(__p[__n], value_type());1779 traits_type::assign(__p[__n], value_type());
1699 return *this;1780 return *this;
1700 }1781 }
17011782
1702 _LIBCPP_HIDE_FROM_ABI basic_string& __null_terminate_at(value_type* __p, size_type __newsz) {1783 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1784 basic_string& __null_terminate_at(value_type* __p, size_type __newsz) {
1703 __set_size(__newsz);1785 __set_size(__newsz);
1704 __invalidate_iterators_past(__newsz);1786 __invalidate_iterators_past(__newsz);
1705 traits_type::assign(__p[__newsz], value_type());1787 traits_type::assign(__p[__newsz], value_type());
1706 return *this;1788 return *this;
1707 }1789 }
17081790
1709 _LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators();1791 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __invalidate_iterators_past(size_type);
1710 _LIBCPP_INLINE_VISIBILITY void __invalidate_iterators_past(size_type);
17111792
1712 template<class _Tp>1793 template<class _Tp>
1713 _LIBCPP_INLINE_VISIBILITY1794 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1714 bool __addr_in_range(_Tp&& __t) const {1795 bool __addr_in_range(_Tp&& __t) const {
1715 const volatile void *__p = _VSTD::addressof(__t);1796 // assume that the ranges overlap, because we can't check during constant evaluation
1797 if (__libcpp_is_constant_evaluated())
1798 return true;
1799 const volatile void *__p = std::addressof(__t);
1716 return data() <= __p && __p <= data() + size();1800 return data() <= __p && __p <= data() + size();
1717 }1801 }
17181802
1719 _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI1803 _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI
1720 void __throw_length_error() const {1804 void __throw_length_error() const {
1721 _VSTD::__throw_length_error("basic_string");1805 std::__throw_length_error("basic_string");
1722 }1806 }
17231807
1724 _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI1808 _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI
1725 void __throw_out_of_range() const {1809 void __throw_out_of_range() const {
1726 _VSTD::__throw_out_of_range("basic_string");1810 std::__throw_out_of_range("basic_string");
1727 }1811 }
17281812
1729 friend basic_string operator+<>(const basic_string&, const basic_string&);1813 friend _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string operator+<>(const basic_string&, const basic_string&);
1730 friend basic_string operator+<>(const value_type*, const basic_string&);1814 friend _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string operator+<>(const value_type*, const basic_string&);
1731 friend basic_string operator+<>(value_type, const basic_string&);1815 friend _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string operator+<>(value_type, const basic_string&);
1732 friend basic_string operator+<>(const basic_string&, const value_type*);1816 friend _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string operator+<>(const basic_string&, const value_type*);
1733 friend basic_string operator+<>(const basic_string&, value_type);1817 friend _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string operator+<>(const basic_string&, value_type);
1734};1818};
17351819
1736// These declarations must appear before any functions are implicitly used1820// These declarations must appear before any functions are implicitly used
1737// so that they have the correct visibility specifier.1821// so that they have the correct visibility specifier.
1822#define _LIBCPP_DECLARE(...) extern template __VA_ARGS__;
1738#ifdef _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION1823#ifdef _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION
1739 _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, char)1824 _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_DECLARE, char)
1740# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS1825# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
1741 _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, wchar_t)1826 _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_DECLARE, wchar_t)
1742# endif1827# endif
1743#else1828#else
1744 _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, char)1829 _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_DECLARE, char)
1745# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS1830# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
1746 _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, wchar_t)1831 _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_DECLARE, wchar_t)
1747# endif1832# endif
1748#endif1833#endif
1834#undef _LIBCPP_DECLARE
17491835
17501836
1751#if _LIBCPP_STD_VER >= 171837#if _LIBCPP_STD_VER >= 17
...@@ -1777,22 +1863,11 @@ basic_string(basic_string_view<_CharT, _Traits>, _Sz, _Sz, const _Allocator& = _...@@ -1777,22 +1863,11 @@ basic_string(basic_string_view<_CharT, _Traits>, _Sz, _Sz, const _Allocator& = _
1777#endif1863#endif
17781864
1779template <class _CharT, class _Traits, class _Allocator>1865template <class _CharT, class _Traits, class _Allocator>
1780inline1866inline _LIBCPP_CONSTEXPR_AFTER_CXX17
1781void
1782basic_string<_CharT, _Traits, _Allocator>::__invalidate_all_iterators()
1783{
1784#if _LIBCPP_DEBUG_LEVEL == 2
1785 if (!__libcpp_is_constant_evaluated())
1786 __get_db()->__invalidate_all(this);
1787#endif
1788}
1789
1790template <class _CharT, class _Traits, class _Allocator>
1791inline
1792void1867void
1793basic_string<_CharT, _Traits, _Allocator>::__invalidate_iterators_past(size_type __pos)1868basic_string<_CharT, _Traits, _Allocator>::__invalidate_iterators_past(size_type __pos)
1794{1869{
1795#if _LIBCPP_DEBUG_LEVEL == 21870#ifdef _LIBCPP_ENABLE_DEBUG_MODE
1796 if (!__libcpp_is_constant_evaluated()) {1871 if (!__libcpp_is_constant_evaluated()) {
1797 __c_node* __c = __get_db()->__find_c_and_lock(this);1872 __c_node* __c = __get_db()->__find_c_and_lock(this);
1798 if (__c)1873 if (__c)
...@@ -1806,7 +1881,7 @@ basic_string<_CharT, _Traits, _Allocator>::__invalidate_iterators_past(size_type...@@ -1806,7 +1881,7 @@ basic_string<_CharT, _Traits, _Allocator>::__invalidate_iterators_past(size_type
1806 {1881 {
1807 (*__p)->__c_ = nullptr;1882 (*__p)->__c_ = nullptr;
1808 if (--__c->end_ != __p)1883 if (--__c->end_ != __p)
1809 _VSTD::memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));1884 std::memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
1810 }1885 }
1811 }1886 }
1812 __get_db()->unlock();1887 __get_db()->unlock();
...@@ -1814,21 +1889,21 @@ basic_string<_CharT, _Traits, _Allocator>::__invalidate_iterators_past(size_type...@@ -1814,21 +1889,21 @@ basic_string<_CharT, _Traits, _Allocator>::__invalidate_iterators_past(size_type
1814 }1889 }
1815#else1890#else
1816 (void)__pos;1891 (void)__pos;
1817#endif // _LIBCPP_DEBUG_LEVEL == 21892#endif // _LIBCPP_ENABLE_DEBUG_MODE
1818}1893}
18191894
1820template <class _CharT, class _Traits, class _Allocator>1895template <class _CharT, class _Traits, class _Allocator>
1821inline1896inline _LIBCPP_CONSTEXPR_AFTER_CXX17
1822basic_string<_CharT, _Traits, _Allocator>::basic_string()1897basic_string<_CharT, _Traits, _Allocator>::basic_string()
1823 _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)1898 _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
1824 : __r_(__default_init_tag(), __default_init_tag())1899 : __r_(__default_init_tag(), __default_init_tag())
1825{1900{
1826 _VSTD::__debug_db_insert_c(this);1901 std::__debug_db_insert_c(this);
1827 __zero();1902 __default_init();
1828}1903}
18291904
1830template <class _CharT, class _Traits, class _Allocator>1905template <class _CharT, class _Traits, class _Allocator>
1831inline1906inline _LIBCPP_CONSTEXPR_AFTER_CXX17
1832basic_string<_CharT, _Traits, _Allocator>::basic_string(const allocator_type& __a)1907basic_string<_CharT, _Traits, _Allocator>::basic_string(const allocator_type& __a)
1833#if _LIBCPP_STD_VER <= 141908#if _LIBCPP_STD_VER <= 14
1834 _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)1909 _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)
...@@ -1837,15 +1912,18 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const allocator_type& __...@@ -1837,15 +1912,18 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const allocator_type& __
1837#endif1912#endif
1838: __r_(__default_init_tag(), __a)1913: __r_(__default_init_tag(), __a)
1839{1914{
1840 _VSTD::__debug_db_insert_c(this);1915 std::__debug_db_insert_c(this);
1841 __zero();1916 __default_init();
1842}1917}
18431918
1844template <class _CharT, class _Traits, class _Allocator>1919template <class _CharT, class _Traits, class _Allocator>
1920_LIBCPP_CONSTEXPR_AFTER_CXX17
1845void basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s,1921void basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s,
1846 size_type __sz,1922 size_type __sz,
1847 size_type __reserve)1923 size_type __reserve)
1848{1924{
1925 if (__libcpp_is_constant_evaluated())
1926 __zero();
1849 if (__reserve > max_size())1927 if (__reserve > max_size())
1850 __throw_length_error();1928 __throw_length_error();
1851 pointer __p;1929 pointer __p;
...@@ -1856,20 +1934,24 @@ void basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s,...@@ -1856,20 +1934,24 @@ void basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s,
1856 }1934 }
1857 else1935 else
1858 {1936 {
1859 size_type __cap = __recommend(__reserve);1937 auto __allocation = std::__allocate_at_least(__alloc(), __recommend(__reserve) + 1);
1860 __p = __alloc_traits::allocate(__alloc(), __cap+1);1938 __p = __allocation.ptr;
1939 __begin_lifetime(__p, __allocation.count);
1861 __set_long_pointer(__p);1940 __set_long_pointer(__p);
1862 __set_long_cap(__cap+1);1941 __set_long_cap(__allocation.count);
1863 __set_long_size(__sz);1942 __set_long_size(__sz);
1864 }1943 }
1865 traits_type::copy(_VSTD::__to_address(__p), __s, __sz);1944 traits_type::copy(std::__to_address(__p), __s, __sz);
1866 traits_type::assign(__p[__sz], value_type());1945 traits_type::assign(__p[__sz], value_type());
1867}1946}
18681947
1869template <class _CharT, class _Traits, class _Allocator>1948template <class _CharT, class _Traits, class _Allocator>
1949_LIBCPP_CONSTEXPR_AFTER_CXX17
1870void1950void
1871basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_type __sz)1951basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_type __sz)
1872{1952{
1953 if (__libcpp_is_constant_evaluated())
1954 __zero();
1873 if (__sz > max_size())1955 if (__sz > max_size())
1874 __throw_length_error();1956 __throw_length_error();
1875 pointer __p;1957 pointer __p;
...@@ -1880,59 +1962,63 @@ basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_ty...@@ -1880,59 +1962,63 @@ basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_ty
1880 }1962 }
1881 else1963 else
1882 {1964 {
1883 size_type __cap = __recommend(__sz);1965 auto __allocation = std::__allocate_at_least(__alloc(), __recommend(__sz) + 1);
1884 __p = __alloc_traits::allocate(__alloc(), __cap+1);1966 __p = __allocation.ptr;
1967 __begin_lifetime(__p, __allocation.count);
1885 __set_long_pointer(__p);1968 __set_long_pointer(__p);
1886 __set_long_cap(__cap+1);1969 __set_long_cap(__allocation.count);
1887 __set_long_size(__sz);1970 __set_long_size(__sz);
1888 }1971 }
1889 traits_type::copy(_VSTD::__to_address(__p), __s, __sz);1972 traits_type::copy(std::__to_address(__p), __s, __sz);
1890 traits_type::assign(__p[__sz], value_type());1973 traits_type::assign(__p[__sz], value_type());
1891}1974}
18921975
1893template <class _CharT, class _Traits, class _Allocator>1976template <class _CharT, class _Traits, class _Allocator>
1894template <class>1977template <class>
1978_LIBCPP_CONSTEXPR_AFTER_CXX17
1895basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, const _Allocator& __a)1979basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, const _Allocator& __a)
1896 : __r_(__default_init_tag(), __a)1980 : __r_(__default_init_tag(), __a)
1897{1981{
1898 _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*, allocator) detected nullptr");1982 _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*, allocator) detected nullptr");
1899 __init(__s, traits_type::length(__s));1983 __init(__s, traits_type::length(__s));
1900 _VSTD::__debug_db_insert_c(this);1984 std::__debug_db_insert_c(this);
1901}1985}
19021986
1903template <class _CharT, class _Traits, class _Allocator>1987template <class _CharT, class _Traits, class _Allocator>
1904inline1988inline _LIBCPP_CONSTEXPR_AFTER_CXX17
1905basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, size_type __n)1989basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, size_type __n)
1906 : __r_(__default_init_tag(), __default_init_tag())1990 : __r_(__default_init_tag(), __default_init_tag())
1907{1991{
1908 _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n) detected nullptr");1992 _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n) detected nullptr");
1909 __init(__s, __n);1993 __init(__s, __n);
1910 _VSTD::__debug_db_insert_c(this);1994 std::__debug_db_insert_c(this);
1911}1995}
19121996
1913template <class _CharT, class _Traits, class _Allocator>1997template <class _CharT, class _Traits, class _Allocator>
1914inline1998inline _LIBCPP_CONSTEXPR_AFTER_CXX17
1915basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, size_type __n, const _Allocator& __a)1999basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, size_type __n, const _Allocator& __a)
1916 : __r_(__default_init_tag(), __a)2000 : __r_(__default_init_tag(), __a)
1917{2001{
1918 _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n, allocator) detected nullptr");2002 _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n, allocator) detected nullptr");
1919 __init(__s, __n);2003 __init(__s, __n);
1920 _VSTD::__debug_db_insert_c(this);2004 std::__debug_db_insert_c(this);
1921}2005}
19222006
1923template <class _CharT, class _Traits, class _Allocator>2007template <class _CharT, class _Traits, class _Allocator>
2008_LIBCPP_CONSTEXPR_AFTER_CXX17
1924basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str)2009basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str)
1925 : __r_(__default_init_tag(), __alloc_traits::select_on_container_copy_construction(__str.__alloc()))2010 : __r_(__default_init_tag(), __alloc_traits::select_on_container_copy_construction(__str.__alloc()))
1926{2011{
1927 if (!__str.__is_long())2012 if (!__str.__is_long())
1928 __r_.first().__r = __str.__r_.first().__r;2013 __r_.first().__r = __str.__r_.first().__r;
1929 else2014 else
1930 __init_copy_ctor_external(_VSTD::__to_address(__str.__get_long_pointer()),2015 __init_copy_ctor_external(std::__to_address(__str.__get_long_pointer()),
1931 __str.__get_long_size());2016 __str.__get_long_size());
1932 _VSTD::__debug_db_insert_c(this);2017 std::__debug_db_insert_c(this);
1933}2018}
19342019
1935template <class _CharT, class _Traits, class _Allocator>2020template <class _CharT, class _Traits, class _Allocator>
2021_LIBCPP_CONSTEXPR_AFTER_CXX17
1936basic_string<_CharT, _Traits, _Allocator>::basic_string(2022basic_string<_CharT, _Traits, _Allocator>::basic_string(
1937 const basic_string& __str, const allocator_type& __a)2023 const basic_string& __str, const allocator_type& __a)
1938 : __r_(__default_init_tag(), __a)2024 : __r_(__default_init_tag(), __a)
...@@ -1940,14 +2026,17 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(...@@ -1940,14 +2026,17 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(
1940 if (!__str.__is_long())2026 if (!__str.__is_long())
1941 __r_.first().__r = __str.__r_.first().__r;2027 __r_.first().__r = __str.__r_.first().__r;
1942 else2028 else
1943 __init_copy_ctor_external(_VSTD::__to_address(__str.__get_long_pointer()),2029 __init_copy_ctor_external(std::__to_address(__str.__get_long_pointer()),
1944 __str.__get_long_size());2030 __str.__get_long_size());
1945 _VSTD::__debug_db_insert_c(this);2031 std::__debug_db_insert_c(this);
1946}2032}
19472033
1948template <class _CharT, class _Traits, class _Allocator>2034template <class _CharT, class _Traits, class _Allocator>
2035_LIBCPP_CONSTEXPR_AFTER_CXX17
1949void basic_string<_CharT, _Traits, _Allocator>::__init_copy_ctor_external(2036void basic_string<_CharT, _Traits, _Allocator>::__init_copy_ctor_external(
1950 const value_type* __s, size_type __sz) {2037 const value_type* __s, size_type __sz) {
2038 if (__libcpp_is_constant_evaluated())
2039 __zero();
1951 pointer __p;2040 pointer __p;
1952 if (__fits_in_sso(__sz)) {2041 if (__fits_in_sso(__sz)) {
1953 __p = __get_short_pointer();2042 __p = __get_short_pointer();
...@@ -1955,60 +2044,65 @@ void basic_string<_CharT, _Traits, _Allocator>::__init_copy_ctor_external(...@@ -1955,60 +2044,65 @@ void basic_string<_CharT, _Traits, _Allocator>::__init_copy_ctor_external(
1955 } else {2044 } else {
1956 if (__sz > max_size())2045 if (__sz > max_size())
1957 __throw_length_error();2046 __throw_length_error();
1958 size_t __cap = __recommend(__sz);2047 auto __allocation = std::__allocate_at_least(__alloc(), __recommend(__sz) + 1);
1959 __p = __alloc_traits::allocate(__alloc(), __cap + 1);2048 __p = __allocation.ptr;
2049 __begin_lifetime(__p, __allocation.count);
1960 __set_long_pointer(__p);2050 __set_long_pointer(__p);
1961 __set_long_cap(__cap + 1);2051 __set_long_cap(__allocation.count);
1962 __set_long_size(__sz);2052 __set_long_size(__sz);
1963 }2053 }
1964 traits_type::copy(_VSTD::__to_address(__p), __s, __sz + 1);2054 traits_type::copy(std::__to_address(__p), __s, __sz + 1);
1965}2055}
19662056
1967#ifndef _LIBCPP_CXX03_LANG2057#ifndef _LIBCPP_CXX03_LANG
19682058
1969template <class _CharT, class _Traits, class _Allocator>2059template <class _CharT, class _Traits, class _Allocator>
1970inline2060inline _LIBCPP_CONSTEXPR_AFTER_CXX17
1971basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str)2061basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str)
1972#if _LIBCPP_STD_VER <= 142062#if _LIBCPP_STD_VER <= 14
1973 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)2063 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
1974#else2064#else
1975 _NOEXCEPT2065 _NOEXCEPT
1976#endif2066#endif
1977 : __r_(_VSTD::move(__str.__r_))2067 : __r_(std::move(__str.__r_))
1978{2068{
1979 __str.__zero();2069 __str.__default_init();
1980 _VSTD::__debug_db_insert_c(this);2070 std::__debug_db_insert_c(this);
1981#if _LIBCPP_DEBUG_LEVEL == 22071 if (__is_long())
1982 if (!__libcpp_is_constant_evaluated() && __is_long())2072 std::__debug_db_swap(this, &__str);
1983 __get_db()->swap(this, &__str);
1984#endif
1985}2073}
19862074
1987template <class _CharT, class _Traits, class _Allocator>2075template <class _CharT, class _Traits, class _Allocator>
1988inline2076inline _LIBCPP_CONSTEXPR_AFTER_CXX17
1989basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str, const allocator_type& __a)2077basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str, const allocator_type& __a)
1990 : __r_(__default_init_tag(), __a)2078 : __r_(__default_init_tag(), __a)
1991{2079{
1992 if (__str.__is_long() && __a != __str.__alloc()) // copy, not move2080 if (__str.__is_long() && __a != __str.__alloc()) // copy, not move
1993 __init(_VSTD::__to_address(__str.__get_long_pointer()), __str.__get_long_size());2081 __init(std::__to_address(__str.__get_long_pointer()), __str.__get_long_size());
1994 else2082 else
1995 {2083 {
1996 __r_.first().__r = __str.__r_.first().__r;2084 if (__libcpp_is_constant_evaluated()) {
1997 __str.__zero();2085 __zero();
2086 __r_.first().__l = __str.__r_.first().__l;
2087 } else {
2088 __r_.first().__r = __str.__r_.first().__r;
2089 }
2090 __str.__default_init();
1998 }2091 }
1999 _VSTD::__debug_db_insert_c(this);2092 std::__debug_db_insert_c(this);
2000#if _LIBCPP_DEBUG_LEVEL == 22093 if (__is_long())
2001 if (!__libcpp_is_constant_evaluated() && __is_long())2094 std::__debug_db_swap(this, &__str);
2002 __get_db()->swap(this, &__str);
2003#endif
2004}2095}
20052096
2006#endif // _LIBCPP_CXX03_LANG2097#endif // _LIBCPP_CXX03_LANG
20072098
2008template <class _CharT, class _Traits, class _Allocator>2099template <class _CharT, class _Traits, class _Allocator>
2100_LIBCPP_CONSTEXPR_AFTER_CXX17
2009void2101void
2010basic_string<_CharT, _Traits, _Allocator>::__init(size_type __n, value_type __c)2102basic_string<_CharT, _Traits, _Allocator>::__init(size_type __n, value_type __c)
2011{2103{
2104 if (__libcpp_is_constant_evaluated())
2105 __zero();
2012 if (__n > max_size())2106 if (__n > max_size())
2013 __throw_length_error();2107 __throw_length_error();
2014 pointer __p;2108 pointer __p;
...@@ -2019,35 +2113,38 @@ basic_string<_CharT, _Traits, _Allocator>::__init(size_type __n, value_type __c)...@@ -2019,35 +2113,38 @@ basic_string<_CharT, _Traits, _Allocator>::__init(size_type __n, value_type __c)
2019 }2113 }
2020 else2114 else
2021 {2115 {
2022 size_type __cap = __recommend(__n);2116 auto __allocation = std::__allocate_at_least(__alloc(), __recommend(__n) + 1);
2023 __p = __alloc_traits::allocate(__alloc(), __cap+1);2117 __p = __allocation.ptr;
2118 __begin_lifetime(__p, __allocation.count);
2024 __set_long_pointer(__p);2119 __set_long_pointer(__p);
2025 __set_long_cap(__cap+1);2120 __set_long_cap(__allocation.count);
2026 __set_long_size(__n);2121 __set_long_size(__n);
2027 }2122 }
2028 traits_type::assign(_VSTD::__to_address(__p), __n, __c);2123 traits_type::assign(std::__to_address(__p), __n, __c);
2029 traits_type::assign(__p[__n], value_type());2124 traits_type::assign(__p[__n], value_type());
2030}2125}
20312126
2032template <class _CharT, class _Traits, class _Allocator>2127template <class _CharT, class _Traits, class _Allocator>
2033inline2128inline _LIBCPP_CONSTEXPR_AFTER_CXX17
2034basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, _CharT __c)2129basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, _CharT __c)
2035 : __r_(__default_init_tag(), __default_init_tag())2130 : __r_(__default_init_tag(), __default_init_tag())
2036{2131{
2037 __init(__n, __c);2132 __init(__n, __c);
2038 _VSTD::__debug_db_insert_c(this);2133 std::__debug_db_insert_c(this);
2039}2134}
20402135
2041template <class _CharT, class _Traits, class _Allocator>2136template <class _CharT, class _Traits, class _Allocator>
2042template <class>2137template <class>
2138_LIBCPP_CONSTEXPR_AFTER_CXX17
2043basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, _CharT __c, const _Allocator& __a)2139basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, _CharT __c, const _Allocator& __a)
2044 : __r_(__default_init_tag(), __a)2140 : __r_(__default_init_tag(), __a)
2045{2141{
2046 __init(__n, __c);2142 __init(__n, __c);
2047 _VSTD::__debug_db_insert_c(this);2143 std::__debug_db_insert_c(this);
2048}2144}
20492145
2050template <class _CharT, class _Traits, class _Allocator>2146template <class _CharT, class _Traits, class _Allocator>
2147_LIBCPP_CONSTEXPR_AFTER_CXX17
2051basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str,2148basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str,
2052 size_type __pos, size_type __n,2149 size_type __pos, size_type __n,
2053 const _Allocator& __a)2150 const _Allocator& __a)
...@@ -2056,12 +2153,12 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st...@@ -2056,12 +2153,12 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st
2056 size_type __str_sz = __str.size();2153 size_type __str_sz = __str.size();
2057 if (__pos > __str_sz)2154 if (__pos > __str_sz)
2058 __throw_out_of_range();2155 __throw_out_of_range();
2059 __init(__str.data() + __pos, _VSTD::min(__n, __str_sz - __pos));2156 __init(__str.data() + __pos, std::min(__n, __str_sz - __pos));
2060 _VSTD::__debug_db_insert_c(this);2157 std::__debug_db_insert_c(this);
2061}2158}
20622159
2063template <class _CharT, class _Traits, class _Allocator>2160template <class _CharT, class _Traits, class _Allocator>
2064inline2161inline _LIBCPP_CONSTEXPR_AFTER_CXX17
2065basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str, size_type __pos,2162basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str, size_type __pos,
2066 const _Allocator& __a)2163 const _Allocator& __a)
2067 : __r_(__default_init_tag(), __a)2164 : __r_(__default_init_tag(), __a)
...@@ -2070,11 +2167,12 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st...@@ -2070,11 +2167,12 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st
2070 if (__pos > __str_sz)2167 if (__pos > __str_sz)
2071 __throw_out_of_range();2168 __throw_out_of_range();
2072 __init(__str.data() + __pos, __str_sz - __pos);2169 __init(__str.data() + __pos, __str_sz - __pos);
2073 _VSTD::__debug_db_insert_c(this);2170 std::__debug_db_insert_c(this);
2074}2171}
20752172
2076template <class _CharT, class _Traits, class _Allocator>2173template <class _CharT, class _Traits, class _Allocator>
2077template <class _Tp, class>2174template <class _Tp, class>
2175_LIBCPP_CONSTEXPR_AFTER_CXX17
2078basic_string<_CharT, _Traits, _Allocator>::basic_string(2176basic_string<_CharT, _Traits, _Allocator>::basic_string(
2079 const _Tp& __t, size_type __pos, size_type __n, const allocator_type& __a)2177 const _Tp& __t, size_type __pos, size_type __n, const allocator_type& __a)
2080 : __r_(__default_init_tag(), __a)2178 : __r_(__default_init_tag(), __a)
...@@ -2082,38 +2180,41 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(...@@ -2082,38 +2180,41 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(
2082 __self_view __sv0 = __t;2180 __self_view __sv0 = __t;
2083 __self_view __sv = __sv0.substr(__pos, __n);2181 __self_view __sv = __sv0.substr(__pos, __n);
2084 __init(__sv.data(), __sv.size());2182 __init(__sv.data(), __sv.size());
2085 _VSTD::__debug_db_insert_c(this);2183 std::__debug_db_insert_c(this);
2086}2184}
20872185
2088template <class _CharT, class _Traits, class _Allocator>2186template <class _CharT, class _Traits, class _Allocator>
2089template <class _Tp, class>2187template <class _Tp, class>
2188_LIBCPP_CONSTEXPR_AFTER_CXX17
2090basic_string<_CharT, _Traits, _Allocator>::basic_string(const _Tp & __t)2189basic_string<_CharT, _Traits, _Allocator>::basic_string(const _Tp & __t)
2091 : __r_(__default_init_tag(), __default_init_tag())2190 : __r_(__default_init_tag(), __default_init_tag())
2092{2191{
2093 __self_view __sv = __t;2192 __self_view __sv = __t;
2094 __init(__sv.data(), __sv.size());2193 __init(__sv.data(), __sv.size());
2095 _VSTD::__debug_db_insert_c(this);2194 std::__debug_db_insert_c(this);
2096}2195}
20972196
2098template <class _CharT, class _Traits, class _Allocator>2197template <class _CharT, class _Traits, class _Allocator>
2099template <class _Tp, class>2198template <class _Tp, class>
2199_LIBCPP_CONSTEXPR_AFTER_CXX17
2100basic_string<_CharT, _Traits, _Allocator>::basic_string(const _Tp & __t, const _Allocator& __a)2200basic_string<_CharT, _Traits, _Allocator>::basic_string(const _Tp & __t, const _Allocator& __a)
2101 : __r_(__default_init_tag(), __a)2201 : __r_(__default_init_tag(), __a)
2102{2202{
2103 __self_view __sv = __t;2203 __self_view __sv = __t;
2104 __init(__sv.data(), __sv.size());2204 __init(__sv.data(), __sv.size());
2105 _VSTD::__debug_db_insert_c(this);2205 std::__debug_db_insert_c(this);
2106}2206}
21072207
2108template <class _CharT, class _Traits, class _Allocator>2208template <class _CharT, class _Traits, class _Allocator>
2109template <class _InputIterator>2209template <class _InputIterator>
2210_LIBCPP_CONSTEXPR_AFTER_CXX17
2110__enable_if_t2211__enable_if_t
2111<2212<
2112 __is_exactly_cpp17_input_iterator<_InputIterator>::value2213 __is_exactly_cpp17_input_iterator<_InputIterator>::value
2113>2214>
2114basic_string<_CharT, _Traits, _Allocator>::__init(_InputIterator __first, _InputIterator __last)2215basic_string<_CharT, _Traits, _Allocator>::__init(_InputIterator __first, _InputIterator __last)
2115{2216{
2116 __zero();2217 __default_init();
2117#ifndef _LIBCPP_NO_EXCEPTIONS2218#ifndef _LIBCPP_NO_EXCEPTIONS
2118 try2219 try
2119 {2220 {
...@@ -2133,13 +2234,16 @@ basic_string<_CharT, _Traits, _Allocator>::__init(_InputIterator __first, _Input...@@ -2133,13 +2234,16 @@ basic_string<_CharT, _Traits, _Allocator>::__init(_InputIterator __first, _Input
21332234
2134template <class _CharT, class _Traits, class _Allocator>2235template <class _CharT, class _Traits, class _Allocator>
2135template <class _ForwardIterator>2236template <class _ForwardIterator>
2237_LIBCPP_CONSTEXPR_AFTER_CXX17
2136__enable_if_t2238__enable_if_t
2137<2239<
2138 __is_cpp17_forward_iterator<_ForwardIterator>::value2240 __is_cpp17_forward_iterator<_ForwardIterator>::value
2139>2241>
2140basic_string<_CharT, _Traits, _Allocator>::__init(_ForwardIterator __first, _ForwardIterator __last)2242basic_string<_CharT, _Traits, _Allocator>::__init(_ForwardIterator __first, _ForwardIterator __last)
2141{2243{
2142 size_type __sz = static_cast<size_type>(_VSTD::distance(__first, __last));2244 if (__libcpp_is_constant_evaluated())
2245 __zero();
2246 size_type __sz = static_cast<size_type>(std::distance(__first, __last));
2143 if (__sz > max_size())2247 if (__sz > max_size())
2144 __throw_length_error();2248 __throw_length_error();
2145 pointer __p;2249 pointer __p;
...@@ -2150,10 +2254,11 @@ basic_string<_CharT, _Traits, _Allocator>::__init(_ForwardIterator __first, _For...@@ -2150,10 +2254,11 @@ basic_string<_CharT, _Traits, _Allocator>::__init(_ForwardIterator __first, _For
2150 }2254 }
2151 else2255 else
2152 {2256 {
2153 size_type __cap = __recommend(__sz);2257 auto __allocation = std::__allocate_at_least(__alloc(), __recommend(__sz) + 1);
2154 __p = __alloc_traits::allocate(__alloc(), __cap+1);2258 __p = __allocation.ptr;
2259 __begin_lifetime(__p, __allocation.count);
2155 __set_long_pointer(__p);2260 __set_long_pointer(__p);
2156 __set_long_cap(__cap+1);2261 __set_long_cap(__allocation.count);
2157 __set_long_size(__sz);2262 __set_long_size(__sz);
2158 }2263 }
21592264
...@@ -2177,62 +2282,60 @@ basic_string<_CharT, _Traits, _Allocator>::__init(_ForwardIterator __first, _For...@@ -2177,62 +2282,60 @@ basic_string<_CharT, _Traits, _Allocator>::__init(_ForwardIterator __first, _For
21772282
2178template <class _CharT, class _Traits, class _Allocator>2283template <class _CharT, class _Traits, class _Allocator>
2179template<class _InputIterator, class>2284template<class _InputIterator, class>
2180inline2285inline _LIBCPP_CONSTEXPR_AFTER_CXX17
2181basic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIterator __first, _InputIterator __last)2286basic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIterator __first, _InputIterator __last)
2182 : __r_(__default_init_tag(), __default_init_tag())2287 : __r_(__default_init_tag(), __default_init_tag())
2183{2288{
2184 __init(__first, __last);2289 __init(__first, __last);
2185 _VSTD::__debug_db_insert_c(this);2290 std::__debug_db_insert_c(this);
2186}2291}
21872292
2188template <class _CharT, class _Traits, class _Allocator>2293template <class _CharT, class _Traits, class _Allocator>
2189template<class _InputIterator, class>2294template<class _InputIterator, class>
2190inline2295inline _LIBCPP_CONSTEXPR_AFTER_CXX17
2191basic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIterator __first, _InputIterator __last,2296basic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIterator __first, _InputIterator __last,
2192 const allocator_type& __a)2297 const allocator_type& __a)
2193 : __r_(__default_init_tag(), __a)2298 : __r_(__default_init_tag(), __a)
2194{2299{
2195 __init(__first, __last);2300 __init(__first, __last);
2196 _VSTD::__debug_db_insert_c(this);2301 std::__debug_db_insert_c(this);
2197}2302}
21982303
2199#ifndef _LIBCPP_CXX03_LANG2304#ifndef _LIBCPP_CXX03_LANG
22002305
2201template <class _CharT, class _Traits, class _Allocator>2306template <class _CharT, class _Traits, class _Allocator>
2202inline2307inline _LIBCPP_CONSTEXPR_AFTER_CXX17
2203basic_string<_CharT, _Traits, _Allocator>::basic_string(2308basic_string<_CharT, _Traits, _Allocator>::basic_string(
2204 initializer_list<_CharT> __il)2309 initializer_list<_CharT> __il)
2205 : __r_(__default_init_tag(), __default_init_tag())2310 : __r_(__default_init_tag(), __default_init_tag())
2206{2311{
2207 __init(__il.begin(), __il.end());2312 __init(__il.begin(), __il.end());
2208 _VSTD::__debug_db_insert_c(this);2313 std::__debug_db_insert_c(this);
2209}2314}
22102315
2211template <class _CharT, class _Traits, class _Allocator>2316template <class _CharT, class _Traits, class _Allocator>
2212inline2317inline _LIBCPP_CONSTEXPR_AFTER_CXX17
2213
2214basic_string<_CharT, _Traits, _Allocator>::basic_string(2318basic_string<_CharT, _Traits, _Allocator>::basic_string(
2215 initializer_list<_CharT> __il, const _Allocator& __a)2319 initializer_list<_CharT> __il, const _Allocator& __a)
2216 : __r_(__default_init_tag(), __a)2320 : __r_(__default_init_tag(), __a)
2217{2321{
2218 __init(__il.begin(), __il.end());2322 __init(__il.begin(), __il.end());
2219 _VSTD::__debug_db_insert_c(this);2323 std::__debug_db_insert_c(this);
2220}2324}
22212325
2222#endif // _LIBCPP_CXX03_LANG2326#endif // _LIBCPP_CXX03_LANG
22232327
2224template <class _CharT, class _Traits, class _Allocator>2328template <class _CharT, class _Traits, class _Allocator>
2329_LIBCPP_CONSTEXPR_AFTER_CXX17
2225basic_string<_CharT, _Traits, _Allocator>::~basic_string()2330basic_string<_CharT, _Traits, _Allocator>::~basic_string()
2226{2331{
2227#if _LIBCPP_DEBUG_LEVEL == 22332 std::__debug_db_erase_c(this);
2228 if (!__libcpp_is_constant_evaluated())
2229 __get_db()->__erase_c(this);
2230#endif
2231 if (__is_long())2333 if (__is_long())
2232 __alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap());2334 __alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap());
2233}2335}
22342336
2235template <class _CharT, class _Traits, class _Allocator>2337template <class _CharT, class _Traits, class _Allocator>
2338_LIBCPP_CONSTEXPR_AFTER_CXX17
2236void2339void
2237basic_string<_CharT, _Traits, _Allocator>::__grow_by_and_replace2340basic_string<_CharT, _Traits, _Allocator>::__grow_by_and_replace
2238 (size_type __old_cap, size_type __delta_cap, size_type __old_sz,2341 (size_type __old_cap, size_type __delta_cap, size_type __old_sz,
...@@ -2243,23 +2346,25 @@ basic_string<_CharT, _Traits, _Allocator>::__grow_by_and_replace...@@ -2243,23 +2346,25 @@ basic_string<_CharT, _Traits, _Allocator>::__grow_by_and_replace
2243 __throw_length_error();2346 __throw_length_error();
2244 pointer __old_p = __get_pointer();2347 pointer __old_p = __get_pointer();
2245 size_type __cap = __old_cap < __ms / 2 - __alignment ?2348 size_type __cap = __old_cap < __ms / 2 - __alignment ?
2246 __recommend(_VSTD::max(__old_cap + __delta_cap, 2 * __old_cap)) :2349 __recommend(std::max(__old_cap + __delta_cap, 2 * __old_cap)) :
2247 __ms - 1;2350 __ms - 1;
2248 pointer __p = __alloc_traits::allocate(__alloc(), __cap+1);2351 auto __allocation = std::__allocate_at_least(__alloc(), __cap + 1);
2249 __invalidate_all_iterators();2352 pointer __p = __allocation.ptr;
2353 __begin_lifetime(__p, __allocation.count);
2354 std::__debug_db_invalidate_all(this);
2250 if (__n_copy != 0)2355 if (__n_copy != 0)
2251 traits_type::copy(_VSTD::__to_address(__p),2356 traits_type::copy(std::__to_address(__p),
2252 _VSTD::__to_address(__old_p), __n_copy);2357 std::__to_address(__old_p), __n_copy);
2253 if (__n_add != 0)2358 if (__n_add != 0)
2254 traits_type::copy(_VSTD::__to_address(__p) + __n_copy, __p_new_stuff, __n_add);2359 traits_type::copy(std::__to_address(__p) + __n_copy, __p_new_stuff, __n_add);
2255 size_type __sec_cp_sz = __old_sz - __n_del - __n_copy;2360 size_type __sec_cp_sz = __old_sz - __n_del - __n_copy;
2256 if (__sec_cp_sz != 0)2361 if (__sec_cp_sz != 0)
2257 traits_type::copy(_VSTD::__to_address(__p) + __n_copy + __n_add,2362 traits_type::copy(std::__to_address(__p) + __n_copy + __n_add,
2258 _VSTD::__to_address(__old_p) + __n_copy + __n_del, __sec_cp_sz);2363 std::__to_address(__old_p) + __n_copy + __n_del, __sec_cp_sz);
2259 if (__old_cap+1 != __min_cap)2364 if (__old_cap+1 != __min_cap || __libcpp_is_constant_evaluated())
2260 __alloc_traits::deallocate(__alloc(), __old_p, __old_cap+1);2365 __alloc_traits::deallocate(__alloc(), __old_p, __old_cap+1);
2261 __set_long_pointer(__p);2366 __set_long_pointer(__p);
2262 __set_long_cap(__cap+1);2367 __set_long_cap(__allocation.count);
2263 __old_sz = __n_copy + __n_add + __sec_cp_sz;2368 __old_sz = __n_copy + __n_add + __sec_cp_sz;
2264 __set_long_size(__old_sz);2369 __set_long_size(__old_sz);
2265 traits_type::assign(__p[__old_sz], value_type());2370 traits_type::assign(__p[__old_sz], value_type());
...@@ -2267,6 +2372,7 @@ basic_string<_CharT, _Traits, _Allocator>::__grow_by_and_replace...@@ -2267,6 +2372,7 @@ basic_string<_CharT, _Traits, _Allocator>::__grow_by_and_replace
22672372
2268template <class _CharT, class _Traits, class _Allocator>2373template <class _CharT, class _Traits, class _Allocator>
2269void2374void
2375_LIBCPP_CONSTEXPR_AFTER_CXX17
2270basic_string<_CharT, _Traits, _Allocator>::__grow_by(size_type __old_cap, size_type __delta_cap, size_type __old_sz,2376basic_string<_CharT, _Traits, _Allocator>::__grow_by(size_type __old_cap, size_type __delta_cap, size_type __old_sz,
2271 size_type __n_copy, size_type __n_del, size_type __n_add)2377 size_type __n_copy, size_type __n_del, size_type __n_add)
2272{2378{
...@@ -2275,36 +2381,39 @@ basic_string<_CharT, _Traits, _Allocator>::__grow_by(size_type __old_cap, size_t...@@ -2275,36 +2381,39 @@ basic_string<_CharT, _Traits, _Allocator>::__grow_by(size_type __old_cap, size_t
2275 __throw_length_error();2381 __throw_length_error();
2276 pointer __old_p = __get_pointer();2382 pointer __old_p = __get_pointer();
2277 size_type __cap = __old_cap < __ms / 2 - __alignment ?2383 size_type __cap = __old_cap < __ms / 2 - __alignment ?
2278 __recommend(_VSTD::max(__old_cap + __delta_cap, 2 * __old_cap)) :2384 __recommend(std::max(__old_cap + __delta_cap, 2 * __old_cap)) :
2279 __ms - 1;2385 __ms - 1;
2280 pointer __p = __alloc_traits::allocate(__alloc(), __cap+1);2386 auto __allocation = std::__allocate_at_least(__alloc(), __cap + 1);
2281 __invalidate_all_iterators();2387 pointer __p = __allocation.ptr;
2388 __begin_lifetime(__p, __allocation.count);
2389 std::__debug_db_invalidate_all(this);
2282 if (__n_copy != 0)2390 if (__n_copy != 0)
2283 traits_type::copy(_VSTD::__to_address(__p),2391 traits_type::copy(std::__to_address(__p),
2284 _VSTD::__to_address(__old_p), __n_copy);2392 std::__to_address(__old_p), __n_copy);
2285 size_type __sec_cp_sz = __old_sz - __n_del - __n_copy;2393 size_type __sec_cp_sz = __old_sz - __n_del - __n_copy;
2286 if (__sec_cp_sz != 0)2394 if (__sec_cp_sz != 0)
2287 traits_type::copy(_VSTD::__to_address(__p) + __n_copy + __n_add,2395 traits_type::copy(std::__to_address(__p) + __n_copy + __n_add,
2288 _VSTD::__to_address(__old_p) + __n_copy + __n_del,2396 std::__to_address(__old_p) + __n_copy + __n_del,
2289 __sec_cp_sz);2397 __sec_cp_sz);
2290 if (__old_cap+1 != __min_cap)2398 if (__libcpp_is_constant_evaluated() || __old_cap + 1 != __min_cap)
2291 __alloc_traits::deallocate(__alloc(), __old_p, __old_cap+1);2399 __alloc_traits::deallocate(__alloc(), __old_p, __old_cap + 1);
2292 __set_long_pointer(__p);2400 __set_long_pointer(__p);
2293 __set_long_cap(__cap+1);2401 __set_long_cap(__allocation.count);
2294}2402}
22952403
2296// assign2404// assign
22972405
2298template <class _CharT, class _Traits, class _Allocator>2406template <class _CharT, class _Traits, class _Allocator>
2299template <bool __is_short>2407template <bool __is_short>
2408_LIBCPP_CONSTEXPR_AFTER_CXX17
2300basic_string<_CharT, _Traits, _Allocator>&2409basic_string<_CharT, _Traits, _Allocator>&
2301basic_string<_CharT, _Traits, _Allocator>::__assign_no_alias(2410basic_string<_CharT, _Traits, _Allocator>::__assign_no_alias(
2302 const value_type* __s, size_type __n) {2411 const value_type* __s, size_type __n) {
2303 size_type __cap = __is_short ? __min_cap : __get_long_cap();2412 size_type __cap = __is_short ? static_cast<size_type>(__min_cap) : __get_long_cap();
2304 if (__n < __cap) {2413 if (__n < __cap) {
2305 pointer __p = __is_short ? __get_short_pointer() : __get_long_pointer();2414 pointer __p = __is_short ? __get_short_pointer() : __get_long_pointer();
2306 __is_short ? __set_short_size(__n) : __set_long_size(__n);2415 __is_short ? __set_short_size(__n) : __set_long_size(__n);
2307 traits_type::copy(_VSTD::__to_address(__p), __s, __n);2416 traits_type::copy(std::__to_address(__p), __s, __n);
2308 traits_type::assign(__p[__n], value_type());2417 traits_type::assign(__p[__n], value_type());
2309 __invalidate_iterators_past(__n);2418 __invalidate_iterators_past(__n);
2310 } else {2419 } else {
...@@ -2315,12 +2424,13 @@ basic_string<_CharT, _Traits, _Allocator>::__assign_no_alias(...@@ -2315,12 +2424,13 @@ basic_string<_CharT, _Traits, _Allocator>::__assign_no_alias(
2315}2424}
23162425
2317template <class _CharT, class _Traits, class _Allocator>2426template <class _CharT, class _Traits, class _Allocator>
2427_LIBCPP_CONSTEXPR_AFTER_CXX17
2318basic_string<_CharT, _Traits, _Allocator>&2428basic_string<_CharT, _Traits, _Allocator>&
2319basic_string<_CharT, _Traits, _Allocator>::__assign_external(2429basic_string<_CharT, _Traits, _Allocator>::__assign_external(
2320 const value_type* __s, size_type __n) {2430 const value_type* __s, size_type __n) {
2321 size_type __cap = capacity();2431 size_type __cap = capacity();
2322 if (__cap >= __n) {2432 if (__cap >= __n) {
2323 value_type* __p = _VSTD::__to_address(__get_pointer());2433 value_type* __p = std::__to_address(__get_pointer());
2324 traits_type::move(__p, __s, __n);2434 traits_type::move(__p, __s, __n);
2325 return __null_terminate_at(__p, __n);2435 return __null_terminate_at(__p, __n);
2326 } else {2436 } else {
...@@ -2331,6 +2441,7 @@ basic_string<_CharT, _Traits, _Allocator>::__assign_external(...@@ -2331,6 +2441,7 @@ basic_string<_CharT, _Traits, _Allocator>::__assign_external(
2331}2441}
23322442
2333template <class _CharT, class _Traits, class _Allocator>2443template <class _CharT, class _Traits, class _Allocator>
2444_LIBCPP_CONSTEXPR_AFTER_CXX17
2334basic_string<_CharT, _Traits, _Allocator>&2445basic_string<_CharT, _Traits, _Allocator>&
2335basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s, size_type __n)2446basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s, size_type __n)
2336{2447{
...@@ -2341,6 +2452,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s, size_ty...@@ -2341,6 +2452,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s, size_ty
2341}2452}
23422453
2343template <class _CharT, class _Traits, class _Allocator>2454template <class _CharT, class _Traits, class _Allocator>
2455_LIBCPP_CONSTEXPR_AFTER_CXX17
2344basic_string<_CharT, _Traits, _Allocator>&2456basic_string<_CharT, _Traits, _Allocator>&
2345basic_string<_CharT, _Traits, _Allocator>::assign(size_type __n, value_type __c)2457basic_string<_CharT, _Traits, _Allocator>::assign(size_type __n, value_type __c)
2346{2458{
...@@ -2350,12 +2462,13 @@ basic_string<_CharT, _Traits, _Allocator>::assign(size_type __n, value_type __c)...@@ -2350,12 +2462,13 @@ basic_string<_CharT, _Traits, _Allocator>::assign(size_type __n, value_type __c)
2350 size_type __sz = size();2462 size_type __sz = size();
2351 __grow_by(__cap, __n - __cap, __sz, 0, __sz);2463 __grow_by(__cap, __n - __cap, __sz, 0, __sz);
2352 }2464 }
2353 value_type* __p = _VSTD::__to_address(__get_pointer());2465 value_type* __p = std::__to_address(__get_pointer());
2354 traits_type::assign(__p, __n, __c);2466 traits_type::assign(__p, __n, __c);
2355 return __null_terminate_at(__p, __n);2467 return __null_terminate_at(__p, __n);
2356}2468}
23572469
2358template <class _CharT, class _Traits, class _Allocator>2470template <class _CharT, class _Traits, class _Allocator>
2471_LIBCPP_CONSTEXPR_AFTER_CXX17
2359basic_string<_CharT, _Traits, _Allocator>&2472basic_string<_CharT, _Traits, _Allocator>&
2360basic_string<_CharT, _Traits, _Allocator>::operator=(value_type __c)2473basic_string<_CharT, _Traits, _Allocator>::operator=(value_type __c)
2361{2474{
...@@ -2377,6 +2490,7 @@ basic_string<_CharT, _Traits, _Allocator>::operator=(value_type __c)...@@ -2377,6 +2490,7 @@ basic_string<_CharT, _Traits, _Allocator>::operator=(value_type __c)
2377}2490}
23782491
2379template <class _CharT, class _Traits, class _Allocator>2492template <class _CharT, class _Traits, class _Allocator>
2493_LIBCPP_CONSTEXPR_AFTER_CXX17
2380basic_string<_CharT, _Traits, _Allocator>&2494basic_string<_CharT, _Traits, _Allocator>&
2381basic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str)2495basic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str)
2382{2496{
...@@ -2398,7 +2512,7 @@ basic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str)...@@ -2398,7 +2512,7 @@ basic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str)
2398#ifndef _LIBCPP_CXX03_LANG2512#ifndef _LIBCPP_CXX03_LANG
23992513
2400template <class _CharT, class _Traits, class _Allocator>2514template <class _CharT, class _Traits, class _Allocator>
2401inline2515inline _LIBCPP_CONSTEXPR_AFTER_CXX17
2402void2516void
2403basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, false_type)2517basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, false_type)
2404 _NOEXCEPT_(__alloc_traits::is_always_equal::value)2518 _NOEXCEPT_(__alloc_traits::is_always_equal::value)
...@@ -2410,7 +2524,7 @@ basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, fa...@@ -2410,7 +2524,7 @@ basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, fa
2410}2524}
24112525
2412template <class _CharT, class _Traits, class _Allocator>2526template <class _CharT, class _Traits, class _Allocator>
2413inline2527inline _LIBCPP_CONSTEXPR_AFTER_CXX17
2414void2528void
2415basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, true_type)2529basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, true_type)
2416#if _LIBCPP_STD_VER > 142530#if _LIBCPP_STD_VER > 14
...@@ -2431,12 +2545,16 @@ basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, tr...@@ -2431,12 +2545,16 @@ basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, tr
2431 }2545 }
2432 __move_assign_alloc(__str);2546 __move_assign_alloc(__str);
2433 __r_.first() = __str.__r_.first();2547 __r_.first() = __str.__r_.first();
2434 __str.__set_short_size(0);2548 if (__libcpp_is_constant_evaluated()) {
2435 traits_type::assign(__str.__get_short_pointer()[0], value_type());2549 __str.__default_init();
2550 } else {
2551 __str.__set_short_size(0);
2552 traits_type::assign(__str.__get_short_pointer()[0], value_type());
2553 }
2436}2554}
24372555
2438template <class _CharT, class _Traits, class _Allocator>2556template <class _CharT, class _Traits, class _Allocator>
2439inline2557inline _LIBCPP_CONSTEXPR_AFTER_CXX17
2440basic_string<_CharT, _Traits, _Allocator>&2558basic_string<_CharT, _Traits, _Allocator>&
2441basic_string<_CharT, _Traits, _Allocator>::operator=(basic_string&& __str)2559basic_string<_CharT, _Traits, _Allocator>::operator=(basic_string&& __str)
2442 _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value))2560 _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value))
...@@ -2450,6 +2568,7 @@ basic_string<_CharT, _Traits, _Allocator>::operator=(basic_string&& __str)...@@ -2450,6 +2568,7 @@ basic_string<_CharT, _Traits, _Allocator>::operator=(basic_string&& __str)
24502568
2451template <class _CharT, class _Traits, class _Allocator>2569template <class _CharT, class _Traits, class _Allocator>
2452template<class _InputIterator>2570template<class _InputIterator>
2571_LIBCPP_CONSTEXPR_AFTER_CXX17
2453__enable_if_t2572__enable_if_t
2454<2573<
2455 __is_exactly_cpp17_input_iterator<_InputIterator>::value,2574 __is_exactly_cpp17_input_iterator<_InputIterator>::value,
...@@ -2464,6 +2583,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(_InputIterator __first, _Input...@@ -2464,6 +2583,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(_InputIterator __first, _Input
24642583
2465template <class _CharT, class _Traits, class _Allocator>2584template <class _CharT, class _Traits, class _Allocator>
2466template<class _ForwardIterator>2585template<class _ForwardIterator>
2586_LIBCPP_CONSTEXPR_AFTER_CXX17
2467__enable_if_t2587__enable_if_t
2468<2588<
2469 __is_cpp17_forward_iterator<_ForwardIterator>::value,2589 __is_cpp17_forward_iterator<_ForwardIterator>::value,
...@@ -2473,7 +2593,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(_ForwardIterator __first, _For...@@ -2473,7 +2593,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(_ForwardIterator __first, _For
2473{2593{
2474 size_type __cap = capacity();2594 size_type __cap = capacity();
2475 size_type __n = __string_is_trivial_iterator<_ForwardIterator>::value ?2595 size_type __n = __string_is_trivial_iterator<_ForwardIterator>::value ?
2476 static_cast<size_type>(_VSTD::distance(__first, __last)) : 0;2596 static_cast<size_type>(std::distance(__first, __last)) : 0;
24772597
2478 if (__string_is_trivial_iterator<_ForwardIterator>::value &&2598 if (__string_is_trivial_iterator<_ForwardIterator>::value &&
2479 (__cap >= __n || !__addr_in_range(*__first)))2599 (__cap >= __n || !__addr_in_range(*__first)))
...@@ -2499,17 +2619,19 @@ basic_string<_CharT, _Traits, _Allocator>::assign(_ForwardIterator __first, _For...@@ -2499,17 +2619,19 @@ basic_string<_CharT, _Traits, _Allocator>::assign(_ForwardIterator __first, _For
2499}2619}
25002620
2501template <class _CharT, class _Traits, class _Allocator>2621template <class _CharT, class _Traits, class _Allocator>
2622_LIBCPP_CONSTEXPR_AFTER_CXX17
2502basic_string<_CharT, _Traits, _Allocator>&2623basic_string<_CharT, _Traits, _Allocator>&
2503basic_string<_CharT, _Traits, _Allocator>::assign(const basic_string& __str, size_type __pos, size_type __n)2624basic_string<_CharT, _Traits, _Allocator>::assign(const basic_string& __str, size_type __pos, size_type __n)
2504{2625{
2505 size_type __sz = __str.size();2626 size_type __sz = __str.size();
2506 if (__pos > __sz)2627 if (__pos > __sz)
2507 __throw_out_of_range();2628 __throw_out_of_range();
2508 return assign(__str.data() + __pos, _VSTD::min(__n, __sz - __pos));2629 return assign(__str.data() + __pos, std::min(__n, __sz - __pos));
2509}2630}
25102631
2511template <class _CharT, class _Traits, class _Allocator>2632template <class _CharT, class _Traits, class _Allocator>
2512template <class _Tp>2633template <class _Tp>
2634_LIBCPP_CONSTEXPR_AFTER_CXX17
2513__enable_if_t2635__enable_if_t
2514<2636<
2515 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value2637 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value
...@@ -2522,17 +2644,19 @@ basic_string<_CharT, _Traits, _Allocator>::assign(const _Tp & __t, size_type __p...@@ -2522,17 +2644,19 @@ basic_string<_CharT, _Traits, _Allocator>::assign(const _Tp & __t, size_type __p
2522 size_type __sz = __sv.size();2644 size_type __sz = __sv.size();
2523 if (__pos > __sz)2645 if (__pos > __sz)
2524 __throw_out_of_range();2646 __throw_out_of_range();
2525 return assign(__sv.data() + __pos, _VSTD::min(__n, __sz - __pos));2647 return assign(__sv.data() + __pos, std::min(__n, __sz - __pos));
2526}2648}
25272649
25282650
2529template <class _CharT, class _Traits, class _Allocator>2651template <class _CharT, class _Traits, class _Allocator>
2652_LIBCPP_CONSTEXPR_AFTER_CXX17
2530basic_string<_CharT, _Traits, _Allocator>&2653basic_string<_CharT, _Traits, _Allocator>&
2531basic_string<_CharT, _Traits, _Allocator>::__assign_external(const value_type* __s) {2654basic_string<_CharT, _Traits, _Allocator>::__assign_external(const value_type* __s) {
2532 return __assign_external(__s, traits_type::length(__s));2655 return __assign_external(__s, traits_type::length(__s));
2533}2656}
25342657
2535template <class _CharT, class _Traits, class _Allocator>2658template <class _CharT, class _Traits, class _Allocator>
2659_LIBCPP_CONSTEXPR_AFTER_CXX17
2536basic_string<_CharT, _Traits, _Allocator>&2660basic_string<_CharT, _Traits, _Allocator>&
2537basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s)2661basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s)
2538{2662{
...@@ -2546,6 +2670,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s)...@@ -2546,6 +2670,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s)
2546// append2670// append
25472671
2548template <class _CharT, class _Traits, class _Allocator>2672template <class _CharT, class _Traits, class _Allocator>
2673_LIBCPP_CONSTEXPR_AFTER_CXX17
2549basic_string<_CharT, _Traits, _Allocator>&2674basic_string<_CharT, _Traits, _Allocator>&
2550basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s, size_type __n)2675basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s, size_type __n)
2551{2676{
...@@ -2556,7 +2681,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s, size_ty...@@ -2556,7 +2681,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s, size_ty
2556 {2681 {
2557 if (__n)2682 if (__n)
2558 {2683 {
2559 value_type* __p = _VSTD::__to_address(__get_pointer());2684 value_type* __p = std::__to_address(__get_pointer());
2560 traits_type::copy(__p + __sz, __s, __n);2685 traits_type::copy(__p + __sz, __s, __n);
2561 __sz += __n;2686 __sz += __n;
2562 __set_size(__sz);2687 __set_size(__sz);
...@@ -2569,6 +2694,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s, size_ty...@@ -2569,6 +2694,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s, size_ty
2569}2694}
25702695
2571template <class _CharT, class _Traits, class _Allocator>2696template <class _CharT, class _Traits, class _Allocator>
2697_LIBCPP_CONSTEXPR_AFTER_CXX17
2572basic_string<_CharT, _Traits, _Allocator>&2698basic_string<_CharT, _Traits, _Allocator>&
2573basic_string<_CharT, _Traits, _Allocator>::append(size_type __n, value_type __c)2699basic_string<_CharT, _Traits, _Allocator>::append(size_type __n, value_type __c)
2574{2700{
...@@ -2579,7 +2705,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(size_type __n, value_type __c)...@@ -2579,7 +2705,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(size_type __n, value_type __c)
2579 if (__cap - __sz < __n)2705 if (__cap - __sz < __n)
2580 __grow_by(__cap, __sz + __n - __cap, __sz, __sz, 0);2706 __grow_by(__cap, __sz + __n - __cap, __sz, __sz, 0);
2581 pointer __p = __get_pointer();2707 pointer __p = __get_pointer();
2582 traits_type::assign(_VSTD::__to_address(__p) + __sz, __n, __c);2708 traits_type::assign(std::__to_address(__p) + __sz, __n, __c);
2583 __sz += __n;2709 __sz += __n;
2584 __set_size(__sz);2710 __set_size(__sz);
2585 traits_type::assign(__p[__sz], value_type());2711 traits_type::assign(__p[__sz], value_type());
...@@ -2588,7 +2714,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(size_type __n, value_type __c)...@@ -2588,7 +2714,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(size_type __n, value_type __c)
2588}2714}
25892715
2590template <class _CharT, class _Traits, class _Allocator>2716template <class _CharT, class _Traits, class _Allocator>
2591inline void2717_LIBCPP_CONSTEXPR_AFTER_CXX17 inline void
2592basic_string<_CharT, _Traits, _Allocator>::__append_default_init(size_type __n)2718basic_string<_CharT, _Traits, _Allocator>::__append_default_init(size_type __n)
2593{2719{
2594 if (__n)2720 if (__n)
...@@ -2605,6 +2731,7 @@ basic_string<_CharT, _Traits, _Allocator>::__append_default_init(size_type __n)...@@ -2605,6 +2731,7 @@ basic_string<_CharT, _Traits, _Allocator>::__append_default_init(size_type __n)
2605}2731}
26062732
2607template <class _CharT, class _Traits, class _Allocator>2733template <class _CharT, class _Traits, class _Allocator>
2734_LIBCPP_CONSTEXPR_AFTER_CXX17
2608void2735void
2609basic_string<_CharT, _Traits, _Allocator>::push_back(value_type __c)2736basic_string<_CharT, _Traits, _Allocator>::push_back(value_type __c)
2610{2737{
...@@ -2626,7 +2753,7 @@ basic_string<_CharT, _Traits, _Allocator>::push_back(value_type __c)...@@ -2626,7 +2753,7 @@ basic_string<_CharT, _Traits, _Allocator>::push_back(value_type __c)
2626 __grow_by(__cap, 1, __sz, __sz, 0);2753 __grow_by(__cap, 1, __sz, __sz, 0);
2627 __is_short = false; // the string is always long after __grow_by2754 __is_short = false; // the string is always long after __grow_by
2628 }2755 }
2629 pointer __p;2756 pointer __p = __get_pointer();
2630 if (__is_short)2757 if (__is_short)
2631 {2758 {
2632 __p = __get_short_pointer() + __sz;2759 __p = __get_short_pointer() + __sz;
...@@ -2643,6 +2770,7 @@ basic_string<_CharT, _Traits, _Allocator>::push_back(value_type __c)...@@ -2643,6 +2770,7 @@ basic_string<_CharT, _Traits, _Allocator>::push_back(value_type __c)
26432770
2644template <class _CharT, class _Traits, class _Allocator>2771template <class _CharT, class _Traits, class _Allocator>
2645template<class _ForwardIterator>2772template<class _ForwardIterator>
2773_LIBCPP_CONSTEXPR_AFTER_CXX17
2646__enable_if_t2774__enable_if_t
2647<2775<
2648 __is_cpp17_forward_iterator<_ForwardIterator>::value,2776 __is_cpp17_forward_iterator<_ForwardIterator>::value,
...@@ -2653,7 +2781,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(...@@ -2653,7 +2781,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(
2653{2781{
2654 size_type __sz = size();2782 size_type __sz = size();
2655 size_type __cap = capacity();2783 size_type __cap = capacity();
2656 size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last));2784 size_type __n = static_cast<size_type>(std::distance(__first, __last));
2657 if (__n)2785 if (__n)
2658 {2786 {
2659 if (__string_is_trivial_iterator<_ForwardIterator>::value &&2787 if (__string_is_trivial_iterator<_ForwardIterator>::value &&
...@@ -2677,7 +2805,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(...@@ -2677,7 +2805,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(
2677}2805}
26782806
2679template <class _CharT, class _Traits, class _Allocator>2807template <class _CharT, class _Traits, class _Allocator>
2680inline2808inline _LIBCPP_CONSTEXPR_AFTER_CXX17
2681basic_string<_CharT, _Traits, _Allocator>&2809basic_string<_CharT, _Traits, _Allocator>&
2682basic_string<_CharT, _Traits, _Allocator>::append(const basic_string& __str)2810basic_string<_CharT, _Traits, _Allocator>::append(const basic_string& __str)
2683{2811{
...@@ -2685,17 +2813,19 @@ basic_string<_CharT, _Traits, _Allocator>::append(const basic_string& __str)...@@ -2685,17 +2813,19 @@ basic_string<_CharT, _Traits, _Allocator>::append(const basic_string& __str)
2685}2813}
26862814
2687template <class _CharT, class _Traits, class _Allocator>2815template <class _CharT, class _Traits, class _Allocator>
2816_LIBCPP_CONSTEXPR_AFTER_CXX17
2688basic_string<_CharT, _Traits, _Allocator>&2817basic_string<_CharT, _Traits, _Allocator>&
2689basic_string<_CharT, _Traits, _Allocator>::append(const basic_string& __str, size_type __pos, size_type __n)2818basic_string<_CharT, _Traits, _Allocator>::append(const basic_string& __str, size_type __pos, size_type __n)
2690{2819{
2691 size_type __sz = __str.size();2820 size_type __sz = __str.size();
2692 if (__pos > __sz)2821 if (__pos > __sz)
2693 __throw_out_of_range();2822 __throw_out_of_range();
2694 return append(__str.data() + __pos, _VSTD::min(__n, __sz - __pos));2823 return append(__str.data() + __pos, std::min(__n, __sz - __pos));
2695}2824}
26962825
2697template <class _CharT, class _Traits, class _Allocator>2826template <class _CharT, class _Traits, class _Allocator>
2698template <class _Tp>2827template <class _Tp>
2828_LIBCPP_CONSTEXPR_AFTER_CXX17
2699 __enable_if_t2829 __enable_if_t
2700 <2830 <
2701 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value,2831 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value,
...@@ -2707,10 +2837,11 @@ basic_string<_CharT, _Traits, _Allocator>::append(const _Tp & __t, size_type __p...@@ -2707,10 +2837,11 @@ basic_string<_CharT, _Traits, _Allocator>::append(const _Tp & __t, size_type __p
2707 size_type __sz = __sv.size();2837 size_type __sz = __sv.size();
2708 if (__pos > __sz)2838 if (__pos > __sz)
2709 __throw_out_of_range();2839 __throw_out_of_range();
2710 return append(__sv.data() + __pos, _VSTD::min(__n, __sz - __pos));2840 return append(__sv.data() + __pos, std::min(__n, __sz - __pos));
2711}2841}
27122842
2713template <class _CharT, class _Traits, class _Allocator>2843template <class _CharT, class _Traits, class _Allocator>
2844_LIBCPP_CONSTEXPR_AFTER_CXX17
2714basic_string<_CharT, _Traits, _Allocator>&2845basic_string<_CharT, _Traits, _Allocator>&
2715basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s)2846basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s)
2716{2847{
...@@ -2721,6 +2852,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s)...@@ -2721,6 +2852,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s)
2721// insert2852// insert
27222853
2723template <class _CharT, class _Traits, class _Allocator>2854template <class _CharT, class _Traits, class _Allocator>
2855_LIBCPP_CONSTEXPR_AFTER_CXX17
2724basic_string<_CharT, _Traits, _Allocator>&2856basic_string<_CharT, _Traits, _Allocator>&
2725basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s, size_type __n)2857basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s, size_type __n)
2726{2858{
...@@ -2729,11 +2861,18 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_t...@@ -2729,11 +2861,18 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_t
2729 if (__pos > __sz)2861 if (__pos > __sz)
2730 __throw_out_of_range();2862 __throw_out_of_range();
2731 size_type __cap = capacity();2863 size_type __cap = capacity();
2864 if (__libcpp_is_constant_evaluated()) {
2865 if (__cap - __sz >= __n)
2866 __grow_by_and_replace(__cap, 0, __sz, __pos, 0, __n, __s);
2867 else
2868 __grow_by_and_replace(__cap, __sz + __n - __cap, __sz, __pos, 0, __n, __s);
2869 return *this;
2870 }
2732 if (__cap - __sz >= __n)2871 if (__cap - __sz >= __n)
2733 {2872 {
2734 if (__n)2873 if (__n)
2735 {2874 {
2736 value_type* __p = _VSTD::__to_address(__get_pointer());2875 value_type* __p = std::__to_address(__get_pointer());
2737 size_type __n_move = __sz - __pos;2876 size_type __n_move = __sz - __pos;
2738 if (__n_move != 0)2877 if (__n_move != 0)
2739 {2878 {
...@@ -2753,6 +2892,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_t...@@ -2753,6 +2892,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_t
2753}2892}
27542893
2755template <class _CharT, class _Traits, class _Allocator>2894template <class _CharT, class _Traits, class _Allocator>
2895_LIBCPP_CONSTEXPR_AFTER_CXX17
2756basic_string<_CharT, _Traits, _Allocator>&2896basic_string<_CharT, _Traits, _Allocator>&
2757basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, size_type __n, value_type __c)2897basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, size_type __n, value_type __c)
2758{2898{
...@@ -2765,7 +2905,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, size_type __n...@@ -2765,7 +2905,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, size_type __n
2765 value_type* __p;2905 value_type* __p;
2766 if (__cap - __sz >= __n)2906 if (__cap - __sz >= __n)
2767 {2907 {
2768 __p = _VSTD::__to_address(__get_pointer());2908 __p = std::__to_address(__get_pointer());
2769 size_type __n_move = __sz - __pos;2909 size_type __n_move = __sz - __pos;
2770 if (__n_move != 0)2910 if (__n_move != 0)
2771 traits_type::move(__p + __pos + __n, __p + __pos, __n_move);2911 traits_type::move(__p + __pos + __n, __p + __pos, __n_move);
...@@ -2773,7 +2913,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, size_type __n...@@ -2773,7 +2913,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, size_type __n
2773 else2913 else
2774 {2914 {
2775 __grow_by(__cap, __sz + __n - __cap, __sz, __pos, 0, __n);2915 __grow_by(__cap, __sz + __n - __cap, __sz, __pos, 0, __n);
2776 __p = _VSTD::__to_address(__get_long_pointer());2916 __p = std::__to_address(__get_long_pointer());
2777 }2917 }
2778 traits_type::assign(__p + __pos, __n, __c);2918 traits_type::assign(__p + __pos, __n, __c);
2779 __sz += __n;2919 __sz += __n;
...@@ -2785,6 +2925,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, size_type __n...@@ -2785,6 +2925,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, size_type __n
27852925
2786template <class _CharT, class _Traits, class _Allocator>2926template <class _CharT, class _Traits, class _Allocator>
2787template<class _InputIterator>2927template<class _InputIterator>
2928_LIBCPP_CONSTEXPR_AFTER_CXX17
2788__enable_if_t2929__enable_if_t
2789<2930<
2790 __is_exactly_cpp17_input_iterator<_InputIterator>::value,2931 __is_exactly_cpp17_input_iterator<_InputIterator>::value,
...@@ -2801,6 +2942,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _InputIt...@@ -2801,6 +2942,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _InputIt
28012942
2802template <class _CharT, class _Traits, class _Allocator>2943template <class _CharT, class _Traits, class _Allocator>
2803template<class _ForwardIterator>2944template<class _ForwardIterator>
2945_LIBCPP_CONSTEXPR_AFTER_CXX17
2804__enable_if_t2946__enable_if_t
2805<2947<
2806 __is_cpp17_forward_iterator<_ForwardIterator>::value,2948 __is_cpp17_forward_iterator<_ForwardIterator>::value,
...@@ -2808,49 +2950,27 @@ __enable_if_t...@@ -2808,49 +2950,27 @@ __enable_if_t
2808>2950>
2809basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last)2951basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last)
2810{2952{
2811 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this,2953 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this,
2812 "string::insert(iterator, range) called with an iterator not"2954 "string::insert(iterator, range) called with an iterator not referring to this string");
2813 " referring to this string");
28142955
2815 size_type __ip = static_cast<size_type>(__pos - begin());2956 size_type __ip = static_cast<size_type>(__pos - begin());
2816 size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last));2957 size_type __n = static_cast<size_type>(std::distance(__first, __last));
2817 if (__n)2958 if (__n == 0)
2959 return begin() + __ip;
2960
2961 if (__string_is_trivial_iterator<_ForwardIterator>::value && !__addr_in_range(*__first))
2818 {2962 {
2819 if (__string_is_trivial_iterator<_ForwardIterator>::value &&2963 return __insert_from_safe_copy(__n, __ip, __first, __last);
2820 !__addr_in_range(*__first))2964 }
2821 {2965 else
2822 size_type __sz = size();2966 {
2823 size_type __cap = capacity();2967 const basic_string __temp(__first, __last, __alloc());
2824 value_type* __p;2968 return __insert_from_safe_copy(__n, __ip, __temp.begin(), __temp.end());
2825 if (__cap - __sz >= __n)
2826 {
2827 __p = _VSTD::__to_address(__get_pointer());
2828 size_type __n_move = __sz - __ip;
2829 if (__n_move != 0)
2830 traits_type::move(__p + __ip + __n, __p + __ip, __n_move);
2831 }
2832 else
2833 {
2834 __grow_by(__cap, __sz + __n - __cap, __sz, __ip, 0, __n);
2835 __p = _VSTD::__to_address(__get_long_pointer());
2836 }
2837 __sz += __n;
2838 __set_size(__sz);
2839 traits_type::assign(__p[__sz], value_type());
2840 for (__p += __ip; __first != __last; ++__p, (void) ++__first)
2841 traits_type::assign(*__p, *__first);
2842 }
2843 else
2844 {
2845 const basic_string __temp(__first, __last, __alloc());
2846 return insert(__pos, __temp.data(), __temp.data() + __temp.size());
2847 }
2848 }2969 }
2849 return begin() + __ip;
2850}2970}
28512971
2852template <class _CharT, class _Traits, class _Allocator>2972template <class _CharT, class _Traits, class _Allocator>
2853inline2973inline _LIBCPP_CONSTEXPR_AFTER_CXX17
2854basic_string<_CharT, _Traits, _Allocator>&2974basic_string<_CharT, _Traits, _Allocator>&
2855basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const basic_string& __str)2975basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const basic_string& __str)
2856{2976{
...@@ -2858,6 +2978,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const basic_...@@ -2858,6 +2978,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const basic_
2858}2978}
28592979
2860template <class _CharT, class _Traits, class _Allocator>2980template <class _CharT, class _Traits, class _Allocator>
2981_LIBCPP_CONSTEXPR_AFTER_CXX17
2861basic_string<_CharT, _Traits, _Allocator>&2982basic_string<_CharT, _Traits, _Allocator>&
2862basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const basic_string& __str,2983basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const basic_string& __str,
2863 size_type __pos2, size_type __n)2984 size_type __pos2, size_type __n)
...@@ -2865,11 +2986,12 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const basic_...@@ -2865,11 +2986,12 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const basic_
2865 size_type __str_sz = __str.size();2986 size_type __str_sz = __str.size();
2866 if (__pos2 > __str_sz)2987 if (__pos2 > __str_sz)
2867 __throw_out_of_range();2988 __throw_out_of_range();
2868 return insert(__pos1, __str.data() + __pos2, _VSTD::min(__n, __str_sz - __pos2));2989 return insert(__pos1, __str.data() + __pos2, std::min(__n, __str_sz - __pos2));
2869}2990}
28702991
2871template <class _CharT, class _Traits, class _Allocator>2992template <class _CharT, class _Traits, class _Allocator>
2872template <class _Tp>2993template <class _Tp>
2994_LIBCPP_CONSTEXPR_AFTER_CXX17
2873__enable_if_t2995__enable_if_t
2874<2996<
2875 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value,2997 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value,
...@@ -2882,10 +3004,11 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const _Tp& _...@@ -2882,10 +3004,11 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const _Tp& _
2882 size_type __str_sz = __sv.size();3004 size_type __str_sz = __sv.size();
2883 if (__pos2 > __str_sz)3005 if (__pos2 > __str_sz)
2884 __throw_out_of_range();3006 __throw_out_of_range();
2885 return insert(__pos1, __sv.data() + __pos2, _VSTD::min(__n, __str_sz - __pos2));3007 return insert(__pos1, __sv.data() + __pos2, std::min(__n, __str_sz - __pos2));
2886}3008}
28873009
2888template <class _CharT, class _Traits, class _Allocator>3010template <class _CharT, class _Traits, class _Allocator>
3011_LIBCPP_CONSTEXPR_AFTER_CXX17
2889basic_string<_CharT, _Traits, _Allocator>&3012basic_string<_CharT, _Traits, _Allocator>&
2890basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s)3013basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s)
2891{3014{
...@@ -2894,6 +3017,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_t...@@ -2894,6 +3017,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_t
2894}3017}
28953018
2896template <class _CharT, class _Traits, class _Allocator>3019template <class _CharT, class _Traits, class _Allocator>
3020_LIBCPP_CONSTEXPR_AFTER_CXX17
2897typename basic_string<_CharT, _Traits, _Allocator>::iterator3021typename basic_string<_CharT, _Traits, _Allocator>::iterator
2898basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, value_type __c)3022basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, value_type __c)
2899{3023{
...@@ -2908,11 +3032,11 @@ basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, value_ty...@@ -2908,11 +3032,11 @@ basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, value_ty
2908 if (__cap == __sz)3032 if (__cap == __sz)
2909 {3033 {
2910 __grow_by(__cap, 1, __sz, __ip, 0, 1);3034 __grow_by(__cap, 1, __sz, __ip, 0, 1);
2911 __p = _VSTD::__to_address(__get_long_pointer());3035 __p = std::__to_address(__get_long_pointer());
2912 }3036 }
2913 else3037 else
2914 {3038 {
2915 __p = _VSTD::__to_address(__get_pointer());3039 __p = std::__to_address(__get_pointer());
2916 size_type __n_move = __sz - __ip;3040 size_type __n_move = __sz - __ip;
2917 if (__n_move != 0)3041 if (__n_move != 0)
2918 traits_type::move(__p + __ip + 1, __p + __ip, __n_move);3042 traits_type::move(__p + __ip + 1, __p + __ip, __n_move);
...@@ -2924,7 +3048,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, value_ty...@@ -2924,7 +3048,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, value_ty
2924}3048}
29253049
2926template <class _CharT, class _Traits, class _Allocator>3050template <class _CharT, class _Traits, class _Allocator>
2927inline3051inline _LIBCPP_CONSTEXPR_AFTER_CXX17
2928typename basic_string<_CharT, _Traits, _Allocator>::iterator3052typename basic_string<_CharT, _Traits, _Allocator>::iterator
2929basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, size_type __n, value_type __c)3053basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, size_type __n, value_type __c)
2930{3054{
...@@ -2939,6 +3063,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, size_typ...@@ -2939,6 +3063,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, size_typ
2939// replace3063// replace
29403064
2941template <class _CharT, class _Traits, class _Allocator>3065template <class _CharT, class _Traits, class _Allocator>
3066_LIBCPP_CONSTEXPR_AFTER_CXX17
2942basic_string<_CharT, _Traits, _Allocator>&3067basic_string<_CharT, _Traits, _Allocator>&
2943basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, const value_type* __s, size_type __n2)3068basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, const value_type* __s, size_type __n2)
2944 _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK3069 _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
...@@ -2947,11 +3072,15 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __...@@ -2947,11 +3072,15 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __
2947 size_type __sz = size();3072 size_type __sz = size();
2948 if (__pos > __sz)3073 if (__pos > __sz)
2949 __throw_out_of_range();3074 __throw_out_of_range();
2950 __n1 = _VSTD::min(__n1, __sz - __pos);3075 __n1 = std::min(__n1, __sz - __pos);
2951 size_type __cap = capacity();3076 size_type __cap = capacity();
2952 if (__cap - __sz + __n1 >= __n2)3077 if (__cap - __sz + __n1 >= __n2)
2953 {3078 {
2954 value_type* __p = _VSTD::__to_address(__get_pointer());3079 if (__libcpp_is_constant_evaluated()) {
3080 __grow_by_and_replace(__cap, 0, __sz, __pos, __n1, __n2, __s);
3081 return *this;
3082 }
3083 value_type* __p = std::__to_address(__get_pointer());
2955 if (__n1 != __n2)3084 if (__n1 != __n2)
2956 {3085 {
2957 size_type __n_move = __sz - __pos - __n1;3086 size_type __n_move = __sz - __pos - __n1;
...@@ -2988,18 +3117,19 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __...@@ -2988,18 +3117,19 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __
2988}3117}
29893118
2990template <class _CharT, class _Traits, class _Allocator>3119template <class _CharT, class _Traits, class _Allocator>
3120_LIBCPP_CONSTEXPR_AFTER_CXX17
2991basic_string<_CharT, _Traits, _Allocator>&3121basic_string<_CharT, _Traits, _Allocator>&
2992basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, size_type __n2, value_type __c)3122basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, size_type __n2, value_type __c)
2993{3123{
2994 size_type __sz = size();3124 size_type __sz = size();
2995 if (__pos > __sz)3125 if (__pos > __sz)
2996 __throw_out_of_range();3126 __throw_out_of_range();
2997 __n1 = _VSTD::min(__n1, __sz - __pos);3127 __n1 = std::min(__n1, __sz - __pos);
2998 size_type __cap = capacity();3128 size_type __cap = capacity();
2999 value_type* __p;3129 value_type* __p;
3000 if (__cap - __sz + __n1 >= __n2)3130 if (__cap - __sz + __n1 >= __n2)
3001 {3131 {
3002 __p = _VSTD::__to_address(__get_pointer());3132 __p = std::__to_address(__get_pointer());
3003 if (__n1 != __n2)3133 if (__n1 != __n2)
3004 {3134 {
3005 size_type __n_move = __sz - __pos - __n1;3135 size_type __n_move = __sz - __pos - __n1;
...@@ -3010,7 +3140,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __...@@ -3010,7 +3140,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __
3010 else3140 else
3011 {3141 {
3012 __grow_by(__cap, __sz - __n1 + __n2 - __cap, __sz, __pos, __n1, __n2);3142 __grow_by(__cap, __sz - __n1 + __n2 - __cap, __sz, __pos, __n1, __n2);
3013 __p = _VSTD::__to_address(__get_long_pointer());3143 __p = std::__to_address(__get_long_pointer());
3014 }3144 }
3015 traits_type::assign(__p + __pos, __n2, __c);3145 traits_type::assign(__p + __pos, __n2, __c);
3016 return __null_terminate_at(__p, __sz - (__n1 - __n2));3146 return __null_terminate_at(__p, __sz - (__n1 - __n2));
...@@ -3018,6 +3148,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __...@@ -3018,6 +3148,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __
30183148
3019template <class _CharT, class _Traits, class _Allocator>3149template <class _CharT, class _Traits, class _Allocator>
3020template<class _InputIterator>3150template<class _InputIterator>
3151_LIBCPP_CONSTEXPR_AFTER_CXX17
3021__enable_if_t3152__enable_if_t
3022<3153<
3023 __is_cpp17_input_iterator<_InputIterator>::value,3154 __is_cpp17_input_iterator<_InputIterator>::value,
...@@ -3031,7 +3162,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_it...@@ -3031,7 +3162,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_it
3031}3162}
30323163
3033template <class _CharT, class _Traits, class _Allocator>3164template <class _CharT, class _Traits, class _Allocator>
3034inline3165inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3035basic_string<_CharT, _Traits, _Allocator>&3166basic_string<_CharT, _Traits, _Allocator>&
3036basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type __n1, const basic_string& __str)3167basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type __n1, const basic_string& __str)
3037{3168{
...@@ -3039,6 +3170,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type _...@@ -3039,6 +3170,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type _
3039}3170}
30403171
3041template <class _CharT, class _Traits, class _Allocator>3172template <class _CharT, class _Traits, class _Allocator>
3173_LIBCPP_CONSTEXPR_AFTER_CXX17
3042basic_string<_CharT, _Traits, _Allocator>&3174basic_string<_CharT, _Traits, _Allocator>&
3043basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type __n1, const basic_string& __str,3175basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type __n1, const basic_string& __str,
3044 size_type __pos2, size_type __n2)3176 size_type __pos2, size_type __n2)
...@@ -3046,11 +3178,12 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type _...@@ -3046,11 +3178,12 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type _
3046 size_type __str_sz = __str.size();3178 size_type __str_sz = __str.size();
3047 if (__pos2 > __str_sz)3179 if (__pos2 > __str_sz)
3048 __throw_out_of_range();3180 __throw_out_of_range();
3049 return replace(__pos1, __n1, __str.data() + __pos2, _VSTD::min(__n2, __str_sz - __pos2));3181 return replace(__pos1, __n1, __str.data() + __pos2, std::min(__n2, __str_sz - __pos2));
3050}3182}
30513183
3052template <class _CharT, class _Traits, class _Allocator>3184template <class _CharT, class _Traits, class _Allocator>
3053template <class _Tp>3185template <class _Tp>
3186_LIBCPP_CONSTEXPR_AFTER_CXX17
3054__enable_if_t3187__enable_if_t
3055<3188<
3056 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value,3189 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value,
...@@ -3063,10 +3196,11 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type _...@@ -3063,10 +3196,11 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type _
3063 size_type __str_sz = __sv.size();3196 size_type __str_sz = __sv.size();
3064 if (__pos2 > __str_sz)3197 if (__pos2 > __str_sz)
3065 __throw_out_of_range();3198 __throw_out_of_range();
3066 return replace(__pos1, __n1, __sv.data() + __pos2, _VSTD::min(__n2, __str_sz - __pos2));3199 return replace(__pos1, __n1, __sv.data() + __pos2, std::min(__n2, __str_sz - __pos2));
3067}3200}
30683201
3069template <class _CharT, class _Traits, class _Allocator>3202template <class _CharT, class _Traits, class _Allocator>
3203_LIBCPP_CONSTEXPR_AFTER_CXX17
3070basic_string<_CharT, _Traits, _Allocator>&3204basic_string<_CharT, _Traits, _Allocator>&
3071basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, const value_type* __s)3205basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, const value_type* __s)
3072{3206{
...@@ -3075,7 +3209,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __...@@ -3075,7 +3209,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __
3075}3209}
30763210
3077template <class _CharT, class _Traits, class _Allocator>3211template <class _CharT, class _Traits, class _Allocator>
3078inline3212inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3079basic_string<_CharT, _Traits, _Allocator>&3213basic_string<_CharT, _Traits, _Allocator>&
3080basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const basic_string& __str)3214basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const basic_string& __str)
3081{3215{
...@@ -3084,7 +3218,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_it...@@ -3084,7 +3218,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_it
3084}3218}
30853219
3086template <class _CharT, class _Traits, class _Allocator>3220template <class _CharT, class _Traits, class _Allocator>
3087inline3221inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3088basic_string<_CharT, _Traits, _Allocator>&3222basic_string<_CharT, _Traits, _Allocator>&
3089basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const value_type* __s, size_type __n)3223basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const value_type* __s, size_type __n)
3090{3224{
...@@ -3092,7 +3226,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_it...@@ -3092,7 +3226,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_it
3092}3226}
30933227
3094template <class _CharT, class _Traits, class _Allocator>3228template <class _CharT, class _Traits, class _Allocator>
3095inline3229inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3096basic_string<_CharT, _Traits, _Allocator>&3230basic_string<_CharT, _Traits, _Allocator>&
3097basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const value_type* __s)3231basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const value_type* __s)
3098{3232{
...@@ -3100,7 +3234,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_it...@@ -3100,7 +3234,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_it
3100}3234}
31013235
3102template <class _CharT, class _Traits, class _Allocator>3236template <class _CharT, class _Traits, class _Allocator>
3103inline3237inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3104basic_string<_CharT, _Traits, _Allocator>&3238basic_string<_CharT, _Traits, _Allocator>&
3105basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, size_type __n, value_type __c)3239basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, size_type __n, value_type __c)
3106{3240{
...@@ -3112,6 +3246,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_it...@@ -3112,6 +3246,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_it
3112// 'externally instantiated' erase() implementation, called when __n != npos.3246// 'externally instantiated' erase() implementation, called when __n != npos.
3113// Does not check __pos against size()3247// Does not check __pos against size()
3114template <class _CharT, class _Traits, class _Allocator>3248template <class _CharT, class _Traits, class _Allocator>
3249_LIBCPP_CONSTEXPR_AFTER_CXX17
3115void3250void
3116basic_string<_CharT, _Traits, _Allocator>::__erase_external_with_move(3251basic_string<_CharT, _Traits, _Allocator>::__erase_external_with_move(
3117 size_type __pos, size_type __n)3252 size_type __pos, size_type __n)
...@@ -3119,8 +3254,8 @@ basic_string<_CharT, _Traits, _Allocator>::__erase_external_with_move(...@@ -3119,8 +3254,8 @@ basic_string<_CharT, _Traits, _Allocator>::__erase_external_with_move(
3119 if (__n)3254 if (__n)
3120 {3255 {
3121 size_type __sz = size();3256 size_type __sz = size();
3122 value_type* __p = _VSTD::__to_address(__get_pointer());3257 value_type* __p = std::__to_address(__get_pointer());
3123 __n = _VSTD::min(__n, __sz - __pos);3258 __n = std::min(__n, __sz - __pos);
3124 size_type __n_move = __sz - __pos - __n;3259 size_type __n_move = __sz - __pos - __n;
3125 if (__n_move != 0)3260 if (__n_move != 0)
3126 traits_type::move(__p + __pos, __p + __pos + __n, __n_move);3261 traits_type::move(__p + __pos, __p + __pos + __n, __n_move);
...@@ -3129,6 +3264,7 @@ basic_string<_CharT, _Traits, _Allocator>::__erase_external_with_move(...@@ -3129,6 +3264,7 @@ basic_string<_CharT, _Traits, _Allocator>::__erase_external_with_move(
3129}3264}
31303265
3131template <class _CharT, class _Traits, class _Allocator>3266template <class _CharT, class _Traits, class _Allocator>
3267_LIBCPP_CONSTEXPR_AFTER_CXX17
3132basic_string<_CharT, _Traits, _Allocator>&3268basic_string<_CharT, _Traits, _Allocator>&
3133basic_string<_CharT, _Traits, _Allocator>::erase(size_type __pos,3269basic_string<_CharT, _Traits, _Allocator>::erase(size_type __pos,
3134 size_type __n) {3270 size_type __n) {
...@@ -3143,7 +3279,7 @@ basic_string<_CharT, _Traits, _Allocator>::erase(size_type __pos,...@@ -3143,7 +3279,7 @@ basic_string<_CharT, _Traits, _Allocator>::erase(size_type __pos,
3143}3279}
31443280
3145template <class _CharT, class _Traits, class _Allocator>3281template <class _CharT, class _Traits, class _Allocator>
3146inline3282inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3147typename basic_string<_CharT, _Traits, _Allocator>::iterator3283typename basic_string<_CharT, _Traits, _Allocator>::iterator
3148basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __pos)3284basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __pos)
3149{3285{
...@@ -3159,7 +3295,7 @@ basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __pos)...@@ -3159,7 +3295,7 @@ basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __pos)
3159}3295}
31603296
3161template <class _CharT, class _Traits, class _Allocator>3297template <class _CharT, class _Traits, class _Allocator>
3162inline3298inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3163typename basic_string<_CharT, _Traits, _Allocator>::iterator3299typename basic_string<_CharT, _Traits, _Allocator>::iterator
3164basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __first, const_iterator __last)3300basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __first, const_iterator __last)
3165{3301{
...@@ -3175,7 +3311,7 @@ basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __first, const_i...@@ -3175,7 +3311,7 @@ basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __first, const_i
3175}3311}
31763312
3177template <class _CharT, class _Traits, class _Allocator>3313template <class _CharT, class _Traits, class _Allocator>
3178inline3314inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3179void3315void
3180basic_string<_CharT, _Traits, _Allocator>::pop_back()3316basic_string<_CharT, _Traits, _Allocator>::pop_back()
3181{3317{
...@@ -3184,11 +3320,11 @@ basic_string<_CharT, _Traits, _Allocator>::pop_back()...@@ -3184,11 +3320,11 @@ basic_string<_CharT, _Traits, _Allocator>::pop_back()
3184}3320}
31853321
3186template <class _CharT, class _Traits, class _Allocator>3322template <class _CharT, class _Traits, class _Allocator>
3187inline3323inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3188void3324void
3189basic_string<_CharT, _Traits, _Allocator>::clear() _NOEXCEPT3325basic_string<_CharT, _Traits, _Allocator>::clear() _NOEXCEPT
3190{3326{
3191 __invalidate_all_iterators();3327 std::__debug_db_invalidate_all(this);
3192 if (__is_long())3328 if (__is_long())
3193 {3329 {
3194 traits_type::assign(*__get_long_pointer(), value_type());3330 traits_type::assign(*__get_long_pointer(), value_type());
...@@ -3202,14 +3338,15 @@ basic_string<_CharT, _Traits, _Allocator>::clear() _NOEXCEPT...@@ -3202,14 +3338,15 @@ basic_string<_CharT, _Traits, _Allocator>::clear() _NOEXCEPT
3202}3338}
32033339
3204template <class _CharT, class _Traits, class _Allocator>3340template <class _CharT, class _Traits, class _Allocator>
3205inline3341inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3206void3342void
3207basic_string<_CharT, _Traits, _Allocator>::__erase_to_end(size_type __pos)3343basic_string<_CharT, _Traits, _Allocator>::__erase_to_end(size_type __pos)
3208{3344{
3209 __null_terminate_at(_VSTD::__to_address(__get_pointer()), __pos);3345 __null_terminate_at(std::__to_address(__get_pointer()), __pos);
3210}3346}
32113347
3212template <class _CharT, class _Traits, class _Allocator>3348template <class _CharT, class _Traits, class _Allocator>
3349_LIBCPP_CONSTEXPR_AFTER_CXX17
3213void3350void
3214basic_string<_CharT, _Traits, _Allocator>::resize(size_type __n, value_type __c)3351basic_string<_CharT, _Traits, _Allocator>::resize(size_type __n, value_type __c)
3215{3352{
...@@ -3221,7 +3358,7 @@ basic_string<_CharT, _Traits, _Allocator>::resize(size_type __n, value_type __c)...@@ -3221,7 +3358,7 @@ basic_string<_CharT, _Traits, _Allocator>::resize(size_type __n, value_type __c)
3221}3358}
32223359
3223template <class _CharT, class _Traits, class _Allocator>3360template <class _CharT, class _Traits, class _Allocator>
3224inline void3361_LIBCPP_CONSTEXPR_AFTER_CXX17 inline void
3225basic_string<_CharT, _Traits, _Allocator>::__resize_default_init(size_type __n)3362basic_string<_CharT, _Traits, _Allocator>::__resize_default_init(size_type __n)
3226{3363{
3227 size_type __sz = size();3364 size_type __sz = size();
...@@ -3232,19 +3369,21 @@ basic_string<_CharT, _Traits, _Allocator>::__resize_default_init(size_type __n)...@@ -3232,19 +3369,21 @@ basic_string<_CharT, _Traits, _Allocator>::__resize_default_init(size_type __n)
3232}3369}
32333370
3234template <class _CharT, class _Traits, class _Allocator>3371template <class _CharT, class _Traits, class _Allocator>
3235inline3372inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3236typename basic_string<_CharT, _Traits, _Allocator>::size_type3373typename basic_string<_CharT, _Traits, _Allocator>::size_type
3237basic_string<_CharT, _Traits, _Allocator>::max_size() const _NOEXCEPT3374basic_string<_CharT, _Traits, _Allocator>::max_size() const _NOEXCEPT
3238{3375{
3239 size_type __m = __alloc_traits::max_size(__alloc());3376 size_type __m = __alloc_traits::max_size(__alloc());
3240#ifdef _LIBCPP_BIG_ENDIAN3377 if (__m <= std::numeric_limits<size_type>::max() / 2) {
3241 return (__m <= ~__long_mask ? __m : __m/2) - __alignment;3378 return __m - __alignment;
3242#else3379 } else {
3243 return __m - __alignment;3380 bool __uses_lsb = __endian_factor == 2;
3244#endif3381 return __uses_lsb ? __m - __alignment : (__m / 2) - __alignment;
3382 }
3245}3383}
32463384
3247template <class _CharT, class _Traits, class _Allocator>3385template <class _CharT, class _Traits, class _Allocator>
3386_LIBCPP_CONSTEXPR_AFTER_CXX17
3248void3387void
3249basic_string<_CharT, _Traits, _Allocator>::reserve(size_type __requested_capacity)3388basic_string<_CharT, _Traits, _Allocator>::reserve(size_type __requested_capacity)
3250{3389{
...@@ -3257,7 +3396,7 @@ basic_string<_CharT, _Traits, _Allocator>::reserve(size_type __requested_capacit...@@ -3257,7 +3396,7 @@ basic_string<_CharT, _Traits, _Allocator>::reserve(size_type __requested_capacit
3257 if (__requested_capacity <= capacity())3396 if (__requested_capacity <= capacity())
3258 return;3397 return;
32593398
3260 size_type __target_capacity = _VSTD::max(__requested_capacity, size());3399 size_type __target_capacity = std::max(__requested_capacity, size());
3261 __target_capacity = __recommend(__target_capacity);3400 __target_capacity = __recommend(__target_capacity);
3262 if (__target_capacity == capacity()) return;3401 if (__target_capacity == capacity()) return;
32633402
...@@ -3265,7 +3404,7 @@ basic_string<_CharT, _Traits, _Allocator>::reserve(size_type __requested_capacit...@@ -3265,7 +3404,7 @@ basic_string<_CharT, _Traits, _Allocator>::reserve(size_type __requested_capacit
3265}3404}
32663405
3267template <class _CharT, class _Traits, class _Allocator>3406template <class _CharT, class _Traits, class _Allocator>
3268inline3407inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3269void3408void
3270basic_string<_CharT, _Traits, _Allocator>::shrink_to_fit() _NOEXCEPT3409basic_string<_CharT, _Traits, _Allocator>::shrink_to_fit() _NOEXCEPT
3271{3410{
...@@ -3276,7 +3415,7 @@ basic_string<_CharT, _Traits, _Allocator>::shrink_to_fit() _NOEXCEPT...@@ -3276,7 +3415,7 @@ basic_string<_CharT, _Traits, _Allocator>::shrink_to_fit() _NOEXCEPT
3276}3415}
32773416
3278template <class _CharT, class _Traits, class _Allocator>3417template <class _CharT, class _Traits, class _Allocator>
3279inline3418inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3280void3419void
3281basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target_capacity)3420basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target_capacity)
3282{3421{
...@@ -3285,7 +3424,7 @@ basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target...@@ -3285,7 +3424,7 @@ basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target
32853424
3286 pointer __new_data, __p;3425 pointer __new_data, __p;
3287 bool __was_long, __now_long;3426 bool __was_long, __now_long;
3288 if (__target_capacity == __min_cap - 1)3427 if (__fits_in_sso(__target_capacity))
3289 {3428 {
3290 __was_long = true;3429 __was_long = true;
3291 __now_long = false;3430 __now_long = false;
...@@ -3294,15 +3433,20 @@ basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target...@@ -3294,15 +3433,20 @@ basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target
3294 }3433 }
3295 else3434 else
3296 {3435 {
3297 if (__target_capacity > __cap)3436 if (__target_capacity > __cap) {
3298 __new_data = __alloc_traits::allocate(__alloc(), __target_capacity+1);3437 auto __allocation = std::__allocate_at_least(__alloc(), __target_capacity + 1);
3438 __new_data = __allocation.ptr;
3439 __target_capacity = __allocation.count - 1;
3440 }
3299 else3441 else
3300 {3442 {
3301 #ifndef _LIBCPP_NO_EXCEPTIONS3443 #ifndef _LIBCPP_NO_EXCEPTIONS
3302 try3444 try
3303 {3445 {
3304 #endif // _LIBCPP_NO_EXCEPTIONS3446 #endif // _LIBCPP_NO_EXCEPTIONS
3305 __new_data = __alloc_traits::allocate(__alloc(), __target_capacity+1);3447 auto __allocation = std::__allocate_at_least(__alloc(), __target_capacity + 1);
3448 __new_data = __allocation.ptr;
3449 __target_capacity = __allocation.count - 1;
3306 #ifndef _LIBCPP_NO_EXCEPTIONS3450 #ifndef _LIBCPP_NO_EXCEPTIONS
3307 }3451 }
3308 catch (...)3452 catch (...)
...@@ -3314,12 +3458,13 @@ basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target...@@ -3314,12 +3458,13 @@ basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target
3314 return;3458 return;
3315 #endif // _LIBCPP_NO_EXCEPTIONS3459 #endif // _LIBCPP_NO_EXCEPTIONS
3316 }3460 }
3461 __begin_lifetime(__new_data, __target_capacity + 1);
3317 __now_long = true;3462 __now_long = true;
3318 __was_long = __is_long();3463 __was_long = __is_long();
3319 __p = __get_pointer();3464 __p = __get_pointer();
3320 }3465 }
3321 traits_type::copy(_VSTD::__to_address(__new_data),3466 traits_type::copy(std::__to_address(__new_data),
3322 _VSTD::__to_address(__p), size()+1);3467 std::__to_address(__p), size()+1);
3323 if (__was_long)3468 if (__was_long)
3324 __alloc_traits::deallocate(__alloc(), __p, __cap+1);3469 __alloc_traits::deallocate(__alloc(), __p, __cap+1);
3325 if (__now_long)3470 if (__now_long)
...@@ -3330,11 +3475,11 @@ basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target...@@ -3330,11 +3475,11 @@ basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target
3330 }3475 }
3331 else3476 else
3332 __set_short_size(__sz);3477 __set_short_size(__sz);
3333 __invalidate_all_iterators();3478 std::__debug_db_invalidate_all(this);
3334}3479}
33353480
3336template <class _CharT, class _Traits, class _Allocator>3481template <class _CharT, class _Traits, class _Allocator>
3337inline3482inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3338typename basic_string<_CharT, _Traits, _Allocator>::const_reference3483typename basic_string<_CharT, _Traits, _Allocator>::const_reference
3339basic_string<_CharT, _Traits, _Allocator>::operator[](size_type __pos) const _NOEXCEPT3484basic_string<_CharT, _Traits, _Allocator>::operator[](size_type __pos) const _NOEXCEPT
3340{3485{
...@@ -3343,7 +3488,7 @@ basic_string<_CharT, _Traits, _Allocator>::operator[](size_type __pos) const _NO...@@ -3343,7 +3488,7 @@ basic_string<_CharT, _Traits, _Allocator>::operator[](size_type __pos) const _NO
3343}3488}
33443489
3345template <class _CharT, class _Traits, class _Allocator>3490template <class _CharT, class _Traits, class _Allocator>
3346inline3491inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3347typename basic_string<_CharT, _Traits, _Allocator>::reference3492typename basic_string<_CharT, _Traits, _Allocator>::reference
3348basic_string<_CharT, _Traits, _Allocator>::operator[](size_type __pos) _NOEXCEPT3493basic_string<_CharT, _Traits, _Allocator>::operator[](size_type __pos) _NOEXCEPT
3349{3494{
...@@ -3352,6 +3497,7 @@ basic_string<_CharT, _Traits, _Allocator>::operator[](size_type __pos) _NOEXCEPT...@@ -3352,6 +3497,7 @@ basic_string<_CharT, _Traits, _Allocator>::operator[](size_type __pos) _NOEXCEPT
3352}3497}
33533498
3354template <class _CharT, class _Traits, class _Allocator>3499template <class _CharT, class _Traits, class _Allocator>
3500_LIBCPP_CONSTEXPR_AFTER_CXX17
3355typename basic_string<_CharT, _Traits, _Allocator>::const_reference3501typename basic_string<_CharT, _Traits, _Allocator>::const_reference
3356basic_string<_CharT, _Traits, _Allocator>::at(size_type __n) const3502basic_string<_CharT, _Traits, _Allocator>::at(size_type __n) const
3357{3503{
...@@ -3361,6 +3507,7 @@ basic_string<_CharT, _Traits, _Allocator>::at(size_type __n) const...@@ -3361,6 +3507,7 @@ basic_string<_CharT, _Traits, _Allocator>::at(size_type __n) const
3361}3507}
33623508
3363template <class _CharT, class _Traits, class _Allocator>3509template <class _CharT, class _Traits, class _Allocator>
3510_LIBCPP_CONSTEXPR_AFTER_CXX17
3364typename basic_string<_CharT, _Traits, _Allocator>::reference3511typename basic_string<_CharT, _Traits, _Allocator>::reference
3365basic_string<_CharT, _Traits, _Allocator>::at(size_type __n)3512basic_string<_CharT, _Traits, _Allocator>::at(size_type __n)
3366{3513{
...@@ -3370,7 +3517,7 @@ basic_string<_CharT, _Traits, _Allocator>::at(size_type __n)...@@ -3370,7 +3517,7 @@ basic_string<_CharT, _Traits, _Allocator>::at(size_type __n)
3370}3517}
33713518
3372template <class _CharT, class _Traits, class _Allocator>3519template <class _CharT, class _Traits, class _Allocator>
3373inline3520inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3374typename basic_string<_CharT, _Traits, _Allocator>::reference3521typename basic_string<_CharT, _Traits, _Allocator>::reference
3375basic_string<_CharT, _Traits, _Allocator>::front() _NOEXCEPT3522basic_string<_CharT, _Traits, _Allocator>::front() _NOEXCEPT
3376{3523{
...@@ -3379,7 +3526,7 @@ basic_string<_CharT, _Traits, _Allocator>::front() _NOEXCEPT...@@ -3379,7 +3526,7 @@ basic_string<_CharT, _Traits, _Allocator>::front() _NOEXCEPT
3379}3526}
33803527
3381template <class _CharT, class _Traits, class _Allocator>3528template <class _CharT, class _Traits, class _Allocator>
3382inline3529inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3383typename basic_string<_CharT, _Traits, _Allocator>::const_reference3530typename basic_string<_CharT, _Traits, _Allocator>::const_reference
3384basic_string<_CharT, _Traits, _Allocator>::front() const _NOEXCEPT3531basic_string<_CharT, _Traits, _Allocator>::front() const _NOEXCEPT
3385{3532{
...@@ -3388,7 +3535,7 @@ basic_string<_CharT, _Traits, _Allocator>::front() const _NOEXCEPT...@@ -3388,7 +3535,7 @@ basic_string<_CharT, _Traits, _Allocator>::front() const _NOEXCEPT
3388}3535}
33893536
3390template <class _CharT, class _Traits, class _Allocator>3537template <class _CharT, class _Traits, class _Allocator>
3391inline3538inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3392typename basic_string<_CharT, _Traits, _Allocator>::reference3539typename basic_string<_CharT, _Traits, _Allocator>::reference
3393basic_string<_CharT, _Traits, _Allocator>::back() _NOEXCEPT3540basic_string<_CharT, _Traits, _Allocator>::back() _NOEXCEPT
3394{3541{
...@@ -3397,7 +3544,7 @@ basic_string<_CharT, _Traits, _Allocator>::back() _NOEXCEPT...@@ -3397,7 +3544,7 @@ basic_string<_CharT, _Traits, _Allocator>::back() _NOEXCEPT
3397}3544}
33983545
3399template <class _CharT, class _Traits, class _Allocator>3546template <class _CharT, class _Traits, class _Allocator>
3400inline3547inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3401typename basic_string<_CharT, _Traits, _Allocator>::const_reference3548typename basic_string<_CharT, _Traits, _Allocator>::const_reference
3402basic_string<_CharT, _Traits, _Allocator>::back() const _NOEXCEPT3549basic_string<_CharT, _Traits, _Allocator>::back() const _NOEXCEPT
3403{3550{
...@@ -3406,19 +3553,20 @@ basic_string<_CharT, _Traits, _Allocator>::back() const _NOEXCEPT...@@ -3406,19 +3553,20 @@ basic_string<_CharT, _Traits, _Allocator>::back() const _NOEXCEPT
3406}3553}
34073554
3408template <class _CharT, class _Traits, class _Allocator>3555template <class _CharT, class _Traits, class _Allocator>
3556_LIBCPP_CONSTEXPR_AFTER_CXX17
3409typename basic_string<_CharT, _Traits, _Allocator>::size_type3557typename basic_string<_CharT, _Traits, _Allocator>::size_type
3410basic_string<_CharT, _Traits, _Allocator>::copy(value_type* __s, size_type __n, size_type __pos) const3558basic_string<_CharT, _Traits, _Allocator>::copy(value_type* __s, size_type __n, size_type __pos) const
3411{3559{
3412 size_type __sz = size();3560 size_type __sz = size();
3413 if (__pos > __sz)3561 if (__pos > __sz)
3414 __throw_out_of_range();3562 __throw_out_of_range();
3415 size_type __rlen = _VSTD::min(__n, __sz - __pos);3563 size_type __rlen = std::min(__n, __sz - __pos);
3416 traits_type::copy(__s, data() + __pos, __rlen);3564 traits_type::copy(__s, data() + __pos, __rlen);
3417 return __rlen;3565 return __rlen;
3418}3566}
34193567
3420template <class _CharT, class _Traits, class _Allocator>3568template <class _CharT, class _Traits, class _Allocator>
3421inline3569inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3422basic_string<_CharT, _Traits, _Allocator>3570basic_string<_CharT, _Traits, _Allocator>
3423basic_string<_CharT, _Traits, _Allocator>::substr(size_type __pos, size_type __n) const3571basic_string<_CharT, _Traits, _Allocator>::substr(size_type __pos, size_type __n) const
3424{3572{
...@@ -3426,7 +3574,7 @@ basic_string<_CharT, _Traits, _Allocator>::substr(size_type __pos, size_type __n...@@ -3426,7 +3574,7 @@ basic_string<_CharT, _Traits, _Allocator>::substr(size_type __pos, size_type __n
3426}3574}
34273575
3428template <class _CharT, class _Traits, class _Allocator>3576template <class _CharT, class _Traits, class _Allocator>
3429inline3577inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3430void3578void
3431basic_string<_CharT, _Traits, _Allocator>::swap(basic_string& __str)3579basic_string<_CharT, _Traits, _Allocator>::swap(basic_string& __str)
3432#if _LIBCPP_STD_VER >= 143580#if _LIBCPP_STD_VER >= 14
...@@ -3436,21 +3584,18 @@ basic_string<_CharT, _Traits, _Allocator>::swap(basic_string& __str)...@@ -3436,21 +3584,18 @@ basic_string<_CharT, _Traits, _Allocator>::swap(basic_string& __str)
3436 __is_nothrow_swappable<allocator_type>::value)3584 __is_nothrow_swappable<allocator_type>::value)
3437#endif3585#endif
3438{3586{
3439#if _LIBCPP_DEBUG_LEVEL == 23587 if (!__is_long())
3440 if (!__libcpp_is_constant_evaluated()) {3588 std::__debug_db_invalidate_all(this);
3441 if (!__is_long())3589 if (!__str.__is_long())
3442 __get_db()->__invalidate_all(this);3590 std::__debug_db_invalidate_all(&__str);
3443 if (!__str.__is_long())3591 std::__debug_db_swap(this, &__str);
3444 __get_db()->__invalidate_all(&__str);3592
3445 __get_db()->swap(this, &__str);
3446 }
3447#endif
3448 _LIBCPP_ASSERT(3593 _LIBCPP_ASSERT(
3449 __alloc_traits::propagate_on_container_swap::value ||3594 __alloc_traits::propagate_on_container_swap::value ||
3450 __alloc_traits::is_always_equal::value ||3595 __alloc_traits::is_always_equal::value ||
3451 __alloc() == __str.__alloc(), "swapping non-equal allocators");3596 __alloc() == __str.__alloc(), "swapping non-equal allocators");
3452 _VSTD::swap(__r_.first(), __str.__r_.first());3597 std::swap(__r_.first(), __str.__r_.first());
3453 _VSTD::__swap_allocator(__alloc(), __str.__alloc());3598 std::__swap_allocator(__alloc(), __str.__alloc());
3454}3599}
34553600
3456// find3601// find
...@@ -3459,12 +3604,13 @@ template <class _Traits>...@@ -3459,12 +3604,13 @@ template <class _Traits>
3459struct _LIBCPP_HIDDEN __traits_eq3604struct _LIBCPP_HIDDEN __traits_eq
3460{3605{
3461 typedef typename _Traits::char_type char_type;3606 typedef typename _Traits::char_type char_type;
3462 _LIBCPP_INLINE_VISIBILITY3607 _LIBCPP_HIDE_FROM_ABI
3463 bool operator()(const char_type& __x, const char_type& __y) _NOEXCEPT3608 bool operator()(const char_type& __x, const char_type& __y) _NOEXCEPT
3464 {return _Traits::eq(__x, __y);}3609 {return _Traits::eq(__x, __y);}
3465};3610};
34663611
3467template<class _CharT, class _Traits, class _Allocator>3612template<class _CharT, class _Traits, class _Allocator>
3613_LIBCPP_CONSTEXPR_AFTER_CXX17
3468typename basic_string<_CharT, _Traits, _Allocator>::size_type3614typename basic_string<_CharT, _Traits, _Allocator>::size_type
3469basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s,3615basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s,
3470 size_type __pos,3616 size_type __pos,
...@@ -3476,7 +3622,7 @@ basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s,...@@ -3476,7 +3622,7 @@ basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s,
3476}3622}
34773623
3478template<class _CharT, class _Traits, class _Allocator>3624template<class _CharT, class _Traits, class _Allocator>
3479inline3625inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3480typename basic_string<_CharT, _Traits, _Allocator>::size_type3626typename basic_string<_CharT, _Traits, _Allocator>::size_type
3481basic_string<_CharT, _Traits, _Allocator>::find(const basic_string& __str,3627basic_string<_CharT, _Traits, _Allocator>::find(const basic_string& __str,
3482 size_type __pos) const _NOEXCEPT3628 size_type __pos) const _NOEXCEPT
...@@ -3487,6 +3633,7 @@ basic_string<_CharT, _Traits, _Allocator>::find(const basic_string& __str,...@@ -3487,6 +3633,7 @@ basic_string<_CharT, _Traits, _Allocator>::find(const basic_string& __str,
34873633
3488template<class _CharT, class _Traits, class _Allocator>3634template<class _CharT, class _Traits, class _Allocator>
3489template <class _Tp>3635template <class _Tp>
3636_LIBCPP_CONSTEXPR_AFTER_CXX17
3490__enable_if_t3637__enable_if_t
3491<3638<
3492 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,3639 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
...@@ -3501,7 +3648,7 @@ basic_string<_CharT, _Traits, _Allocator>::find(const _Tp &__t,...@@ -3501,7 +3648,7 @@ basic_string<_CharT, _Traits, _Allocator>::find(const _Tp &__t,
3501}3648}
35023649
3503template<class _CharT, class _Traits, class _Allocator>3650template<class _CharT, class _Traits, class _Allocator>
3504inline3651inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3505typename basic_string<_CharT, _Traits, _Allocator>::size_type3652typename basic_string<_CharT, _Traits, _Allocator>::size_type
3506basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s,3653basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s,
3507 size_type __pos) const _NOEXCEPT3654 size_type __pos) const _NOEXCEPT
...@@ -3512,6 +3659,7 @@ basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s,...@@ -3512,6 +3659,7 @@ basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s,
3512}3659}
35133660
3514template<class _CharT, class _Traits, class _Allocator>3661template<class _CharT, class _Traits, class _Allocator>
3662_LIBCPP_CONSTEXPR_AFTER_CXX17
3515typename basic_string<_CharT, _Traits, _Allocator>::size_type3663typename basic_string<_CharT, _Traits, _Allocator>::size_type
3516basic_string<_CharT, _Traits, _Allocator>::find(value_type __c,3664basic_string<_CharT, _Traits, _Allocator>::find(value_type __c,
3517 size_type __pos) const _NOEXCEPT3665 size_type __pos) const _NOEXCEPT
...@@ -3523,6 +3671,7 @@ basic_string<_CharT, _Traits, _Allocator>::find(value_type __c,...@@ -3523,6 +3671,7 @@ basic_string<_CharT, _Traits, _Allocator>::find(value_type __c,
3523// rfind3671// rfind
35243672
3525template<class _CharT, class _Traits, class _Allocator>3673template<class _CharT, class _Traits, class _Allocator>
3674_LIBCPP_CONSTEXPR_AFTER_CXX17
3526typename basic_string<_CharT, _Traits, _Allocator>::size_type3675typename basic_string<_CharT, _Traits, _Allocator>::size_type
3527basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s,3676basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s,
3528 size_type __pos,3677 size_type __pos,
...@@ -3534,7 +3683,7 @@ basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s,...@@ -3534,7 +3683,7 @@ basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s,
3534}3683}
35353684
3536template<class _CharT, class _Traits, class _Allocator>3685template<class _CharT, class _Traits, class _Allocator>
3537inline3686inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3538typename basic_string<_CharT, _Traits, _Allocator>::size_type3687typename basic_string<_CharT, _Traits, _Allocator>::size_type
3539basic_string<_CharT, _Traits, _Allocator>::rfind(const basic_string& __str,3688basic_string<_CharT, _Traits, _Allocator>::rfind(const basic_string& __str,
3540 size_type __pos) const _NOEXCEPT3689 size_type __pos) const _NOEXCEPT
...@@ -3545,6 +3694,7 @@ basic_string<_CharT, _Traits, _Allocator>::rfind(const basic_string& __str,...@@ -3545,6 +3694,7 @@ basic_string<_CharT, _Traits, _Allocator>::rfind(const basic_string& __str,
35453694
3546template<class _CharT, class _Traits, class _Allocator>3695template<class _CharT, class _Traits, class _Allocator>
3547template <class _Tp>3696template <class _Tp>
3697_LIBCPP_CONSTEXPR_AFTER_CXX17
3548__enable_if_t3698__enable_if_t
3549<3699<
3550 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,3700 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
...@@ -3559,7 +3709,7 @@ basic_string<_CharT, _Traits, _Allocator>::rfind(const _Tp& __t,...@@ -3559,7 +3709,7 @@ basic_string<_CharT, _Traits, _Allocator>::rfind(const _Tp& __t,
3559}3709}
35603710
3561template<class _CharT, class _Traits, class _Allocator>3711template<class _CharT, class _Traits, class _Allocator>
3562inline3712inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3563typename basic_string<_CharT, _Traits, _Allocator>::size_type3713typename basic_string<_CharT, _Traits, _Allocator>::size_type
3564basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s,3714basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s,
3565 size_type __pos) const _NOEXCEPT3715 size_type __pos) const _NOEXCEPT
...@@ -3570,6 +3720,7 @@ basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s,...@@ -3570,6 +3720,7 @@ basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s,
3570}3720}
35713721
3572template<class _CharT, class _Traits, class _Allocator>3722template<class _CharT, class _Traits, class _Allocator>
3723_LIBCPP_CONSTEXPR_AFTER_CXX17
3573typename basic_string<_CharT, _Traits, _Allocator>::size_type3724typename basic_string<_CharT, _Traits, _Allocator>::size_type
3574basic_string<_CharT, _Traits, _Allocator>::rfind(value_type __c,3725basic_string<_CharT, _Traits, _Allocator>::rfind(value_type __c,
3575 size_type __pos) const _NOEXCEPT3726 size_type __pos) const _NOEXCEPT
...@@ -3581,6 +3732,7 @@ basic_string<_CharT, _Traits, _Allocator>::rfind(value_type __c,...@@ -3581,6 +3732,7 @@ basic_string<_CharT, _Traits, _Allocator>::rfind(value_type __c,
3581// find_first_of3732// find_first_of
35823733
3583template<class _CharT, class _Traits, class _Allocator>3734template<class _CharT, class _Traits, class _Allocator>
3735_LIBCPP_CONSTEXPR_AFTER_CXX17
3584typename basic_string<_CharT, _Traits, _Allocator>::size_type3736typename basic_string<_CharT, _Traits, _Allocator>::size_type
3585basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s,3737basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s,
3586 size_type __pos,3738 size_type __pos,
...@@ -3592,7 +3744,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s,...@@ -3592,7 +3744,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s,
3592}3744}
35933745
3594template<class _CharT, class _Traits, class _Allocator>3746template<class _CharT, class _Traits, class _Allocator>
3595inline3747inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3596typename basic_string<_CharT, _Traits, _Allocator>::size_type3748typename basic_string<_CharT, _Traits, _Allocator>::size_type
3597basic_string<_CharT, _Traits, _Allocator>::find_first_of(const basic_string& __str,3749basic_string<_CharT, _Traits, _Allocator>::find_first_of(const basic_string& __str,
3598 size_type __pos) const _NOEXCEPT3750 size_type __pos) const _NOEXCEPT
...@@ -3603,6 +3755,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_of(const basic_string& __s...@@ -3603,6 +3755,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_of(const basic_string& __s
36033755
3604template<class _CharT, class _Traits, class _Allocator>3756template<class _CharT, class _Traits, class _Allocator>
3605template <class _Tp>3757template <class _Tp>
3758_LIBCPP_CONSTEXPR_AFTER_CXX17
3606__enable_if_t3759__enable_if_t
3607<3760<
3608 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,3761 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
...@@ -3617,7 +3770,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_of(const _Tp& __t,...@@ -3617,7 +3770,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_of(const _Tp& __t,
3617}3770}
36183771
3619template<class _CharT, class _Traits, class _Allocator>3772template<class _CharT, class _Traits, class _Allocator>
3620inline3773inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3621typename basic_string<_CharT, _Traits, _Allocator>::size_type3774typename basic_string<_CharT, _Traits, _Allocator>::size_type
3622basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s,3775basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s,
3623 size_type __pos) const _NOEXCEPT3776 size_type __pos) const _NOEXCEPT
...@@ -3628,7 +3781,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s,...@@ -3628,7 +3781,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s,
3628}3781}
36293782
3630template<class _CharT, class _Traits, class _Allocator>3783template<class _CharT, class _Traits, class _Allocator>
3631inline3784inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3632typename basic_string<_CharT, _Traits, _Allocator>::size_type3785typename basic_string<_CharT, _Traits, _Allocator>::size_type
3633basic_string<_CharT, _Traits, _Allocator>::find_first_of(value_type __c,3786basic_string<_CharT, _Traits, _Allocator>::find_first_of(value_type __c,
3634 size_type __pos) const _NOEXCEPT3787 size_type __pos) const _NOEXCEPT
...@@ -3639,6 +3792,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_of(value_type __c,...@@ -3639,6 +3792,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_of(value_type __c,
3639// find_last_of3792// find_last_of
36403793
3641template<class _CharT, class _Traits, class _Allocator>3794template<class _CharT, class _Traits, class _Allocator>
3795inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3642typename basic_string<_CharT, _Traits, _Allocator>::size_type3796typename basic_string<_CharT, _Traits, _Allocator>::size_type
3643basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s,3797basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s,
3644 size_type __pos,3798 size_type __pos,
...@@ -3650,7 +3804,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s,...@@ -3650,7 +3804,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s,
3650}3804}
36513805
3652template<class _CharT, class _Traits, class _Allocator>3806template<class _CharT, class _Traits, class _Allocator>
3653inline3807inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3654typename basic_string<_CharT, _Traits, _Allocator>::size_type3808typename basic_string<_CharT, _Traits, _Allocator>::size_type
3655basic_string<_CharT, _Traits, _Allocator>::find_last_of(const basic_string& __str,3809basic_string<_CharT, _Traits, _Allocator>::find_last_of(const basic_string& __str,
3656 size_type __pos) const _NOEXCEPT3810 size_type __pos) const _NOEXCEPT
...@@ -3661,6 +3815,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_of(const basic_string& __st...@@ -3661,6 +3815,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_of(const basic_string& __st
36613815
3662template<class _CharT, class _Traits, class _Allocator>3816template<class _CharT, class _Traits, class _Allocator>
3663template <class _Tp>3817template <class _Tp>
3818_LIBCPP_CONSTEXPR_AFTER_CXX17
3664__enable_if_t3819__enable_if_t
3665<3820<
3666 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,3821 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
...@@ -3675,7 +3830,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_of(const _Tp& __t,...@@ -3675,7 +3830,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_of(const _Tp& __t,
3675}3830}
36763831
3677template<class _CharT, class _Traits, class _Allocator>3832template<class _CharT, class _Traits, class _Allocator>
3678inline3833inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3679typename basic_string<_CharT, _Traits, _Allocator>::size_type3834typename basic_string<_CharT, _Traits, _Allocator>::size_type
3680basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s,3835basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s,
3681 size_type __pos) const _NOEXCEPT3836 size_type __pos) const _NOEXCEPT
...@@ -3686,7 +3841,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s,...@@ -3686,7 +3841,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s,
3686}3841}
36873842
3688template<class _CharT, class _Traits, class _Allocator>3843template<class _CharT, class _Traits, class _Allocator>
3689inline3844inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3690typename basic_string<_CharT, _Traits, _Allocator>::size_type3845typename basic_string<_CharT, _Traits, _Allocator>::size_type
3691basic_string<_CharT, _Traits, _Allocator>::find_last_of(value_type __c,3846basic_string<_CharT, _Traits, _Allocator>::find_last_of(value_type __c,
3692 size_type __pos) const _NOEXCEPT3847 size_type __pos) const _NOEXCEPT
...@@ -3697,6 +3852,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_of(value_type __c,...@@ -3697,6 +3852,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_of(value_type __c,
3697// find_first_not_of3852// find_first_not_of
36983853
3699template<class _CharT, class _Traits, class _Allocator>3854template<class _CharT, class _Traits, class _Allocator>
3855_LIBCPP_CONSTEXPR_AFTER_CXX17
3700typename basic_string<_CharT, _Traits, _Allocator>::size_type3856typename basic_string<_CharT, _Traits, _Allocator>::size_type
3701basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* __s,3857basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* __s,
3702 size_type __pos,3858 size_type __pos,
...@@ -3708,7 +3864,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* _...@@ -3708,7 +3864,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* _
3708}3864}
37093865
3710template<class _CharT, class _Traits, class _Allocator>3866template<class _CharT, class _Traits, class _Allocator>
3711inline3867inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3712typename basic_string<_CharT, _Traits, _Allocator>::size_type3868typename basic_string<_CharT, _Traits, _Allocator>::size_type
3713basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const basic_string& __str,3869basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const basic_string& __str,
3714 size_type __pos) const _NOEXCEPT3870 size_type __pos) const _NOEXCEPT
...@@ -3719,6 +3875,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const basic_string&...@@ -3719,6 +3875,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const basic_string&
37193875
3720template<class _CharT, class _Traits, class _Allocator>3876template<class _CharT, class _Traits, class _Allocator>
3721template <class _Tp>3877template <class _Tp>
3878_LIBCPP_CONSTEXPR_AFTER_CXX17
3722__enable_if_t3879__enable_if_t
3723<3880<
3724 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,3881 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
...@@ -3733,7 +3890,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const _Tp& __t,...@@ -3733,7 +3890,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const _Tp& __t,
3733}3890}
37343891
3735template<class _CharT, class _Traits, class _Allocator>3892template<class _CharT, class _Traits, class _Allocator>
3736inline3893inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3737typename basic_string<_CharT, _Traits, _Allocator>::size_type3894typename basic_string<_CharT, _Traits, _Allocator>::size_type
3738basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* __s,3895basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* __s,
3739 size_type __pos) const _NOEXCEPT3896 size_type __pos) const _NOEXCEPT
...@@ -3744,7 +3901,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* _...@@ -3744,7 +3901,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* _
3744}3901}
37453902
3746template<class _CharT, class _Traits, class _Allocator>3903template<class _CharT, class _Traits, class _Allocator>
3747inline3904inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3748typename basic_string<_CharT, _Traits, _Allocator>::size_type3905typename basic_string<_CharT, _Traits, _Allocator>::size_type
3749basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(value_type __c,3906basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(value_type __c,
3750 size_type __pos) const _NOEXCEPT3907 size_type __pos) const _NOEXCEPT
...@@ -3756,6 +3913,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(value_type __c,...@@ -3756,6 +3913,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(value_type __c,
3756// find_last_not_of3913// find_last_not_of
37573914
3758template<class _CharT, class _Traits, class _Allocator>3915template<class _CharT, class _Traits, class _Allocator>
3916_LIBCPP_CONSTEXPR_AFTER_CXX17
3759typename basic_string<_CharT, _Traits, _Allocator>::size_type3917typename basic_string<_CharT, _Traits, _Allocator>::size_type
3760basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __s,3918basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __s,
3761 size_type __pos,3919 size_type __pos,
...@@ -3767,7 +3925,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __...@@ -3767,7 +3925,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __
3767}3925}
37683926
3769template<class _CharT, class _Traits, class _Allocator>3927template<class _CharT, class _Traits, class _Allocator>
3770inline3928inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3771typename basic_string<_CharT, _Traits, _Allocator>::size_type3929typename basic_string<_CharT, _Traits, _Allocator>::size_type
3772basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const basic_string& __str,3930basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const basic_string& __str,
3773 size_type __pos) const _NOEXCEPT3931 size_type __pos) const _NOEXCEPT
...@@ -3778,6 +3936,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const basic_string&...@@ -3778,6 +3936,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const basic_string&
37783936
3779template<class _CharT, class _Traits, class _Allocator>3937template<class _CharT, class _Traits, class _Allocator>
3780template <class _Tp>3938template <class _Tp>
3939_LIBCPP_CONSTEXPR_AFTER_CXX17
3781__enable_if_t3940__enable_if_t
3782<3941<
3783 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,3942 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
...@@ -3792,7 +3951,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const _Tp& __t,...@@ -3792,7 +3951,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const _Tp& __t,
3792}3951}
37933952
3794template<class _CharT, class _Traits, class _Allocator>3953template<class _CharT, class _Traits, class _Allocator>
3795inline3954inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3796typename basic_string<_CharT, _Traits, _Allocator>::size_type3955typename basic_string<_CharT, _Traits, _Allocator>::size_type
3797basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __s,3956basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __s,
3798 size_type __pos) const _NOEXCEPT3957 size_type __pos) const _NOEXCEPT
...@@ -3803,7 +3962,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __...@@ -3803,7 +3962,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __
3803}3962}
38043963
3805template<class _CharT, class _Traits, class _Allocator>3964template<class _CharT, class _Traits, class _Allocator>
3806inline3965inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3807typename basic_string<_CharT, _Traits, _Allocator>::size_type3966typename basic_string<_CharT, _Traits, _Allocator>::size_type
3808basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(value_type __c,3967basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(value_type __c,
3809 size_type __pos) const _NOEXCEPT3968 size_type __pos) const _NOEXCEPT
...@@ -3816,6 +3975,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(value_type __c,...@@ -3816,6 +3975,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(value_type __c,
38163975
3817template <class _CharT, class _Traits, class _Allocator>3976template <class _CharT, class _Traits, class _Allocator>
3818template <class _Tp>3977template <class _Tp>
3978_LIBCPP_CONSTEXPR_AFTER_CXX17
3819__enable_if_t3979__enable_if_t
3820<3980<
3821 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,3981 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
...@@ -3827,7 +3987,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(const _Tp& __t) const _NOEXCE...@@ -3827,7 +3987,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(const _Tp& __t) const _NOEXCE
3827 size_t __lhs_sz = size();3987 size_t __lhs_sz = size();
3828 size_t __rhs_sz = __sv.size();3988 size_t __rhs_sz = __sv.size();
3829 int __result = traits_type::compare(data(), __sv.data(),3989 int __result = traits_type::compare(data(), __sv.data(),
3830 _VSTD::min(__lhs_sz, __rhs_sz));3990 std::min(__lhs_sz, __rhs_sz));
3831 if (__result != 0)3991 if (__result != 0)
3832 return __result;3992 return __result;
3833 if (__lhs_sz < __rhs_sz)3993 if (__lhs_sz < __rhs_sz)
...@@ -3838,7 +3998,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(const _Tp& __t) const _NOEXCE...@@ -3838,7 +3998,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(const _Tp& __t) const _NOEXCE
3838}3998}
38393999
3840template <class _CharT, class _Traits, class _Allocator>4000template <class _CharT, class _Traits, class _Allocator>
3841inline4001inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3842int4002int
3843basic_string<_CharT, _Traits, _Allocator>::compare(const basic_string& __str) const _NOEXCEPT4003basic_string<_CharT, _Traits, _Allocator>::compare(const basic_string& __str) const _NOEXCEPT
3844{4004{
...@@ -3846,6 +4006,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(const basic_string& __str) co...@@ -3846,6 +4006,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(const basic_string& __str) co
3846}4006}
38474007
3848template <class _CharT, class _Traits, class _Allocator>4008template <class _CharT, class _Traits, class _Allocator>
4009inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3849int4010int
3850basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,4011basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
3851 size_type __n1,4012 size_type __n1,
...@@ -3856,8 +4017,8 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,...@@ -3856,8 +4017,8 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
3856 size_type __sz = size();4017 size_type __sz = size();
3857 if (__pos1 > __sz || __n2 == npos)4018 if (__pos1 > __sz || __n2 == npos)
3858 __throw_out_of_range();4019 __throw_out_of_range();
3859 size_type __rlen = _VSTD::min(__n1, __sz - __pos1);4020 size_type __rlen = std::min(__n1, __sz - __pos1);
3860 int __r = traits_type::compare(data() + __pos1, __s, _VSTD::min(__rlen, __n2));4021 int __r = traits_type::compare(data() + __pos1, __s, std::min(__rlen, __n2));
3861 if (__r == 0)4022 if (__r == 0)
3862 {4023 {
3863 if (__rlen < __n2)4024 if (__rlen < __n2)
...@@ -3870,6 +4031,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,...@@ -3870,6 +4031,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
38704031
3871template <class _CharT, class _Traits, class _Allocator>4032template <class _CharT, class _Traits, class _Allocator>
3872template <class _Tp>4033template <class _Tp>
4034_LIBCPP_CONSTEXPR_AFTER_CXX17
3873__enable_if_t4035__enable_if_t
3874<4036<
3875 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,4037 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
...@@ -3884,7 +4046,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,...@@ -3884,7 +4046,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
3884}4046}
38854047
3886template <class _CharT, class _Traits, class _Allocator>4048template <class _CharT, class _Traits, class _Allocator>
3887inline4049inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3888int4050int
3889basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,4051basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
3890 size_type __n1,4052 size_type __n1,
...@@ -3895,6 +4057,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,...@@ -3895,6 +4057,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
38954057
3896template <class _CharT, class _Traits, class _Allocator>4058template <class _CharT, class _Traits, class _Allocator>
3897template <class _Tp>4059template <class _Tp>
4060_LIBCPP_CONSTEXPR_AFTER_CXX17
3898__enable_if_t4061__enable_if_t
3899<4062<
3900 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value4063 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value
...@@ -3912,6 +4075,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,...@@ -3912,6 +4075,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
3912}4075}
39134076
3914template <class _CharT, class _Traits, class _Allocator>4077template <class _CharT, class _Traits, class _Allocator>
4078_LIBCPP_CONSTEXPR_AFTER_CXX17
3915int4079int
3916basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,4080basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
3917 size_type __n1,4081 size_type __n1,
...@@ -3923,6 +4087,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,...@@ -3923,6 +4087,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
3923}4087}
39244088
3925template <class _CharT, class _Traits, class _Allocator>4089template <class _CharT, class _Traits, class _Allocator>
4090_LIBCPP_CONSTEXPR_AFTER_CXX17
3926int4091int
3927basic_string<_CharT, _Traits, _Allocator>::compare(const value_type* __s) const _NOEXCEPT4092basic_string<_CharT, _Traits, _Allocator>::compare(const value_type* __s) const _NOEXCEPT
3928{4093{
...@@ -3931,6 +4096,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(const value_type* __s) const...@@ -3931,6 +4096,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(const value_type* __s) const
3931}4096}
39324097
3933template <class _CharT, class _Traits, class _Allocator>4098template <class _CharT, class _Traits, class _Allocator>
4099_LIBCPP_CONSTEXPR_AFTER_CXX17
3934int4100int
3935basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,4101basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
3936 size_type __n1,4102 size_type __n1,
...@@ -3943,7 +4109,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,...@@ -3943,7 +4109,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
3943// __invariants4109// __invariants
39444110
3945template<class _CharT, class _Traits, class _Allocator>4111template<class _CharT, class _Traits, class _Allocator>
3946inline4112inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3947bool4113bool
3948basic_string<_CharT, _Traits, _Allocator>::__invariants() const4114basic_string<_CharT, _Traits, _Allocator>::__invariants() const
3949{4115{
...@@ -3961,7 +4127,7 @@ basic_string<_CharT, _Traits, _Allocator>::__invariants() const...@@ -3961,7 +4127,7 @@ basic_string<_CharT, _Traits, _Allocator>::__invariants() const
3961// __clear_and_shrink4127// __clear_and_shrink
39624128
3963template<class _CharT, class _Traits, class _Allocator>4129template<class _CharT, class _Traits, class _Allocator>
3964inline4130inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3965void4131void
3966basic_string<_CharT, _Traits, _Allocator>::__clear_and_shrink() _NOEXCEPT4132basic_string<_CharT, _Traits, _Allocator>::__clear_and_shrink() _NOEXCEPT
3967{4133{
...@@ -3978,7 +4144,7 @@ basic_string<_CharT, _Traits, _Allocator>::__clear_and_shrink() _NOEXCEPT...@@ -3978,7 +4144,7 @@ basic_string<_CharT, _Traits, _Allocator>::__clear_and_shrink() _NOEXCEPT
3978// operator==4144// operator==
39794145
3980template<class _CharT, class _Traits, class _Allocator>4146template<class _CharT, class _Traits, class _Allocator>
3981inline _LIBCPP_INLINE_VISIBILITY4147inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
3982bool4148bool
3983operator==(const basic_string<_CharT, _Traits, _Allocator>& __lhs,4149operator==(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
3984 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT4150 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
...@@ -3990,7 +4156,7 @@ operator==(const basic_string<_CharT, _Traits, _Allocator>& __lhs,...@@ -3990,7 +4156,7 @@ operator==(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
3990}4156}
39914157
3992template<class _Allocator>4158template<class _Allocator>
3993inline _LIBCPP_INLINE_VISIBILITY4159inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
3994bool4160bool
3995operator==(const basic_string<char, char_traits<char>, _Allocator>& __lhs,4161operator==(const basic_string<char, char_traits<char>, _Allocator>& __lhs,
3996 const basic_string<char, char_traits<char>, _Allocator>& __rhs) _NOEXCEPT4162 const basic_string<char, char_traits<char>, _Allocator>& __rhs) _NOEXCEPT
...@@ -4009,7 +4175,7 @@ operator==(const basic_string<char, char_traits<char>, _Allocator>& __lhs,...@@ -4009,7 +4175,7 @@ operator==(const basic_string<char, char_traits<char>, _Allocator>& __lhs,
4009}4175}
40104176
4011template<class _CharT, class _Traits, class _Allocator>4177template<class _CharT, class _Traits, class _Allocator>
4012inline _LIBCPP_INLINE_VISIBILITY4178inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
4013bool4179bool
4014operator==(const _CharT* __lhs,4180operator==(const _CharT* __lhs,
4015 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT4181 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
...@@ -4022,7 +4188,7 @@ operator==(const _CharT* __lhs,...@@ -4022,7 +4188,7 @@ operator==(const _CharT* __lhs,
4022}4188}
40234189
4024template<class _CharT, class _Traits, class _Allocator>4190template<class _CharT, class _Traits, class _Allocator>
4025inline _LIBCPP_INLINE_VISIBILITY4191inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
4026bool4192bool
4027operator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs,4193operator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
4028 const _CharT* __rhs) _NOEXCEPT4194 const _CharT* __rhs) _NOEXCEPT
...@@ -4035,7 +4201,7 @@ operator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs,...@@ -4035,7 +4201,7 @@ operator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
4035}4201}
40364202
4037template<class _CharT, class _Traits, class _Allocator>4203template<class _CharT, class _Traits, class _Allocator>
4038inline _LIBCPP_INLINE_VISIBILITY4204inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
4039bool4205bool
4040operator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,4206operator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
4041 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT4207 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
...@@ -4044,7 +4210,7 @@ operator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,...@@ -4044,7 +4210,7 @@ operator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
4044}4210}
40454211
4046template<class _CharT, class _Traits, class _Allocator>4212template<class _CharT, class _Traits, class _Allocator>
4047inline _LIBCPP_INLINE_VISIBILITY4213inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
4048bool4214bool
4049operator!=(const _CharT* __lhs,4215operator!=(const _CharT* __lhs,
4050 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT4216 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
...@@ -4053,7 +4219,7 @@ operator!=(const _CharT* __lhs,...@@ -4053,7 +4219,7 @@ operator!=(const _CharT* __lhs,
4053}4219}
40544220
4055template<class _CharT, class _Traits, class _Allocator>4221template<class _CharT, class _Traits, class _Allocator>
4056inline _LIBCPP_INLINE_VISIBILITY4222inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
4057bool4223bool
4058operator!=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,4224operator!=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
4059 const _CharT* __rhs) _NOEXCEPT4225 const _CharT* __rhs) _NOEXCEPT
...@@ -4064,7 +4230,7 @@ operator!=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,...@@ -4064,7 +4230,7 @@ operator!=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
4064// operator<4230// operator<
40654231
4066template<class _CharT, class _Traits, class _Allocator>4232template<class _CharT, class _Traits, class _Allocator>
4067inline _LIBCPP_INLINE_VISIBILITY4233inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
4068bool4234bool
4069operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs,4235operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
4070 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT4236 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
...@@ -4073,7 +4239,7 @@ operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs,...@@ -4073,7 +4239,7 @@ operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
4073}4239}
40744240
4075template<class _CharT, class _Traits, class _Allocator>4241template<class _CharT, class _Traits, class _Allocator>
4076inline _LIBCPP_INLINE_VISIBILITY4242inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
4077bool4243bool
4078operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs,4244operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
4079 const _CharT* __rhs) _NOEXCEPT4245 const _CharT* __rhs) _NOEXCEPT
...@@ -4082,7 +4248,7 @@ operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs,...@@ -4082,7 +4248,7 @@ operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
4082}4248}
40834249
4084template<class _CharT, class _Traits, class _Allocator>4250template<class _CharT, class _Traits, class _Allocator>
4085inline _LIBCPP_INLINE_VISIBILITY4251inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
4086bool4252bool
4087operator< (const _CharT* __lhs,4253operator< (const _CharT* __lhs,
4088 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT4254 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
...@@ -4093,7 +4259,7 @@ operator< (const _CharT* __lhs,...@@ -4093,7 +4259,7 @@ operator< (const _CharT* __lhs,
4093// operator>4259// operator>
40944260
4095template<class _CharT, class _Traits, class _Allocator>4261template<class _CharT, class _Traits, class _Allocator>
4096inline _LIBCPP_INLINE_VISIBILITY4262inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
4097bool4263bool
4098operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs,4264operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
4099 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT4265 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
...@@ -4102,7 +4268,7 @@ operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs,...@@ -4102,7 +4268,7 @@ operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
4102}4268}
41034269
4104template<class _CharT, class _Traits, class _Allocator>4270template<class _CharT, class _Traits, class _Allocator>
4105inline _LIBCPP_INLINE_VISIBILITY4271inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
4106bool4272bool
4107operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs,4273operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
4108 const _CharT* __rhs) _NOEXCEPT4274 const _CharT* __rhs) _NOEXCEPT
...@@ -4111,7 +4277,7 @@ operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs,...@@ -4111,7 +4277,7 @@ operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
4111}4277}
41124278
4113template<class _CharT, class _Traits, class _Allocator>4279template<class _CharT, class _Traits, class _Allocator>
4114inline _LIBCPP_INLINE_VISIBILITY4280inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
4115bool4281bool
4116operator> (const _CharT* __lhs,4282operator> (const _CharT* __lhs,
4117 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT4283 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
...@@ -4122,7 +4288,7 @@ operator> (const _CharT* __lhs,...@@ -4122,7 +4288,7 @@ operator> (const _CharT* __lhs,
4122// operator<=4288// operator<=
41234289
4124template<class _CharT, class _Traits, class _Allocator>4290template<class _CharT, class _Traits, class _Allocator>
4125inline _LIBCPP_INLINE_VISIBILITY4291inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
4126bool4292bool
4127operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,4293operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
4128 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT4294 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
...@@ -4131,7 +4297,7 @@ operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,...@@ -4131,7 +4297,7 @@ operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
4131}4297}
41324298
4133template<class _CharT, class _Traits, class _Allocator>4299template<class _CharT, class _Traits, class _Allocator>
4134inline _LIBCPP_INLINE_VISIBILITY4300inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
4135bool4301bool
4136operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,4302operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
4137 const _CharT* __rhs) _NOEXCEPT4303 const _CharT* __rhs) _NOEXCEPT
...@@ -4140,7 +4306,7 @@ operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,...@@ -4140,7 +4306,7 @@ operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
4140}4306}
41414307
4142template<class _CharT, class _Traits, class _Allocator>4308template<class _CharT, class _Traits, class _Allocator>
4143inline _LIBCPP_INLINE_VISIBILITY4309inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
4144bool4310bool
4145operator<=(const _CharT* __lhs,4311operator<=(const _CharT* __lhs,
4146 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT4312 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
...@@ -4151,7 +4317,7 @@ operator<=(const _CharT* __lhs,...@@ -4151,7 +4317,7 @@ operator<=(const _CharT* __lhs,
4151// operator>=4317// operator>=
41524318
4153template<class _CharT, class _Traits, class _Allocator>4319template<class _CharT, class _Traits, class _Allocator>
4154inline _LIBCPP_INLINE_VISIBILITY4320inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
4155bool4321bool
4156operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,4322operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
4157 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT4323 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
...@@ -4160,7 +4326,7 @@ operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,...@@ -4160,7 +4326,7 @@ operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
4160}4326}
41614327
4162template<class _CharT, class _Traits, class _Allocator>4328template<class _CharT, class _Traits, class _Allocator>
4163inline _LIBCPP_INLINE_VISIBILITY4329inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
4164bool4330bool
4165operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,4331operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
4166 const _CharT* __rhs) _NOEXCEPT4332 const _CharT* __rhs) _NOEXCEPT
...@@ -4169,7 +4335,7 @@ operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,...@@ -4169,7 +4335,7 @@ operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
4169}4335}
41704336
4171template<class _CharT, class _Traits, class _Allocator>4337template<class _CharT, class _Traits, class _Allocator>
4172inline _LIBCPP_INLINE_VISIBILITY4338inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
4173bool4339bool
4174operator>=(const _CharT* __lhs,4340operator>=(const _CharT* __lhs,
4175 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT4341 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
...@@ -4180,123 +4346,152 @@ operator>=(const _CharT* __lhs,...@@ -4180,123 +4346,152 @@ operator>=(const _CharT* __lhs,
4180// operator +4346// operator +
41814347
4182template<class _CharT, class _Traits, class _Allocator>4348template<class _CharT, class _Traits, class _Allocator>
4349_LIBCPP_CONSTEXPR_AFTER_CXX17
4183basic_string<_CharT, _Traits, _Allocator>4350basic_string<_CharT, _Traits, _Allocator>
4184operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs,4351operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
4185 const basic_string<_CharT, _Traits, _Allocator>& __rhs)4352 const basic_string<_CharT, _Traits, _Allocator>& __rhs)
4186{4353{
4187 basic_string<_CharT, _Traits, _Allocator> __r(__lhs.get_allocator());4354 using _String = basic_string<_CharT, _Traits, _Allocator>;
4188 typename basic_string<_CharT, _Traits, _Allocator>::size_type __lhs_sz = __lhs.size();4355 auto __lhs_sz = __lhs.size();
4189 typename basic_string<_CharT, _Traits, _Allocator>::size_type __rhs_sz = __rhs.size();4356 auto __rhs_sz = __rhs.size();
4190 __r.__init(__lhs.data(), __lhs_sz, __lhs_sz + __rhs_sz);4357 _String __r(__uninitialized_size_tag(),
4191 __r.append(__rhs.data(), __rhs_sz);4358 __lhs_sz + __rhs_sz,
4359 _String::__alloc_traits::select_on_container_copy_construction(__lhs.get_allocator()));
4360 auto __ptr = std::__to_address(__r.__get_pointer());
4361 _Traits::copy(__ptr, __lhs.data(), __lhs_sz);
4362 _Traits::copy(__ptr + __lhs_sz, __rhs.data(), __rhs_sz);
4363 _Traits::assign(__ptr + __lhs_sz + __rhs_sz, 1, _CharT());
4192 return __r;4364 return __r;
4193}4365}
41944366
4195template<class _CharT, class _Traits, class _Allocator>4367template<class _CharT, class _Traits, class _Allocator>
4368_LIBCPP_CONSTEXPR_AFTER_CXX17
4196basic_string<_CharT, _Traits, _Allocator>4369basic_string<_CharT, _Traits, _Allocator>
4197operator+(const _CharT* __lhs , const basic_string<_CharT,_Traits,_Allocator>& __rhs)4370operator+(const _CharT* __lhs , const basic_string<_CharT,_Traits,_Allocator>& __rhs)
4198{4371{
4199 basic_string<_CharT, _Traits, _Allocator> __r(__rhs.get_allocator());4372 using _String = basic_string<_CharT, _Traits, _Allocator>;
4200 typename basic_string<_CharT, _Traits, _Allocator>::size_type __lhs_sz = _Traits::length(__lhs);4373 auto __lhs_sz = _Traits::length(__lhs);
4201 typename basic_string<_CharT, _Traits, _Allocator>::size_type __rhs_sz = __rhs.size();4374 auto __rhs_sz = __rhs.size();
4202 __r.__init(__lhs, __lhs_sz, __lhs_sz + __rhs_sz);4375 _String __r(__uninitialized_size_tag(),
4203 __r.append(__rhs.data(), __rhs_sz);4376 __lhs_sz + __rhs_sz,
4377 _String::__alloc_traits::select_on_container_copy_construction(__rhs.get_allocator()));
4378 auto __ptr = std::__to_address(__r.__get_pointer());
4379 _Traits::copy(__ptr, __lhs, __lhs_sz);
4380 _Traits::copy(__ptr + __lhs_sz, __rhs.data(), __rhs_sz);
4381 _Traits::assign(__ptr + __lhs_sz + __rhs_sz, 1, _CharT());
4204 return __r;4382 return __r;
4205}4383}
42064384
4207template<class _CharT, class _Traits, class _Allocator>4385template<class _CharT, class _Traits, class _Allocator>
4386_LIBCPP_CONSTEXPR_AFTER_CXX17
4208basic_string<_CharT, _Traits, _Allocator>4387basic_string<_CharT, _Traits, _Allocator>
4209operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Allocator>& __rhs)4388operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Allocator>& __rhs)
4210{4389{
4211 basic_string<_CharT, _Traits, _Allocator> __r(__rhs.get_allocator());4390 using _String = basic_string<_CharT, _Traits, _Allocator>;
4212 typename basic_string<_CharT, _Traits, _Allocator>::size_type __rhs_sz = __rhs.size();4391 typename _String::size_type __rhs_sz = __rhs.size();
4213 __r.__init(&__lhs, 1, 1 + __rhs_sz);4392 _String __r(__uninitialized_size_tag(),
4214 __r.append(__rhs.data(), __rhs_sz);4393 __rhs_sz + 1,
4394 _String::__alloc_traits::select_on_container_copy_construction(__rhs.get_allocator()));
4395 auto __ptr = std::__to_address(__r.__get_pointer());
4396 _Traits::assign(__ptr, 1, __lhs);
4397 _Traits::copy(__ptr + 1, __rhs.data(), __rhs_sz);
4398 _Traits::assign(__ptr + 1 + __rhs_sz, 1, _CharT());
4215 return __r;4399 return __r;
4216}4400}
42174401
4218template<class _CharT, class _Traits, class _Allocator>4402template<class _CharT, class _Traits, class _Allocator>
4219inline4403inline _LIBCPP_CONSTEXPR_AFTER_CXX17
4220basic_string<_CharT, _Traits, _Allocator>4404basic_string<_CharT, _Traits, _Allocator>
4221operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs)4405operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs)
4222{4406{
4223 basic_string<_CharT, _Traits, _Allocator> __r(__lhs.get_allocator());4407 using _String = basic_string<_CharT, _Traits, _Allocator>;
4224 typename basic_string<_CharT, _Traits, _Allocator>::size_type __lhs_sz = __lhs.size();4408 typename _String::size_type __lhs_sz = __lhs.size();
4225 typename basic_string<_CharT, _Traits, _Allocator>::size_type __rhs_sz = _Traits::length(__rhs);4409 typename _String::size_type __rhs_sz = _Traits::length(__rhs);
4226 __r.__init(__lhs.data(), __lhs_sz, __lhs_sz + __rhs_sz);4410 _String __r(__uninitialized_size_tag(),
4227 __r.append(__rhs, __rhs_sz);4411 __lhs_sz + __rhs_sz,
4412 _String::__alloc_traits::select_on_container_copy_construction(__lhs.get_allocator()));
4413 auto __ptr = std::__to_address(__r.__get_pointer());
4414 _Traits::copy(__ptr, __lhs.data(), __lhs_sz);
4415 _Traits::copy(__ptr + __lhs_sz, __rhs, __rhs_sz);
4416 _Traits::assign(__ptr + __lhs_sz + __rhs_sz, 1, _CharT());
4228 return __r;4417 return __r;
4229}4418}
42304419
4231template<class _CharT, class _Traits, class _Allocator>4420template<class _CharT, class _Traits, class _Allocator>
4421_LIBCPP_CONSTEXPR_AFTER_CXX17
4232basic_string<_CharT, _Traits, _Allocator>4422basic_string<_CharT, _Traits, _Allocator>
4233operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, _CharT __rhs)4423operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, _CharT __rhs)
4234{4424{
4235 basic_string<_CharT, _Traits, _Allocator> __r(__lhs.get_allocator());4425 using _String = basic_string<_CharT, _Traits, _Allocator>;
4236 typename basic_string<_CharT, _Traits, _Allocator>::size_type __lhs_sz = __lhs.size();4426 typename _String::size_type __lhs_sz = __lhs.size();
4237 __r.__init(__lhs.data(), __lhs_sz, __lhs_sz + 1);4427 _String __r(__uninitialized_size_tag(),
4238 __r.push_back(__rhs);4428 __lhs_sz + 1,
4429 _String::__alloc_traits::select_on_container_copy_construction(__lhs.get_allocator()));
4430 auto __ptr = std::__to_address(__r.__get_pointer());
4431 _Traits::copy(__ptr, __lhs.data(), __lhs_sz);
4432 _Traits::assign(__ptr + __lhs_sz, 1, __rhs);
4433 _Traits::assign(__ptr + 1 + __lhs_sz, 1, _CharT());
4239 return __r;4434 return __r;
4240}4435}
42414436
4242#ifndef _LIBCPP_CXX03_LANG4437#ifndef _LIBCPP_CXX03_LANG
42434438
4244template<class _CharT, class _Traits, class _Allocator>4439template<class _CharT, class _Traits, class _Allocator>
4245inline _LIBCPP_INLINE_VISIBILITY4440inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
4246basic_string<_CharT, _Traits, _Allocator>4441basic_string<_CharT, _Traits, _Allocator>
4247operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs)4442operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs)
4248{4443{
4249 return _VSTD::move(__lhs.append(__rhs));4444 return std::move(__lhs.append(__rhs));
4250}4445}
42514446
4252template<class _CharT, class _Traits, class _Allocator>4447template<class _CharT, class _Traits, class _Allocator>
4253inline _LIBCPP_INLINE_VISIBILITY4448inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
4254basic_string<_CharT, _Traits, _Allocator>4449basic_string<_CharT, _Traits, _Allocator>
4255operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs)4450operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs)
4256{4451{
4257 return _VSTD::move(__rhs.insert(0, __lhs));4452 return std::move(__rhs.insert(0, __lhs));
4258}4453}
42594454
4260template<class _CharT, class _Traits, class _Allocator>4455template<class _CharT, class _Traits, class _Allocator>
4261inline _LIBCPP_INLINE_VISIBILITY4456inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
4262basic_string<_CharT, _Traits, _Allocator>4457basic_string<_CharT, _Traits, _Allocator>
4263operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs)4458operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs)
4264{4459{
4265 return _VSTD::move(__lhs.append(__rhs));4460 return std::move(__lhs.append(__rhs));
4266}4461}
42674462
4268template<class _CharT, class _Traits, class _Allocator>4463template<class _CharT, class _Traits, class _Allocator>
4269inline _LIBCPP_INLINE_VISIBILITY4464inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
4270basic_string<_CharT, _Traits, _Allocator>4465basic_string<_CharT, _Traits, _Allocator>
4271operator+(const _CharT* __lhs , basic_string<_CharT,_Traits,_Allocator>&& __rhs)4466operator+(const _CharT* __lhs , basic_string<_CharT,_Traits,_Allocator>&& __rhs)
4272{4467{
4273 return _VSTD::move(__rhs.insert(0, __lhs));4468 return std::move(__rhs.insert(0, __lhs));
4274}4469}
42754470
4276template<class _CharT, class _Traits, class _Allocator>4471template<class _CharT, class _Traits, class _Allocator>
4277inline _LIBCPP_INLINE_VISIBILITY4472inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
4278basic_string<_CharT, _Traits, _Allocator>4473basic_string<_CharT, _Traits, _Allocator>
4279operator+(_CharT __lhs, basic_string<_CharT,_Traits,_Allocator>&& __rhs)4474operator+(_CharT __lhs, basic_string<_CharT,_Traits,_Allocator>&& __rhs)
4280{4475{
4281 __rhs.insert(__rhs.begin(), __lhs);4476 __rhs.insert(__rhs.begin(), __lhs);
4282 return _VSTD::move(__rhs);4477 return std::move(__rhs);
4283}4478}
42844479
4285template<class _CharT, class _Traits, class _Allocator>4480template<class _CharT, class _Traits, class _Allocator>
4286inline _LIBCPP_INLINE_VISIBILITY4481inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
4287basic_string<_CharT, _Traits, _Allocator>4482basic_string<_CharT, _Traits, _Allocator>
4288operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const _CharT* __rhs)4483operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const _CharT* __rhs)
4289{4484{
4290 return _VSTD::move(__lhs.append(__rhs));4485 return std::move(__lhs.append(__rhs));
4291}4486}
42924487
4293template<class _CharT, class _Traits, class _Allocator>4488template<class _CharT, class _Traits, class _Allocator>
4294inline _LIBCPP_INLINE_VISIBILITY4489inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
4295basic_string<_CharT, _Traits, _Allocator>4490basic_string<_CharT, _Traits, _Allocator>
4296operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, _CharT __rhs)4491operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, _CharT __rhs)
4297{4492{
4298 __lhs.push_back(__rhs);4493 __lhs.push_back(__rhs);
4299 return _VSTD::move(__lhs);4494 return std::move(__lhs);
4300}4495}
43014496
4302#endif // _LIBCPP_CXX03_LANG4497#endif // _LIBCPP_CXX03_LANG
...@@ -4304,7 +4499,7 @@ operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, _CharT __rhs)...@@ -4304,7 +4499,7 @@ operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, _CharT __rhs)
4304// swap4499// swap
43054500
4306template<class _CharT, class _Traits, class _Allocator>4501template<class _CharT, class _Traits, class _Allocator>
4307inline _LIBCPP_INLINE_VISIBILITY4502inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
4308void4503void
4309swap(basic_string<_CharT, _Traits, _Allocator>& __lhs,4504swap(basic_string<_CharT, _Traits, _Allocator>& __lhs,
4310 basic_string<_CharT, _Traits, _Allocator>& __rhs)4505 basic_string<_CharT, _Traits, _Allocator>& __rhs)
...@@ -4363,15 +4558,13 @@ const typename basic_string<_CharT, _Traits, _Allocator>::size_type...@@ -4363,15 +4558,13 @@ const typename basic_string<_CharT, _Traits, _Allocator>::size_type
4363template <class _CharT, class _Allocator>4558template <class _CharT, class _Allocator>
4364struct _LIBCPP_TEMPLATE_VIS4559struct _LIBCPP_TEMPLATE_VIS
4365 hash<basic_string<_CharT, char_traits<_CharT>, _Allocator> >4560 hash<basic_string<_CharT, char_traits<_CharT>, _Allocator> >
4366 : public unary_function<4561 : public __unary_function<basic_string<_CharT, char_traits<_CharT>, _Allocator>, size_t>
4367 basic_string<_CharT, char_traits<_CharT>, _Allocator>, size_t>
4368{4562{
4369 size_t4563 size_t
4370 operator()(const basic_string<_CharT, char_traits<_CharT>, _Allocator>& __val) const _NOEXCEPT4564 operator()(const basic_string<_CharT, char_traits<_CharT>, _Allocator>& __val) const _NOEXCEPT
4371 { return __do_string_hash(__val.data(), __val.data() + __val.size()); }4565 { return __do_string_hash(__val.data(), __val.data() + __val.size()); }
4372};4566};
43734567
4374
4375template<class _CharT, class _Traits, class _Allocator>4568template<class _CharT, class _Traits, class _Allocator>
4376basic_ostream<_CharT, _Traits>&4569basic_ostream<_CharT, _Traits>&
4377operator<<(basic_ostream<_CharT, _Traits>& __os,4570operator<<(basic_ostream<_CharT, _Traits>& __os,
...@@ -4388,68 +4581,68 @@ getline(basic_istream<_CharT, _Traits>& __is,...@@ -4388,68 +4581,68 @@ getline(basic_istream<_CharT, _Traits>& __is,
4388 basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm);4581 basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm);
43894582
4390template<class _CharT, class _Traits, class _Allocator>4583template<class _CharT, class _Traits, class _Allocator>
4391inline _LIBCPP_INLINE_VISIBILITY4584inline _LIBCPP_HIDE_FROM_ABI
4392basic_istream<_CharT, _Traits>&4585basic_istream<_CharT, _Traits>&
4393getline(basic_istream<_CharT, _Traits>& __is,4586getline(basic_istream<_CharT, _Traits>& __is,
4394 basic_string<_CharT, _Traits, _Allocator>& __str);4587 basic_string<_CharT, _Traits, _Allocator>& __str);
43954588
4396template<class _CharT, class _Traits, class _Allocator>4589template<class _CharT, class _Traits, class _Allocator>
4397inline _LIBCPP_INLINE_VISIBILITY4590inline _LIBCPP_HIDE_FROM_ABI
4398basic_istream<_CharT, _Traits>&4591basic_istream<_CharT, _Traits>&
4399getline(basic_istream<_CharT, _Traits>&& __is,4592getline(basic_istream<_CharT, _Traits>&& __is,
4400 basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm);4593 basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm);
44014594
4402template<class _CharT, class _Traits, class _Allocator>4595template<class _CharT, class _Traits, class _Allocator>
4403inline _LIBCPP_INLINE_VISIBILITY4596inline _LIBCPP_HIDE_FROM_ABI
4404basic_istream<_CharT, _Traits>&4597basic_istream<_CharT, _Traits>&
4405getline(basic_istream<_CharT, _Traits>&& __is,4598getline(basic_istream<_CharT, _Traits>&& __is,
4406 basic_string<_CharT, _Traits, _Allocator>& __str);4599 basic_string<_CharT, _Traits, _Allocator>& __str);
44074600
4408#if _LIBCPP_STD_VER > 174601#if _LIBCPP_STD_VER > 17
4409template <class _CharT, class _Traits, class _Allocator, class _Up>4602template <class _CharT, class _Traits, class _Allocator, class _Up>
4410inline _LIBCPP_INLINE_VISIBILITY4603inline _LIBCPP_HIDE_FROM_ABI
4411 typename basic_string<_CharT, _Traits, _Allocator>::size_type4604 typename basic_string<_CharT, _Traits, _Allocator>::size_type
4412 erase(basic_string<_CharT, _Traits, _Allocator>& __str, const _Up& __v) {4605 erase(basic_string<_CharT, _Traits, _Allocator>& __str, const _Up& __v) {
4413 auto __old_size = __str.size();4606 auto __old_size = __str.size();
4414 __str.erase(_VSTD::remove(__str.begin(), __str.end(), __v), __str.end());4607 __str.erase(std::remove(__str.begin(), __str.end(), __v), __str.end());
4415 return __old_size - __str.size();4608 return __old_size - __str.size();
4416}4609}
44174610
4418template <class _CharT, class _Traits, class _Allocator, class _Predicate>4611template <class _CharT, class _Traits, class _Allocator, class _Predicate>
4419inline _LIBCPP_INLINE_VISIBILITY4612inline _LIBCPP_HIDE_FROM_ABI
4420 typename basic_string<_CharT, _Traits, _Allocator>::size_type4613 typename basic_string<_CharT, _Traits, _Allocator>::size_type
4421 erase_if(basic_string<_CharT, _Traits, _Allocator>& __str,4614 erase_if(basic_string<_CharT, _Traits, _Allocator>& __str,
4422 _Predicate __pred) {4615 _Predicate __pred) {
4423 auto __old_size = __str.size();4616 auto __old_size = __str.size();
4424 __str.erase(_VSTD::remove_if(__str.begin(), __str.end(), __pred),4617 __str.erase(std::remove_if(__str.begin(), __str.end(), __pred),
4425 __str.end());4618 __str.end());
4426 return __old_size - __str.size();4619 return __old_size - __str.size();
4427}4620}
4428#endif4621#endif
44294622
4430#if _LIBCPP_DEBUG_LEVEL == 24623#ifdef _LIBCPP_ENABLE_DEBUG_MODE
44314624
4432template<class _CharT, class _Traits, class _Allocator>4625template<class _CharT, class _Traits, class _Allocator>
4433bool4626bool
4434basic_string<_CharT, _Traits, _Allocator>::__dereferenceable(const const_iterator* __i) const4627basic_string<_CharT, _Traits, _Allocator>::__dereferenceable(const const_iterator* __i) const
4435{4628{
4436 return data() <= _VSTD::__to_address(__i->base()) &&4629 return data() <= std::__to_address(__i->base()) &&
4437 _VSTD::__to_address(__i->base()) < data() + size();4630 std::__to_address(__i->base()) < data() + size();
4438}4631}
44394632
4440template<class _CharT, class _Traits, class _Allocator>4633template<class _CharT, class _Traits, class _Allocator>
4441bool4634bool
4442basic_string<_CharT, _Traits, _Allocator>::__decrementable(const const_iterator* __i) const4635basic_string<_CharT, _Traits, _Allocator>::__decrementable(const const_iterator* __i) const
4443{4636{
4444 return data() < _VSTD::__to_address(__i->base()) &&4637 return data() < std::__to_address(__i->base()) &&
4445 _VSTD::__to_address(__i->base()) <= data() + size();4638 std::__to_address(__i->base()) <= data() + size();
4446}4639}
44474640
4448template<class _CharT, class _Traits, class _Allocator>4641template<class _CharT, class _Traits, class _Allocator>
4449bool4642bool
4450basic_string<_CharT, _Traits, _Allocator>::__addable(const const_iterator* __i, ptrdiff_t __n) const4643basic_string<_CharT, _Traits, _Allocator>::__addable(const const_iterator* __i, ptrdiff_t __n) const
4451{4644{
4452 const value_type* __p = _VSTD::__to_address(__i->base()) + __n;4645 const value_type* __p = std::__to_address(__i->base()) + __n;
4453 return data() <= __p && __p <= data() + size();4646 return data() <= __p && __p <= data() + size();
4454}4647}
44554648
...@@ -4457,11 +4650,11 @@ template<class _CharT, class _Traits, class _Allocator>...@@ -4457,11 +4650,11 @@ template<class _CharT, class _Traits, class _Allocator>
4457bool4650bool
4458basic_string<_CharT, _Traits, _Allocator>::__subscriptable(const const_iterator* __i, ptrdiff_t __n) const4651basic_string<_CharT, _Traits, _Allocator>::__subscriptable(const const_iterator* __i, ptrdiff_t __n) const
4459{4652{
4460 const value_type* __p = _VSTD::__to_address(__i->base()) + __n;4653 const value_type* __p = std::__to_address(__i->base()) + __n;
4461 return data() <= __p && __p < data() + size();4654 return data() <= __p && __p < data() + size();
4462}4655}
44634656
4464#endif // _LIBCPP_DEBUG_LEVEL == 24657#endif // _LIBCPP_ENABLE_DEBUG_MODE
44654658
4466#if _LIBCPP_STD_VER > 114659#if _LIBCPP_STD_VER > 11
4467// Literal suffixes for basic_string [basic.string.literals]4660// Literal suffixes for basic_string [basic.string.literals]
...@@ -4469,14 +4662,14 @@ inline namespace literals...@@ -4469,14 +4662,14 @@ inline namespace literals
4469{4662{
4470 inline namespace string_literals4663 inline namespace string_literals
4471 {4664 {
4472 inline _LIBCPP_INLINE_VISIBILITY4665 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
4473 basic_string<char> operator "" s( const char *__str, size_t __len )4666 basic_string<char> operator "" s( const char *__str, size_t __len )
4474 {4667 {
4475 return basic_string<char> (__str, __len);4668 return basic_string<char> (__str, __len);
4476 }4669 }
44774670
4478#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS4671#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
4479 inline _LIBCPP_INLINE_VISIBILITY4672 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
4480 basic_string<wchar_t> operator "" s( const wchar_t *__str, size_t __len )4673 basic_string<wchar_t> operator "" s( const wchar_t *__str, size_t __len )
4481 {4674 {
4482 return basic_string<wchar_t> (__str, __len);4675 return basic_string<wchar_t> (__str, __len);
...@@ -4484,26 +4677,36 @@ inline namespace literals...@@ -4484,26 +4677,36 @@ inline namespace literals
4484#endif4677#endif
44854678
4486#ifndef _LIBCPP_HAS_NO_CHAR8_T4679#ifndef _LIBCPP_HAS_NO_CHAR8_T
4487 inline _LIBCPP_INLINE_VISIBILITY4680 inline _LIBCPP_HIDE_FROM_ABI constexpr
4488 basic_string<char8_t> operator "" s(const char8_t *__str, size_t __len) _NOEXCEPT4681 basic_string<char8_t> operator "" s(const char8_t *__str, size_t __len) _NOEXCEPT
4489 {4682 {
4490 return basic_string<char8_t> (__str, __len);4683 return basic_string<char8_t> (__str, __len);
4491 }4684 }
4492#endif4685#endif
44934686
4494 inline _LIBCPP_INLINE_VISIBILITY4687 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
4495 basic_string<char16_t> operator "" s( const char16_t *__str, size_t __len )4688 basic_string<char16_t> operator "" s( const char16_t *__str, size_t __len )
4496 {4689 {
4497 return basic_string<char16_t> (__str, __len);4690 return basic_string<char16_t> (__str, __len);
4498 }4691 }
44994692
4500 inline _LIBCPP_INLINE_VISIBILITY4693 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
4501 basic_string<char32_t> operator "" s( const char32_t *__str, size_t __len )4694 basic_string<char32_t> operator "" s( const char32_t *__str, size_t __len )
4502 {4695 {
4503 return basic_string<char32_t> (__str, __len);4696 return basic_string<char32_t> (__str, __len);
4504 }4697 }
4505 } // namespace string_literals4698 } // namespace string_literals
4506} // namespace literals4699} // namespace literals
4700
4701#if _LIBCPP_STD_VER > 17
4702template <>
4703inline constexpr bool __format::__enable_insertable<std::basic_string<char>> = true;
4704#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
4705template <>
4706inline constexpr bool __format::__enable_insertable<std::basic_string<wchar_t>> = true;
4707#endif
4708#endif
4709
4507#endif4710#endif
45084711
4509_LIBCPP_END_NAMESPACE_STD4712_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/string.h+1-1
...@@ -54,7 +54,7 @@ size_t strlen(const char* s);...@@ -54,7 +54,7 @@ size_t strlen(const char* s);
54#include <__config>54#include <__config>
5555
56#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)56#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
57#pragma GCC system_header57# pragma GCC system_header
58#endif58#endif
5959
60#include_next <string.h>60#include_next <string.h>
lib/libcxx/include/string_view+52-33
...@@ -11,7 +11,8 @@...@@ -11,7 +11,8 @@
11#define _LIBCPP_STRING_VIEW11#define _LIBCPP_STRING_VIEW
1212
13/*13/*
14string_view synopsis14
15 string_view synopsis
1516
16namespace std {17namespace std {
1718
...@@ -195,25 +196,48 @@ namespace std {...@@ -195,25 +196,48 @@ namespace std {
195196
196*/197*/
197198
199#include <__algorithm/min.h>
200#include <__assert> // all public C++ headers provide the assertion handler
198#include <__config>201#include <__config>
199#include <__debug>202#include <__functional/hash.h>
203#include <__functional/unary_function.h>
204#include <__fwd/string_view.h>
205#include <__iterator/concepts.h>
206#include <__iterator/readable_traits.h>
207#include <__iterator/reverse_iterator.h>
208#include <__memory/pointer_traits.h>
200#include <__ranges/concepts.h>209#include <__ranges/concepts.h>
201#include <__ranges/data.h>210#include <__ranges/data.h>
202#include <__ranges/enable_borrowed_range.h>211#include <__ranges/enable_borrowed_range.h>
203#include <__ranges/enable_view.h>212#include <__ranges/enable_view.h>
204#include <__ranges/size.h>213#include <__ranges/size.h>
205#include <__string>214#include <__string/char_traits.h>
206#include <algorithm>
207#include <compare>
208#include <iosfwd>215#include <iosfwd>
209#include <iterator>
210#include <limits>216#include <limits>
211#include <stdexcept>217#include <stdexcept>
212#include <type_traits>218#include <type_traits>
213#include <version>219#include <version>
214220
221#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
222# include <algorithm>
223# include <functional>
224# include <iterator>
225#endif
226
227// standard-mandated includes
228
229// [iterator.range]
230#include <__iterator/access.h>
231#include <__iterator/data.h>
232#include <__iterator/empty.h>
233#include <__iterator/reverse_access.h>
234#include <__iterator/size.h>
235
236// [string.view.synop]
237#include <compare>
238
215#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)239#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
216#pragma GCC system_header240# pragma GCC system_header
217#endif241#endif
218242
219_LIBCPP_PUSH_MACROS243_LIBCPP_PUSH_MACROS
...@@ -222,18 +246,14 @@ _LIBCPP_PUSH_MACROS...@@ -222,18 +246,14 @@ _LIBCPP_PUSH_MACROS
222246
223_LIBCPP_BEGIN_NAMESPACE_STD247_LIBCPP_BEGIN_NAMESPACE_STD
224248
225template<class _CharT, class _Traits = char_traits<_CharT> >249// TODO: This is a workaround for some vendors to carry a downstream diff to accept `nullptr` in
226 class _LIBCPP_TEMPLATE_VIS basic_string_view;250// string_view constructors. This can be refactored when this exact form isn't needed anymore.
227251template <class _Traits>
228typedef basic_string_view<char> string_view;252_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
229#ifndef _LIBCPP_HAS_NO_CHAR8_T253inline size_t __char_traits_length_checked(const typename _Traits::char_type* __s) _NOEXCEPT {
230typedef basic_string_view<char8_t> u8string_view;254 // This needs to be a single statement for C++11 constexpr
231#endif255 return _LIBCPP_ASSERT(__s != nullptr, "null pointer passed to non-null argument of char_traits<...>::length"), _Traits::length(__s);
232typedef basic_string_view<char16_t> u16string_view;256}
233typedef basic_string_view<char32_t> u32string_view;
234#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
235typedef basic_string_view<wchar_t> wstring_view;
236#endif
237257
238template<class _CharT, class _Traits>258template<class _CharT, class _Traits>
239class259class
...@@ -286,7 +306,7 @@ public:...@@ -286,7 +306,7 @@ public:
286#endif306#endif
287 }307 }
288308
289#if !defined(_LIBCPP_HAS_NO_CONCEPTS)309#if _LIBCPP_STD_VER > 17
290 template <contiguous_iterator _It, sized_sentinel_for<_It> _End>310 template <contiguous_iterator _It, sized_sentinel_for<_It> _End>
291 requires (is_same_v<iter_value_t<_It>, _CharT> && !is_convertible_v<_End, size_type>)311 requires (is_same_v<iter_value_t<_It>, _CharT> && !is_convertible_v<_End, size_type>)
292 constexpr _LIBCPP_HIDE_FROM_ABI basic_string_view(_It __begin, _End __end)312 constexpr _LIBCPP_HIDE_FROM_ABI basic_string_view(_It __begin, _End __end)
...@@ -294,9 +314,9 @@ public:...@@ -294,9 +314,9 @@ public:
294 {314 {
295 _LIBCPP_ASSERT((__end - __begin) >= 0, "std::string_view::string_view(iterator, sentinel) received invalid range");315 _LIBCPP_ASSERT((__end - __begin) >= 0, "std::string_view::string_view(iterator, sentinel) received invalid range");
296 }316 }
297#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)317#endif // _LIBCPP_STD_VER > 17
298318
299#if _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)319#if _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
300 template <class _Range>320 template <class _Range>
301 requires (321 requires (
302 !is_same_v<remove_cvref_t<_Range>, basic_string_view> &&322 !is_same_v<remove_cvref_t<_Range>, basic_string_view> &&
...@@ -304,8 +324,8 @@ public:...@@ -304,8 +324,8 @@ public:
304 ranges::sized_range<_Range> &&324 ranges::sized_range<_Range> &&
305 is_same_v<ranges::range_value_t<_Range>, _CharT> &&325 is_same_v<ranges::range_value_t<_Range>, _CharT> &&
306 !is_convertible_v<_Range, const _CharT*> &&326 !is_convertible_v<_Range, const _CharT*> &&
307 (!requires(remove_cvref_t<_Range>& d) {327 (!requires(remove_cvref_t<_Range>& __d) {
308 d.operator _VSTD::basic_string_view<_CharT, _Traits>();328 __d.operator _VSTD::basic_string_view<_CharT, _Traits>();
309 }) &&329 }) &&
310 (!requires {330 (!requires {
311 typename remove_reference_t<_Range>::traits_type;331 typename remove_reference_t<_Range>::traits_type;
...@@ -313,7 +333,7 @@ public:...@@ -313,7 +333,7 @@ public:
313 )333 )
314 constexpr _LIBCPP_HIDE_FROM_ABI334 constexpr _LIBCPP_HIDE_FROM_ABI
315 basic_string_view(_Range&& __r) : __data(ranges::data(__r)), __size(ranges::size(__r)) {}335 basic_string_view(_Range&& __r) : __data(ranges::data(__r)), __size(ranges::size(__r)) {}
316#endif336#endif // _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
317337
318 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY338 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
319 basic_string_view(const _CharT* __s)339 basic_string_view(const _CharT* __s)
...@@ -707,26 +727,26 @@ private:...@@ -707,26 +727,26 @@ private:
707 size_type __size;727 size_type __size;
708};728};
709729
710#if !defined(_LIBCPP_HAS_NO_CONCEPTS)730#if _LIBCPP_STD_VER > 17
711template <class _CharT, class _Traits>731template <class _CharT, class _Traits>
712inline constexpr bool ranges::enable_view<basic_string_view<_CharT, _Traits>> = true;732inline constexpr bool ranges::enable_view<basic_string_view<_CharT, _Traits>> = true;
713733
714template <class _CharT, class _Traits>734template <class _CharT, class _Traits>
715inline constexpr bool ranges::enable_borrowed_range<basic_string_view<_CharT, _Traits> > = true;735inline constexpr bool ranges::enable_borrowed_range<basic_string_view<_CharT, _Traits> > = true;
716#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)736#endif // _LIBCPP_STD_VER > 17
717737
718// [string.view.deduct]738// [string.view.deduct]
719739
720#if !defined(_LIBCPP_HAS_NO_CONCEPTS)740#if _LIBCPP_STD_VER > 17
721template <contiguous_iterator _It, sized_sentinel_for<_It> _End>741template <contiguous_iterator _It, sized_sentinel_for<_It> _End>
722 basic_string_view(_It, _End) -> basic_string_view<iter_value_t<_It>>;742 basic_string_view(_It, _End) -> basic_string_view<iter_value_t<_It>>;
723#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)743#endif // _LIBCPP_STD_VER > 17
724744
725745
726#if _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)746#if _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
727template <ranges::contiguous_range _Range>747template <ranges::contiguous_range _Range>
728 basic_string_view(_Range) -> basic_string_view<ranges::range_value_t<_Range>>;748 basic_string_view(_Range) -> basic_string_view<ranges::range_value_t<_Range>>;
729#endif749#endif // _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
730750
731// [string.view.comparison]751// [string.view.comparison]
732// operator ==752// operator ==
...@@ -900,7 +920,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,...@@ -900,7 +920,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
900// [string.view.hash]920// [string.view.hash]
901template<class _CharT>921template<class _CharT>
902struct _LIBCPP_TEMPLATE_VIS hash<basic_string_view<_CharT, char_traits<_CharT> > >922struct _LIBCPP_TEMPLATE_VIS hash<basic_string_view<_CharT, char_traits<_CharT> > >
903 : public unary_function<basic_string_view<_CharT, char_traits<_CharT> >, size_t>923 : public __unary_function<basic_string_view<_CharT, char_traits<_CharT> >, size_t>
904{924{
905 _LIBCPP_INLINE_VISIBILITY925 _LIBCPP_INLINE_VISIBILITY
906 size_t operator()(const basic_string_view<_CharT, char_traits<_CharT> > __val) const _NOEXCEPT {926 size_t operator()(const basic_string_view<_CharT, char_traits<_CharT> > __val) const _NOEXCEPT {
...@@ -908,7 +928,6 @@ struct _LIBCPP_TEMPLATE_VIS hash<basic_string_view<_CharT, char_traits<_CharT> >...@@ -908,7 +928,6 @@ struct _LIBCPP_TEMPLATE_VIS hash<basic_string_view<_CharT, char_traits<_CharT> >
908 }928 }
909};929};
910930
911
912#if _LIBCPP_STD_VER > 11931#if _LIBCPP_STD_VER > 11
913inline namespace literals932inline namespace literals
914{933{
lib/libcxx/include/strstream+5-4
...@@ -129,13 +129,14 @@ private:...@@ -129,13 +129,14 @@ private:
129129
130*/130*/
131131
132#include <__assert> // all public C++ headers provide the assertion handler
132#include <__config>133#include <__config>
133#include <istream>134#include <istream>
134#include <ostream>135#include <ostream>
135#include <version>136#include <version>
136137
137#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)138#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
138#pragma GCC system_header139# pragma GCC system_header
139#endif140#endif
140141
141_LIBCPP_BEGIN_NAMESPACE_STD142_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -265,8 +266,8 @@ public:...@@ -265,8 +266,8 @@ public:
265 _LIBCPP_INLINE_VISIBILITY266 _LIBCPP_INLINE_VISIBILITY
266 istrstream& operator=(istrstream&& __rhs)267 istrstream& operator=(istrstream&& __rhs)
267 {268 {
268 istream::operator=(_VSTD::move(__rhs));
269 __sb_ = _VSTD::move(__rhs.__sb_);269 __sb_ = _VSTD::move(__rhs.__sb_);
270 istream::operator=(_VSTD::move(__rhs));
270 return *this;271 return *this;
271 }272 }
272#endif // _LIBCPP_CXX03_LANG273#endif // _LIBCPP_CXX03_LANG
...@@ -314,8 +315,8 @@ public:...@@ -314,8 +315,8 @@ public:
314 _LIBCPP_INLINE_VISIBILITY315 _LIBCPP_INLINE_VISIBILITY
315 ostrstream& operator=(ostrstream&& __rhs)316 ostrstream& operator=(ostrstream&& __rhs)
316 {317 {
317 ostream::operator=(_VSTD::move(__rhs));
318 __sb_ = _VSTD::move(__rhs.__sb_);318 __sb_ = _VSTD::move(__rhs.__sb_);
319 ostream::operator=(_VSTD::move(__rhs));
319 return *this;320 return *this;
320 }321 }
321#endif // _LIBCPP_CXX03_LANG322#endif // _LIBCPP_CXX03_LANG
...@@ -374,8 +375,8 @@ public:...@@ -374,8 +375,8 @@ public:
374 _LIBCPP_INLINE_VISIBILITY375 _LIBCPP_INLINE_VISIBILITY
375 strstream& operator=(strstream&& __rhs)376 strstream& operator=(strstream&& __rhs)
376 {377 {
377 iostream::operator=(_VSTD::move(__rhs));
378 __sb_ = _VSTD::move(__rhs.__sb_);378 __sb_ = _VSTD::move(__rhs.__sb_);
379 iostream::operator=(_VSTD::move(__rhs));
379 return *this;380 return *this;
380 }381 }
381#endif // _LIBCPP_CXX03_LANG382#endif // _LIBCPP_CXX03_LANG
lib/libcxx/include/system_error+13-11
...@@ -142,18 +142,21 @@ template <> struct hash<std::error_condition>;...@@ -142,18 +142,21 @@ template <> struct hash<std::error_condition>;
142142
143*/143*/
144144
145#include <__assert> // all public C++ headers provide the assertion handler
145#include <__config>146#include <__config>
146#include <__errc>147#include <__errc>
148#include <__functional/hash.h>
147#include <__functional/unary_function.h>149#include <__functional/unary_function.h>
148#include <__functional_base>
149#include <compare>
150#include <stdexcept>150#include <stdexcept>
151#include <string>151#include <string>
152#include <type_traits>152#include <type_traits>
153#include <version>153#include <version>
154154
155// standard-mandated includes
156#include <compare>
157
155#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)158#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
156#pragma GCC system_header159# pragma GCC system_header
157#endif160#endif
158161
159_LIBCPP_BEGIN_NAMESPACE_STD162_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -184,7 +187,7 @@ template <>...@@ -184,7 +187,7 @@ template <>
184struct _LIBCPP_TEMPLATE_VIS is_error_condition_enum<errc>187struct _LIBCPP_TEMPLATE_VIS is_error_condition_enum<errc>
185 : true_type { };188 : true_type { };
186189
187#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS190#ifdef _LIBCPP_CXX03_LANG
188template <>191template <>
189struct _LIBCPP_TEMPLATE_VIS is_error_condition_enum<errc::__lx>192struct _LIBCPP_TEMPLATE_VIS is_error_condition_enum<errc::__lx>
190 : true_type { };193 : true_type { };
...@@ -202,9 +205,8 @@ class _LIBCPP_TYPE_VIS error_category...@@ -202,9 +205,8 @@ class _LIBCPP_TYPE_VIS error_category
202public:205public:
203 virtual ~error_category() _NOEXCEPT;206 virtual ~error_category() _NOEXCEPT;
204207
205#if defined(_LIBCPP_BUILDING_LIBRARY) && \208#if defined(_LIBCPP_ERROR_CATEGORY_DEFINE_LEGACY_INLINE_FUNCTIONS)
206 defined(_LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS)209 error_category() noexcept;
207 error_category() _NOEXCEPT;
208#else210#else
209 _LIBCPP_INLINE_VISIBILITY211 _LIBCPP_INLINE_VISIBILITY
210 _LIBCPP_CONSTEXPR_AFTER_CXX11 error_category() _NOEXCEPT = default;212 _LIBCPP_CONSTEXPR_AFTER_CXX11 error_category() _NOEXCEPT = default;
...@@ -234,7 +236,7 @@ class _LIBCPP_HIDDEN __do_message...@@ -234,7 +236,7 @@ class _LIBCPP_HIDDEN __do_message
234 : public error_category236 : public error_category
235{237{
236public:238public:
237 virtual string message(int ev) const;239 virtual string message(int __ev) const;
238};240};
239241
240_LIBCPP_FUNC_VIS const error_category& generic_category() _NOEXCEPT;242_LIBCPP_FUNC_VIS const error_category& generic_category() _NOEXCEPT;
...@@ -436,7 +438,7 @@ operator!=(const error_condition& __x, const error_condition& __y) _NOEXCEPT...@@ -436,7 +438,7 @@ operator!=(const error_condition& __x, const error_condition& __y) _NOEXCEPT
436438
437template <>439template <>
438struct _LIBCPP_TEMPLATE_VIS hash<error_code>440struct _LIBCPP_TEMPLATE_VIS hash<error_code>
439 : public unary_function<error_code, size_t>441 : public __unary_function<error_code, size_t>
440{442{
441 _LIBCPP_INLINE_VISIBILITY443 _LIBCPP_INLINE_VISIBILITY
442 size_t operator()(const error_code& __ec) const _NOEXCEPT444 size_t operator()(const error_code& __ec) const _NOEXCEPT
...@@ -447,7 +449,7 @@ struct _LIBCPP_TEMPLATE_VIS hash<error_code>...@@ -447,7 +449,7 @@ struct _LIBCPP_TEMPLATE_VIS hash<error_code>
447449
448template <>450template <>
449struct _LIBCPP_TEMPLATE_VIS hash<error_condition>451struct _LIBCPP_TEMPLATE_VIS hash<error_condition>
450 : public unary_function<error_condition, size_t>452 : public __unary_function<error_condition, size_t>
451{453{
452 _LIBCPP_INLINE_VISIBILITY454 _LIBCPP_INLINE_VISIBILITY
453 size_t operator()(const error_condition& __ec) const _NOEXCEPT455 size_t operator()(const error_condition& __ec) const _NOEXCEPT
...@@ -480,7 +482,7 @@ private:...@@ -480,7 +482,7 @@ private:
480};482};
481483
482_LIBCPP_NORETURN _LIBCPP_FUNC_VIS484_LIBCPP_NORETURN _LIBCPP_FUNC_VIS
483void __throw_system_error(int ev, const char* what_arg);485void __throw_system_error(int __ev, const char* __what_arg);
484486
485_LIBCPP_END_NAMESPACE_STD487_LIBCPP_END_NAMESPACE_STD
486488
lib/libcxx/include/tgmath.h+1-1
...@@ -20,7 +20,7 @@...@@ -20,7 +20,7 @@
20#include <__config>20#include <__config>
2121
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23#pragma GCC system_header23# pragma GCC system_header
24#endif24#endif
2525
26#ifdef __cplusplus26#ifdef __cplusplus
lib/libcxx/include/thread+15-15
...@@ -82,17 +82,15 @@ void sleep_for(const chrono::duration<Rep, Period>& rel_time);...@@ -82,17 +82,15 @@ void sleep_for(const chrono::duration<Rep, Period>& rel_time);
8282
83*/83*/
8484
85#include <__assert> // all public C++ headers provide the assertion handler
85#include <__config>86#include <__config>
86#include <__debug>87#include <__functional/hash.h>
87#include <__functional_base>
88#include <__mutex_base>88#include <__mutex_base>
89#include <__thread/poll_with_backoff.h>89#include <__thread/poll_with_backoff.h>
90#include <__thread/timed_backoff_policy.h>90#include <__thread/timed_backoff_policy.h>
91#include <__threading_support>91#include <__threading_support>
92#include <__utility/forward.h>92#include <__utility/forward.h>
93#include <chrono>
94#include <cstddef>93#include <cstddef>
95#include <functional>
96#include <iosfwd>94#include <iosfwd>
97#include <memory>95#include <memory>
98#include <system_error>96#include <system_error>
...@@ -100,16 +98,24 @@ void sleep_for(const chrono::duration<Rep, Period>& rel_time);...@@ -100,16 +98,24 @@ void sleep_for(const chrono::duration<Rep, Period>& rel_time);
100#include <type_traits>98#include <type_traits>
101#include <version>99#include <version>
102100
101#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
102# include <chrono>
103# include <functional>
104#endif
105
106// standard-mandated includes
107#include <compare>
108
103#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)109#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
104#pragma GCC system_header110# pragma GCC system_header
105#endif111#endif
106112
107_LIBCPP_PUSH_MACROS113_LIBCPP_PUSH_MACROS
108#include <__undef_macros>114#include <__undef_macros>
109115
110#ifdef _LIBCPP_HAS_NO_THREADS116#ifdef _LIBCPP_HAS_NO_THREADS
111#error <thread> is not supported on this single threaded system117# error "<thread> is not supported since libc++ has been configured without support for threads."
112#else // !_LIBCPP_HAS_NO_THREADS118#endif
113119
114_LIBCPP_BEGIN_NAMESPACE_STD120_LIBCPP_BEGIN_NAMESPACE_STD
115121
...@@ -200,7 +206,7 @@ __thread_specific_ptr<_Tp>::set_pointer(pointer __p)...@@ -200,7 +206,7 @@ __thread_specific_ptr<_Tp>::set_pointer(pointer __p)
200206
201template<>207template<>
202struct _LIBCPP_TEMPLATE_VIS hash<__thread_id>208struct _LIBCPP_TEMPLATE_VIS hash<__thread_id>
203 : public unary_function<__thread_id, size_t>209 : public __unary_function<__thread_id, size_t>
204{210{
205 _LIBCPP_INLINE_VISIBILITY211 _LIBCPP_INLINE_VISIBILITY
206 size_t operator()(__thread_id __v) const _NOEXCEPT212 size_t operator()(__thread_id __v) const _NOEXCEPT
...@@ -229,11 +235,7 @@ public:...@@ -229,11 +235,7 @@ public:
229 thread() _NOEXCEPT : __t_(_LIBCPP_NULL_THREAD) {}235 thread() _NOEXCEPT : __t_(_LIBCPP_NULL_THREAD) {}
230#ifndef _LIBCPP_CXX03_LANG236#ifndef _LIBCPP_CXX03_LANG
231 template <class _Fp, class ..._Args,237 template <class _Fp, class ..._Args,
232 class = typename enable_if238 class = __enable_if_t<!is_same<__uncvref_t<_Fp>, thread>::value> >
233 <
234 !is_same<typename __uncvref<_Fp>::type, thread>::value
235 >::type
236 >
237 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS239 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
238 explicit thread(_Fp&& __f, _Args&&... __args);240 explicit thread(_Fp&& __f, _Args&&... __args);
239#else // _LIBCPP_CXX03_LANG241#else // _LIBCPP_CXX03_LANG
...@@ -408,8 +410,6 @@ void yield() _NOEXCEPT {__libcpp_thread_yield();}...@@ -408,8 +410,6 @@ void yield() _NOEXCEPT {__libcpp_thread_yield();}
408410
409_LIBCPP_END_NAMESPACE_STD411_LIBCPP_END_NAMESPACE_STD
410412
411#endif // !_LIBCPP_HAS_NO_THREADS
412
413_LIBCPP_POP_MACROS413_LIBCPP_POP_MACROS
414414
415#endif // _LIBCPP_THREAD415#endif // _LIBCPP_THREAD
lib/libcxx/include/tuple+341-147
...@@ -25,14 +25,24 @@ public:...@@ -25,14 +25,24 @@ public:
25 explicit(see-below) tuple(U&&...); // constexpr in C++1425 explicit(see-below) tuple(U&&...); // constexpr in C++14
26 tuple(const tuple&) = default;26 tuple(const tuple&) = default;
27 tuple(tuple&&) = default;27 tuple(tuple&&) = default;
28
29 template<class... UTypes>
30 constexpr explicit(see-below) tuple(tuple<UTypes...>&); // C++23
28 template <class... U>31 template <class... U>
29 explicit(see-below) tuple(const tuple<U...>&); // constexpr in C++1432 explicit(see-below) tuple(const tuple<U...>&); // constexpr in C++14
30 template <class... U>33 template <class... U>
31 explicit(see-below) tuple(tuple<U...>&&); // constexpr in C++1434 explicit(see-below) tuple(tuple<U...>&&); // constexpr in C++14
35 template<class... UTypes>
36 constexpr explicit(see-below) tuple(const tuple<UTypes...>&&); // C++23
37
38 template<class U1, class U2>
39 constexpr explicit(see-below) tuple(pair<U1, U2>&); // iff sizeof...(Types) == 2 // C++23
32 template <class U1, class U2>40 template <class U1, class U2>
33 explicit(see-below) tuple(const pair<U1, U2>&); // iff sizeof...(T) == 2 // constexpr in C++1441 explicit(see-below) tuple(const pair<U1, U2>&); // iff sizeof...(T) == 2 // constexpr in C++14
34 template <class U1, class U2>42 template <class U1, class U2>
35 explicit(see-below) tuple(pair<U1, U2>&&); // iff sizeof...(T) == 2 // constexpr in C++1443 explicit(see-below) tuple(pair<U1, U2>&&); // iff sizeof...(T) == 2 // constexpr in C++14
44 template<class U1, class U2>
45 constexpr explicit(see-below) tuple(const pair<U1, U2>&&); // iff sizeof...(Types) == 2 // C++23
3646
37 // allocator-extended constructors47 // allocator-extended constructors
38 template <class Alloc>48 template <class Alloc>
...@@ -45,25 +55,47 @@ public:...@@ -45,25 +55,47 @@ public:
45 tuple(allocator_arg_t, const Alloc& a, const tuple&); // constexpr in C++2055 tuple(allocator_arg_t, const Alloc& a, const tuple&); // constexpr in C++20
46 template <class Alloc>56 template <class Alloc>
47 tuple(allocator_arg_t, const Alloc& a, tuple&&); // constexpr in C++2057 tuple(allocator_arg_t, const Alloc& a, tuple&&); // constexpr in C++20
58 template<class Alloc, class... UTypes>
59 constexpr explicit(see-below)
60 tuple(allocator_arg_t, const Alloc& a, tuple<UTypes...>&); // C++23
48 template <class Alloc, class... U>61 template <class Alloc, class... U>
49 explicit(see-below) tuple(allocator_arg_t, const Alloc& a, const tuple<U...>&); // constexpr in C++2062 explicit(see-below) tuple(allocator_arg_t, const Alloc& a, const tuple<U...>&); // constexpr in C++20
50 template <class Alloc, class... U>63 template <class Alloc, class... U>
51 explicit(see-below) tuple(allocator_arg_t, const Alloc& a, tuple<U...>&&); // constexpr in C++2064 explicit(see-below) tuple(allocator_arg_t, const Alloc& a, tuple<U...>&&); // constexpr in C++20
65 template<class Alloc, class... UTypes>
66 constexpr explicit(see-below)
67 tuple(allocator_arg_t, const Alloc& a, const tuple<UTypes...>&&); // C++23
68 template<class Alloc, class U1, class U2>
69 constexpr explicit(see-below)
70 tuple(allocator_arg_t, const Alloc& a, pair<U1, U2>&); // C++23
52 template <class Alloc, class U1, class U2>71 template <class Alloc, class U1, class U2>
53 explicit(see-below) tuple(allocator_arg_t, const Alloc& a, const pair<U1, U2>&); // constexpr in C++2072 explicit(see-below) tuple(allocator_arg_t, const Alloc& a, const pair<U1, U2>&); // constexpr in C++20
54 template <class Alloc, class U1, class U2>73 template <class Alloc, class U1, class U2>
55 explicit(see-below) tuple(allocator_arg_t, const Alloc& a, pair<U1, U2>&&); // constexpr in C++2074 explicit(see-below) tuple(allocator_arg_t, const Alloc& a, pair<U1, U2>&&); // constexpr in C++20
75 template<class Alloc, class U1, class U2>
76 constexpr explicit(see-below)
77 tuple(allocator_arg_t, const Alloc& a, const pair<U1, U2>&&); // C++23
5678
57 tuple& operator=(const tuple&); // constexpr in C++2079 tuple& operator=(const tuple&); // constexpr in C++20
80 constexpr const tuple& operator=(const tuple&) const; // C++23
58 tuple& operator=(tuple&&) noexcept(is_nothrow_move_assignable_v<T> && ...); // constexpr in C++2081 tuple& operator=(tuple&&) noexcept(is_nothrow_move_assignable_v<T> && ...); // constexpr in C++20
82 constexpr const tuple& operator=(tuple&&) const; // C++23
59 template <class... U>83 template <class... U>
60 tuple& operator=(const tuple<U...>&); // constexpr in C++2084 tuple& operator=(const tuple<U...>&); // constexpr in C++20
85 template<class... UTypes>
86 constexpr const tuple& operator=(const tuple<UTypes...>&) const; // C++23
61 template <class... U>87 template <class... U>
62 tuple& operator=(tuple<U...>&&); // constexpr in C++2088 tuple& operator=(tuple<U...>&&); // constexpr in C++20
89 template<class... UTypes>
90 constexpr const tuple& operator=(tuple<UTypes...>&&) const; // C++23
63 template <class U1, class U2>91 template <class U1, class U2>
64 tuple& operator=(const pair<U1, U2>&); // iff sizeof...(T) == 2 // constexpr in C++2092 tuple& operator=(const pair<U1, U2>&); // iff sizeof...(T) == 2 // constexpr in C++20
93 template<class U1, class U2>
94 constexpr const tuple& operator=(const pair<U1, U2>&) const; // iff sizeof...(Types) == 2 // C++23
65 template <class U1, class U2>95 template <class U1, class U2>
66 tuple& operator=(pair<U1, U2>&&); // iff sizeof...(T) == 2 // constexpr in C++2096 tuple& operator=(pair<U1, U2>&&); // iff sizeof...(T) == 2 // constexpr in C++20
97 template<class U1, class U2>
98 constexpr const tuple& operator=(pair<U1, U2>&&) const; // iff sizeof...(Types) == 2 // C++23
6799
68 template<class U, size_t N>100 template<class U, size_t N>
69 tuple& operator=(array<U, N> const&) // iff sizeof...(T) == N, EXTENSION101 tuple& operator=(array<U, N> const&) // iff sizeof...(T) == N, EXTENSION
...@@ -71,6 +103,7 @@ public:...@@ -71,6 +103,7 @@ public:
71 tuple& operator=(array<U, N>&&) // iff sizeof...(T) == N, EXTENSION103 tuple& operator=(array<U, N>&&) // iff sizeof...(T) == N, EXTENSION
72104
73 void swap(tuple&) noexcept(AND(swap(declval<T&>(), declval<T&>())...)); // constexpr in C++20105 void swap(tuple&) noexcept(AND(swap(declval<T&>(), declval<T&>())...)); // constexpr in C++20
106 constexpr void swap(const tuple&) const noexcept(see-below); // C++23
74};107};
75108
76109
...@@ -161,29 +194,44 @@ template <class... Types>...@@ -161,29 +194,44 @@ template <class... Types>
161 void194 void
162 swap(tuple<Types...>& x, tuple<Types...>& y) noexcept(noexcept(x.swap(y)));195 swap(tuple<Types...>& x, tuple<Types...>& y) noexcept(noexcept(x.swap(y)));
163196
197template <class... Types>
198 constexpr void swap(const tuple<Types...>& x, const tuple<Types...>& y) noexcept(see-below); // C++23
199
164} // std200} // std
165201
166*/202*/
167203
204#include <__assert> // all public C++ headers provide the assertion handler
168#include <__compare/common_comparison_category.h>205#include <__compare/common_comparison_category.h>
169#include <__compare/synth_three_way.h>206#include <__compare/synth_three_way.h>
170#include <__config>207#include <__config>
171#include <__functional/unwrap_ref.h>208#include <__functional/unwrap_ref.h>
172#include <__functional_base>
173#include <__memory/allocator_arg_t.h>209#include <__memory/allocator_arg_t.h>
174#include <__memory/uses_allocator.h>210#include <__memory/uses_allocator.h>
175#include <__tuple>211#include <__tuple>
176#include <__utility/forward.h>212#include <__utility/forward.h>
177#include <__utility/integer_sequence.h>213#include <__utility/integer_sequence.h>
178#include <__utility/move.h>214#include <__utility/move.h>
179#include <compare>215#include <__utility/pair.h>
216#include <__utility/piecewise_construct.h>
217#include <__utility/swap.h>
180#include <cstddef>218#include <cstddef>
181#include <type_traits>219#include <type_traits>
182#include <utility>
183#include <version>220#include <version>
184221
222#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
223# include <exception>
224# include <iosfwd>
225# include <new>
226# include <typeinfo>
227# include <utility>
228#endif
229
230// standard-mandated includes
231#include <compare>
232
185#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)233#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
186#pragma GCC system_header234# pragma GCC system_header
187#endif235#endif
188236
189_LIBCPP_BEGIN_NAMESPACE_STD237_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -206,6 +254,13 @@ void swap(__tuple_leaf<_Ip, _Hp, _Ep>& __x, __tuple_leaf<_Ip, _Hp, _Ep>& __y)...@@ -206,6 +254,13 @@ void swap(__tuple_leaf<_Ip, _Hp, _Ep>& __x, __tuple_leaf<_Ip, _Hp, _Ep>& __y)
206 swap(__x.get(), __y.get());254 swap(__x.get(), __y.get());
207}255}
208256
257template <size_t _Ip, class _Hp, bool _Ep>
258_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
259void swap(const __tuple_leaf<_Ip, _Hp, _Ep>& __x, const __tuple_leaf<_Ip, _Hp, _Ep>& __y)
260 _NOEXCEPT_(__is_nothrow_swappable<const _Hp>::value) {
261 swap(__x.get(), __y.get());
262}
263
209template <size_t _Ip, class _Hp, bool>264template <size_t _Ip, class _Hp, bool>
210class __tuple_leaf265class __tuple_leaf
211{266{
...@@ -294,6 +349,12 @@ public:...@@ -294,6 +349,12 @@ public:
294 return 0;349 return 0;
295 }350 }
296351
352 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
353 int swap(const __tuple_leaf& __t) const _NOEXCEPT_(__is_nothrow_swappable<const __tuple_leaf>::value) {
354 _VSTD::swap(*this, __t);
355 return 0;
356 }
357
297 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Hp& get() _NOEXCEPT {return __value_;}358 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Hp& get() _NOEXCEPT {return __value_;}
298 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Hp& get() const _NOEXCEPT {return __value_;}359 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Hp& get() const _NOEXCEPT {return __value_;}
299};360};
...@@ -360,6 +421,12 @@ public:...@@ -360,6 +421,12 @@ public:
360 return 0;421 return 0;
361 }422 }
362423
424 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
425 int swap(const __tuple_leaf& __rhs) const _NOEXCEPT_(__is_nothrow_swappable<const __tuple_leaf>::value) {
426 _VSTD::swap(*this, __rhs);
427 return 0;
428 }
429
363 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Hp& get() _NOEXCEPT {return static_cast<_Hp&>(*this);}430 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Hp& get() _NOEXCEPT {return static_cast<_Hp&>(*this);}
364 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Hp& get() const _NOEXCEPT {return static_cast<const _Hp&>(*this);}431 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Hp& get() const _NOEXCEPT {return static_cast<const _Hp&>(*this);}
365};432};
...@@ -415,10 +482,7 @@ struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp....@@ -415,10 +482,7 @@ struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp.
415 {}482 {}
416483
417 template <class _Tuple,484 template <class _Tuple,
418 class = typename enable_if485 class = __enable_if_t<__tuple_constructible<_Tuple, tuple<_Tp...> >::value>
419 <
420 __tuple_constructible<_Tuple, tuple<_Tp...> >::value
421 >::type
422 >486 >
423 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11487 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
424 __tuple_impl(_Tuple&& __t) _NOEXCEPT_((__all<is_nothrow_constructible<_Tp, typename tuple_element<_Indx,488 __tuple_impl(_Tuple&& __t) _NOEXCEPT_((__all<is_nothrow_constructible<_Tp, typename tuple_element<_Indx,
...@@ -428,10 +492,7 @@ struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp....@@ -428,10 +492,7 @@ struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp.
428 {}492 {}
429493
430 template <class _Alloc, class _Tuple,494 template <class _Alloc, class _Tuple,
431 class = typename enable_if495 class = __enable_if_t<__tuple_constructible<_Tuple, tuple<_Tp...> >::value>
432 <
433 __tuple_constructible<_Tuple, tuple<_Tp...> >::value
434 >::type
435 >496 >
436 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11497 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
437 __tuple_impl(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)498 __tuple_impl(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
...@@ -450,6 +511,13 @@ struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp....@@ -450,6 +511,13 @@ struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp.
450 {511 {
451 _VSTD::__swallow(__tuple_leaf<_Indx, _Tp>::swap(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t))...);512 _VSTD::__swallow(__tuple_leaf<_Indx, _Tp>::swap(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t))...);
452 }513 }
514
515 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
516 void swap(const __tuple_impl& __t) const
517 _NOEXCEPT_(__all<__is_nothrow_swappable<const _Tp>::value...>::value)
518 {
519 _VSTD::__swallow(__tuple_leaf<_Indx, _Tp>::swap(static_cast<const __tuple_leaf<_Indx, _Tp>&>(__t))...);
520 }
453};521};
454522
455template<class _Dest, class _Source, size_t ..._Np>523template<class _Dest, class _Source, size_t ..._Np>
...@@ -685,6 +753,7 @@ public:...@@ -685,6 +753,7 @@ public:
685 template <class _Alloc, template<class...> class _And = _And, __enable_if_t<753 template <class _Alloc, template<class...> class _And = _And, __enable_if_t<
686 _And<is_copy_constructible<_Tp>...>::value754 _And<is_copy_constructible<_Tp>...>::value
687 , int> = 0>755 , int> = 0>
756 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
688 tuple(allocator_arg_t, const _Alloc& __alloc, const tuple& __t)757 tuple(allocator_arg_t, const _Alloc& __alloc, const tuple& __t)
689 : __base_(allocator_arg_t(), __alloc, __t)758 : __base_(allocator_arg_t(), __alloc, __t)
690 { }759 { }
...@@ -692,30 +761,39 @@ public:...@@ -692,30 +761,39 @@ public:
692 template <class _Alloc, template<class...> class _And = _And, __enable_if_t<761 template <class _Alloc, template<class...> class _And = _And, __enable_if_t<
693 _And<is_move_constructible<_Tp>...>::value762 _And<is_move_constructible<_Tp>...>::value
694 , int> = 0>763 , int> = 0>
764 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
695 tuple(allocator_arg_t, const _Alloc& __alloc, tuple&& __t)765 tuple(allocator_arg_t, const _Alloc& __alloc, tuple&& __t)
696 : __base_(allocator_arg_t(), __alloc, _VSTD::move(__t))766 : __base_(allocator_arg_t(), __alloc, _VSTD::move(__t))
697 { }767 { }
698768
699 // tuple(const tuple<U...>&) constructors (including allocator_arg_t variants)769 // tuple(const tuple<U...>&) constructors (including allocator_arg_t variants)
700 template <class ..._Up>770
701 struct _EnableCopyFromOtherTuple : _And<771 template <class _OtherTuple, class _DecayedOtherTuple = __uncvref_t<_OtherTuple>, class = void>
702 _Not<is_same<tuple<_Tp...>, tuple<_Up...> > >,772 struct _EnableCtorFromUTypesTuple : false_type {};
703 _Lazy<_Or,773
704 _BoolConstant<sizeof...(_Tp) != 1>,774 template <class _OtherTuple, class... _Up>
775 struct _EnableCtorFromUTypesTuple<_OtherTuple, tuple<_Up...>,
776 // the length of the packs needs to checked first otherwise the 2 packs cannot be expanded simultaneously below
777 __enable_if_t<sizeof...(_Up) == sizeof...(_Tp)>> : _And<
778 // the two conditions below are not in spec. The purpose is to disable the UTypes Ctor when copy/move Ctor can work.
779 // Otherwise, is_constructible can trigger hard error in those cases https://godbolt.org/z/M94cGdKcE
780 _Not<is_same<_OtherTuple, const tuple&> >,
781 _Not<is_same<_OtherTuple, tuple&&> >,
782 is_constructible<_Tp, __copy_cvref_t<_OtherTuple, _Up> >...,
783 _Lazy<_Or, _BoolConstant<sizeof...(_Tp) != 1>,
705 // _Tp and _Up are 1-element packs - the pack expansions look784 // _Tp and _Up are 1-element packs - the pack expansions look
706 // weird to avoid tripping up the type traits in degenerate cases785 // weird to avoid tripping up the type traits in degenerate cases
707 _Lazy<_And,786 _Lazy<_And,
708 _Not<is_convertible<const tuple<_Up>&, _Tp> >...,787 _Not<is_same<_Tp, _Up> >...,
709 _Not<is_constructible<_Tp, const tuple<_Up>&> >...788 _Not<is_convertible<_OtherTuple, _Tp> >...,
789 _Not<is_constructible<_Tp, _OtherTuple> >...
710 >790 >
711 >,791 >
712 is_constructible<_Tp, const _Up&>...792 > {};
713 > { };
714793
715 template <class ..._Up, __enable_if_t<794 template <class ..._Up, __enable_if_t<
716 _And<795 _And<
717 _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>,796 _EnableCtorFromUTypesTuple<const tuple<_Up...>&>,
718 _EnableCopyFromOtherTuple<_Up...>,
719 is_convertible<const _Up&, _Tp>... // explicit check797 is_convertible<const _Up&, _Tp>... // explicit check
720 >::value798 >::value
721 , int> = 0>799 , int> = 0>
...@@ -727,8 +805,7 @@ public:...@@ -727,8 +805,7 @@ public:
727805
728 template <class ..._Up, __enable_if_t<806 template <class ..._Up, __enable_if_t<
729 _And<807 _And<
730 _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>,808 _EnableCtorFromUTypesTuple<const tuple<_Up...>&>,
731 _EnableCopyFromOtherTuple<_Up...>,
732 _Not<_Lazy<_And, is_convertible<const _Up&, _Tp>...> > // explicit check809 _Not<_Lazy<_And, is_convertible<const _Up&, _Tp>...> > // explicit check
733 >::value810 >::value
734 , int> = 0>811 , int> = 0>
...@@ -740,8 +817,7 @@ public:...@@ -740,8 +817,7 @@ public:
740817
741 template <class ..._Up, class _Alloc, __enable_if_t<818 template <class ..._Up, class _Alloc, __enable_if_t<
742 _And<819 _And<
743 _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>,820 _EnableCtorFromUTypesTuple<const tuple<_Up...>&>,
744 _EnableCopyFromOtherTuple<_Up...>,
745 is_convertible<const _Up&, _Tp>... // explicit check821 is_convertible<const _Up&, _Tp>... // explicit check
746 >::value822 >::value
747 , int> = 0>823 , int> = 0>
...@@ -752,8 +828,7 @@ public:...@@ -752,8 +828,7 @@ public:
752828
753 template <class ..._Up, class _Alloc, __enable_if_t<829 template <class ..._Up, class _Alloc, __enable_if_t<
754 _And<830 _And<
755 _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>,831 _EnableCtorFromUTypesTuple<const tuple<_Up...>&>,
756 _EnableCopyFromOtherTuple<_Up...>,
757 _Not<_Lazy<_And, is_convertible<const _Up&, _Tp>...> > // explicit check832 _Not<_Lazy<_And, is_convertible<const _Up&, _Tp>...> > // explicit check
758 >::value833 >::value
759 , int> = 0>834 , int> = 0>
...@@ -762,26 +837,27 @@ public:...@@ -762,26 +837,27 @@ public:
762 : __base_(allocator_arg_t(), __a, __t)837 : __base_(allocator_arg_t(), __a, __t)
763 { }838 { }
764839
840#if _LIBCPP_STD_VER > 20
841 // tuple(tuple<U...>&) constructors (including allocator_arg_t variants)
842
843 template <class... _Up, enable_if_t<
844 _EnableCtorFromUTypesTuple<tuple<_Up...>&>::value>* = nullptr>
845 _LIBCPP_HIDE_FROM_ABI constexpr
846 explicit(!(is_convertible_v<_Up&, _Tp> && ...))
847 tuple(tuple<_Up...>& __t) : __base_(__t) {}
848
849 template <class _Alloc, class... _Up, enable_if_t<
850 _EnableCtorFromUTypesTuple<tuple<_Up...>&>::value>* = nullptr>
851 _LIBCPP_HIDE_FROM_ABI constexpr
852 explicit(!(is_convertible_v<_Up&, _Tp> && ...))
853 tuple(allocator_arg_t, const _Alloc& __alloc, tuple<_Up...>& __t) : __base_(allocator_arg_t(), __alloc, __t) {}
854#endif // _LIBCPP_STD_VER > 20
855
765 // tuple(tuple<U...>&&) constructors (including allocator_arg_t variants)856 // tuple(tuple<U...>&&) constructors (including allocator_arg_t variants)
766 template <class ..._Up>
767 struct _EnableMoveFromOtherTuple : _And<
768 _Not<is_same<tuple<_Tp...>, tuple<_Up...> > >,
769 _Lazy<_Or,
770 _BoolConstant<sizeof...(_Tp) != 1>,
771 // _Tp and _Up are 1-element packs - the pack expansions look
772 // weird to avoid tripping up the type traits in degenerate cases
773 _Lazy<_And,
774 _Not<is_convertible<tuple<_Up>, _Tp> >...,
775 _Not<is_constructible<_Tp, tuple<_Up> > >...
776 >
777 >,
778 is_constructible<_Tp, _Up>...
779 > { };
780857
781 template <class ..._Up, __enable_if_t<858 template <class ..._Up, __enable_if_t<
782 _And<859 _And<
783 _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>,860 _EnableCtorFromUTypesTuple<tuple<_Up...>&&>,
784 _EnableMoveFromOtherTuple<_Up...>,
785 is_convertible<_Up, _Tp>... // explicit check861 is_convertible<_Up, _Tp>... // explicit check
786 >::value862 >::value
787 , int> = 0>863 , int> = 0>
...@@ -793,8 +869,7 @@ public:...@@ -793,8 +869,7 @@ public:
793869
794 template <class ..._Up, __enable_if_t<870 template <class ..._Up, __enable_if_t<
795 _And<871 _And<
796 _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>,872 _EnableCtorFromUTypesTuple<tuple<_Up...>&&>,
797 _EnableMoveFromOtherTuple<_Up...>,
798 _Not<_Lazy<_And, is_convertible<_Up, _Tp>...> > // explicit check873 _Not<_Lazy<_And, is_convertible<_Up, _Tp>...> > // explicit check
799 >::value874 >::value
800 , int> = 0>875 , int> = 0>
...@@ -806,8 +881,7 @@ public:...@@ -806,8 +881,7 @@ public:
806881
807 template <class _Alloc, class ..._Up, __enable_if_t<882 template <class _Alloc, class ..._Up, __enable_if_t<
808 _And<883 _And<
809 _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>,884 _EnableCtorFromUTypesTuple<tuple<_Up...>&&>,
810 _EnableMoveFromOtherTuple<_Up...>,
811 is_convertible<_Up, _Tp>... // explicit check885 is_convertible<_Up, _Tp>... // explicit check
812 >::value886 >::value
813 , int> = 0>887 , int> = 0>
...@@ -818,8 +892,7 @@ public:...@@ -818,8 +892,7 @@ public:
818892
819 template <class _Alloc, class ..._Up, __enable_if_t<893 template <class _Alloc, class ..._Up, __enable_if_t<
820 _And<894 _And<
821 _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>,895 _EnableCtorFromUTypesTuple<tuple<_Up...>&&>,
822 _EnableMoveFromOtherTuple<_Up...>,
823 _Not<_Lazy<_And, is_convertible<_Up, _Tp>...> > // explicit check896 _Not<_Lazy<_And, is_convertible<_Up, _Tp>...> > // explicit check
824 >::value897 >::value
825 , int> = 0>898 , int> = 0>
...@@ -828,57 +901,77 @@ public:...@@ -828,57 +901,77 @@ public:
828 : __base_(allocator_arg_t(), __a, _VSTD::move(__t))901 : __base_(allocator_arg_t(), __a, _VSTD::move(__t))
829 { }902 { }
830903
904#if _LIBCPP_STD_VER > 20
905 // tuple(const tuple<U...>&&) constructors (including allocator_arg_t variants)
906
907 template <class... _Up, enable_if_t<
908 _EnableCtorFromUTypesTuple<const tuple<_Up...>&&>::value>* = nullptr>
909 _LIBCPP_HIDE_FROM_ABI constexpr
910 explicit(!(is_convertible_v<const _Up&&, _Tp> && ...))
911 tuple(const tuple<_Up...>&& __t) : __base_(std::move(__t)) {}
912
913 template <class _Alloc, class... _Up, enable_if_t<
914 _EnableCtorFromUTypesTuple<const tuple<_Up...>&&>::value>* = nullptr>
915 _LIBCPP_HIDE_FROM_ABI constexpr
916 explicit(!(is_convertible_v<const _Up&&, _Tp> && ...))
917 tuple(allocator_arg_t, const _Alloc& __alloc, const tuple<_Up...>&& __t)
918 : __base_(allocator_arg_t(), __alloc, std::move(__t)) {}
919#endif // _LIBCPP_STD_VER > 20
920
831 // tuple(const pair<U1, U2>&) constructors (including allocator_arg_t variants)921 // tuple(const pair<U1, U2>&) constructors (including allocator_arg_t variants)
832 template <class _Up1, class _Up2, class ..._DependentTp>
833 struct _EnableImplicitCopyFromPair : _And<
834 is_constructible<_FirstType<_DependentTp...>, const _Up1&>,
835 is_constructible<_SecondType<_DependentTp...>, const _Up2&>,
836 is_convertible<const _Up1&, _FirstType<_DependentTp...> >, // explicit check
837 is_convertible<const _Up2&, _SecondType<_DependentTp...> >
838 > { };
839922
840 template <class _Up1, class _Up2, class ..._DependentTp>923 template <template <class...> class Pred, class _Pair, class _DecayedPair = __uncvref_t<_Pair>, class _Tuple = tuple>
841 struct _EnableExplicitCopyFromPair : _And<924 struct _CtorPredicateFromPair : false_type{};
842 is_constructible<_FirstType<_DependentTp...>, const _Up1&>,925
843 is_constructible<_SecondType<_DependentTp...>, const _Up2&>,926 template <template <class...> class Pred, class _Pair, class _Up1, class _Up2, class _Tp1, class _Tp2>
844 _Not<is_convertible<const _Up1&, _FirstType<_DependentTp...> > >, // explicit check927 struct _CtorPredicateFromPair<Pred, _Pair, pair<_Up1, _Up2>, tuple<_Tp1, _Tp2> > : _And<
845 _Not<is_convertible<const _Up2&, _SecondType<_DependentTp...> > >928 Pred<_Tp1, __copy_cvref_t<_Pair, _Up1> >,
846 > { };929 Pred<_Tp2, __copy_cvref_t<_Pair, _Up2> >
930 > {};
931
932 template <class _Pair>
933 struct _EnableCtorFromPair : _CtorPredicateFromPair<is_constructible, _Pair>{};
934
935 template <class _Pair>
936 struct _NothrowConstructibleFromPair : _CtorPredicateFromPair<is_nothrow_constructible, _Pair>{};
937
938 template <class _Pair, class _DecayedPair = __uncvref_t<_Pair>, class _Tuple = tuple>
939 struct _BothImplicitlyConvertible : false_type{};
940
941 template <class _Pair, class _Up1, class _Up2, class _Tp1, class _Tp2>
942 struct _BothImplicitlyConvertible<_Pair, pair<_Up1, _Up2>, tuple<_Tp1, _Tp2> > : _And<
943 is_convertible<__copy_cvref_t<_Pair, _Up1>, _Tp1>,
944 is_convertible<__copy_cvref_t<_Pair, _Up2>, _Tp2>
945 > {};
847946
848 template <class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t<947 template <class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t<
849 _And<948 _And<
850 _BoolConstant<sizeof...(_Tp) == 2>,949 _EnableCtorFromPair<const pair<_Up1, _Up2>&>,
851 _EnableImplicitCopyFromPair<_Up1, _Up2, _Tp...>950 _BothImplicitlyConvertible<const pair<_Up1, _Up2>&> // explicit check
852 >::value951 >::value
853 , int> = 0>952 , int> = 0>
854 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11953 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
855 tuple(const pair<_Up1, _Up2>& __p)954 tuple(const pair<_Up1, _Up2>& __p)
856 _NOEXCEPT_((_And<955 _NOEXCEPT_((_NothrowConstructibleFromPair<const pair<_Up1, _Up2>&>::value))
857 is_nothrow_constructible<_FirstType<_Tp...>, const _Up1&>,
858 is_nothrow_constructible<_SecondType<_Tp...>, const _Up2&>
859 >::value))
860 : __base_(__p)956 : __base_(__p)
861 { }957 { }
862958
863 template <class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t<959 template <class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t<
864 _And<960 _And<
865 _BoolConstant<sizeof...(_Tp) == 2>,961 _EnableCtorFromPair<const pair<_Up1, _Up2>&>,
866 _EnableExplicitCopyFromPair<_Up1, _Up2, _Tp...>962 _Not<_BothImplicitlyConvertible<const pair<_Up1, _Up2>&> > // explicit check
867 >::value963 >::value
868 , int> = 0>964 , int> = 0>
869 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11965 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
870 explicit tuple(const pair<_Up1, _Up2>& __p)966 explicit tuple(const pair<_Up1, _Up2>& __p)
871 _NOEXCEPT_((_And<967 _NOEXCEPT_((_NothrowConstructibleFromPair<const pair<_Up1, _Up2>&>::value))
872 is_nothrow_constructible<_FirstType<_Tp...>, const _Up1&>,
873 is_nothrow_constructible<_SecondType<_Tp...>, const _Up2&>
874 >::value))
875 : __base_(__p)968 : __base_(__p)
876 { }969 { }
877970
878 template <class _Alloc, class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t<971 template <class _Alloc, class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t<
879 _And<972 _And<
880 _BoolConstant<sizeof...(_Tp) == 2>,973 _EnableCtorFromPair<const pair<_Up1, _Up2>&>,
881 _EnableImplicitCopyFromPair<_Up1, _Up2, _Tp...>974 _BothImplicitlyConvertible<const pair<_Up1, _Up2>&> // explicit check
882 >::value975 >::value
883 , int> = 0>976 , int> = 0>
884 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17977 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
...@@ -888,8 +981,8 @@ public:...@@ -888,8 +981,8 @@ public:
888981
889 template <class _Alloc, class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t<982 template <class _Alloc, class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t<
890 _And<983 _And<
891 _BoolConstant<sizeof...(_Tp) == 2>,984 _EnableCtorFromPair<const pair<_Up1, _Up2>&>,
892 _EnableExplicitCopyFromPair<_Up1, _Up2, _Tp...>985 _Not<_BothImplicitlyConvertible<const pair<_Up1, _Up2>&> > // explicit check
893 >::value986 >::value
894 , int> = 0>987 , int> = 0>
895 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17988 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
...@@ -897,57 +990,52 @@ public:...@@ -897,57 +990,52 @@ public:
897 : __base_(allocator_arg_t(), __a, __p)990 : __base_(allocator_arg_t(), __a, __p)
898 { }991 { }
899992
900 // tuple(pair<U1, U2>&&) constructors (including allocator_arg_t variants)993#if _LIBCPP_STD_VER > 20
901 template <class _Up1, class _Up2, class ..._DependentTp>994 // tuple(pair<U1, U2>&) constructors (including allocator_arg_t variants)
902 struct _EnableImplicitMoveFromPair : _And<995
903 is_constructible<_FirstType<_DependentTp...>, _Up1>,996 template <class _U1, class _U2, enable_if_t<
904 is_constructible<_SecondType<_DependentTp...>, _Up2>,997 _EnableCtorFromPair<pair<_U1, _U2>&>::value>* = nullptr>
905 is_convertible<_Up1, _FirstType<_DependentTp...> >, // explicit check998 _LIBCPP_HIDE_FROM_ABI constexpr
906 is_convertible<_Up2, _SecondType<_DependentTp...> >999 explicit(!_BothImplicitlyConvertible<pair<_U1, _U2>&>::value)
907 > { };1000 tuple(pair<_U1, _U2>& __p) : __base_(__p) {}
1001
1002 template <class _Alloc, class _U1, class _U2, enable_if_t<
1003 _EnableCtorFromPair<std::pair<_U1, _U2>&>::value>* = nullptr>
1004 _LIBCPP_HIDE_FROM_ABI constexpr
1005 explicit(!_BothImplicitlyConvertible<pair<_U1, _U2>&>::value)
1006 tuple(allocator_arg_t, const _Alloc& __alloc, pair<_U1, _U2>& __p) : __base_(allocator_arg_t(), __alloc, __p) {}
1007#endif
9081008
909 template <class _Up1, class _Up2, class ..._DependentTp>1009 // tuple(pair<U1, U2>&&) constructors (including allocator_arg_t variants)
910 struct _EnableExplicitMoveFromPair : _And<
911 is_constructible<_FirstType<_DependentTp...>, _Up1>,
912 is_constructible<_SecondType<_DependentTp...>, _Up2>,
913 _Not<is_convertible<_Up1, _FirstType<_DependentTp...> > >, // explicit check
914 _Not<is_convertible<_Up2, _SecondType<_DependentTp...> > >
915 > { };
9161010
917 template <class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t<1011 template <class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t<
918 _And<1012 _And<
919 _BoolConstant<sizeof...(_Tp) == 2>,1013 _EnableCtorFromPair<pair<_Up1, _Up2>&&>,
920 _EnableImplicitMoveFromPair<_Up1, _Up2, _Tp...>1014 _BothImplicitlyConvertible<pair<_Up1, _Up2>&&> // explicit check
921 >::value1015 >::value
922 , int> = 0>1016 , int> = 0>
923 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX111017 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
924 tuple(pair<_Up1, _Up2>&& __p)1018 tuple(pair<_Up1, _Up2>&& __p)
925 _NOEXCEPT_((_And<1019 _NOEXCEPT_((_NothrowConstructibleFromPair<pair<_Up1, _Up2>&&>::value))
926 is_nothrow_constructible<_FirstType<_Tp...>, _Up1>,
927 is_nothrow_constructible<_SecondType<_Tp...>, _Up2>
928 >::value))
929 : __base_(_VSTD::move(__p))1020 : __base_(_VSTD::move(__p))
930 { }1021 { }
9311022
932 template <class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t<1023 template <class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t<
933 _And<1024 _And<
934 _BoolConstant<sizeof...(_Tp) == 2>,1025 _EnableCtorFromPair<pair<_Up1, _Up2>&&>,
935 _EnableExplicitMoveFromPair<_Up1, _Up2, _Tp...>1026 _Not<_BothImplicitlyConvertible<pair<_Up1, _Up2>&&> > // explicit check
936 >::value1027 >::value
937 , int> = 0>1028 , int> = 0>
938 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX111029 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
939 explicit tuple(pair<_Up1, _Up2>&& __p)1030 explicit tuple(pair<_Up1, _Up2>&& __p)
940 _NOEXCEPT_((_And<1031 _NOEXCEPT_((_NothrowConstructibleFromPair<pair<_Up1, _Up2>&&>::value))
941 is_nothrow_constructible<_FirstType<_Tp...>, _Up1>,
942 is_nothrow_constructible<_SecondType<_Tp...>, _Up2>
943 >::value))
944 : __base_(_VSTD::move(__p))1032 : __base_(_VSTD::move(__p))
945 { }1033 { }
9461034
947 template <class _Alloc, class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t<1035 template <class _Alloc, class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t<
948 _And<1036 _And<
949 _BoolConstant<sizeof...(_Tp) == 2>,1037 _EnableCtorFromPair<pair<_Up1, _Up2>&&>,
950 _EnableImplicitMoveFromPair<_Up1, _Up2, _Tp...>1038 _BothImplicitlyConvertible<pair<_Up1, _Up2>&&> // explicit check
951 >::value1039 >::value
952 , int> = 0>1040 , int> = 0>
953 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX171041 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
...@@ -957,8 +1045,8 @@ public:...@@ -957,8 +1045,8 @@ public:
9571045
958 template <class _Alloc, class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t<1046 template <class _Alloc, class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t<
959 _And<1047 _And<
960 _BoolConstant<sizeof...(_Tp) == 2>,1048 _EnableCtorFromPair<pair<_Up1, _Up2>&&>,
961 _EnableExplicitMoveFromPair<_Up1, _Up2, _Tp...>1049 _Not<_BothImplicitlyConvertible<pair<_Up1, _Up2>&&> > // explicit check
962 >::value1050 >::value
963 , int> = 0>1051 , int> = 0>
964 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX171052 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
...@@ -966,6 +1054,23 @@ public:...@@ -966,6 +1054,23 @@ public:
966 : __base_(allocator_arg_t(), __a, _VSTD::move(__p))1054 : __base_(allocator_arg_t(), __a, _VSTD::move(__p))
967 { }1055 { }
9681056
1057#if _LIBCPP_STD_VER > 20
1058 // tuple(const pair<U1, U2>&&) constructors (including allocator_arg_t variants)
1059
1060 template <class _U1, class _U2, enable_if_t<
1061 _EnableCtorFromPair<const pair<_U1, _U2>&&>::value>* = nullptr>
1062 _LIBCPP_HIDE_FROM_ABI constexpr
1063 explicit(!_BothImplicitlyConvertible<const pair<_U1, _U2>&&>::value)
1064 tuple(const pair<_U1, _U2>&& __p) : __base_(std::move(__p)) {}
1065
1066 template <class _Alloc, class _U1, class _U2, enable_if_t<
1067 _EnableCtorFromPair<const pair<_U1, _U2>&&>::value>* = nullptr>
1068 _LIBCPP_HIDE_FROM_ABI constexpr
1069 explicit(!_BothImplicitlyConvertible<const pair<_U1, _U2>&&>::value)
1070 tuple(allocator_arg_t, const _Alloc& __alloc, const pair<_U1, _U2>&& __p)
1071 : __base_(allocator_arg_t(), __alloc, std::move(__p)) {}
1072#endif // _LIBCPP_STD_VER > 20
1073
969 // [tuple.assign]1074 // [tuple.assign]
970 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX171075 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
971 tuple& operator=(_If<_And<is_copy_assignable<_Tp>...>::value, tuple, __nat> const& __tuple)1076 tuple& operator=(_If<_And<is_copy_assignable<_Tp>...>::value, tuple, __nat> const& __tuple)
...@@ -976,6 +1081,25 @@ public:...@@ -976,6 +1081,25 @@ public:
976 return *this;1081 return *this;
977 }1082 }
9781083
1084#if _LIBCPP_STD_VER > 20
1085 _LIBCPP_HIDE_FROM_ABI constexpr
1086 const tuple& operator=(tuple const& __tuple) const
1087 requires (_And<is_copy_assignable<const _Tp>...>::value) {
1088 std::__memberwise_copy_assign(*this, __tuple, typename __make_tuple_indices<sizeof...(_Tp)>::type());
1089 return *this;
1090 }
1091
1092 _LIBCPP_HIDE_FROM_ABI constexpr
1093 const tuple& operator=(tuple&& __tuple) const
1094 requires (_And<is_assignable<const _Tp&, _Tp>...>::value) {
1095 std::__memberwise_forward_assign(*this,
1096 std::move(__tuple),
1097 __tuple_types<_Tp...>(),
1098 typename __make_tuple_indices<sizeof...(_Tp)>::type());
1099 return *this;
1100 }
1101#endif // _LIBCPP_STD_VER > 20
1102
979 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX171103 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
980 tuple& operator=(_If<_And<is_move_assignable<_Tp>...>::value, tuple, __nat>&& __tuple)1104 tuple& operator=(_If<_And<is_move_assignable<_Tp>...>::value, tuple, __nat>&& __tuple)
981 _NOEXCEPT_((_And<is_nothrow_move_assignable<_Tp>...>::value))1105 _NOEXCEPT_((_And<is_nothrow_move_assignable<_Tp>...>::value))
...@@ -1017,38 +1141,89 @@ public:...@@ -1017,38 +1141,89 @@ public:
1017 return *this;1141 return *this;
1018 }1142 }
10191143
1020 template<class _Up1, class _Up2, class _Dep = true_type, __enable_if_t<1144
1021 _And<_Dep,1145#if _LIBCPP_STD_VER > 20
1022 _BoolConstant<sizeof...(_Tp) == 2>,1146 template <class... _UTypes, enable_if_t<
1023 is_assignable<_FirstType<_Tp..., _Dep>&, _Up1 const&>,1147 _And<_BoolConstant<sizeof...(_Tp) == sizeof...(_UTypes)>,
1024 is_assignable<_SecondType<_Tp..., _Dep>&, _Up2 const&>1148 is_assignable<const _Tp&, const _UTypes&>...>::value>* = nullptr>
1025 >::value1149 _LIBCPP_HIDE_FROM_ABI constexpr
1150 const tuple& operator=(const tuple<_UTypes...>& __u) const {
1151 std::__memberwise_copy_assign(*this,
1152 __u,
1153 typename __make_tuple_indices<sizeof...(_Tp)>::type());
1154 return *this;
1155 }
1156
1157 template <class... _UTypes, enable_if_t<
1158 _And<_BoolConstant<sizeof...(_Tp) == sizeof...(_UTypes)>,
1159 is_assignable<const _Tp&, _UTypes>...>::value>* = nullptr>
1160 _LIBCPP_HIDE_FROM_ABI constexpr
1161 const tuple& operator=(tuple<_UTypes...>&& __u) const {
1162 std::__memberwise_forward_assign(*this,
1163 __u,
1164 __tuple_types<_UTypes...>(),
1165 typename __make_tuple_indices<sizeof...(_Tp)>::type());
1166 return *this;
1167 }
1168#endif // _LIBCPP_STD_VER > 20
1169
1170 template <template<class...> class Pred, bool _Const,
1171 class _Pair, class _DecayedPair = __uncvref_t<_Pair>, class _Tuple = tuple>
1172 struct _AssignPredicateFromPair : false_type {};
1173
1174 template <template<class...> class Pred, bool _Const,
1175 class _Pair, class _Up1, class _Up2, class _Tp1, class _Tp2>
1176 struct _AssignPredicateFromPair<Pred, _Const, _Pair, pair<_Up1, _Up2>, tuple<_Tp1, _Tp2> > :
1177 _And<Pred<__maybe_const<_Const, _Tp1>&, __copy_cvref_t<_Pair, _Up1> >,
1178 Pred<__maybe_const<_Const, _Tp2>&, __copy_cvref_t<_Pair, _Up2> >
1179 > {};
1180
1181 template <bool _Const, class _Pair>
1182 struct _EnableAssignFromPair : _AssignPredicateFromPair<is_assignable, _Const, _Pair> {};
1183
1184 template <bool _Const, class _Pair>
1185 struct _NothrowAssignFromPair : _AssignPredicateFromPair<is_nothrow_assignable, _Const, _Pair> {};
1186
1187#if _LIBCPP_STD_VER > 20
1188 template <class _U1, class _U2, enable_if_t<
1189 _EnableAssignFromPair<true, const pair<_U1, _U2>&>::value>* = nullptr>
1190 _LIBCPP_HIDE_FROM_ABI constexpr
1191 const tuple& operator=(const pair<_U1, _U2>& __pair) const
1192 noexcept(_NothrowAssignFromPair<true, const pair<_U1, _U2>&>::value) {
1193 std::get<0>(*this) = __pair.first;
1194 std::get<1>(*this) = __pair.second;
1195 return *this;
1196 }
1197
1198 template <class _U1, class _U2, enable_if_t<
1199 _EnableAssignFromPair<true, pair<_U1, _U2>&&>::value>* = nullptr>
1200 _LIBCPP_HIDE_FROM_ABI constexpr
1201 const tuple& operator=(pair<_U1, _U2>&& __pair) const
1202 noexcept(_NothrowAssignFromPair<true, pair<_U1, _U2>&&>::value) {
1203 std::get<0>(*this) = std::move(__pair.first);
1204 std::get<1>(*this) = std::move(__pair.second);
1205 return *this;
1206 }
1207#endif // _LIBCPP_STD_VER > 20
1208
1209 template<class _Up1, class _Up2, __enable_if_t<
1210 _EnableAssignFromPair<false, pair<_Up1, _Up2> const&>::value
1026 ,int> = 0>1211 ,int> = 0>
1027 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX171212 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1028 tuple& operator=(pair<_Up1, _Up2> const& __pair)1213 tuple& operator=(pair<_Up1, _Up2> const& __pair)
1029 _NOEXCEPT_((_And<1214 _NOEXCEPT_((_NothrowAssignFromPair<false, pair<_Up1, _Up2> const&>::value))
1030 is_nothrow_assignable<_FirstType<_Tp...>&, _Up1 const&>,
1031 is_nothrow_assignable<_SecondType<_Tp...>&, _Up2 const&>
1032 >::value))
1033 {1215 {
1034 _VSTD::get<0>(*this) = __pair.first;1216 _VSTD::get<0>(*this) = __pair.first;
1035 _VSTD::get<1>(*this) = __pair.second;1217 _VSTD::get<1>(*this) = __pair.second;
1036 return *this;1218 return *this;
1037 }1219 }
10381220
1039 template<class _Up1, class _Up2, class _Dep = true_type, __enable_if_t<1221 template<class _Up1, class _Up2, __enable_if_t<
1040 _And<_Dep,1222 _EnableAssignFromPair<false, pair<_Up1, _Up2>&&>::value
1041 _BoolConstant<sizeof...(_Tp) == 2>,
1042 is_assignable<_FirstType<_Tp..., _Dep>&, _Up1>,
1043 is_assignable<_SecondType<_Tp..., _Dep>&, _Up2>
1044 >::value
1045 ,int> = 0>1223 ,int> = 0>
1046 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX171224 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1047 tuple& operator=(pair<_Up1, _Up2>&& __pair)1225 tuple& operator=(pair<_Up1, _Up2>&& __pair)
1048 _NOEXCEPT_((_And<1226 _NOEXCEPT_((_NothrowAssignFromPair<false, pair<_Up1, _Up2>&&>::value))
1049 is_nothrow_assignable<_FirstType<_Tp...>&, _Up1>,
1050 is_nothrow_assignable<_SecondType<_Tp...>&, _Up2>
1051 >::value))
1052 {1227 {
1053 _VSTD::get<0>(*this) = _VSTD::forward<_Up1>(__pair.first);1228 _VSTD::get<0>(*this) = _VSTD::forward<_Up1>(__pair.first);
1054 _VSTD::get<1>(*this) = _VSTD::forward<_Up2>(__pair.second);1229 _VSTD::get<1>(*this) = _VSTD::forward<_Up2>(__pair.second);
...@@ -1092,6 +1267,13 @@ public:...@@ -1092,6 +1267,13 @@ public:
1092 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX171267 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1093 void swap(tuple& __t) _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)1268 void swap(tuple& __t) _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
1094 {__base_.swap(__t.__base_);}1269 {__base_.swap(__t.__base_);}
1270
1271#if _LIBCPP_STD_VER > 20
1272 _LIBCPP_HIDE_FROM_ABI constexpr
1273 void swap(const tuple& __t) const noexcept(__all<is_nothrow_swappable_v<const _Tp&>...>::value) {
1274 __base_.swap(__t.__base_);
1275 }
1276#endif // _LIBCPP_STD_VER > 20
1095};1277};
10961278
1097template <>1279template <>
...@@ -1114,6 +1296,9 @@ public:...@@ -1114,6 +1296,9 @@ public:
1114 tuple(allocator_arg_t, const _Alloc&, array<_Up, 0>) _NOEXCEPT {}1296 tuple(allocator_arg_t, const _Alloc&, array<_Up, 0>) _NOEXCEPT {}
1115 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX171297 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1116 void swap(tuple&) _NOEXCEPT {}1298 void swap(tuple&) _NOEXCEPT {}
1299#if _LIBCPP_STD_VER > 20
1300 _LIBCPP_HIDE_FROM_ABI constexpr void swap(const tuple&) const noexcept {}
1301#endif
1117};1302};
11181303
1119#if _LIBCPP_STD_VER > 201304#if _LIBCPP_STD_VER > 20
...@@ -1128,7 +1313,7 @@ template <class... _TTypes, class... _UTypes>...@@ -1128,7 +1313,7 @@ template <class... _TTypes, class... _UTypes>
1128struct common_type<tuple<_TTypes...>, tuple<_UTypes...>> {1313struct common_type<tuple<_TTypes...>, tuple<_UTypes...>> {
1129 using type = tuple<common_type_t<_TTypes, _UTypes>...>;1314 using type = tuple<common_type_t<_TTypes, _UTypes>...>;
1130};1315};
1131#endif1316#endif // _LIBCPP_STD_VER > 20
11321317
1133#if _LIBCPP_STD_VER > 141318#if _LIBCPP_STD_VER > 14
1134template <class ..._Tp>1319template <class ..._Tp>
...@@ -1145,15 +1330,21 @@ tuple(allocator_arg_t, _Alloc, tuple<_Tp...>) -> tuple<_Tp...>;...@@ -1145,15 +1330,21 @@ tuple(allocator_arg_t, _Alloc, tuple<_Tp...>) -> tuple<_Tp...>;
11451330
1146template <class ..._Tp>1331template <class ..._Tp>
1147inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX171332inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1148typename enable_if1333__enable_if_t<__all<__is_swappable<_Tp>::value...>::value, void>
1149<
1150 __all<__is_swappable<_Tp>::value...>::value,
1151 void
1152>::type
1153swap(tuple<_Tp...>& __t, tuple<_Tp...>& __u)1334swap(tuple<_Tp...>& __t, tuple<_Tp...>& __u)
1154 _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)1335 _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
1155 {__t.swap(__u);}1336 {__t.swap(__u);}
11561337
1338#if _LIBCPP_STD_VER > 20
1339template <class... _Tp>
1340_LIBCPP_HIDE_FROM_ABI constexpr
1341enable_if_t<__all<is_swappable_v<const _Tp>...>::value, void>
1342swap(const tuple<_Tp...>& __lhs, const tuple<_Tp...>& __rhs)
1343 noexcept(__all<is_nothrow_swappable_v<const _Tp>...>::value) {
1344 __lhs.swap(__rhs);
1345}
1346#endif
1347
1157// get1348// get
11581349
1159template <size_t _Ip, class ..._Tp>1350template <size_t _Ip, class ..._Tp>
...@@ -1333,7 +1524,7 @@ operator==(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)...@@ -1333,7 +1524,7 @@ operator==(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1333 return __tuple_equal<sizeof...(_Tp)>()(__x, __y);1524 return __tuple_equal<sizeof...(_Tp)>()(__x, __y);
1334}1525}
13351526
1336#if !defined(_LIBCPP_HAS_NO_CONCEPTS)1527#if _LIBCPP_STD_VER > 17
13371528
1338// operator<=>1529// operator<=>
13391530
...@@ -1355,7 +1546,7 @@ operator<=>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)...@@ -1355,7 +1546,7 @@ operator<=>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1355 return _VSTD::__tuple_compare_three_way(__x, __y, index_sequence_for<_Tp...>{});1546 return _VSTD::__tuple_compare_three_way(__x, __y, index_sequence_for<_Tp...>{});
1356}1547}
13571548
1358#else // !defined(_LIBCPP_HAS_NO_CONCEPTS)1549#else // _LIBCPP_STD_VER > 17
13591550
1360template <class ..._Tp, class ..._Up>1551template <class ..._Tp, class ..._Up>
1361inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX111552inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
...@@ -1425,7 +1616,7 @@ operator<=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)...@@ -1425,7 +1616,7 @@ operator<=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1425 return !(__y < __x);1616 return !(__y < __x);
1426}1617}
14271618
1428#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)1619#endif // _LIBCPP_STD_VER > 17
14291620
1430// tuple_cat1621// tuple_cat
14311622
...@@ -1445,9 +1636,10 @@ struct __tuple_cat_return_1...@@ -1445,9 +1636,10 @@ struct __tuple_cat_return_1
1445template <class ..._Types, class _Tuple0>1636template <class ..._Types, class _Tuple0>
1446struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0>1637struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0>
1447{1638{
1448 typedef _LIBCPP_NODEBUG typename __tuple_cat_type<tuple<_Types...>,1639 using type _LIBCPP_NODEBUG = typename __tuple_cat_type<
1449 typename __make_tuple_types<typename __uncvref<_Tuple0>::type>::type>::type1640 tuple<_Types...>,
1450 type;1641 typename __make_tuple_types<__uncvref_t<_Tuple0> >::type
1642 >::type;
1451};1643};
14521644
1453template <class ..._Types, class _Tuple0, class _Tuple1, class ..._Tuples>1645template <class ..._Types, class _Tuple0, class _Tuple1, class ..._Tuples>
...@@ -1455,7 +1647,7 @@ struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0, _Tuple1, _Tuples......@@ -1455,7 +1647,7 @@ struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0, _Tuple1, _Tuples...
1455 : public __tuple_cat_return_1<1647 : public __tuple_cat_return_1<
1456 typename __tuple_cat_type<1648 typename __tuple_cat_type<
1457 tuple<_Types...>,1649 tuple<_Types...>,
1458 typename __make_tuple_types<typename __uncvref<_Tuple0>::type>::type1650 typename __make_tuple_types<__uncvref_t<_Tuple0> >::type
1459 >::type,1651 >::type,
1460 __tuple_like<typename remove_reference<_Tuple1>::type>::value,1652 __tuple_like<typename remove_reference<_Tuple1>::type>::value,
1461 _Tuple1, _Tuples...>1653 _Tuple1, _Tuples...>
...@@ -1529,6 +1721,7 @@ struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J...@@ -1529,6 +1721,7 @@ struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J
1529 typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&>::type1721 typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&>::type
1530 operator()(tuple<_Types...> __t, _Tuple0&& __t0)1722 operator()(tuple<_Types...> __t, _Tuple0&& __t0)
1531 {1723 {
1724 (void)__t; // avoid unused parameter warning on GCC when _I0 is empty
1532 return _VSTD::forward_as_tuple(1725 return _VSTD::forward_as_tuple(
1533 _VSTD::forward<_Types>(_VSTD::get<_I0>(__t))...,1726 _VSTD::forward<_Types>(_VSTD::get<_I0>(__t))...,
1534 _VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...);1727 _VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...);
...@@ -1539,6 +1732,7 @@ struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J...@@ -1539,6 +1732,7 @@ struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J
1539 typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&, _Tuple1&&, _Tuples&&...>::type1732 typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&, _Tuple1&&, _Tuples&&...>::type
1540 operator()(tuple<_Types...> __t, _Tuple0&& __t0, _Tuple1&& __t1, _Tuples&& ...__tpls)1733 operator()(tuple<_Types...> __t, _Tuple0&& __t0, _Tuple1&& __t1, _Tuples&& ...__tpls)
1541 {1734 {
1735 (void)__t; // avoid unused parameter warning on GCC when _I0 is empty
1542 typedef _LIBCPP_NODEBUG typename remove_reference<_Tuple0>::type _T0;1736 typedef _LIBCPP_NODEBUG typename remove_reference<_Tuple0>::type _T0;
1543 typedef _LIBCPP_NODEBUG typename remove_reference<_Tuple1>::type _T1;1737 typedef _LIBCPP_NODEBUG typename remove_reference<_Tuple1>::type _T1;
1544 return __tuple_cat<1738 return __tuple_cat<
...@@ -1593,7 +1787,7 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -1593,7 +1787,7 @@ inline _LIBCPP_INLINE_VISIBILITY
1593constexpr decltype(auto) __apply_tuple_impl(_Fn && __f, _Tuple && __t,1787constexpr decltype(auto) __apply_tuple_impl(_Fn && __f, _Tuple && __t,
1594 __tuple_indices<_Id...>)1788 __tuple_indices<_Id...>)
1595_LIBCPP_NOEXCEPT_RETURN(1789_LIBCPP_NOEXCEPT_RETURN(
1596 _VSTD::__invoke_constexpr(1790 _VSTD::__invoke(
1597 _VSTD::forward<_Fn>(__f),1791 _VSTD::forward<_Fn>(__f),
1598 _VSTD::get<_Id>(_VSTD::forward<_Tuple>(__t))...)1792 _VSTD::get<_Id>(_VSTD::forward<_Tuple>(__t))...)
1599)1793)
lib/libcxx/include/type_traits+132-3477
...@@ -416,3457 +416,178 @@ namespace std...@@ -416,3457 +416,178 @@ namespace std
416}416}
417417
418*/418*/
419#include <__assert> // all public C++ headers provide the assertion handler
419#include <__config>420#include <__config>
421#include <__functional/invoke.h>
422#include <__type_traits/add_const.h>
423#include <__type_traits/add_cv.h>
424#include <__type_traits/add_lvalue_reference.h>
425#include <__type_traits/add_pointer.h>
426#include <__type_traits/add_rvalue_reference.h>
427#include <__type_traits/add_volatile.h>
428#include <__type_traits/aligned_storage.h>
429#include <__type_traits/aligned_union.h>
430#include <__type_traits/alignment_of.h>
431#include <__type_traits/apply_cv.h>
432#include <__type_traits/common_reference.h>
433#include <__type_traits/common_type.h>
434#include <__type_traits/conditional.h>
435#include <__type_traits/conjunction.h>
436#include <__type_traits/decay.h>
437#include <__type_traits/disjunction.h>
438#include <__type_traits/enable_if.h>
439#include <__type_traits/extent.h>
440#include <__type_traits/has_unique_object_representation.h>
441#include <__type_traits/has_virtual_destructor.h>
442#include <__type_traits/integral_constant.h>
443#include <__type_traits/is_abstract.h>
444#include <__type_traits/is_aggregate.h>
445#include <__type_traits/is_arithmetic.h>
446#include <__type_traits/is_array.h>
447#include <__type_traits/is_assignable.h>
448#include <__type_traits/is_base_of.h>
449#include <__type_traits/is_bounded_array.h>
450#include <__type_traits/is_callable.h>
451#include <__type_traits/is_class.h>
452#include <__type_traits/is_compound.h>
453#include <__type_traits/is_const.h>
454#include <__type_traits/is_constant_evaluated.h>
455#include <__type_traits/is_constructible.h>
456#include <__type_traits/is_convertible.h>
457#include <__type_traits/is_copy_assignable.h>
458#include <__type_traits/is_copy_constructible.h>
459#include <__type_traits/is_default_constructible.h>
460#include <__type_traits/is_destructible.h>
461#include <__type_traits/is_empty.h>
462#include <__type_traits/is_enum.h>
463#include <__type_traits/is_final.h>
464#include <__type_traits/is_floating_point.h>
465#include <__type_traits/is_function.h>
466#include <__type_traits/is_fundamental.h>
467#include <__type_traits/is_integral.h>
468#include <__type_traits/is_literal_type.h>
469#include <__type_traits/is_member_function_pointer.h>
470#include <__type_traits/is_member_object_pointer.h>
471#include <__type_traits/is_member_pointer.h>
472#include <__type_traits/is_move_assignable.h>
473#include <__type_traits/is_move_constructible.h>
474#include <__type_traits/is_nothrow_assignable.h>
475#include <__type_traits/is_nothrow_constructible.h>
476#include <__type_traits/is_nothrow_convertible.h>
477#include <__type_traits/is_nothrow_copy_assignable.h>
478#include <__type_traits/is_nothrow_copy_constructible.h>
479#include <__type_traits/is_nothrow_default_constructible.h>
480#include <__type_traits/is_nothrow_destructible.h>
481#include <__type_traits/is_nothrow_move_assignable.h>
482#include <__type_traits/is_nothrow_move_constructible.h>
483#include <__type_traits/is_null_pointer.h>
484#include <__type_traits/is_object.h>
485#include <__type_traits/is_pod.h>
486#include <__type_traits/is_pointer.h>
487#include <__type_traits/is_polymorphic.h>
488#include <__type_traits/is_reference.h>
489#include <__type_traits/is_reference_wrapper.h>
490#include <__type_traits/is_referenceable.h>
491#include <__type_traits/is_same.h>
492#include <__type_traits/is_scalar.h>
493#include <__type_traits/is_scoped_enum.h>
494#include <__type_traits/is_signed.h>
495#include <__type_traits/is_standard_layout.h>
496#include <__type_traits/is_trivial.h>
497#include <__type_traits/is_trivially_assignable.h>
498#include <__type_traits/is_trivially_constructible.h>
499#include <__type_traits/is_trivially_copy_assignable.h>
500#include <__type_traits/is_trivially_copy_constructible.h>
501#include <__type_traits/is_trivially_copyable.h>
502#include <__type_traits/is_trivially_default_constructible.h>
503#include <__type_traits/is_trivially_destructible.h>
504#include <__type_traits/is_trivially_move_assignable.h>
505#include <__type_traits/is_trivially_move_constructible.h>
506#include <__type_traits/is_unbounded_array.h>
507#include <__type_traits/is_union.h>
508#include <__type_traits/is_unsigned.h>
509#include <__type_traits/is_void.h>
510#include <__type_traits/is_volatile.h>
511#include <__type_traits/make_signed.h>
512#include <__type_traits/make_unsigned.h>
513#include <__type_traits/negation.h>
514#include <__type_traits/rank.h>
515#include <__type_traits/remove_all_extents.h>
516#include <__type_traits/remove_const.h>
517#include <__type_traits/remove_cv.h>
518#include <__type_traits/remove_extent.h>
519#include <__type_traits/remove_pointer.h>
520#include <__type_traits/remove_reference.h>
521#include <__type_traits/remove_volatile.h>
522#include <__type_traits/type_identity.h>
523#include <__type_traits/underlying_type.h>
524#include <__type_traits/void_t.h>
525#include <__utility/declval.h>
420#include <cstddef>526#include <cstddef>
527#include <cstdint>
421#include <version>528#include <version>
422529
423#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)530#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
424#pragma GCC system_header531# pragma GCC system_header
425#endif532#endif
426533
427_LIBCPP_BEGIN_NAMESPACE_STD534_LIBCPP_BEGIN_NAMESPACE_STD
428535
429template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS pair;536template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS pair;
430template <class _Tp> class _LIBCPP_TEMPLATE_VIS reference_wrapper;
431template <class _Tp> struct _LIBCPP_TEMPLATE_VIS hash;537template <class _Tp> struct _LIBCPP_TEMPLATE_VIS hash;
432538
433template <class _Tp, _Tp __v>539// Member detector base
434struct _LIBCPP_TEMPLATE_VIS integral_constant
435{
436 static _LIBCPP_CONSTEXPR const _Tp value = __v;
437 typedef _Tp value_type;
438 typedef integral_constant type;
439 _LIBCPP_INLINE_VISIBILITY
440 _LIBCPP_CONSTEXPR operator value_type() const _NOEXCEPT {return value;}
441#if _LIBCPP_STD_VER > 11
442 _LIBCPP_INLINE_VISIBILITY
443 constexpr value_type operator ()() const _NOEXCEPT {return value;}
444#endif
445};
446
447template <class _Tp, _Tp __v>
448_LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value;
449
450#if _LIBCPP_STD_VER > 14
451template <bool __b>
452using bool_constant = integral_constant<bool, __b>;
453#define _LIBCPP_BOOL_CONSTANT(__b) bool_constant<(__b)>
454#else
455#define _LIBCPP_BOOL_CONSTANT(__b) integral_constant<bool,(__b)>
456#endif
457
458template <bool, class _Tp = void> struct _LIBCPP_TEMPLATE_VIS enable_if {};
459template <class _Tp> struct _LIBCPP_TEMPLATE_VIS enable_if<true, _Tp> {typedef _Tp type;};
460
461template <bool _Bp, class _Tp = void> using __enable_if_t _LIBCPP_NODEBUG = typename enable_if<_Bp, _Tp>::type;
462
463#if _LIBCPP_STD_VER > 11
464template <bool _Bp, class _Tp = void> using enable_if_t = typename enable_if<_Bp, _Tp>::type;
465#endif
466
467typedef _LIBCPP_BOOL_CONSTANT(true) true_type;
468typedef _LIBCPP_BOOL_CONSTANT(false) false_type;
469
470template <bool _Val>
471using _BoolConstant _LIBCPP_NODEBUG = integral_constant<bool, _Val>;
472
473template <bool> struct _MetaBase;
474template <>
475struct _MetaBase<true> {
476 template <class _Tp, class _Up>
477 using _SelectImpl _LIBCPP_NODEBUG = _Tp;
478 template <template <class...> class _FirstFn, template <class...> class, class ..._Args>
479 using _SelectApplyImpl _LIBCPP_NODEBUG = _FirstFn<_Args...>;
480 template <class _First, class...>
481 using _FirstImpl _LIBCPP_NODEBUG = _First;
482 template <class, class _Second, class...>
483 using _SecondImpl _LIBCPP_NODEBUG = _Second;
484 template <class _Result, class _First, class ..._Rest>
485 using _OrImpl _LIBCPP_NODEBUG = typename _MetaBase<_First::value != true && sizeof...(_Rest) != 0>::template _OrImpl<_First, _Rest...>;
486};
487
488template <>
489struct _MetaBase<false> {
490 template <class _Tp, class _Up>
491 using _SelectImpl _LIBCPP_NODEBUG = _Up;
492 template <template <class...> class, template <class...> class _SecondFn, class ..._Args>
493 using _SelectApplyImpl _LIBCPP_NODEBUG = _SecondFn<_Args...>;
494 template <class _Result, class ...>
495 using _OrImpl _LIBCPP_NODEBUG = _Result;
496};
497template <bool _Cond, class _IfRes, class _ElseRes>
498using _If _LIBCPP_NODEBUG = typename _MetaBase<_Cond>::template _SelectImpl<_IfRes, _ElseRes>;
499template <class ..._Rest>
500using _Or _LIBCPP_NODEBUG = typename _MetaBase< sizeof...(_Rest) != 0 >::template _OrImpl<false_type, _Rest...>;
501template <class _Pred>
502struct _Not : _BoolConstant<!_Pred::value> {};
503template <class ..._Args>
504using _FirstType _LIBCPP_NODEBUG = typename _MetaBase<(sizeof...(_Args) >= 1)>::template _FirstImpl<_Args...>;
505template <class ..._Args>
506using _SecondType _LIBCPP_NODEBUG = typename _MetaBase<(sizeof...(_Args) >= 2)>::template _SecondImpl<_Args...>;
507
508template <class ...> using __expand_to_true = true_type;
509template <class ..._Pred>
510__expand_to_true<__enable_if_t<_Pred::value>...> __and_helper(int);
511template <class ...>
512false_type __and_helper(...);
513template <class ..._Pred>
514using _And _LIBCPP_NODEBUG = decltype(__and_helper<_Pred...>(0));
515
516template <template <class...> class _Func, class ..._Args>
517struct _Lazy : _Func<_Args...> {};
518
519// Member detector base
520
521template <template <class...> class _Templ, class ..._Args, class = _Templ<_Args...> >
522true_type __sfinae_test_impl(int);
523template <template <class...> class, class ...>
524false_type __sfinae_test_impl(...);
525
526template <template <class ...> class _Templ, class ..._Args>
527using _IsValidExpansion _LIBCPP_NODEBUG = decltype(__sfinae_test_impl<_Templ, _Args...>(0));
528
529template <class>
530struct __void_t { typedef void type; };
531
532template <class _Tp>
533struct __identity { typedef _Tp type; };
534
535template <class _Tp>
536using __identity_t _LIBCPP_NODEBUG = typename __identity<_Tp>::type;
537
538template <class _Tp, bool>
539struct _LIBCPP_TEMPLATE_VIS __dependent_type : public _Tp {};
540
541
542template <bool _Bp, class _If, class _Then>
543 struct _LIBCPP_TEMPLATE_VIS conditional {typedef _If type;};
544template <class _If, class _Then>
545 struct _LIBCPP_TEMPLATE_VIS conditional<false, _If, _Then> {typedef _Then type;};
546
547#if _LIBCPP_STD_VER > 11
548template <bool _Bp, class _If, class _Then> using conditional_t = typename conditional<_Bp, _If, _Then>::type;
549#endif
550
551// is_same
552
553template <class _Tp, class _Up>
554struct _LIBCPP_TEMPLATE_VIS is_same : _BoolConstant<__is_same(_Tp, _Up)> { };
555
556#if _LIBCPP_STD_VER > 14
557template <class _Tp, class _Up>
558inline constexpr bool is_same_v = __is_same(_Tp, _Up);
559#endif
560
561// _IsSame<T,U> has the same effect as is_same<T,U> but instantiates fewer types:
562// is_same<A,B> and is_same<C,D> are guaranteed to be different types, but
563// _IsSame<A,B> and _IsSame<C,D> are the same type (namely, false_type).
564// Neither GCC nor Clang can mangle the __is_same builtin, so _IsSame
565// mustn't be directly used anywhere that contributes to name-mangling
566// (such as in a dependent return type).
567
568template <class _Tp, class _Up>
569using _IsSame = _BoolConstant<__is_same(_Tp, _Up)>;
570
571template <class _Tp, class _Up>
572using _IsNotSame = _BoolConstant<!__is_same(_Tp, _Up)>;
573
574template <class _Tp>
575using __test_for_primary_template = __enable_if_t<
576 _IsSame<_Tp, typename _Tp::__primary_template>::value
577 >;
578template <class _Tp>
579using __is_primary_template = _IsValidExpansion<
580 __test_for_primary_template, _Tp
581 >;
582
583// helper class
584
585struct __two {char __lx[2];};
586
587// is_const
588
589#if __has_keyword(__is_const)
590
591template <class _Tp>
592struct _LIBCPP_TEMPLATE_VIS is_const : _BoolConstant<__is_const(_Tp)> { };
593
594#if _LIBCPP_STD_VER > 14
595template <class _Tp>
596inline constexpr bool is_const_v = __is_const(_Tp);
597#endif
598
599#else
600
601template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const : public false_type {};
602template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const<_Tp const> : public true_type {};
603
604#if _LIBCPP_STD_VER > 14
605template <class _Tp>
606inline constexpr bool is_const_v = is_const<_Tp>::value;
607#endif
608
609#endif // __has_keyword(__is_const)
610
611// is_volatile
612
613#if __has_keyword(__is_volatile)
614
615template <class _Tp>
616struct _LIBCPP_TEMPLATE_VIS is_volatile : _BoolConstant<__is_volatile(_Tp)> { };
617
618#if _LIBCPP_STD_VER > 14
619template <class _Tp>
620inline constexpr bool is_volatile_v = __is_volatile(_Tp);
621#endif
622
623#else
624
625template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile : public false_type {};
626template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile<_Tp volatile> : public true_type {};
627
628#if _LIBCPP_STD_VER > 14
629template <class _Tp>
630inline constexpr bool is_volatile_v = is_volatile<_Tp>::value;
631#endif
632
633#endif // __has_keyword(__is_volatile)
634
635// remove_const
636
637#if __has_keyword(__remove_const)
638
639template <class _Tp>
640struct _LIBCPP_TEMPLATE_VIS remove_const {typedef __remove_const(_Tp) type;};
641
642#if _LIBCPP_STD_VER > 11
643template <class _Tp> using remove_const_t = __remove_const(_Tp);
644#endif
645
646#else
647
648template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const {typedef _Tp type;};
649template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const<const _Tp> {typedef _Tp type;};
650#if _LIBCPP_STD_VER > 11
651template <class _Tp> using remove_const_t = typename remove_const<_Tp>::type;
652#endif
653
654#endif // __has_keyword(__remove_const)
655
656// remove_volatile
657
658#if __has_keyword(__remove_volatile)
659
660template <class _Tp>
661struct _LIBCPP_TEMPLATE_VIS remove_volatile {typedef __remove_volatile(_Tp) type;};
662
663#if _LIBCPP_STD_VER > 11
664template <class _Tp> using remove_volatile_t = __remove_volatile(_Tp);
665#endif
666
667#else
668
669template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile {typedef _Tp type;};
670template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile<volatile _Tp> {typedef _Tp type;};
671#if _LIBCPP_STD_VER > 11
672template <class _Tp> using remove_volatile_t = typename remove_volatile<_Tp>::type;
673#endif
674
675#endif // __has_keyword(__remove_volatile)
676
677// remove_cv
678
679#if __has_keyword(__remove_cv)
680
681template <class _Tp>
682struct _LIBCPP_TEMPLATE_VIS remove_cv {typedef __remove_cv(_Tp) type;};
683
684#if _LIBCPP_STD_VER > 11
685template <class _Tp> using remove_cv_t = __remove_cv(_Tp);
686#endif
687
688#else
689
690template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_cv
691{typedef typename remove_volatile<typename remove_const<_Tp>::type>::type type;};
692#if _LIBCPP_STD_VER > 11
693template <class _Tp> using remove_cv_t = typename remove_cv<_Tp>::type;
694#endif
695
696#endif // __has_keyword(__remove_cv)
697
698// is_void
699
700#if __has_keyword(__is_void)
701
702template <class _Tp>
703struct _LIBCPP_TEMPLATE_VIS is_void : _BoolConstant<__is_void(_Tp)> { };
704
705#if _LIBCPP_STD_VER > 14
706template <class _Tp>
707inline constexpr bool is_void_v = __is_void(_Tp);
708#endif
709
710#else
711
712template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_void
713 : public is_same<typename remove_cv<_Tp>::type, void> {};
714
715#if _LIBCPP_STD_VER > 14
716template <class _Tp>
717inline constexpr bool is_void_v = is_void<_Tp>::value;
718#endif
719
720#endif // __has_keyword(__is_void)
721
722// __is_nullptr_t
723
724template <class _Tp> struct __is_nullptr_t_impl : public false_type {};
725template <> struct __is_nullptr_t_impl<nullptr_t> : public true_type {};
726
727template <class _Tp> struct _LIBCPP_TEMPLATE_VIS __is_nullptr_t
728 : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
729
730#if _LIBCPP_STD_VER > 11
731template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_null_pointer
732 : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
733
734#if _LIBCPP_STD_VER > 14
735template <class _Tp>
736inline constexpr bool is_null_pointer_v = is_null_pointer<_Tp>::value;
737#endif
738#endif // _LIBCPP_STD_VER > 11
739
740// is_integral
741
742#if __has_keyword(__is_integral)
743
744template <class _Tp>
745struct _LIBCPP_TEMPLATE_VIS is_integral : _BoolConstant<__is_integral(_Tp)> { };
746
747#if _LIBCPP_STD_VER > 14
748template <class _Tp>
749inline constexpr bool is_integral_v = __is_integral(_Tp);
750#endif
751
752#else
753
754template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_integral
755 : public _BoolConstant<__libcpp_is_integral<typename remove_cv<_Tp>::type>::value> {};
756
757#if _LIBCPP_STD_VER > 14
758template <class _Tp>
759inline constexpr bool is_integral_v = is_integral<_Tp>::value;
760#endif
761
762#endif // __has_keyword(__is_integral)
763
764// [basic.fundamental] defines five standard signed integer types;
765// __int128_t is an extended signed integer type.
766// The signed and unsigned integer types, plus bool and the
767// five types with "char" in their name, compose the "integral" types.
768
769template <class _Tp> struct __libcpp_is_signed_integer : public false_type {};
770template <> struct __libcpp_is_signed_integer<signed char> : public true_type {};
771template <> struct __libcpp_is_signed_integer<signed short> : public true_type {};
772template <> struct __libcpp_is_signed_integer<signed int> : public true_type {};
773template <> struct __libcpp_is_signed_integer<signed long> : public true_type {};
774template <> struct __libcpp_is_signed_integer<signed long long> : public true_type {};
775#ifndef _LIBCPP_HAS_NO_INT128
776template <> struct __libcpp_is_signed_integer<__int128_t> : public true_type {};
777#endif
778
779template <class _Tp> struct __libcpp_is_unsigned_integer : public false_type {};
780template <> struct __libcpp_is_unsigned_integer<unsigned char> : public true_type {};
781template <> struct __libcpp_is_unsigned_integer<unsigned short> : public true_type {};
782template <> struct __libcpp_is_unsigned_integer<unsigned int> : public true_type {};
783template <> struct __libcpp_is_unsigned_integer<unsigned long> : public true_type {};
784template <> struct __libcpp_is_unsigned_integer<unsigned long long> : public true_type {};
785#ifndef _LIBCPP_HAS_NO_INT128
786template <> struct __libcpp_is_unsigned_integer<__uint128_t> : public true_type {};
787#endif
788
789// is_floating_point
790// <concepts> implements __libcpp_floating_point
791
792template <class _Tp> struct __libcpp_is_floating_point : public false_type {};
793template <> struct __libcpp_is_floating_point<float> : public true_type {};
794template <> struct __libcpp_is_floating_point<double> : public true_type {};
795template <> struct __libcpp_is_floating_point<long double> : public true_type {};
796
797template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_floating_point
798 : public __libcpp_is_floating_point<typename remove_cv<_Tp>::type> {};
799
800#if _LIBCPP_STD_VER > 14
801template <class _Tp>
802inline constexpr bool is_floating_point_v = is_floating_point<_Tp>::value;
803#endif
804
805// is_array
806
807#if __has_keyword(__is_array)
808
809template <class _Tp>
810struct _LIBCPP_TEMPLATE_VIS is_array : _BoolConstant<__is_array(_Tp)> { };
811
812#if _LIBCPP_STD_VER > 14
813template <class _Tp>
814inline constexpr bool is_array_v = __is_array(_Tp);
815#endif
816
817#else
818
819template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array
820 : public false_type {};
821template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[]>
822 : public true_type {};
823template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[_Np]>
824 : public true_type {};
825
826#if _LIBCPP_STD_VER > 14
827template <class _Tp>
828inline constexpr bool is_array_v = is_array<_Tp>::value;
829#endif
830
831#endif // __has_keyword(__is_array)
832
833// is_pointer
834
835// Before AppleClang 12.0.5, __is_pointer didn't work for Objective-C types.
836#if __has_keyword(__is_pointer) && \
837 !(defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 1205)
838
839template<class _Tp>
840struct _LIBCPP_TEMPLATE_VIS is_pointer : _BoolConstant<__is_pointer(_Tp)> { };
841
842#if _LIBCPP_STD_VER > 14
843template <class _Tp>
844inline constexpr bool is_pointer_v = __is_pointer(_Tp);
845#endif
846
847#else // __has_keyword(__is_pointer)
848
849template <class _Tp> struct __libcpp_is_pointer : public false_type {};
850template <class _Tp> struct __libcpp_is_pointer<_Tp*> : public true_type {};
851
852template <class _Tp> struct __libcpp_remove_objc_qualifiers { typedef _Tp type; };
853#if defined(_LIBCPP_HAS_OBJC_ARC)
854template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __strong> { typedef _Tp type; };
855template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __weak> { typedef _Tp type; };
856template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __autoreleasing> { typedef _Tp type; };
857template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __unsafe_unretained> { typedef _Tp type; };
858#endif
859
860template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pointer
861 : public __libcpp_is_pointer<typename __libcpp_remove_objc_qualifiers<typename remove_cv<_Tp>::type>::type> {};
862
863#if _LIBCPP_STD_VER > 14
864template <class _Tp>
865inline constexpr bool is_pointer_v = is_pointer<_Tp>::value;
866#endif
867
868#endif // __has_keyword(__is_pointer)
869
870// is_reference
871
872#if __has_keyword(__is_lvalue_reference) && \
873 __has_keyword(__is_rvalue_reference) && \
874 __has_keyword(__is_reference)
875
876template<class _Tp>
877struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : _BoolConstant<__is_lvalue_reference(_Tp)> { };
878
879template<class _Tp>
880struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : _BoolConstant<__is_rvalue_reference(_Tp)> { };
881
882template<class _Tp>
883struct _LIBCPP_TEMPLATE_VIS is_reference : _BoolConstant<__is_reference(_Tp)> { };
884
885#if _LIBCPP_STD_VER > 14
886template <class _Tp>
887inline constexpr bool is_reference_v = __is_reference(_Tp);
888template <class _Tp>
889inline constexpr bool is_lvalue_reference_v = __is_lvalue_reference(_Tp);
890template <class _Tp>
891inline constexpr bool is_rvalue_reference_v = __is_rvalue_reference(_Tp);
892#endif
893
894#else // __has_keyword(__is_lvalue_reference) && etc...
895
896template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : public false_type {};
897template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference<_Tp&> : public true_type {};
898
899template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : public false_type {};
900template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference<_Tp&&> : public true_type {};
901
902template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference : public false_type {};
903template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&> : public true_type {};
904template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&&> : public true_type {};
905
906#if _LIBCPP_STD_VER > 14
907template <class _Tp>
908inline constexpr bool is_reference_v = is_reference<_Tp>::value;
909
910template <class _Tp>
911inline constexpr bool is_lvalue_reference_v = is_lvalue_reference<_Tp>::value;
912
913template <class _Tp>
914inline constexpr bool is_rvalue_reference_v = is_rvalue_reference<_Tp>::value;
915#endif
916
917#endif // __has_keyword(__is_lvalue_reference) && etc...
918
919// is_union
920
921#if __has_feature(is_union) || defined(_LIBCPP_COMPILER_GCC)
922
923template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_union
924 : public integral_constant<bool, __is_union(_Tp)> {};
925
926#else
927
928template <class _Tp> struct __libcpp_union : public false_type {};
929template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_union
930 : public __libcpp_union<typename remove_cv<_Tp>::type> {};
931
932#endif
933
934#if _LIBCPP_STD_VER > 14
935template <class _Tp>
936inline constexpr bool is_union_v = is_union<_Tp>::value;
937#endif
938
939// is_class
940
941#if __has_feature(is_class) || defined(_LIBCPP_COMPILER_GCC)
942
943template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_class
944 : public integral_constant<bool, __is_class(_Tp)> {};
945
946#else
947
948namespace __is_class_imp
949{
950template <class _Tp> char __test(int _Tp::*);
951template <class _Tp> __two __test(...);
952}
953
954template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_class
955 : public integral_constant<bool, sizeof(__is_class_imp::__test<_Tp>(0)) == 1 && !is_union<_Tp>::value> {};
956
957#endif
958
959#if _LIBCPP_STD_VER > 14
960template <class _Tp>
961inline constexpr bool is_class_v = is_class<_Tp>::value;
962#endif
963
964// is_function
965
966template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_function
967 : public _BoolConstant<
968#ifdef __clang__
969 __is_function(_Tp)
970#else
971 !(is_reference<_Tp>::value || is_const<const _Tp>::value)
972#endif
973 > {};
974
975
976#if _LIBCPP_STD_VER > 14
977template <class _Tp>
978inline constexpr bool is_function_v = is_function<_Tp>::value;
979#endif
980
981template <class _Tp> struct __libcpp_is_member_pointer {
982 enum {
983 __is_member = false,
984 __is_func = false,
985 __is_obj = false
986 };
987};
988template <class _Tp, class _Up> struct __libcpp_is_member_pointer<_Tp _Up::*> {
989 enum {
990 __is_member = true,
991 __is_func = is_function<_Tp>::value,
992 __is_obj = !__is_func,
993 };
994};
995
996#if __has_keyword(__is_member_function_pointer)
997
998template<class _Tp>
999struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer
1000 : _BoolConstant<__is_member_function_pointer(_Tp)> { };
1001
1002#if _LIBCPP_STD_VER > 14
1003template <class _Tp>
1004inline constexpr bool is_member_function_pointer_v = __is_member_function_pointer(_Tp);
1005#endif
1006
1007#else // __has_keyword(__is_member_function_pointer)
1008
1009template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer
1010 : public _BoolConstant< __libcpp_is_member_pointer<typename remove_cv<_Tp>::type>::__is_func > {};
1011
1012#if _LIBCPP_STD_VER > 14
1013template <class _Tp>
1014inline constexpr bool is_member_function_pointer_v = is_member_function_pointer<_Tp>::value;
1015#endif
1016
1017#endif // __has_keyword(__is_member_function_pointer)
1018
1019// is_member_pointer
1020
1021#if __has_keyword(__is_member_pointer)
1022
1023template<class _Tp>
1024struct _LIBCPP_TEMPLATE_VIS is_member_pointer : _BoolConstant<__is_member_pointer(_Tp)> { };
1025
1026#if _LIBCPP_STD_VER > 14
1027template <class _Tp>
1028inline constexpr bool is_member_pointer_v = __is_member_pointer(_Tp);
1029#endif
1030
1031#else // __has_keyword(__is_member_pointer)
1032
1033template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_pointer
1034 : public _BoolConstant< __libcpp_is_member_pointer<typename remove_cv<_Tp>::type>::__is_member > {};
1035
1036#if _LIBCPP_STD_VER > 14
1037template <class _Tp>
1038inline constexpr bool is_member_pointer_v = is_member_pointer<_Tp>::value;
1039#endif
1040
1041#endif // __has_keyword(__is_member_pointer)
1042
1043// is_member_object_pointer
1044
1045#if __has_keyword(__is_member_object_pointer)
1046
1047template<class _Tp>
1048struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer
1049 : _BoolConstant<__is_member_object_pointer(_Tp)> { };
1050
1051#if _LIBCPP_STD_VER > 14
1052template <class _Tp>
1053inline constexpr bool is_member_object_pointer_v = __is_member_object_pointer(_Tp);
1054#endif
1055
1056#else // __has_keyword(__is_member_object_pointer)
1057
1058template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer
1059 : public _BoolConstant< __libcpp_is_member_pointer<typename remove_cv<_Tp>::type>::__is_obj > {};
1060
1061#if _LIBCPP_STD_VER > 14
1062template <class _Tp>
1063inline constexpr bool is_member_object_pointer_v = is_member_object_pointer<_Tp>::value;
1064#endif
1065
1066#endif // __has_keyword(__is_member_object_pointer)
1067
1068// is_enum
1069
1070#if __has_feature(is_enum) || defined(_LIBCPP_COMPILER_GCC)
1071
1072template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum
1073 : public integral_constant<bool, __is_enum(_Tp)> {};
1074
1075#if _LIBCPP_STD_VER > 14
1076template <class _Tp>
1077inline constexpr bool is_enum_v = __is_enum(_Tp);
1078#endif
1079
1080#else
1081
1082template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum
1083 : public integral_constant<bool, !is_void<_Tp>::value &&
1084 !is_integral<_Tp>::value &&
1085 !is_floating_point<_Tp>::value &&
1086 !is_array<_Tp>::value &&
1087 !is_pointer<_Tp>::value &&
1088 !is_reference<_Tp>::value &&
1089 !is_member_pointer<_Tp>::value &&
1090 !is_union<_Tp>::value &&
1091 !is_class<_Tp>::value &&
1092 !is_function<_Tp>::value > {};
1093
1094#if _LIBCPP_STD_VER > 14
1095template <class _Tp>
1096inline constexpr bool is_enum_v = is_enum<_Tp>::value;
1097#endif
1098
1099#endif // __has_feature(is_enum) || defined(_LIBCPP_COMPILER_GCC)
1100
1101// is_arithmetic
1102
1103
1104template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_arithmetic
1105 : public integral_constant<bool, is_integral<_Tp>::value ||
1106 is_floating_point<_Tp>::value> {};
1107
1108#if _LIBCPP_STD_VER > 14
1109template <class _Tp>
1110inline constexpr bool is_arithmetic_v = is_arithmetic<_Tp>::value;
1111#endif
1112
1113// is_fundamental
1114
1115// Before Clang 10, __is_fundamental didn't work for nullptr_t.
1116// In C++03 nullptr_t is library-provided but must still count as "fundamental."
1117#if __has_keyword(__is_fundamental) && \
1118 !(defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 1000) && \
1119 !defined(_LIBCPP_CXX03_LANG)
1120
1121template<class _Tp>
1122struct _LIBCPP_TEMPLATE_VIS is_fundamental : _BoolConstant<__is_fundamental(_Tp)> { };
1123
1124#if _LIBCPP_STD_VER > 14
1125template <class _Tp>
1126inline constexpr bool is_fundamental_v = __is_fundamental(_Tp);
1127#endif
1128
1129#else // __has_keyword(__is_fundamental)
1130
1131template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_fundamental
1132 : public integral_constant<bool, is_void<_Tp>::value ||
1133 __is_nullptr_t<_Tp>::value ||
1134 is_arithmetic<_Tp>::value> {};
1135
1136#if _LIBCPP_STD_VER > 14
1137template <class _Tp>
1138inline constexpr bool is_fundamental_v = is_fundamental<_Tp>::value;
1139#endif
1140
1141#endif // __has_keyword(__is_fundamental)
1142
1143// is_scalar
1144
1145// In C++03 nullptr_t is library-provided but must still count as "scalar."
1146#if __has_keyword(__is_scalar) && !defined(_LIBCPP_CXX03_LANG)
1147
1148template<class _Tp>
1149struct _LIBCPP_TEMPLATE_VIS is_scalar : _BoolConstant<__is_scalar(_Tp)> { };
1150
1151#if _LIBCPP_STD_VER > 14
1152template <class _Tp>
1153inline constexpr bool is_scalar_v = __is_scalar(_Tp);
1154#endif
1155
1156#else // __has_keyword(__is_scalar)
1157
1158template <class _Tp> struct __is_block : false_type {};
1159#if defined(_LIBCPP_HAS_EXTENSION_BLOCKS)
1160template <class _Rp, class ..._Args> struct __is_block<_Rp (^)(_Args...)> : true_type {};
1161#endif
1162
1163template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_scalar
1164 : public integral_constant<bool, is_arithmetic<_Tp>::value ||
1165 is_member_pointer<_Tp>::value ||
1166 is_pointer<_Tp>::value ||
1167 __is_nullptr_t<_Tp>::value ||
1168 __is_block<_Tp>::value ||
1169 is_enum<_Tp>::value > {};
1170
1171template <> struct _LIBCPP_TEMPLATE_VIS is_scalar<nullptr_t> : public true_type {};
1172
1173#if _LIBCPP_STD_VER > 14
1174template <class _Tp>
1175inline constexpr bool is_scalar_v = is_scalar<_Tp>::value;
1176#endif
1177
1178#endif // __has_keyword(__is_scalar)
1179
1180// is_object
1181
1182#if __has_keyword(__is_object)
1183
1184template<class _Tp>
1185struct _LIBCPP_TEMPLATE_VIS is_object : _BoolConstant<__is_object(_Tp)> { };
1186
1187#if _LIBCPP_STD_VER > 14
1188template <class _Tp>
1189inline constexpr bool is_object_v = __is_object(_Tp);
1190#endif
1191
1192#else // __has_keyword(__is_object)
1193
1194template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_object
1195 : public integral_constant<bool, is_scalar<_Tp>::value ||
1196 is_array<_Tp>::value ||
1197 is_union<_Tp>::value ||
1198 is_class<_Tp>::value > {};
1199
1200#if _LIBCPP_STD_VER > 14
1201template <class _Tp>
1202inline constexpr bool is_object_v = is_object<_Tp>::value;
1203#endif
1204
1205#endif // __has_keyword(__is_object)
1206
1207// is_compound
1208
1209// >= 11 because in C++03 nullptr isn't actually nullptr
1210#if __has_keyword(__is_compound) && !defined(_LIBCPP_CXX03_LANG)
1211
1212template<class _Tp>
1213struct _LIBCPP_TEMPLATE_VIS is_compound : _BoolConstant<__is_compound(_Tp)> { };
1214
1215#if _LIBCPP_STD_VER > 14
1216template <class _Tp>
1217inline constexpr bool is_compound_v = __is_compound(_Tp);
1218#endif
1219
1220#else // __has_keyword(__is_compound)
1221
1222template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_compound
1223 : public integral_constant<bool, !is_fundamental<_Tp>::value> {};
1224
1225#if _LIBCPP_STD_VER > 14
1226template <class _Tp>
1227inline constexpr bool is_compound_v = is_compound<_Tp>::value;
1228#endif
1229
1230#endif // __has_keyword(__is_compound)
1231
1232// __is_referenceable [defns.referenceable]
1233
1234struct __is_referenceable_impl {
1235 template <class _Tp> static _Tp& __test(int);
1236 template <class _Tp> static __two __test(...);
1237};
1238
1239template <class _Tp>
1240struct __is_referenceable : integral_constant<bool,
1241 _IsNotSame<decltype(__is_referenceable_impl::__test<_Tp>(0)), __two>::value> {};
1242
1243
1244// add_const
1245
1246template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_const {
1247 typedef _LIBCPP_NODEBUG const _Tp type;
1248};
1249
1250#if _LIBCPP_STD_VER > 11
1251template <class _Tp> using add_const_t = typename add_const<_Tp>::type;
1252#endif
1253
1254// add_volatile
1255
1256template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_volatile {
1257 typedef _LIBCPP_NODEBUG volatile _Tp type;
1258};
1259
1260#if _LIBCPP_STD_VER > 11
1261template <class _Tp> using add_volatile_t = typename add_volatile<_Tp>::type;
1262#endif
1263
1264// add_cv
1265template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_cv {
1266 typedef _LIBCPP_NODEBUG const volatile _Tp type;
1267};
1268
1269#if _LIBCPP_STD_VER > 11
1270template <class _Tp> using add_cv_t = typename add_cv<_Tp>::type;
1271#endif
1272
1273// remove_reference
1274
1275#if __has_keyword(__remove_reference)
1276
1277template<class _Tp>
1278struct _LIBCPP_TEMPLATE_VIS remove_reference { typedef __remove_reference(_Tp) type; };
1279
1280#else // __has_keyword(__remove_reference)
1281
1282template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference {typedef _LIBCPP_NODEBUG _Tp type;};
1283template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&> {typedef _LIBCPP_NODEBUG _Tp type;};
1284template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&&> {typedef _LIBCPP_NODEBUG _Tp type;};
1285
1286#if _LIBCPP_STD_VER > 11
1287template <class _Tp> using remove_reference_t = typename remove_reference<_Tp>::type;
1288#endif
1289
1290#endif // __has_keyword(__remove_reference)
1291
1292// add_lvalue_reference
1293
1294template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_lvalue_reference_impl { typedef _LIBCPP_NODEBUG _Tp type; };
1295template <class _Tp > struct __add_lvalue_reference_impl<_Tp, true> { typedef _LIBCPP_NODEBUG _Tp& type; };
1296
1297template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_lvalue_reference
1298{typedef _LIBCPP_NODEBUG typename __add_lvalue_reference_impl<_Tp>::type type;};
1299
1300#if _LIBCPP_STD_VER > 11
1301template <class _Tp> using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type;
1302#endif
1303
1304template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_rvalue_reference_impl { typedef _LIBCPP_NODEBUG _Tp type; };
1305template <class _Tp > struct __add_rvalue_reference_impl<_Tp, true> { typedef _LIBCPP_NODEBUG _Tp&& type; };
1306
1307template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_rvalue_reference
1308{typedef _LIBCPP_NODEBUG typename __add_rvalue_reference_impl<_Tp>::type type;};
1309
1310#if _LIBCPP_STD_VER > 11
1311template <class _Tp> using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type;
1312#endif
1313
1314// Suppress deprecation notice for volatile-qualified return type resulting
1315// from volatile-qualified types _Tp.
1316_LIBCPP_SUPPRESS_DEPRECATED_PUSH
1317template <class _Tp> _Tp&& __declval(int);
1318template <class _Tp> _Tp __declval(long);
1319_LIBCPP_SUPPRESS_DEPRECATED_POP
1320
1321template <class _Tp>
1322decltype(__declval<_Tp>(0))
1323declval() _NOEXCEPT;
1324
1325// __uncvref
1326
1327template <class _Tp>
1328struct __uncvref {
1329 typedef _LIBCPP_NODEBUG typename remove_cv<typename remove_reference<_Tp>::type>::type type;
1330};
1331
1332template <class _Tp>
1333struct __unconstref {
1334 typedef _LIBCPP_NODEBUG typename remove_const<typename remove_reference<_Tp>::type>::type type;
1335};
1336
1337#ifndef _LIBCPP_CXX03_LANG
1338template <class _Tp>
1339using __uncvref_t _LIBCPP_NODEBUG = typename __uncvref<_Tp>::type;
1340#endif
1341
1342// __is_same_uncvref
1343
1344template <class _Tp, class _Up>
1345struct __is_same_uncvref : _IsSame<typename __uncvref<_Tp>::type,
1346 typename __uncvref<_Up>::type> {};
1347
1348#if _LIBCPP_STD_VER > 17
1349// remove_cvref - same as __uncvref
1350template <class _Tp>
1351struct remove_cvref : public __uncvref<_Tp> {};
1352
1353template <class _Tp> using remove_cvref_t = typename remove_cvref<_Tp>::type;
1354#endif
1355
1356
1357struct __any
1358{
1359 __any(...);
1360};
1361
1362// remove_pointer
1363
1364template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer {typedef _LIBCPP_NODEBUG _Tp type;};
1365template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp*> {typedef _LIBCPP_NODEBUG _Tp type;};
1366template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const> {typedef _LIBCPP_NODEBUG _Tp type;};
1367template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* volatile> {typedef _LIBCPP_NODEBUG _Tp type;};
1368template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const volatile> {typedef _LIBCPP_NODEBUG _Tp type;};
1369
1370#if _LIBCPP_STD_VER > 11
1371template <class _Tp> using remove_pointer_t = typename remove_pointer<_Tp>::type;
1372#endif
1373
1374// add_pointer
1375
1376template <class _Tp,
1377 bool = __is_referenceable<_Tp>::value ||
1378 _IsSame<typename remove_cv<_Tp>::type, void>::value>
1379struct __add_pointer_impl
1380 {typedef _LIBCPP_NODEBUG typename remove_reference<_Tp>::type* type;};
1381template <class _Tp> struct __add_pointer_impl<_Tp, false>
1382 {typedef _LIBCPP_NODEBUG _Tp type;};
1383
1384template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_pointer
1385 {typedef _LIBCPP_NODEBUG typename __add_pointer_impl<_Tp>::type type;};
1386
1387#if _LIBCPP_STD_VER > 11
1388template <class _Tp> using add_pointer_t = typename add_pointer<_Tp>::type;
1389#endif
1390
1391// type_identity
1392#if _LIBCPP_STD_VER > 17
1393template<class _Tp> struct type_identity { typedef _Tp type; };
1394template<class _Tp> using type_identity_t = typename type_identity<_Tp>::type;
1395#endif
1396
1397// is_signed
1398
1399#if __has_keyword(__is_signed)
1400
1401template<class _Tp>
1402struct _LIBCPP_TEMPLATE_VIS is_signed : _BoolConstant<__is_signed(_Tp)> { };
1403
1404#if _LIBCPP_STD_VER > 14
1405template <class _Tp>
1406inline constexpr bool is_signed_v = __is_signed(_Tp);
1407#endif
1408
1409#else // __has_keyword(__is_signed)
1410
1411template <class _Tp, bool = is_integral<_Tp>::value>
1412struct __libcpp_is_signed_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(-1) < _Tp(0)) {};
1413
1414template <class _Tp>
1415struct __libcpp_is_signed_impl<_Tp, false> : public true_type {}; // floating point
1416
1417template <class _Tp, bool = is_arithmetic<_Tp>::value>
1418struct __libcpp_is_signed : public __libcpp_is_signed_impl<_Tp> {};
1419
1420template <class _Tp> struct __libcpp_is_signed<_Tp, false> : public false_type {};
1421
1422template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_signed : public __libcpp_is_signed<_Tp> {};
1423
1424#if _LIBCPP_STD_VER > 14
1425template <class _Tp>
1426inline constexpr bool is_signed_v = is_signed<_Tp>::value;
1427#endif
1428
1429#endif // __has_keyword(__is_signed)
1430
1431// is_unsigned
1432
1433// Before Clang 13, __is_unsigned returned true for enums with signed underlying type.
1434// No currently-released version of AppleClang contains the fixed intrinsic.
1435#if __has_keyword(__is_unsigned) && \
1436 !(defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 1300) && \
1437 !defined(_LIBCPP_APPLE_CLANG_VER)
1438
1439template<class _Tp>
1440struct _LIBCPP_TEMPLATE_VIS is_unsigned : _BoolConstant<__is_unsigned(_Tp)> { };
1441
1442#if _LIBCPP_STD_VER > 14
1443template <class _Tp>
1444inline constexpr bool is_unsigned_v = __is_unsigned(_Tp);
1445#endif
1446
1447#else // __has_keyword(__is_unsigned)
1448
1449template <class _Tp, bool = is_integral<_Tp>::value>
1450struct __libcpp_is_unsigned_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(0) < _Tp(-1)) {};
1451
1452template <class _Tp>
1453struct __libcpp_is_unsigned_impl<_Tp, false> : public false_type {}; // floating point
1454
1455template <class _Tp, bool = is_arithmetic<_Tp>::value>
1456struct __libcpp_is_unsigned : public __libcpp_is_unsigned_impl<_Tp> {};
1457
1458template <class _Tp> struct __libcpp_is_unsigned<_Tp, false> : public false_type {};
1459
1460template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_unsigned : public __libcpp_is_unsigned<_Tp> {};
1461
1462#if _LIBCPP_STD_VER > 14
1463template <class _Tp>
1464inline constexpr bool is_unsigned_v = is_unsigned<_Tp>::value;
1465#endif
1466
1467#endif // __has_keyword(__is_unsigned)
1468
1469// rank
1470
1471template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank
1472 : public integral_constant<size_t, 0> {};
1473template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[]>
1474 : public integral_constant<size_t, rank<_Tp>::value + 1> {};
1475template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[_Np]>
1476 : public integral_constant<size_t, rank<_Tp>::value + 1> {};
1477
1478#if _LIBCPP_STD_VER > 14
1479template <class _Tp>
1480inline constexpr size_t rank_v = rank<_Tp>::value;
1481#endif
1482
1483// extent
1484
1485#if __has_keyword(__array_extent)
1486
1487template<class _Tp, size_t _Dim = 0>
1488struct _LIBCPP_TEMPLATE_VIS extent
1489 : integral_constant<size_t, __array_extent(_Tp, _Dim)> { };
1490
1491#if _LIBCPP_STD_VER > 14
1492template <class _Tp, unsigned _Ip = 0>
1493inline constexpr size_t extent_v = __array_extent(_Tp, _Ip);
1494#endif
1495
1496#else // __has_keyword(__array_extent)
1497
1498template <class _Tp, unsigned _Ip = 0> struct _LIBCPP_TEMPLATE_VIS extent
1499 : public integral_constant<size_t, 0> {};
1500template <class _Tp> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], 0>
1501 : public integral_constant<size_t, 0> {};
1502template <class _Tp, unsigned _Ip> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], _Ip>
1503 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
1504template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], 0>
1505 : public integral_constant<size_t, _Np> {};
1506template <class _Tp, size_t _Np, unsigned _Ip> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], _Ip>
1507 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
1508
1509#if _LIBCPP_STD_VER > 14
1510template <class _Tp, unsigned _Ip = 0>
1511inline constexpr size_t extent_v = extent<_Tp, _Ip>::value;
1512#endif
1513
1514#endif // __has_keyword(__array_extent)
1515
1516// remove_extent
1517
1518template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent
1519 {typedef _Tp type;};
1520template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[]>
1521 {typedef _Tp type;};
1522template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[_Np]>
1523 {typedef _Tp type;};
1524
1525#if _LIBCPP_STD_VER > 11
1526template <class _Tp> using remove_extent_t = typename remove_extent<_Tp>::type;
1527#endif
1528
1529// remove_all_extents
1530
1531template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents
1532 {typedef _Tp type;};
1533template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[]>
1534 {typedef typename remove_all_extents<_Tp>::type type;};
1535template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[_Np]>
1536 {typedef typename remove_all_extents<_Tp>::type type;};
1537
1538#if _LIBCPP_STD_VER > 11
1539template <class _Tp> using remove_all_extents_t = typename remove_all_extents<_Tp>::type;
1540#endif
1541
1542#if _LIBCPP_STD_VER > 17
1543// is_bounded_array
1544
1545template <class> struct _LIBCPP_TEMPLATE_VIS is_bounded_array : false_type {};
1546template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS is_bounded_array<_Tp[_Np]> : true_type {};
1547
1548template <class _Tp>
1549inline constexpr
1550bool is_bounded_array_v = is_bounded_array<_Tp>::value;
1551
1552// is_unbounded_array
1553
1554template <class> struct _LIBCPP_TEMPLATE_VIS is_unbounded_array : false_type {};
1555template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_unbounded_array<_Tp[]> : true_type {};
1556
1557template <class _Tp>
1558inline constexpr
1559bool is_unbounded_array_v = is_unbounded_array<_Tp>::value;
1560#endif
1561
1562// decay
1563
1564template <class _Up, bool>
1565struct __decay {
1566 typedef _LIBCPP_NODEBUG typename remove_cv<_Up>::type type;
1567};
1568
1569template <class _Up>
1570struct __decay<_Up, true> {
1571public:
1572 typedef _LIBCPP_NODEBUG typename conditional
1573 <
1574 is_array<_Up>::value,
1575 typename remove_extent<_Up>::type*,
1576 typename conditional
1577 <
1578 is_function<_Up>::value,
1579 typename add_pointer<_Up>::type,
1580 typename remove_cv<_Up>::type
1581 >::type
1582 >::type type;
1583};
1584
1585template <class _Tp>
1586struct _LIBCPP_TEMPLATE_VIS decay
1587{
1588private:
1589 typedef _LIBCPP_NODEBUG typename remove_reference<_Tp>::type _Up;
1590public:
1591 typedef _LIBCPP_NODEBUG typename __decay<_Up, __is_referenceable<_Up>::value>::type type;
1592};
1593
1594#if _LIBCPP_STD_VER > 11
1595template <class _Tp> using decay_t = typename decay<_Tp>::type;
1596#endif
1597
1598// is_abstract
1599
1600template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_abstract
1601 : public integral_constant<bool, __is_abstract(_Tp)> {};
1602
1603#if _LIBCPP_STD_VER > 14
1604template <class _Tp>
1605inline constexpr bool is_abstract_v = is_abstract<_Tp>::value;
1606#endif
1607
1608// is_final
1609
1610template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
1611__libcpp_is_final : public integral_constant<bool, __is_final(_Tp)> {};
1612
1613#if _LIBCPP_STD_VER > 11
1614template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
1615is_final : public integral_constant<bool, __is_final(_Tp)> {};
1616#endif
1617
1618#if _LIBCPP_STD_VER > 14
1619template <class _Tp>
1620inline constexpr bool is_final_v = is_final<_Tp>::value;
1621#endif
1622
1623// is_aggregate
1624#if _LIBCPP_STD_VER > 14
1625
1626template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
1627is_aggregate : public integral_constant<bool, __is_aggregate(_Tp)> {};
1628
1629template <class _Tp>
1630inline constexpr bool is_aggregate_v = is_aggregate<_Tp>::value;
1631
1632#endif // _LIBCPP_STD_VER > 14
1633
1634// is_base_of
1635
1636template <class _Bp, class _Dp>
1637struct _LIBCPP_TEMPLATE_VIS is_base_of
1638 : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {};
1639
1640#if _LIBCPP_STD_VER > 14
1641template <class _Bp, class _Dp>
1642inline constexpr bool is_base_of_v = is_base_of<_Bp, _Dp>::value;
1643#endif
1644
1645// __is_core_convertible
1646
1647// [conv.general]/3 says "E is convertible to T" whenever "T t=E;" is well-formed.
1648// We can't test for that, but we can test implicit convertibility by passing it
1649// to a function. Notice that __is_core_convertible<void,void> is false,
1650// and __is_core_convertible<immovable-type,immovable-type> is true in C++17 and later.
1651
1652template <class _Tp, class _Up, class = void>
1653struct __is_core_convertible : public false_type {};
1654
1655template <class _Tp, class _Up>
1656struct __is_core_convertible<_Tp, _Up, decltype(
1657 static_cast<void(*)(_Up)>(0) ( static_cast<_Tp(*)()>(0)() )
1658)> : public true_type {};
1659
1660// is_convertible
1661
1662#if __has_feature(is_convertible_to) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK)
1663
1664template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS is_convertible
1665 : public integral_constant<bool, __is_convertible_to(_T1, _T2)> {};
1666
1667#else // __has_feature(is_convertible_to)
1668
1669namespace __is_convertible_imp
1670{
1671template <class _Tp> void __test_convert(_Tp);
1672
1673template <class _From, class _To, class = void>
1674struct __is_convertible_test : public false_type {};
1675
1676template <class _From, class _To>
1677struct __is_convertible_test<_From, _To,
1678 decltype(__is_convertible_imp::__test_convert<_To>(declval<_From>()))> : public true_type
1679{};
1680
1681template <class _Tp, bool _IsArray = is_array<_Tp>::value,
1682 bool _IsFunction = is_function<_Tp>::value,
1683 bool _IsVoid = is_void<_Tp>::value>
1684 struct __is_array_function_or_void {enum {value = 0};};
1685template <class _Tp> struct __is_array_function_or_void<_Tp, true, false, false> {enum {value = 1};};
1686template <class _Tp> struct __is_array_function_or_void<_Tp, false, true, false> {enum {value = 2};};
1687template <class _Tp> struct __is_array_function_or_void<_Tp, false, false, true> {enum {value = 3};};
1688}
1689
1690template <class _Tp,
1691 unsigned = __is_convertible_imp::__is_array_function_or_void<typename remove_reference<_Tp>::type>::value>
1692struct __is_convertible_check
1693{
1694 static const size_t __v = 0;
1695};
1696
1697template <class _Tp>
1698struct __is_convertible_check<_Tp, 0>
1699{
1700 static const size_t __v = sizeof(_Tp);
1701};
1702
1703template <class _T1, class _T2,
1704 unsigned _T1_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T1>::value,
1705 unsigned _T2_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T2>::value>
1706struct __is_convertible
1707 : public integral_constant<bool,
1708 __is_convertible_imp::__is_convertible_test<_T1, _T2>::value
1709 >
1710{};
1711
1712template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 1> : public false_type {};
1713template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 1> : public false_type {};
1714template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 1> : public false_type {};
1715template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 1> : public false_type {};
1716
1717template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 2> : public false_type {};
1718template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 2> : public false_type {};
1719template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 2> : public false_type {};
1720template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 2> : public false_type {};
1721
1722template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 3> : public false_type {};
1723template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 3> : public false_type {};
1724template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 3> : public false_type {};
1725template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 3> : public true_type {};
1726
1727template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS is_convertible
1728 : public __is_convertible<_T1, _T2>
1729{
1730 static const size_t __complete_check1 = __is_convertible_check<_T1>::__v;
1731 static const size_t __complete_check2 = __is_convertible_check<_T2>::__v;
1732};
1733
1734#endif // __has_feature(is_convertible_to)
1735
1736#if _LIBCPP_STD_VER > 14
1737template <class _From, class _To>
1738inline constexpr bool is_convertible_v = is_convertible<_From, _To>::value;
1739#endif
1740
1741// is_nothrow_convertible
1742
1743#if _LIBCPP_STD_VER > 17
1744
1745template <typename _Tp>
1746static void __test_noexcept(_Tp) noexcept;
1747
1748template<typename _Fm, typename _To>
1749static bool_constant<noexcept(_VSTD::__test_noexcept<_To>(declval<_Fm>()))>
1750__is_nothrow_convertible_test();
1751
1752template <typename _Fm, typename _To>
1753struct __is_nothrow_convertible_helper: decltype(__is_nothrow_convertible_test<_Fm, _To>())
1754{ };
1755
1756template <typename _Fm, typename _To>
1757struct is_nothrow_convertible : _Or<
1758 _And<is_void<_To>, is_void<_Fm>>,
1759 _Lazy<_And, is_convertible<_Fm, _To>, __is_nothrow_convertible_helper<_Fm, _To>>
1760>::type { };
1761
1762template <typename _Fm, typename _To>
1763inline constexpr bool is_nothrow_convertible_v = is_nothrow_convertible<_Fm, _To>::value;
1764
1765#endif // _LIBCPP_STD_VER > 17
1766
1767// is_empty
1768
1769#if __has_feature(is_empty) || defined(_LIBCPP_COMPILER_GCC)
1770
1771template <class _Tp>
1772struct _LIBCPP_TEMPLATE_VIS is_empty
1773 : public integral_constant<bool, __is_empty(_Tp)> {};
1774
1775#else // __has_feature(is_empty)
1776
1777template <class _Tp>
1778struct __is_empty1
1779 : public _Tp
1780{
1781 double __lx;
1782};
1783
1784struct __is_empty2
1785{
1786 double __lx;
1787};
1788
1789template <class _Tp, bool = is_class<_Tp>::value>
1790struct __libcpp_empty : public integral_constant<bool, sizeof(__is_empty1<_Tp>) == sizeof(__is_empty2)> {};
1791
1792template <class _Tp> struct __libcpp_empty<_Tp, false> : public false_type {};
1793
1794template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_empty : public __libcpp_empty<_Tp> {};
1795
1796#endif // __has_feature(is_empty)
1797
1798#if _LIBCPP_STD_VER > 14
1799template <class _Tp>
1800inline constexpr bool is_empty_v = is_empty<_Tp>::value;
1801#endif
1802
1803// is_polymorphic
1804
1805#if __has_feature(is_polymorphic) || defined(_LIBCPP_COMPILER_MSVC)
1806
1807template <class _Tp>
1808struct _LIBCPP_TEMPLATE_VIS is_polymorphic
1809 : public integral_constant<bool, __is_polymorphic(_Tp)> {};
1810
1811#else
1812
1813template<typename _Tp> char &__is_polymorphic_impl(
1814 typename enable_if<sizeof((_Tp*)dynamic_cast<const volatile void*>(declval<_Tp*>())) != 0,
1815 int>::type);
1816template<typename _Tp> __two &__is_polymorphic_impl(...);
1817
1818template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_polymorphic
1819 : public integral_constant<bool, sizeof(__is_polymorphic_impl<_Tp>(0)) == 1> {};
1820
1821#endif // __has_feature(is_polymorphic)
1822
1823#if _LIBCPP_STD_VER > 14
1824template <class _Tp>
1825inline constexpr bool is_polymorphic_v = is_polymorphic<_Tp>::value;
1826#endif
1827
1828// has_virtual_destructor
1829
1830#if __has_feature(has_virtual_destructor) || defined(_LIBCPP_COMPILER_GCC)
1831
1832template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor
1833 : public integral_constant<bool, __has_virtual_destructor(_Tp)> {};
1834
1835#else
1836
1837template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor
1838 : public false_type {};
1839
1840#endif
1841
1842#if _LIBCPP_STD_VER > 14
1843template <class _Tp>
1844inline constexpr bool has_virtual_destructor_v = has_virtual_destructor<_Tp>::value;
1845#endif
1846
1847// has_unique_object_representations
1848
1849#if _LIBCPP_STD_VER > 14
1850
1851template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_unique_object_representations
1852 : public integral_constant<bool,
1853 __has_unique_object_representations(remove_cv_t<remove_all_extents_t<_Tp>>)> {};
1854
1855template <class _Tp>
1856inline constexpr bool has_unique_object_representations_v = has_unique_object_representations<_Tp>::value;
1857
1858#endif
1859
1860// alignment_of
1861
1862template <class _Tp> struct _LIBCPP_TEMPLATE_VIS alignment_of
1863 : public integral_constant<size_t, _LIBCPP_ALIGNOF(_Tp)> {};
1864
1865#if _LIBCPP_STD_VER > 14
1866template <class _Tp>
1867inline constexpr size_t alignment_of_v = alignment_of<_Tp>::value;
1868#endif
1869
1870// aligned_storage
1871
1872template <class _Hp, class _Tp>
1873struct __type_list
1874{
1875 typedef _Hp _Head;
1876 typedef _Tp _Tail;
1877};
1878
1879struct __nat
1880{
1881#ifndef _LIBCPP_CXX03_LANG
1882 __nat() = delete;
1883 __nat(const __nat&) = delete;
1884 __nat& operator=(const __nat&) = delete;
1885 ~__nat() = delete;
1886#endif
1887};
1888
1889template <class _Tp>
1890struct __align_type
1891{
1892 static const size_t value = _LIBCPP_PREFERRED_ALIGNOF(_Tp);
1893 typedef _Tp type;
1894};
1895
1896struct __struct_double {long double __lx;};
1897struct __struct_double4 {double __lx[4];};
1898
1899typedef
1900 __type_list<__align_type<unsigned char>,
1901 __type_list<__align_type<unsigned short>,
1902 __type_list<__align_type<unsigned int>,
1903 __type_list<__align_type<unsigned long>,
1904 __type_list<__align_type<unsigned long long>,
1905 __type_list<__align_type<double>,
1906 __type_list<__align_type<long double>,
1907 __type_list<__align_type<__struct_double>,
1908 __type_list<__align_type<__struct_double4>,
1909 __type_list<__align_type<int*>,
1910 __nat
1911 > > > > > > > > > > __all_types;
1912
1913template <size_t _Align>
1914struct _ALIGNAS(_Align) __fallback_overaligned {};
1915
1916template <class _TL, size_t _Align> struct __find_pod;
1917
1918template <class _Hp, size_t _Align>
1919struct __find_pod<__type_list<_Hp, __nat>, _Align>
1920{
1921 typedef typename conditional<
1922 _Align == _Hp::value,
1923 typename _Hp::type,
1924 __fallback_overaligned<_Align>
1925 >::type type;
1926};
1927
1928template <class _Hp, class _Tp, size_t _Align>
1929struct __find_pod<__type_list<_Hp, _Tp>, _Align>
1930{
1931 typedef typename conditional<
1932 _Align == _Hp::value,
1933 typename _Hp::type,
1934 typename __find_pod<_Tp, _Align>::type
1935 >::type type;
1936};
1937
1938template <class _TL, size_t _Len> struct __find_max_align;
1939
1940template <class _Hp, size_t _Len>
1941struct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant<size_t, _Hp::value> {};
1942
1943template <size_t _Len, size_t _A1, size_t _A2>
1944struct __select_align
1945{
1946private:
1947 static const size_t __min = _A2 < _A1 ? _A2 : _A1;
1948 static const size_t __max = _A1 < _A2 ? _A2 : _A1;
1949public:
1950 static const size_t value = _Len < __max ? __min : __max;
1951};
1952
1953template <class _Hp, class _Tp, size_t _Len>
1954struct __find_max_align<__type_list<_Hp, _Tp>, _Len>
1955 : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {};
1956
1957template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
1958struct _LIBCPP_TEMPLATE_VIS aligned_storage
1959{
1960 typedef typename __find_pod<__all_types, _Align>::type _Aligner;
1961 union type
1962 {
1963 _Aligner __align;
1964 unsigned char __data[(_Len + _Align - 1)/_Align * _Align];
1965 };
1966};
1967
1968#if _LIBCPP_STD_VER > 11
1969template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
1970 using aligned_storage_t = typename aligned_storage<_Len, _Align>::type;
1971#endif
1972
1973#define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \
1974template <size_t _Len>\
1975struct _LIBCPP_TEMPLATE_VIS aligned_storage<_Len, n>\
1976{\
1977 struct _ALIGNAS(n) type\
1978 {\
1979 unsigned char __lx[(_Len + n - 1)/n * n];\
1980 };\
1981}
1982
1983_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1);
1984_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2);
1985_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4);
1986_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x8);
1987_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x10);
1988_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x20);
1989_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x40);
1990_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x80);
1991_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x100);
1992_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x200);
1993_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x400);
1994_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800);
1995_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000);
1996_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000);
1997// PE/COFF does not support alignment beyond 8192 (=0x2000)
1998#if !defined(_LIBCPP_OBJECT_FORMAT_COFF)
1999_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000);
2000#endif // !defined(_LIBCPP_OBJECT_FORMAT_COFF)
2001
2002#undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION
2003
2004
2005// aligned_union
2006
2007template <size_t _I0, size_t ..._In>
2008struct __static_max;
2009
2010template <size_t _I0>
2011struct __static_max<_I0>
2012{
2013 static const size_t value = _I0;
2014};
2015
2016template <size_t _I0, size_t _I1, size_t ..._In>
2017struct __static_max<_I0, _I1, _In...>
2018{
2019 static const size_t value = _I0 >= _I1 ? __static_max<_I0, _In...>::value :
2020 __static_max<_I1, _In...>::value;
2021};
2022
2023template <size_t _Len, class _Type0, class ..._Types>
2024struct aligned_union
2025{
2026 static const size_t alignment_value = __static_max<_LIBCPP_PREFERRED_ALIGNOF(_Type0),
2027 _LIBCPP_PREFERRED_ALIGNOF(_Types)...>::value;
2028 static const size_t __len = __static_max<_Len, sizeof(_Type0),
2029 sizeof(_Types)...>::value;
2030 typedef typename aligned_storage<__len, alignment_value>::type type;
2031};
2032
2033#if _LIBCPP_STD_VER > 11
2034template <size_t _Len, class ..._Types> using aligned_union_t = typename aligned_union<_Len, _Types...>::type;
2035#endif
2036
2037template <class _Tp>
2038struct __numeric_type
2039{
2040 static void __test(...);
2041 static float __test(float);
2042 static double __test(char);
2043 static double __test(int);
2044 static double __test(unsigned);
2045 static double __test(long);
2046 static double __test(unsigned long);
2047 static double __test(long long);
2048 static double __test(unsigned long long);
2049 static double __test(double);
2050 static long double __test(long double);
2051
2052 typedef decltype(__test(declval<_Tp>())) type;
2053 static const bool value = _IsNotSame<type, void>::value;
2054};
2055
2056template <>
2057struct __numeric_type<void>
2058{
2059 static const bool value = true;
2060};
2061
2062// __promote
2063
2064template <class _A1, class _A2 = void, class _A3 = void,
2065 bool = __numeric_type<_A1>::value &&
2066 __numeric_type<_A2>::value &&
2067 __numeric_type<_A3>::value>
2068class __promote_imp
2069{
2070public:
2071 static const bool value = false;
2072};
2073
2074template <class _A1, class _A2, class _A3>
2075class __promote_imp<_A1, _A2, _A3, true>
2076{
2077private:
2078 typedef typename __promote_imp<_A1>::type __type1;
2079 typedef typename __promote_imp<_A2>::type __type2;
2080 typedef typename __promote_imp<_A3>::type __type3;
2081public:
2082 typedef decltype(__type1() + __type2() + __type3()) type;
2083 static const bool value = true;
2084};
2085
2086template <class _A1, class _A2>
2087class __promote_imp<_A1, _A2, void, true>
2088{
2089private:
2090 typedef typename __promote_imp<_A1>::type __type1;
2091 typedef typename __promote_imp<_A2>::type __type2;
2092public:
2093 typedef decltype(__type1() + __type2()) type;
2094 static const bool value = true;
2095};
2096
2097template <class _A1>
2098class __promote_imp<_A1, void, void, true>
2099{
2100public:
2101 typedef typename __numeric_type<_A1>::type type;
2102 static const bool value = true;
2103};
2104
2105template <class _A1, class _A2 = void, class _A3 = void>
2106class __promote : public __promote_imp<_A1, _A2, _A3> {};
2107
2108// make_signed / make_unsigned
2109
2110typedef
2111 __type_list<signed char,
2112 __type_list<signed short,
2113 __type_list<signed int,
2114 __type_list<signed long,
2115 __type_list<signed long long,
2116#ifndef _LIBCPP_HAS_NO_INT128
2117 __type_list<__int128_t,
2118#endif
2119 __nat
2120#ifndef _LIBCPP_HAS_NO_INT128
2121 >
2122#endif
2123 > > > > > __signed_types;
2124
2125typedef
2126 __type_list<unsigned char,
2127 __type_list<unsigned short,
2128 __type_list<unsigned int,
2129 __type_list<unsigned long,
2130 __type_list<unsigned long long,
2131#ifndef _LIBCPP_HAS_NO_INT128
2132 __type_list<__uint128_t,
2133#endif
2134 __nat
2135#ifndef _LIBCPP_HAS_NO_INT128
2136 >
2137#endif
2138 > > > > > __unsigned_types;
2139
2140template <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeList::_Head)> struct __find_first;
2141
2142template <class _Hp, class _Tp, size_t _Size>
2143struct __find_first<__type_list<_Hp, _Tp>, _Size, true>
2144{
2145 typedef _LIBCPP_NODEBUG _Hp type;
2146};
2147
2148template <class _Hp, class _Tp, size_t _Size>
2149struct __find_first<__type_list<_Hp, _Tp>, _Size, false>
2150{
2151 typedef _LIBCPP_NODEBUG typename __find_first<_Tp, _Size>::type type;
2152};
2153
2154template <class _Tp, class _Up, bool = is_const<typename remove_reference<_Tp>::type>::value,
2155 bool = is_volatile<typename remove_reference<_Tp>::type>::value>
2156struct __apply_cv
2157{
2158 typedef _LIBCPP_NODEBUG _Up type;
2159};
2160
2161template <class _Tp, class _Up>
2162struct __apply_cv<_Tp, _Up, true, false>
2163{
2164 typedef _LIBCPP_NODEBUG const _Up type;
2165};
2166
2167template <class _Tp, class _Up>
2168struct __apply_cv<_Tp, _Up, false, true>
2169{
2170 typedef volatile _Up type;
2171};
2172
2173template <class _Tp, class _Up>
2174struct __apply_cv<_Tp, _Up, true, true>
2175{
2176 typedef const volatile _Up type;
2177};
2178
2179template <class _Tp, class _Up>
2180struct __apply_cv<_Tp&, _Up, false, false>
2181{
2182 typedef _Up& type;
2183};
2184
2185template <class _Tp, class _Up>
2186struct __apply_cv<_Tp&, _Up, true, false>
2187{
2188 typedef const _Up& type;
2189};
2190
2191template <class _Tp, class _Up>
2192struct __apply_cv<_Tp&, _Up, false, true>
2193{
2194 typedef volatile _Up& type;
2195};
2196
2197template <class _Tp, class _Up>
2198struct __apply_cv<_Tp&, _Up, true, true>
2199{
2200 typedef const volatile _Up& type;
2201};
2202
2203template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
2204struct __make_signed {};
2205
2206template <class _Tp>
2207struct __make_signed<_Tp, true>
2208{
2209 typedef typename __find_first<__signed_types, sizeof(_Tp)>::type type;
2210};
2211
2212template <> struct __make_signed<bool, true> {};
2213template <> struct __make_signed< signed short, true> {typedef short type;};
2214template <> struct __make_signed<unsigned short, true> {typedef short type;};
2215template <> struct __make_signed< signed int, true> {typedef int type;};
2216template <> struct __make_signed<unsigned int, true> {typedef int type;};
2217template <> struct __make_signed< signed long, true> {typedef long type;};
2218template <> struct __make_signed<unsigned long, true> {typedef long type;};
2219template <> struct __make_signed< signed long long, true> {typedef long long type;};
2220template <> struct __make_signed<unsigned long long, true> {typedef long long type;};
2221#ifndef _LIBCPP_HAS_NO_INT128
2222template <> struct __make_signed<__int128_t, true> {typedef __int128_t type;};
2223template <> struct __make_signed<__uint128_t, true> {typedef __int128_t type;};
2224#endif
2225
2226template <class _Tp>
2227struct _LIBCPP_TEMPLATE_VIS make_signed
2228{
2229 typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type;
2230};
2231
2232#if _LIBCPP_STD_VER > 11
2233template <class _Tp> using make_signed_t = typename make_signed<_Tp>::type;
2234#endif
2235
2236template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
2237struct __make_unsigned {};
2238
2239template <class _Tp>
2240struct __make_unsigned<_Tp, true>
2241{
2242 typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type;
2243};
2244
2245template <> struct __make_unsigned<bool, true> {};
2246template <> struct __make_unsigned< signed short, true> {typedef unsigned short type;};
2247template <> struct __make_unsigned<unsigned short, true> {typedef unsigned short type;};
2248template <> struct __make_unsigned< signed int, true> {typedef unsigned int type;};
2249template <> struct __make_unsigned<unsigned int, true> {typedef unsigned int type;};
2250template <> struct __make_unsigned< signed long, true> {typedef unsigned long type;};
2251template <> struct __make_unsigned<unsigned long, true> {typedef unsigned long type;};
2252template <> struct __make_unsigned< signed long long, true> {typedef unsigned long long type;};
2253template <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;};
2254#ifndef _LIBCPP_HAS_NO_INT128
2255template <> struct __make_unsigned<__int128_t, true> {typedef __uint128_t type;};
2256template <> struct __make_unsigned<__uint128_t, true> {typedef __uint128_t type;};
2257#endif
2258
2259template <class _Tp>
2260struct _LIBCPP_TEMPLATE_VIS make_unsigned
2261{
2262 typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type;
2263};
2264
2265#if _LIBCPP_STD_VER > 11
2266template <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type;
2267#endif
2268
2269#ifndef _LIBCPP_CXX03_LANG
2270template <class _Tp>
2271_LIBCPP_HIDE_FROM_ABI constexpr
2272typename make_unsigned<_Tp>::type __to_unsigned_like(_Tp __x) noexcept {
2273 return static_cast<typename make_unsigned<_Tp>::type>(__x);
2274}
2275#endif
2276
2277#if _LIBCPP_STD_VER > 14
2278template <class...> using void_t = void;
2279#endif
2280
2281#if _LIBCPP_STD_VER > 17
2282// Let COND_RES(X, Y) be:
2283template <class _Tp, class _Up>
2284using __cond_type = decltype(false ? declval<_Tp>() : declval<_Up>());
2285
2286template <class _Tp, class _Up, class = void>
2287struct __common_type3 {};
2288
2289// sub-bullet 4 - "if COND_RES(CREF(D1), CREF(D2)) denotes a type..."
2290template <class _Tp, class _Up>
2291struct __common_type3<_Tp, _Up, void_t<__cond_type<const _Tp&, const _Up&>>>
2292{
2293 using type = remove_cvref_t<__cond_type<const _Tp&, const _Up&>>;
2294};
2295
2296template <class _Tp, class _Up, class = void>
2297struct __common_type2_imp : __common_type3<_Tp, _Up> {};
2298#else
2299template <class _Tp, class _Up, class = void>
2300struct __common_type2_imp {};
2301#endif
2302
2303// sub-bullet 3 - "if decay_t<decltype(false ? declval<D1>() : declval<D2>())> ..."
2304template <class _Tp, class _Up>
2305struct __common_type2_imp<_Tp, _Up,
2306 typename __void_t<decltype(
2307 true ? declval<_Tp>() : declval<_Up>()
2308 )>::type>
2309{
2310 typedef _LIBCPP_NODEBUG typename decay<decltype(
2311 true ? declval<_Tp>() : declval<_Up>()
2312 )>::type type;
2313};
2314
2315template <class, class = void>
2316struct __common_type_impl {};
2317
2318// Clang provides variadic templates in C++03 as an extension.
2319#if !defined(_LIBCPP_CXX03_LANG) || defined(__clang__)
2320# define _LIBCPP_OPTIONAL_PACK(...) , __VA_ARGS__
2321template <class... _Tp>
2322struct __common_types;
2323template <class... _Tp>
2324struct _LIBCPP_TEMPLATE_VIS common_type;
2325#else
2326# define _LIBCPP_OPTIONAL_PACK(...)
2327struct __no_arg;
2328template <class _Tp, class _Up, class = __no_arg>
2329struct __common_types;
2330template <class _Tp = __no_arg, class _Up = __no_arg, class _Vp = __no_arg,
2331 class _Unused = __no_arg>
2332struct common_type {
2333 static_assert(sizeof(_Unused) == 0,
2334 "common_type accepts at most 3 arguments in C++03");
2335};
2336#endif // _LIBCPP_CXX03_LANG
2337
2338template <class _Tp, class _Up>
2339struct __common_type_impl<
2340 __common_types<_Tp, _Up>,
2341 typename __void_t<typename common_type<_Tp, _Up>::type>::type>
2342{
2343 typedef typename common_type<_Tp, _Up>::type type;
2344};
2345
2346template <class _Tp, class _Up, class _Vp _LIBCPP_OPTIONAL_PACK(class... _Rest)>
2347struct __common_type_impl<
2348 __common_types<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)>,
2349 typename __void_t<typename common_type<_Tp, _Up>::type>::type>
2350 : __common_type_impl<__common_types<typename common_type<_Tp, _Up>::type,
2351 _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)> > {
2352};
2353
2354// bullet 1 - sizeof...(Tp) == 0
2355
2356template <>
2357struct _LIBCPP_TEMPLATE_VIS common_type<> {};
2358
2359// bullet 2 - sizeof...(Tp) == 1
2360
2361template <class _Tp>
2362struct _LIBCPP_TEMPLATE_VIS common_type<_Tp>
2363 : public common_type<_Tp, _Tp> {};
2364
2365// bullet 3 - sizeof...(Tp) == 2
2366
2367// sub-bullet 1 - "If is_same_v<T1, D1> is false or ..."
2368template <class _Tp, class _Up>
2369struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up>
2370 : conditional<
2371 _IsSame<_Tp, typename decay<_Tp>::type>::value && _IsSame<_Up, typename decay<_Up>::type>::value,
2372 __common_type2_imp<_Tp, _Up>,
2373 common_type<typename decay<_Tp>::type, typename decay<_Up>::type>
2374 >::type
2375{};
2376
2377// bullet 4 - sizeof...(Tp) > 2
2378
2379template <class _Tp, class _Up, class _Vp _LIBCPP_OPTIONAL_PACK(class... _Rest)>
2380struct _LIBCPP_TEMPLATE_VIS
2381 common_type<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)>
2382 : __common_type_impl<
2383 __common_types<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)> > {};
2384
2385#undef _LIBCPP_OPTIONAL_PACK
2386
2387#if _LIBCPP_STD_VER > 11
2388template <class ..._Tp> using common_type_t = typename common_type<_Tp...>::type;
2389#endif
2390
2391#if _LIBCPP_STD_VER > 11
2392// Let COPYCV(FROM, TO) be an alias for type TO with the addition of FROM's
2393// top-level cv-qualifiers.
2394template <class _From, class _To>
2395struct __copy_cv
2396{
2397 using type = _To;
2398};
2399
2400template <class _From, class _To>
2401struct __copy_cv<const _From, _To>
2402{
2403 using type = add_const_t<_To>;
2404};
2405
2406template <class _From, class _To>
2407struct __copy_cv<volatile _From, _To>
2408{
2409 using type = add_volatile_t<_To>;
2410};
2411
2412template <class _From, class _To>
2413struct __copy_cv<const volatile _From, _To>
2414{
2415 using type = add_cv_t<_To>;
2416};
2417
2418template <class _From, class _To>
2419using __copy_cv_t = typename __copy_cv<_From, _To>::type;
2420
2421template <class _From, class _To>
2422struct __copy_cvref
2423{
2424 using type = __copy_cv_t<_From, _To>;
2425};
2426
2427template <class _From, class _To>
2428struct __copy_cvref<_From&, _To>
2429{
2430 using type = add_lvalue_reference_t<__copy_cv_t<_From, _To>>;
2431};
2432
2433template <class _From, class _To>
2434struct __copy_cvref<_From&&, _To>
2435{
2436 using type = add_rvalue_reference_t<__copy_cv_t<_From, _To>>;
2437};
2438
2439template <class _From, class _To>
2440using __copy_cvref_t = typename __copy_cvref<_From, _To>::type;
2441
2442#endif // _LIBCPP_STD_VER > 11
2443
2444// common_reference
2445#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
2446// Let COND_RES(X, Y) be:
2447template <class _Xp, class _Yp>
2448using __cond_res =
2449 decltype(false ? declval<_Xp(&)()>()() : declval<_Yp(&)()>()());
2450
2451// Let `XREF(A)` denote a unary alias template `T` such that `T<U>` denotes the same type as `U`
2452// with the addition of `A`'s cv and reference qualifiers, for a non-reference cv-unqualified type
2453// `U`.
2454// [Note: `XREF(A)` is `__xref<A>::template __apply`]
2455template <class _Tp>
2456struct __xref {
2457 template<class _Up>
2458 using __apply = __copy_cvref_t<_Tp, _Up>;
2459};
2460
2461// Given types A and B, let X be remove_reference_t<A>, let Y be remove_reference_t<B>,
2462// and let COMMON-REF(A, B) be:
2463template<class _Ap, class _Bp, class _Xp = remove_reference_t<_Ap>, class _Yp = remove_reference_t<_Bp>>
2464struct __common_ref;
2465
2466template<class _Xp, class _Yp>
2467using __common_ref_t = typename __common_ref<_Xp, _Yp>::__type;
2468
2469template<class _Xp, class _Yp>
2470using __cv_cond_res = __cond_res<__copy_cv_t<_Xp, _Yp>&, __copy_cv_t<_Yp, _Xp>&>;
2471
2472
2473// If A and B are both lvalue reference types, COMMON-REF(A, B) is
2474// COND-RES(COPYCV(X, Y)&, COPYCV(Y, X)&) if that type exists and is a reference type.
2475template<class _Ap, class _Bp, class _Xp, class _Yp>
2476requires requires { typename __cv_cond_res<_Xp, _Yp>; } && is_reference_v<__cv_cond_res<_Xp, _Yp>>
2477struct __common_ref<_Ap&, _Bp&, _Xp, _Yp>
2478{
2479 using __type = __cv_cond_res<_Xp, _Yp>;
2480};
2481
2482// Otherwise, let C be remove_reference_t<COMMON-REF(X&, Y&)>&&. ...
2483template <class _Xp, class _Yp>
2484using __common_ref_C = remove_reference_t<__common_ref_t<_Xp&, _Yp&>>&&;
2485
2486
2487// .... If A and B are both rvalue reference types, C is well-formed, and
2488// is_convertible_v<A, C> && is_convertible_v<B, C> is true, then COMMON-REF(A, B) is C.
2489template<class _Ap, class _Bp, class _Xp, class _Yp>
2490requires
2491 requires { typename __common_ref_C<_Xp, _Yp>; } &&
2492 is_convertible_v<_Ap&&, __common_ref_C<_Xp, _Yp>> &&
2493 is_convertible_v<_Bp&&, __common_ref_C<_Xp, _Yp>>
2494struct __common_ref<_Ap&&, _Bp&&, _Xp, _Yp>
2495{
2496 using __type = __common_ref_C<_Xp, _Yp>;
2497};
2498
2499// Otherwise, let D be COMMON-REF(const X&, Y&). ...
2500template <class _Tp, class _Up>
2501using __common_ref_D = __common_ref_t<const _Tp&, _Up&>;
2502
2503// ... If A is an rvalue reference and B is an lvalue reference and D is well-formed and
2504// is_convertible_v<A, D> is true, then COMMON-REF(A, B) is D.
2505template<class _Ap, class _Bp, class _Xp, class _Yp>
2506requires requires { typename __common_ref_D<_Xp, _Yp>; } &&
2507 is_convertible_v<_Ap&&, __common_ref_D<_Xp, _Yp>>
2508struct __common_ref<_Ap&&, _Bp&, _Xp, _Yp>
2509{
2510 using __type = __common_ref_D<_Xp, _Yp>;
2511};
2512
2513// Otherwise, if A is an lvalue reference and B is an rvalue reference, then
2514// COMMON-REF(A, B) is COMMON-REF(B, A).
2515template<class _Ap, class _Bp, class _Xp, class _Yp>
2516struct __common_ref<_Ap&, _Bp&&, _Xp, _Yp> : __common_ref<_Bp&&, _Ap&> {};
2517
2518// Otherwise, COMMON-REF(A, B) is ill-formed.
2519template<class _Ap, class _Bp, class _Xp, class _Yp>
2520struct __common_ref {};
2521
2522// Note C: For the common_reference trait applied to a parameter pack [...]
2523
2524template <class...>
2525struct common_reference;
2526
2527template <class... _Types>
2528using common_reference_t = typename common_reference<_Types...>::type;
2529
2530// bullet 1 - sizeof...(T) == 0
2531template<>
2532struct common_reference<> {};
2533
2534// bullet 2 - sizeof...(T) == 1
2535template <class _Tp>
2536struct common_reference<_Tp>
2537{
2538 using type = _Tp;
2539};
2540
2541// bullet 3 - sizeof...(T) == 2
2542template <class _Tp, class _Up> struct __common_reference_sub_bullet3;
2543template <class _Tp, class _Up> struct __common_reference_sub_bullet2 : __common_reference_sub_bullet3<_Tp, _Up> {};
2544template <class _Tp, class _Up> struct __common_reference_sub_bullet1 : __common_reference_sub_bullet2<_Tp, _Up> {};
2545
2546// sub-bullet 1 - If T1 and T2 are reference types and COMMON-REF(T1, T2) is well-formed, then
2547// the member typedef `type` denotes that type.
2548template <class _Tp, class _Up> struct common_reference<_Tp, _Up> : __common_reference_sub_bullet1<_Tp, _Up> {};
2549
2550template <class _Tp, class _Up>
2551requires is_reference_v<_Tp> && is_reference_v<_Up> && requires { typename __common_ref_t<_Tp, _Up>; }
2552struct __common_reference_sub_bullet1<_Tp, _Up>
2553{
2554 using type = __common_ref_t<_Tp, _Up>;
2555};
2556
2557// sub-bullet 2 - Otherwise, if basic_common_reference<remove_cvref_t<T1>, remove_cvref_t<T2>, XREF(T1), XREF(T2)>::type
2558// is well-formed, then the member typedef `type` denotes that type.
2559template <class, class, template <class> class, template <class> class> struct basic_common_reference {};
2560
2561template <class _Tp, class _Up>
2562using __basic_common_reference_t = typename basic_common_reference<
2563 remove_cvref_t<_Tp>, remove_cvref_t<_Up>,
2564 __xref<_Tp>::template __apply, __xref<_Up>::template __apply>::type;
2565
2566template <class _Tp, class _Up>
2567requires requires { typename __basic_common_reference_t<_Tp, _Up>; }
2568struct __common_reference_sub_bullet2<_Tp, _Up>
2569{
2570 using type = __basic_common_reference_t<_Tp, _Up>;
2571};
2572
2573// sub-bullet 3 - Otherwise, if COND-RES(T1, T2) is well-formed,
2574// then the member typedef `type` denotes that type.
2575template <class _Tp, class _Up>
2576requires requires { typename __cond_res<_Tp, _Up>; }
2577struct __common_reference_sub_bullet3<_Tp, _Up>
2578{
2579 using type = __cond_res<_Tp, _Up>;
2580};
2581
2582
2583// sub-bullet 4 & 5 - Otherwise, if common_type_t<T1, T2> is well-formed,
2584// then the member typedef `type` denotes that type.
2585// - Otherwise, there shall be no member `type`.
2586template <class _Tp, class _Up> struct __common_reference_sub_bullet3 : common_type<_Tp, _Up> {};
2587
2588// bullet 4 - If there is such a type `C`, the member typedef type shall denote the same type, if
2589// any, as `common_reference_t<C, Rest...>`.
2590template <class _Tp, class _Up, class _Vp, class... _Rest>
2591requires requires { typename common_reference_t<_Tp, _Up>; }
2592struct common_reference<_Tp, _Up, _Vp, _Rest...>
2593 : common_reference<common_reference_t<_Tp, _Up>, _Vp, _Rest...>
2594{};
2595
2596// bullet 5 - Otherwise, there shall be no member `type`.
2597template <class...> struct common_reference {};
2598
2599#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
2600
2601// is_assignable
2602
2603template<typename, typename _Tp> struct __select_2nd { typedef _LIBCPP_NODEBUG _Tp type; };
2604
2605#if __has_keyword(__is_assignable)
2606
2607template<class _Tp, class _Up>
2608struct _LIBCPP_TEMPLATE_VIS is_assignable : _BoolConstant<__is_assignable(_Tp, _Up)> { };
2609
2610#if _LIBCPP_STD_VER > 14
2611template <class _Tp, class _Arg>
2612inline constexpr bool is_assignable_v = __is_assignable(_Tp, _Arg);
2613#endif
2614
2615#else // __has_keyword(__is_assignable)
2616
2617template <class _Tp, class _Arg>
2618typename __select_2nd<decltype((declval<_Tp>() = declval<_Arg>())), true_type>::type
2619__is_assignable_test(int);
2620
2621template <class, class>
2622false_type __is_assignable_test(...);
2623
2624
2625template <class _Tp, class _Arg, bool = is_void<_Tp>::value || is_void<_Arg>::value>
2626struct __is_assignable_imp
2627 : public decltype((_VSTD::__is_assignable_test<_Tp, _Arg>(0))) {};
2628
2629template <class _Tp, class _Arg>
2630struct __is_assignable_imp<_Tp, _Arg, true>
2631 : public false_type
2632{
2633};
2634
2635template <class _Tp, class _Arg>
2636struct is_assignable
2637 : public __is_assignable_imp<_Tp, _Arg> {};
2638
2639#if _LIBCPP_STD_VER > 14
2640template <class _Tp, class _Arg>
2641inline constexpr bool is_assignable_v = is_assignable<_Tp, _Arg>::value;
2642#endif
2643
2644#endif // __has_keyword(__is_assignable)
2645
2646// is_copy_assignable
2647
2648template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_copy_assignable
2649 : public is_assignable<typename add_lvalue_reference<_Tp>::type,
2650 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
2651
2652#if _LIBCPP_STD_VER > 14
2653template <class _Tp>
2654inline constexpr bool is_copy_assignable_v = is_copy_assignable<_Tp>::value;
2655#endif
2656
2657// is_move_assignable
2658
2659template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_move_assignable
2660 : public is_assignable<typename add_lvalue_reference<_Tp>::type,
2661 typename add_rvalue_reference<_Tp>::type> {};
2662
2663#if _LIBCPP_STD_VER > 14
2664template <class _Tp>
2665inline constexpr bool is_move_assignable_v = is_move_assignable<_Tp>::value;
2666#endif
2667
2668// is_destructible
2669
2670#if __has_keyword(__is_destructible)
2671
2672template<class _Tp>
2673struct _LIBCPP_TEMPLATE_VIS is_destructible : _BoolConstant<__is_destructible(_Tp)> { };
2674
2675#if _LIBCPP_STD_VER > 14
2676template <class _Tp>
2677inline constexpr bool is_destructible_v = __is_destructible(_Tp);
2678#endif
2679
2680#else // __has_keyword(__is_destructible)
2681
2682// if it's a reference, return true
2683// if it's a function, return false
2684// if it's void, return false
2685// if it's an array of unknown bound, return false
2686// Otherwise, return "declval<_Up&>().~_Up()" is well-formed
2687// where _Up is remove_all_extents<_Tp>::type
2688
2689template <class>
2690struct __is_destructible_apply { typedef int type; };
2691
2692template <typename _Tp>
2693struct __is_destructor_wellformed {
2694 template <typename _Tp1>
2695 static char __test (
2696 typename __is_destructible_apply<decltype(declval<_Tp1&>().~_Tp1())>::type
2697 );
2698
2699 template <typename _Tp1>
2700 static __two __test (...);
2701
2702 static const bool value = sizeof(__test<_Tp>(12)) == sizeof(char);
2703};
2704
2705template <class _Tp, bool>
2706struct __destructible_imp;
2707
2708template <class _Tp>
2709struct __destructible_imp<_Tp, false>
2710 : public integral_constant<bool,
2711 __is_destructor_wellformed<typename remove_all_extents<_Tp>::type>::value> {};
2712
2713template <class _Tp>
2714struct __destructible_imp<_Tp, true>
2715 : public true_type {};
2716
2717template <class _Tp, bool>
2718struct __destructible_false;
2719
2720template <class _Tp>
2721struct __destructible_false<_Tp, false> : public __destructible_imp<_Tp, is_reference<_Tp>::value> {};
2722
2723template <class _Tp>
2724struct __destructible_false<_Tp, true> : public false_type {};
2725
2726template <class _Tp>
2727struct is_destructible
2728 : public __destructible_false<_Tp, is_function<_Tp>::value> {};
2729
2730template <class _Tp>
2731struct is_destructible<_Tp[]>
2732 : public false_type {};
2733
2734template <>
2735struct is_destructible<void>
2736 : public false_type {};
2737
2738#if _LIBCPP_STD_VER > 14
2739template <class _Tp>
2740inline constexpr bool is_destructible_v = is_destructible<_Tp>::value;
2741#endif
2742
2743#endif // __has_keyword(__is_destructible)
2744
2745template <class _MP, bool _IsMemberFunctionPtr, bool _IsMemberObjectPtr>
2746struct __member_pointer_traits_imp
2747{
2748};
2749
2750template <class _Rp, class _Class, class ..._Param>
2751struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...), true, false>
2752{
2753 typedef _Class _ClassType;
2754 typedef _Rp _ReturnType;
2755 typedef _Rp (_FnType) (_Param...);
2756};
2757
2758template <class _Rp, class _Class, class ..._Param>
2759struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...), true, false>
2760{
2761 typedef _Class _ClassType;
2762 typedef _Rp _ReturnType;
2763 typedef _Rp (_FnType) (_Param..., ...);
2764};
2765
2766template <class _Rp, class _Class, class ..._Param>
2767struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const, true, false>
2768{
2769 typedef _Class const _ClassType;
2770 typedef _Rp _ReturnType;
2771 typedef _Rp (_FnType) (_Param...);
2772};
2773
2774template <class _Rp, class _Class, class ..._Param>
2775struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const, true, false>
2776{
2777 typedef _Class const _ClassType;
2778 typedef _Rp _ReturnType;
2779 typedef _Rp (_FnType) (_Param..., ...);
2780};
2781
2782template <class _Rp, class _Class, class ..._Param>
2783struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile, true, false>
2784{
2785 typedef _Class volatile _ClassType;
2786 typedef _Rp _ReturnType;
2787 typedef _Rp (_FnType) (_Param...);
2788};
2789
2790template <class _Rp, class _Class, class ..._Param>
2791struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile, true, false>
2792{
2793 typedef _Class volatile _ClassType;
2794 typedef _Rp _ReturnType;
2795 typedef _Rp (_FnType) (_Param..., ...);
2796};
2797
2798template <class _Rp, class _Class, class ..._Param>
2799struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile, true, false>
2800{
2801 typedef _Class const volatile _ClassType;
2802 typedef _Rp _ReturnType;
2803 typedef _Rp (_FnType) (_Param...);
2804};
2805
2806template <class _Rp, class _Class, class ..._Param>
2807struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile, true, false>
2808{
2809 typedef _Class const volatile _ClassType;
2810 typedef _Rp _ReturnType;
2811 typedef _Rp (_FnType) (_Param..., ...);
2812};
2813
2814#if __has_feature(cxx_reference_qualified_functions) || defined(_LIBCPP_COMPILER_GCC)
2815
2816template <class _Rp, class _Class, class ..._Param>
2817struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &, true, false>
2818{
2819 typedef _Class& _ClassType;
2820 typedef _Rp _ReturnType;
2821 typedef _Rp (_FnType) (_Param...);
2822};
2823
2824template <class _Rp, class _Class, class ..._Param>
2825struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &, true, false>
2826{
2827 typedef _Class& _ClassType;
2828 typedef _Rp _ReturnType;
2829 typedef _Rp (_FnType) (_Param..., ...);
2830};
2831
2832template <class _Rp, class _Class, class ..._Param>
2833struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&, true, false>
2834{
2835 typedef _Class const& _ClassType;
2836 typedef _Rp _ReturnType;
2837 typedef _Rp (_FnType) (_Param...);
2838};
2839
2840template <class _Rp, class _Class, class ..._Param>
2841struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&, true, false>
2842{
2843 typedef _Class const& _ClassType;
2844 typedef _Rp _ReturnType;
2845 typedef _Rp (_FnType) (_Param..., ...);
2846};
2847
2848template <class _Rp, class _Class, class ..._Param>
2849struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&, true, false>
2850{
2851 typedef _Class volatile& _ClassType;
2852 typedef _Rp _ReturnType;
2853 typedef _Rp (_FnType) (_Param...);
2854};
2855
2856template <class _Rp, class _Class, class ..._Param>
2857struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&, true, false>
2858{
2859 typedef _Class volatile& _ClassType;
2860 typedef _Rp _ReturnType;
2861 typedef _Rp (_FnType) (_Param..., ...);
2862};
2863
2864template <class _Rp, class _Class, class ..._Param>
2865struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&, true, false>
2866{
2867 typedef _Class const volatile& _ClassType;
2868 typedef _Rp _ReturnType;
2869 typedef _Rp (_FnType) (_Param...);
2870};
2871
2872template <class _Rp, class _Class, class ..._Param>
2873struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&, true, false>
2874{
2875 typedef _Class const volatile& _ClassType;
2876 typedef _Rp _ReturnType;
2877 typedef _Rp (_FnType) (_Param..., ...);
2878};
2879
2880template <class _Rp, class _Class, class ..._Param>
2881struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &&, true, false>
2882{
2883 typedef _Class&& _ClassType;
2884 typedef _Rp _ReturnType;
2885 typedef _Rp (_FnType) (_Param...);
2886};
2887
2888template <class _Rp, class _Class, class ..._Param>
2889struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &&, true, false>
2890{
2891 typedef _Class&& _ClassType;
2892 typedef _Rp _ReturnType;
2893 typedef _Rp (_FnType) (_Param..., ...);
2894};
2895
2896template <class _Rp, class _Class, class ..._Param>
2897struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&&, true, false>
2898{
2899 typedef _Class const&& _ClassType;
2900 typedef _Rp _ReturnType;
2901 typedef _Rp (_FnType) (_Param...);
2902};
2903
2904template <class _Rp, class _Class, class ..._Param>
2905struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&&, true, false>
2906{
2907 typedef _Class const&& _ClassType;
2908 typedef _Rp _ReturnType;
2909 typedef _Rp (_FnType) (_Param..., ...);
2910};
2911
2912template <class _Rp, class _Class, class ..._Param>
2913struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&&, true, false>
2914{
2915 typedef _Class volatile&& _ClassType;
2916 typedef _Rp _ReturnType;
2917 typedef _Rp (_FnType) (_Param...);
2918};
2919
2920template <class _Rp, class _Class, class ..._Param>
2921struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&&, true, false>
2922{
2923 typedef _Class volatile&& _ClassType;
2924 typedef _Rp _ReturnType;
2925 typedef _Rp (_FnType) (_Param..., ...);
2926};
2927
2928template <class _Rp, class _Class, class ..._Param>
2929struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&&, true, false>
2930{
2931 typedef _Class const volatile&& _ClassType;
2932 typedef _Rp _ReturnType;
2933 typedef _Rp (_FnType) (_Param...);
2934};
2935
2936template <class _Rp, class _Class, class ..._Param>
2937struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&&, true, false>
2938{
2939 typedef _Class const volatile&& _ClassType;
2940 typedef _Rp _ReturnType;
2941 typedef _Rp (_FnType) (_Param..., ...);
2942};
2943
2944#endif // __has_feature(cxx_reference_qualified_functions) || defined(_LIBCPP_COMPILER_GCC)
2945
2946
2947template <class _Rp, class _Class>
2948struct __member_pointer_traits_imp<_Rp _Class::*, false, true>
2949{
2950 typedef _Class _ClassType;
2951 typedef _Rp _ReturnType;
2952};
2953
2954template <class _MP>
2955struct __member_pointer_traits
2956 : public __member_pointer_traits_imp<typename remove_cv<_MP>::type,
2957 is_member_function_pointer<_MP>::value,
2958 is_member_object_pointer<_MP>::value>
2959{
2960// typedef ... _ClassType;
2961// typedef ... _ReturnType;
2962// typedef ... _FnType;
2963};
2964
2965
2966template <class _DecayedFp>
2967struct __member_pointer_class_type {};
2968
2969template <class _Ret, class _ClassType>
2970struct __member_pointer_class_type<_Ret _ClassType::*> {
2971 typedef _ClassType type;
2972};
2973
2974// template <class T, class... Args> struct is_constructible;
2975
2976template <class _Tp, class ..._Args>
2977struct _LIBCPP_TEMPLATE_VIS is_constructible
2978 : public integral_constant<bool, __is_constructible(_Tp, _Args...)>
2979{ };
2980
2981#if _LIBCPP_STD_VER > 14
2982template <class _Tp, class ..._Args>
2983inline constexpr bool is_constructible_v = is_constructible<_Tp, _Args...>::value;
2984#endif
2985
2986// is_default_constructible
2987
2988template <class _Tp>
2989struct _LIBCPP_TEMPLATE_VIS is_default_constructible
2990 : public is_constructible<_Tp>
2991 {};
2992
2993#if _LIBCPP_STD_VER > 14
2994template <class _Tp>
2995inline constexpr bool is_default_constructible_v = is_default_constructible<_Tp>::value;
2996#endif
2997
2998#ifndef _LIBCPP_CXX03_LANG
2999// First of all, we can't implement this check in C++03 mode because the {}
3000// default initialization syntax isn't valid.
3001// Second, we implement the trait in a funny manner with two defaulted template
3002// arguments to workaround Clang's PR43454.
3003template <class _Tp>
3004void __test_implicit_default_constructible(_Tp);
3005
3006template <class _Tp, class = void, class = typename is_default_constructible<_Tp>::type>
3007struct __is_implicitly_default_constructible
3008 : false_type
3009{ };
3010
3011template <class _Tp>
3012struct __is_implicitly_default_constructible<_Tp, decltype(__test_implicit_default_constructible<_Tp const&>({})), true_type>
3013 : true_type
3014{ };
3015
3016template <class _Tp>
3017struct __is_implicitly_default_constructible<_Tp, decltype(__test_implicit_default_constructible<_Tp const&>({})), false_type>
3018 : false_type
3019{ };
3020#endif // !C++03
3021
3022// is_copy_constructible
3023
3024template <class _Tp>
3025struct _LIBCPP_TEMPLATE_VIS is_copy_constructible
3026 : public is_constructible<_Tp,
3027 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3028
3029#if _LIBCPP_STD_VER > 14
3030template <class _Tp>
3031inline constexpr bool is_copy_constructible_v = is_copy_constructible<_Tp>::value;
3032#endif
3033
3034// is_move_constructible
3035
3036template <class _Tp>
3037struct _LIBCPP_TEMPLATE_VIS is_move_constructible
3038 : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
3039 {};
3040
3041#if _LIBCPP_STD_VER > 14
3042template <class _Tp>
3043inline constexpr bool is_move_constructible_v = is_move_constructible<_Tp>::value;
3044#endif
3045
3046// is_trivially_constructible
3047
3048template <class _Tp, class... _Args>
3049struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible
3050 : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)>
3051{
3052};
3053
3054#if _LIBCPP_STD_VER > 14
3055template <class _Tp, class... _Args>
3056inline constexpr bool is_trivially_constructible_v = is_trivially_constructible<_Tp, _Args...>::value;
3057#endif
3058
3059// is_trivially_default_constructible
3060
3061template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_default_constructible
3062 : public is_trivially_constructible<_Tp>
3063 {};
3064
3065#if _LIBCPP_STD_VER > 14
3066template <class _Tp>
3067inline constexpr bool is_trivially_default_constructible_v = is_trivially_default_constructible<_Tp>::value;
3068#endif
3069
3070// is_trivially_copy_constructible
3071
3072template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_constructible
3073 : public is_trivially_constructible<_Tp, typename add_lvalue_reference<const _Tp>::type>
3074 {};
3075
3076#if _LIBCPP_STD_VER > 14
3077template <class _Tp>
3078inline constexpr bool is_trivially_copy_constructible_v = is_trivially_copy_constructible<_Tp>::value;
3079#endif
3080
3081// is_trivially_move_constructible
3082
3083template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_constructible
3084 : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
3085 {};
3086
3087#if _LIBCPP_STD_VER > 14
3088template <class _Tp>
3089inline constexpr bool is_trivially_move_constructible_v = is_trivially_move_constructible<_Tp>::value;
3090#endif
3091
3092// is_trivially_assignable
3093
3094template <class _Tp, class _Arg>
3095struct is_trivially_assignable
3096 : integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)>
3097{ };
3098
3099#if _LIBCPP_STD_VER > 14
3100template <class _Tp, class _Arg>
3101inline constexpr bool is_trivially_assignable_v = is_trivially_assignable<_Tp, _Arg>::value;
3102#endif
3103
3104// is_trivially_copy_assignable
3105
3106template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_assignable
3107 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
3108 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3109
3110#if _LIBCPP_STD_VER > 14
3111template <class _Tp>
3112inline constexpr bool is_trivially_copy_assignable_v = is_trivially_copy_assignable<_Tp>::value;
3113#endif
3114
3115// is_trivially_move_assignable
3116
3117template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_assignable
3118 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
3119 typename add_rvalue_reference<_Tp>::type>
3120 {};
3121
3122#if _LIBCPP_STD_VER > 14
3123template <class _Tp>
3124inline constexpr bool is_trivially_move_assignable_v = is_trivially_move_assignable<_Tp>::value;
3125#endif
3126
3127// is_trivially_destructible
3128
3129#if __has_keyword(__is_trivially_destructible)
3130
3131template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
3132 : public integral_constant<bool, __is_trivially_destructible(_Tp)> {};
3133
3134#elif __has_feature(has_trivial_destructor) || defined(_LIBCPP_COMPILER_GCC)
3135
3136template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
3137 : public integral_constant<bool, is_destructible<_Tp>::value && __has_trivial_destructor(_Tp)> {};
3138
3139#else
3140
3141template <class _Tp> struct __libcpp_trivial_destructor
3142 : public integral_constant<bool, is_scalar<_Tp>::value ||
3143 is_reference<_Tp>::value> {};
3144
3145template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
3146 : public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {};
3147
3148template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible<_Tp[]>
3149 : public false_type {};
3150
3151#endif
3152
3153#if _LIBCPP_STD_VER > 14
3154template <class _Tp>
3155inline constexpr bool is_trivially_destructible_v = is_trivially_destructible<_Tp>::value;
3156#endif
3157
3158// is_nothrow_constructible
3159
3160#if __has_keyword(__is_nothrow_constructible)
3161
3162template <class _Tp, class... _Args>
3163struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
3164 : public integral_constant<bool, __is_nothrow_constructible(_Tp, _Args...)> {};
3165
3166#else
3167
3168template <bool, bool, class _Tp, class... _Args> struct __libcpp_is_nothrow_constructible;
3169
3170template <class _Tp, class... _Args>
3171struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/false, _Tp, _Args...>
3172 : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))>
3173{
3174};
3175
3176template <class _Tp>
3177void __implicit_conversion_to(_Tp) noexcept { }
3178
3179template <class _Tp, class _Arg>
3180struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/true, _Tp, _Arg>
3181 : public integral_constant<bool, noexcept(_VSTD::__implicit_conversion_to<_Tp>(declval<_Arg>()))>
3182{
3183};
3184
3185template <class _Tp, bool _IsReference, class... _Args>
3186struct __libcpp_is_nothrow_constructible</*is constructible*/false, _IsReference, _Tp, _Args...>
3187 : public false_type
3188{
3189};
3190
3191template <class _Tp, class... _Args>
3192struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
3193 : __libcpp_is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, is_reference<_Tp>::value, _Tp, _Args...>
3194{
3195};
3196
3197template <class _Tp, size_t _Ns>
3198struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp[_Ns]>
3199 : __libcpp_is_nothrow_constructible<is_constructible<_Tp>::value, is_reference<_Tp>::value, _Tp>
3200{
3201};
3202
3203#endif // _LIBCPP_HAS_NO_NOEXCEPT
3204
3205
3206#if _LIBCPP_STD_VER > 14
3207template <class _Tp, class ..._Args>
3208inline constexpr bool is_nothrow_constructible_v = is_nothrow_constructible<_Tp, _Args...>::value;
3209#endif
3210
3211// is_nothrow_default_constructible
3212
3213template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_default_constructible
3214 : public is_nothrow_constructible<_Tp>
3215 {};
3216
3217#if _LIBCPP_STD_VER > 14
3218template <class _Tp>
3219inline constexpr bool is_nothrow_default_constructible_v = is_nothrow_default_constructible<_Tp>::value;
3220#endif
3221
3222// is_nothrow_copy_constructible
3223
3224template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_constructible
3225 : public is_nothrow_constructible<_Tp,
3226 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3227
3228#if _LIBCPP_STD_VER > 14
3229template <class _Tp>
3230inline constexpr bool is_nothrow_copy_constructible_v = is_nothrow_copy_constructible<_Tp>::value;
3231#endif
3232
3233// is_nothrow_move_constructible
3234
3235template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_constructible
3236 : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
3237 {};
3238
3239#if _LIBCPP_STD_VER > 14
3240template <class _Tp>
3241inline constexpr bool is_nothrow_move_constructible_v = is_nothrow_move_constructible<_Tp>::value;
3242#endif
3243
3244// is_nothrow_assignable
3245
3246#if __has_keyword(__is_nothrow_assignable)
3247
3248template <class _Tp, class _Arg>
3249struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable
3250 : public integral_constant<bool, __is_nothrow_assignable(_Tp, _Arg)> {};
3251
3252#else
3253
3254template <bool, class _Tp, class _Arg> struct __libcpp_is_nothrow_assignable;
3255
3256template <class _Tp, class _Arg>
3257struct __libcpp_is_nothrow_assignable<false, _Tp, _Arg>
3258 : public false_type
3259{
3260};
3261
3262template <class _Tp, class _Arg>
3263struct __libcpp_is_nothrow_assignable<true, _Tp, _Arg>
3264 : public integral_constant<bool, noexcept(declval<_Tp>() = declval<_Arg>()) >
3265{
3266};
3267
3268template <class _Tp, class _Arg>
3269struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable
3270 : public __libcpp_is_nothrow_assignable<is_assignable<_Tp, _Arg>::value, _Tp, _Arg>
3271{
3272};
3273
3274#endif // _LIBCPP_HAS_NO_NOEXCEPT
3275
3276#if _LIBCPP_STD_VER > 14
3277template <class _Tp, class _Arg>
3278inline constexpr bool is_nothrow_assignable_v = is_nothrow_assignable<_Tp, _Arg>::value;
3279#endif
3280
3281// is_nothrow_copy_assignable
3282
3283template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_assignable
3284 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
3285 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3286
3287#if _LIBCPP_STD_VER > 14
3288template <class _Tp>
3289inline constexpr bool is_nothrow_copy_assignable_v = is_nothrow_copy_assignable<_Tp>::value;
3290#endif
3291
3292// is_nothrow_move_assignable
3293
3294template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_assignable
3295 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
3296 typename add_rvalue_reference<_Tp>::type>
3297 {};
3298
3299#if _LIBCPP_STD_VER > 14
3300template <class _Tp>
3301inline constexpr bool is_nothrow_move_assignable_v = is_nothrow_move_assignable<_Tp>::value;
3302#endif
3303
3304// is_nothrow_destructible
3305
3306#if !defined(_LIBCPP_CXX03_LANG)
3307
3308template <bool, class _Tp> struct __libcpp_is_nothrow_destructible;
3309
3310template <class _Tp>
3311struct __libcpp_is_nothrow_destructible<false, _Tp>
3312 : public false_type
3313{
3314};
3315
3316template <class _Tp>
3317struct __libcpp_is_nothrow_destructible<true, _Tp>
3318 : public integral_constant<bool, noexcept(declval<_Tp>().~_Tp()) >
3319{
3320};
3321
3322template <class _Tp>
3323struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible
3324 : public __libcpp_is_nothrow_destructible<is_destructible<_Tp>::value, _Tp>
3325{
3326};
3327540
3328template <class _Tp, size_t _Ns>541template <class _Tp, bool>
3329struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[_Ns]>542struct _LIBCPP_TEMPLATE_VIS __dependent_type : public _Tp {};
3330 : public is_nothrow_destructible<_Tp>
3331{
3332};
3333543
3334template <class _Tp>544// is_integral
3335struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&>
3336 : public true_type
3337{
3338};
3339545
3340template <class _Tp>546template <class _Tp>
3341struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&&>547struct __unconstref {
3342 : public true_type548 typedef _LIBCPP_NODEBUG typename remove_const<typename remove_reference<_Tp>::type>::type type;
3343{
3344};549};
3345550
3346#else551#ifndef _LIBCPP_CXX03_LANG
3347552// First of all, we can't implement this check in C++03 mode because the {}
3348template <class _Tp> struct __libcpp_nothrow_destructor553// default initialization syntax isn't valid.
3349 : public integral_constant<bool, is_scalar<_Tp>::value ||554// Second, we implement the trait in a funny manner with two defaulted template
3350 is_reference<_Tp>::value> {};555// arguments to workaround Clang's PR43454.
3351
3352template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible
3353 : public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {};
3354
3355template <class _Tp>
3356struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[]>
3357 : public false_type {};
3358
3359#endif
3360
3361#if _LIBCPP_STD_VER > 14
3362template <class _Tp>
3363inline constexpr bool is_nothrow_destructible_v = is_nothrow_destructible<_Tp>::value;
3364#endif
3365
3366// is_pod
3367
3368#if __has_feature(is_pod) || defined(_LIBCPP_COMPILER_GCC)
3369
3370template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod
3371 : public integral_constant<bool, __is_pod(_Tp)> {};
3372
3373#else
3374
3375template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod
3376 : public integral_constant<bool, is_trivially_default_constructible<_Tp>::value &&
3377 is_trivially_copy_constructible<_Tp>::value &&
3378 is_trivially_copy_assignable<_Tp>::value &&
3379 is_trivially_destructible<_Tp>::value> {};
3380
3381#endif
3382
3383#if _LIBCPP_STD_VER > 14
3384template <class _Tp>
3385inline constexpr bool is_pod_v = is_pod<_Tp>::value;
3386#endif
3387
3388// is_literal_type;
3389
3390#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)
3391template <class _Tp> struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 is_literal_type
3392 : public integral_constant<bool, __is_literal_type(_Tp)>
3393 {};
3394
3395#if _LIBCPP_STD_VER > 14
3396template <class _Tp>
3397_LIBCPP_DEPRECATED_IN_CXX17 inline constexpr bool is_literal_type_v = is_literal_type<_Tp>::value;
3398#endif // _LIBCPP_STD_VER > 14
3399#endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)
3400
3401// is_standard_layout;
3402
3403template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_standard_layout
3404#if __has_feature(is_standard_layout) || defined(_LIBCPP_COMPILER_GCC)
3405 : public integral_constant<bool, __is_standard_layout(_Tp)>
3406#else
3407 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
3408#endif
3409 {};
3410
3411#if _LIBCPP_STD_VER > 14
3412template <class _Tp>556template <class _Tp>
3413inline constexpr bool is_standard_layout_v = is_standard_layout<_Tp>::value;557void __test_implicit_default_constructible(_Tp);
3414#endif
3415
3416// is_trivially_copyable;
3417558
3418template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copyable559template <class _Tp, class = void, class = typename is_default_constructible<_Tp>::type>
3419 : public integral_constant<bool, __is_trivially_copyable(_Tp)>560struct __is_implicitly_default_constructible
3420 {};561 : false_type
562{ };
3421563
3422#if _LIBCPP_STD_VER > 14
3423template <class _Tp>564template <class _Tp>
3424inline constexpr bool is_trivially_copyable_v = is_trivially_copyable<_Tp>::value;565struct __is_implicitly_default_constructible<_Tp, decltype(__test_implicit_default_constructible<_Tp const&>({})), true_type>
3425#endif566 : true_type
3426567{ };
3427// is_trivial;
3428
3429template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivial
3430#if __has_feature(is_trivial) || defined(_LIBCPP_COMPILER_GCC)
3431 : public integral_constant<bool, __is_trivial(_Tp)>
3432#else
3433 : integral_constant<bool, is_trivially_copyable<_Tp>::value &&
3434 is_trivially_default_constructible<_Tp>::value>
3435#endif
3436 {};
3437568
3438#if _LIBCPP_STD_VER > 14
3439template <class _Tp>569template <class _Tp>
3440inline constexpr bool is_trivial_v = is_trivial<_Tp>::value;570struct __is_implicitly_default_constructible<_Tp, decltype(__test_implicit_default_constructible<_Tp const&>({})), false_type>
3441#endif571 : false_type
3442572{ };
3443template <class _Tp> struct __is_reference_wrapper_impl : public false_type {};573#endif // !C++03
3444template <class _Tp> struct __is_reference_wrapper_impl<reference_wrapper<_Tp> > : public true_type {};
3445template <class _Tp> struct __is_reference_wrapper
3446 : public __is_reference_wrapper_impl<typename remove_cv<_Tp>::type> {};
3447
3448#ifndef _LIBCPP_CXX03_LANG
3449
3450template <class _Fp, class _A0,
3451 class _DecayFp = typename decay<_Fp>::type,
3452 class _DecayA0 = typename decay<_A0>::type,
3453 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
3454using __enable_if_bullet1 = typename enable_if
3455 <
3456 is_member_function_pointer<_DecayFp>::value
3457 && is_base_of<_ClassT, _DecayA0>::value
3458 >::type;
3459
3460template <class _Fp, class _A0,
3461 class _DecayFp = typename decay<_Fp>::type,
3462 class _DecayA0 = typename decay<_A0>::type>
3463using __enable_if_bullet2 = typename enable_if
3464 <
3465 is_member_function_pointer<_DecayFp>::value
3466 && __is_reference_wrapper<_DecayA0>::value
3467 >::type;
3468
3469template <class _Fp, class _A0,
3470 class _DecayFp = typename decay<_Fp>::type,
3471 class _DecayA0 = typename decay<_A0>::type,
3472 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
3473using __enable_if_bullet3 = typename enable_if
3474 <
3475 is_member_function_pointer<_DecayFp>::value
3476 && !is_base_of<_ClassT, _DecayA0>::value
3477 && !__is_reference_wrapper<_DecayA0>::value
3478 >::type;
3479
3480template <class _Fp, class _A0,
3481 class _DecayFp = typename decay<_Fp>::type,
3482 class _DecayA0 = typename decay<_A0>::type,
3483 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
3484using __enable_if_bullet4 = typename enable_if
3485 <
3486 is_member_object_pointer<_DecayFp>::value
3487 && is_base_of<_ClassT, _DecayA0>::value
3488 >::type;
3489
3490template <class _Fp, class _A0,
3491 class _DecayFp = typename decay<_Fp>::type,
3492 class _DecayA0 = typename decay<_A0>::type>
3493using __enable_if_bullet5 = typename enable_if
3494 <
3495 is_member_object_pointer<_DecayFp>::value
3496 && __is_reference_wrapper<_DecayA0>::value
3497 >::type;
3498
3499template <class _Fp, class _A0,
3500 class _DecayFp = typename decay<_Fp>::type,
3501 class _DecayA0 = typename decay<_A0>::type,
3502 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
3503using __enable_if_bullet6 = typename enable_if
3504 <
3505 is_member_object_pointer<_DecayFp>::value
3506 && !is_base_of<_ClassT, _DecayA0>::value
3507 && !__is_reference_wrapper<_DecayA0>::value
3508 >::type;
3509
3510// __invoke forward declarations
3511
3512// fall back - none of the bullets
3513
3514template <class ..._Args>
3515auto __invoke(__any, _Args&& ...__args) -> __nat;
3516
3517template <class ..._Args>
3518auto __invoke_constexpr(__any, _Args&& ...__args) -> __nat;
3519
3520// bullets 1, 2 and 3
3521
3522template <class _Fp, class _A0, class ..._Args,
3523 class = __enable_if_bullet1<_Fp, _A0>>
3524inline _LIBCPP_INLINE_VISIBILITY
3525_LIBCPP_CONSTEXPR_AFTER_CXX17 auto
3526__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
3527 noexcept(noexcept((static_cast<_A0&&>(__a0).*__f)(static_cast<_Args&&>(__args)...)))
3528 -> decltype( (static_cast<_A0&&>(__a0).*__f)(static_cast<_Args&&>(__args)...))
3529 { return (static_cast<_A0&&>(__a0).*__f)(static_cast<_Args&&>(__args)...); }
3530
3531template <class _Fp, class _A0, class ..._Args,
3532 class = __enable_if_bullet1<_Fp, _A0>>
3533inline _LIBCPP_INLINE_VISIBILITY
3534_LIBCPP_CONSTEXPR auto
3535__invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
3536 noexcept(noexcept((static_cast<_A0&&>(__a0).*__f)(static_cast<_Args&&>(__args)...)))
3537 -> decltype( (static_cast<_A0&&>(__a0).*__f)(static_cast<_Args&&>(__args)...))
3538 { return (static_cast<_A0&&>(__a0).*__f)(static_cast<_Args&&>(__args)...); }
3539
3540template <class _Fp, class _A0, class ..._Args,
3541 class = __enable_if_bullet2<_Fp, _A0>>
3542inline _LIBCPP_INLINE_VISIBILITY
3543_LIBCPP_CONSTEXPR_AFTER_CXX17 auto
3544__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
3545 noexcept(noexcept((__a0.get().*__f)(static_cast<_Args&&>(__args)...)))
3546 -> decltype( (__a0.get().*__f)(static_cast<_Args&&>(__args)...))
3547 { return (__a0.get().*__f)(static_cast<_Args&&>(__args)...); }
3548
3549template <class _Fp, class _A0, class ..._Args,
3550 class = __enable_if_bullet2<_Fp, _A0>>
3551inline _LIBCPP_INLINE_VISIBILITY
3552_LIBCPP_CONSTEXPR auto
3553__invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
3554 noexcept(noexcept((__a0.get().*__f)(static_cast<_Args&&>(__args)...)))
3555 -> decltype( (__a0.get().*__f)(static_cast<_Args&&>(__args)...))
3556 { return (__a0.get().*__f)(static_cast<_Args&&>(__args)...); }
3557
3558template <class _Fp, class _A0, class ..._Args,
3559 class = __enable_if_bullet3<_Fp, _A0>>
3560inline _LIBCPP_INLINE_VISIBILITY
3561_LIBCPP_CONSTEXPR_AFTER_CXX17 auto
3562__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
3563 noexcept(noexcept(((*static_cast<_A0&&>(__a0)).*__f)(static_cast<_Args&&>(__args)...)))
3564 -> decltype( ((*static_cast<_A0&&>(__a0)).*__f)(static_cast<_Args&&>(__args)...))
3565 { return ((*static_cast<_A0&&>(__a0)).*__f)(static_cast<_Args&&>(__args)...); }
3566
3567template <class _Fp, class _A0, class ..._Args,
3568 class = __enable_if_bullet3<_Fp, _A0>>
3569inline _LIBCPP_INLINE_VISIBILITY
3570_LIBCPP_CONSTEXPR auto
3571__invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
3572 noexcept(noexcept(((*static_cast<_A0&&>(__a0)).*__f)(static_cast<_Args&&>(__args)...)))
3573 -> decltype( ((*static_cast<_A0&&>(__a0)).*__f)(static_cast<_Args&&>(__args)...))
3574 { return ((*static_cast<_A0&&>(__a0)).*__f)(static_cast<_Args&&>(__args)...); }
3575
3576// bullets 4, 5 and 6
3577
3578template <class _Fp, class _A0,
3579 class = __enable_if_bullet4<_Fp, _A0>>
3580inline _LIBCPP_INLINE_VISIBILITY
3581_LIBCPP_CONSTEXPR_AFTER_CXX17 auto
3582__invoke(_Fp&& __f, _A0&& __a0)
3583 noexcept(noexcept(static_cast<_A0&&>(__a0).*__f))
3584 -> decltype( static_cast<_A0&&>(__a0).*__f)
3585 { return static_cast<_A0&&>(__a0).*__f; }
3586
3587template <class _Fp, class _A0,
3588 class = __enable_if_bullet4<_Fp, _A0>>
3589inline _LIBCPP_INLINE_VISIBILITY
3590_LIBCPP_CONSTEXPR auto
3591__invoke_constexpr(_Fp&& __f, _A0&& __a0)
3592 noexcept(noexcept(static_cast<_A0&&>(__a0).*__f))
3593 -> decltype( static_cast<_A0&&>(__a0).*__f)
3594 { return static_cast<_A0&&>(__a0).*__f; }
3595
3596template <class _Fp, class _A0,
3597 class = __enable_if_bullet5<_Fp, _A0>>
3598inline _LIBCPP_INLINE_VISIBILITY
3599_LIBCPP_CONSTEXPR_AFTER_CXX17 auto
3600__invoke(_Fp&& __f, _A0&& __a0)
3601 noexcept(noexcept(__a0.get().*__f))
3602 -> decltype( __a0.get().*__f)
3603 { return __a0.get().*__f; }
3604
3605template <class _Fp, class _A0,
3606 class = __enable_if_bullet5<_Fp, _A0>>
3607inline _LIBCPP_INLINE_VISIBILITY
3608_LIBCPP_CONSTEXPR auto
3609__invoke_constexpr(_Fp&& __f, _A0&& __a0)
3610 noexcept(noexcept(__a0.get().*__f))
3611 -> decltype( __a0.get().*__f)
3612 { return __a0.get().*__f; }
3613
3614template <class _Fp, class _A0,
3615 class = __enable_if_bullet6<_Fp, _A0>>
3616inline _LIBCPP_INLINE_VISIBILITY
3617_LIBCPP_CONSTEXPR_AFTER_CXX17 auto
3618__invoke(_Fp&& __f, _A0&& __a0)
3619 noexcept(noexcept((*static_cast<_A0&&>(__a0)).*__f))
3620 -> decltype( (*static_cast<_A0&&>(__a0)).*__f)
3621 { return (*static_cast<_A0&&>(__a0)).*__f; }
3622
3623template <class _Fp, class _A0,
3624 class = __enable_if_bullet6<_Fp, _A0>>
3625inline _LIBCPP_INLINE_VISIBILITY
3626_LIBCPP_CONSTEXPR auto
3627__invoke_constexpr(_Fp&& __f, _A0&& __a0)
3628 noexcept(noexcept((*static_cast<_A0&&>(__a0)).*__f))
3629 -> decltype( (*static_cast<_A0&&>(__a0)).*__f)
3630 { return (*static_cast<_A0&&>(__a0)).*__f; }
3631
3632// bullet 7
3633
3634template <class _Fp, class ..._Args>
3635inline _LIBCPP_INLINE_VISIBILITY
3636_LIBCPP_CONSTEXPR_AFTER_CXX17 auto
3637__invoke(_Fp&& __f, _Args&& ...__args)
3638 noexcept(noexcept(static_cast<_Fp&&>(__f)(static_cast<_Args&&>(__args)...)))
3639 -> decltype( static_cast<_Fp&&>(__f)(static_cast<_Args&&>(__args)...))
3640 { return static_cast<_Fp&&>(__f)(static_cast<_Args&&>(__args)...); }
3641
3642template <class _Fp, class ..._Args>
3643inline _LIBCPP_INLINE_VISIBILITY
3644_LIBCPP_CONSTEXPR auto
3645__invoke_constexpr(_Fp&& __f, _Args&& ...__args)
3646 noexcept(noexcept(static_cast<_Fp&&>(__f)(static_cast<_Args&&>(__args)...)))
3647 -> decltype( static_cast<_Fp&&>(__f)(static_cast<_Args&&>(__args)...))
3648 { return static_cast<_Fp&&>(__f)(static_cast<_Args&&>(__args)...); }
3649
3650// __invokable
3651template <class _Ret, class _Fp, class ..._Args>
3652struct __invokable_r
3653{
3654 template <class _XFp, class ..._XArgs>
3655 static auto __try_call(int) -> decltype(
3656 _VSTD::__invoke(declval<_XFp>(), declval<_XArgs>()...));
3657 template <class _XFp, class ..._XArgs>
3658 static __nat __try_call(...);
3659
3660 // FIXME: Check that _Ret, _Fp, and _Args... are all complete types, cv void,
3661 // or incomplete array types as required by the standard.
3662 using _Result = decltype(__try_call<_Fp, _Args...>(0));
3663
3664 using type =
3665 typename conditional<
3666 _IsNotSame<_Result, __nat>::value,
3667 typename conditional<
3668 is_void<_Ret>::value,
3669 true_type,
3670 is_convertible<_Result, _Ret>
3671 >::type,
3672 false_type
3673 >::type;
3674 static const bool value = type::value;
3675};
3676template <class _Fp, class ..._Args>
3677using __invokable = __invokable_r<void, _Fp, _Args...>;
3678
3679template <bool _IsInvokable, bool _IsCVVoid, class _Ret, class _Fp, class ..._Args>
3680struct __nothrow_invokable_r_imp {
3681 static const bool value = false;
3682};
3683
3684template <class _Ret, class _Fp, class ..._Args>
3685struct __nothrow_invokable_r_imp<true, false, _Ret, _Fp, _Args...>
3686{
3687 typedef __nothrow_invokable_r_imp _ThisT;
3688
3689 template <class _Tp>
3690 static void __test_noexcept(_Tp) noexcept;
3691
3692 static const bool value = noexcept(_ThisT::__test_noexcept<_Ret>(
3693 _VSTD::__invoke(declval<_Fp>(), declval<_Args>()...)));
3694};
3695
3696template <class _Ret, class _Fp, class ..._Args>
3697struct __nothrow_invokable_r_imp<true, true, _Ret, _Fp, _Args...>
3698{
3699 static const bool value = noexcept(
3700 _VSTD::__invoke(declval<_Fp>(), declval<_Args>()...));
3701};
3702
3703template <class _Ret, class _Fp, class ..._Args>
3704using __nothrow_invokable_r =
3705 __nothrow_invokable_r_imp<
3706 __invokable_r<_Ret, _Fp, _Args...>::value,
3707 is_void<_Ret>::value,
3708 _Ret, _Fp, _Args...
3709 >;
3710
3711template <class _Fp, class ..._Args>
3712using __nothrow_invokable =
3713 __nothrow_invokable_r_imp<
3714 __invokable<_Fp, _Args...>::value,
3715 true, void, _Fp, _Args...
3716 >;
3717
3718template <class _Fp, class ..._Args>
3719struct __invoke_of
3720 : public enable_if<
3721 __invokable<_Fp, _Args...>::value,
3722 typename __invokable_r<void, _Fp, _Args...>::_Result>
3723{
3724};
3725
3726#endif // _LIBCPP_CXX03_LANG
3727574
3728// result_of575// result_of
3729576
3730#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)577#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)
3731template <class _Callable> class _LIBCPP_DEPRECATED_IN_CXX17 result_of;578template <class _Callable> class _LIBCPP_DEPRECATED_IN_CXX17 result_of;
3732579
3733#ifndef _LIBCPP_CXX03_LANG
3734
3735template <class _Fp, class ..._Args>580template <class _Fp, class ..._Args>
3736class _LIBCPP_TEMPLATE_VIS result_of<_Fp(_Args...)>581class _LIBCPP_TEMPLATE_VIS result_of<_Fp(_Args...)>
3737 : public __invoke_of<_Fp, _Args...>582 : public __invoke_of<_Fp, _Args...>
3738{583{
3739};584};
3740585
3741#else // C++03
3742
3743template <class _Fn, bool, bool>
3744class __result_of
3745{
3746};
3747
3748template <class _Fn, class ..._Args>
3749class __result_of<_Fn(_Args...), true, false>
3750{
3751public:
3752 typedef decltype(declval<_Fn>()(declval<_Args>()...)) type;
3753};
3754
3755template <class _MP, class _Tp, bool _IsMemberFunctionPtr>
3756struct __result_of_mp;
3757
3758// member function pointer
3759
3760template <class _MP, class _Tp>
3761struct __result_of_mp<_MP, _Tp, true>
3762{
3763 using type = typename __member_pointer_traits<_MP>::_ReturnType;
3764};
3765
3766// member data pointer
3767
3768template <class _MP, class _Tp, bool>
3769struct __result_of_mdp;
3770
3771template <class _Rp, class _Class, class _Tp>
3772struct __result_of_mdp<_Rp _Class::*, _Tp, false>
3773{
3774 using type = typename __apply_cv<decltype(*declval<_Tp>()), _Rp>::type&;
3775};
3776
3777template <class _Rp, class _Class, class _Tp>
3778struct __result_of_mdp<_Rp _Class::*, _Tp, true>
3779{
3780 using type = typename __apply_cv<_Tp, _Rp>::type&;
3781};
3782
3783template <class _Rp, class _Class, class _Tp>
3784struct __result_of_mp<_Rp _Class::*, _Tp, false>
3785 : public __result_of_mdp<_Rp _Class::*, _Tp,
3786 is_base_of<_Class, typename remove_reference<_Tp>::type>::value>
3787{
3788};
3789
3790template <class _Fn, class _Tp>
3791class __result_of<_Fn(_Tp), false, true> // _Fn must be member pointer
3792 : public __result_of_mp<typename remove_reference<_Fn>::type,
3793 _Tp,
3794 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
3795{
3796};
3797
3798template <class _Fn, class _Tp, class ..._Args>
3799class __result_of<_Fn(_Tp, _Args...), false, true> // _Fn must be member pointer
3800 : public __result_of_mp<typename remove_reference<_Fn>::type,
3801 _Tp,
3802 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
3803{
3804};
3805
3806template <class _Fn, class ..._Args>
3807class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_Args...)>
3808 : public __result_of<_Fn(_Args...),
3809 is_class<typename remove_reference<_Fn>::type>::value ||
3810 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
3811 is_member_pointer<typename remove_reference<_Fn>::type>::value
3812 >
3813{
3814};
3815
3816#endif // C++03
3817
3818#if _LIBCPP_STD_VER > 11586#if _LIBCPP_STD_VER > 11
3819template <class _Tp> using result_of_t _LIBCPP_DEPRECATED_IN_CXX17 = typename result_of<_Tp>::type;587template <class _Tp> using result_of_t _LIBCPP_DEPRECATED_IN_CXX17 = typename result_of<_Tp>::type;
3820#endif // _LIBCPP_STD_VER > 11588#endif // _LIBCPP_STD_VER > 11
3821#endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)589#endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)
3822590
3823#if _LIBCPP_STD_VER > 14
3824
3825// invoke_result
3826
3827template <class _Fn, class... _Args>
3828struct _LIBCPP_TEMPLATE_VIS invoke_result
3829 : __invoke_of<_Fn, _Args...>
3830{
3831};
3832
3833template <class _Fn, class... _Args>
3834using invoke_result_t = typename invoke_result<_Fn, _Args...>::type;
3835
3836// is_invocable
3837
3838template <class _Fn, class ..._Args>
3839struct _LIBCPP_TEMPLATE_VIS is_invocable
3840 : integral_constant<bool, __invokable<_Fn, _Args...>::value> {};
3841
3842template <class _Ret, class _Fn, class ..._Args>
3843struct _LIBCPP_TEMPLATE_VIS is_invocable_r
3844 : integral_constant<bool, __invokable_r<_Ret, _Fn, _Args...>::value> {};
3845
3846template <class _Fn, class ..._Args>
3847inline constexpr bool is_invocable_v = is_invocable<_Fn, _Args...>::value;
3848
3849template <class _Ret, class _Fn, class ..._Args>
3850inline constexpr bool is_invocable_r_v = is_invocable_r<_Ret, _Fn, _Args...>::value;
3851
3852// is_nothrow_invocable
3853
3854template <class _Fn, class ..._Args>
3855struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable
3856 : integral_constant<bool, __nothrow_invokable<_Fn, _Args...>::value> {};
3857
3858template <class _Ret, class _Fn, class ..._Args>
3859struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable_r
3860 : integral_constant<bool, __nothrow_invokable_r<_Ret, _Fn, _Args...>::value> {};
3861
3862template <class _Fn, class ..._Args>
3863inline constexpr bool is_nothrow_invocable_v = is_nothrow_invocable<_Fn, _Args...>::value;
3864
3865template <class _Ret, class _Fn, class ..._Args>
3866inline constexpr bool is_nothrow_invocable_r_v = is_nothrow_invocable_r<_Ret, _Fn, _Args...>::value;
3867
3868#endif // _LIBCPP_STD_VER > 14
3869
3870// __swappable591// __swappable
3871592
3872template <class _Tp> struct __is_swappable;593template <class _Tp> struct __is_swappable;
...@@ -3999,24 +720,6 @@ inline constexpr bool is_nothrow_swappable_v = is_nothrow_swappable<_Tp>::value;...@@ -3999,24 +720,6 @@ inline constexpr bool is_nothrow_swappable_v = is_nothrow_swappable<_Tp>::value;
3999720
4000#endif // _LIBCPP_STD_VER > 14721#endif // _LIBCPP_STD_VER > 14
4001722
4002template <class _Tp, bool = is_enum<_Tp>::value> struct __underlying_type_impl;
4003
4004template <class _Tp>
4005struct __underlying_type_impl<_Tp, false> {};
4006
4007template <class _Tp>
4008struct __underlying_type_impl<_Tp, true>
4009{
4010 typedef __underlying_type(_Tp) type;
4011};
4012
4013template <class _Tp>
4014struct underlying_type : __underlying_type_impl<_Tp, is_enum<_Tp>::value> {};
4015
4016#if _LIBCPP_STD_VER > 11
4017template <class _Tp> using underlying_type_t = typename underlying_type<_Tp>::type;
4018#endif
4019
4020template <class _Tp, bool = is_enum<_Tp>::value>723template <class _Tp, bool = is_enum<_Tp>::value>
4021struct __sfinae_underlying_type724struct __sfinae_underlying_type
4022{725{
...@@ -4063,42 +766,6 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR...@@ -4063,42 +766,6 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
4063typename __sfinae_underlying_type<_Tp>::__promoted_type766typename __sfinae_underlying_type<_Tp>::__promoted_type
4064__convert_to_integral(_Tp __val) { return __val; }767__convert_to_integral(_Tp __val) { return __val; }
4065768
4066// is_scoped_enum [meta.unary.prop]
4067
4068#if _LIBCPP_STD_VER > 20
4069template <class _Tp, bool = is_enum_v<_Tp> >
4070struct __is_scoped_enum_helper : false_type {};
4071
4072template <class _Tp>
4073struct __is_scoped_enum_helper<_Tp, true>
4074 : public bool_constant<!is_convertible_v<_Tp, underlying_type_t<_Tp> > > {};
4075
4076template <class _Tp>
4077struct _LIBCPP_TEMPLATE_VIS is_scoped_enum
4078 : public __is_scoped_enum_helper<_Tp> {};
4079
4080template <class _Tp>
4081inline constexpr bool is_scoped_enum_v = is_scoped_enum<_Tp>::value;
4082#endif
4083
4084#if _LIBCPP_STD_VER > 14
4085
4086template <class... _Args>
4087struct conjunction : _And<_Args...> {};
4088template<class... _Args>
4089inline constexpr bool conjunction_v = conjunction<_Args...>::value;
4090
4091template <class... _Args>
4092struct disjunction : _Or<_Args...> {};
4093template<class... _Args>
4094inline constexpr bool disjunction_v = disjunction<_Args...>::value;
4095
4096template <class _Tp>
4097struct negation : _Not<_Tp> {};
4098template<class _Tp>
4099inline constexpr bool negation_v = negation<_Tp>::value;
4100#endif // _LIBCPP_STD_VER > 14
4101
4102// These traits are used in __tree and __hash_table769// These traits are used in __tree and __hash_table
4103struct __extract_key_fail_tag {};770struct __extract_key_fail_tag {};
4104struct __extract_key_self_tag {};771struct __extract_key_self_tag {};
...@@ -4129,26 +796,14 @@ template <class _ValTy, class _Key, class _RawValTy>...@@ -4129,26 +796,14 @@ template <class _ValTy, class _Key, class _RawValTy>
4129struct __can_extract_map_key<_ValTy, _Key, _Key, _RawValTy>796struct __can_extract_map_key<_ValTy, _Key, _Key, _RawValTy>
4130 : false_type {};797 : false_type {};
4131798
4132#if _LIBCPP_STD_VER > 17
4133_LIBCPP_INLINE_VISIBILITY
4134inline constexpr bool is_constant_evaluated() noexcept {
4135 return __builtin_is_constant_evaluated();
4136}
4137#endif
4138
4139inline _LIBCPP_CONSTEXPR
4140bool __libcpp_is_constant_evaluated() _NOEXCEPT { return __builtin_is_constant_evaluated(); }
4141
4142template <class _CharT>799template <class _CharT>
4143using _IsCharLikeType = _And<is_standard_layout<_CharT>, is_trivial<_CharT> >;800using _IsCharLikeType = _And<is_standard_layout<_CharT>, is_trivial<_CharT> >;
4144801
4145template<class _Tp>802template<class _Tp>
4146using __make_const_lvalue_ref = const typename remove_reference<_Tp>::type&;803using __make_const_lvalue_ref = const typename remove_reference<_Tp>::type&;
4147804
4148#if _LIBCPP_STD_VER > 17
4149template<bool _Const, class _Tp>805template<bool _Const, class _Tp>
4150using __maybe_const = conditional_t<_Const, const _Tp, _Tp>;806using __maybe_const = typename conditional<_Const, const _Tp, _Tp>::type;
4151#endif // _LIBCPP_STD_VER > 17
4152807
4153_LIBCPP_END_NAMESPACE_STD808_LIBCPP_END_NAMESPACE_STD
4154809
lib/libcxx/include/typeindex+12-4
...@@ -44,15 +44,23 @@ struct hash<type_index>...@@ -44,15 +44,23 @@ struct hash<type_index>
4444
45*/45*/
4646
47#include <__assert> // all public C++ headers provide the assertion handler
47#include <__config>48#include <__config>
48#include <__functional/unary_function.h>49#include <__functional/unary_function.h>
49#include <__functional_base>
50#include <compare>
51#include <typeinfo>50#include <typeinfo>
52#include <version>51#include <version>
5352
53#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
54# include <iosfwd>
55# include <new>
56# include <utility>
57#endif
58
59// standard-mandated includes
60#include <compare>
61
54#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)62#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
55#pragma GCC system_header63# pragma GCC system_header
56#endif64#endif
5765
58_LIBCPP_BEGIN_NAMESPACE_STD66_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -93,7 +101,7 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS hash;...@@ -93,7 +101,7 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS hash;
93101
94template <>102template <>
95struct _LIBCPP_TEMPLATE_VIS hash<type_index>103struct _LIBCPP_TEMPLATE_VIS hash<type_index>
96 : public unary_function<type_index, size_t>104 : public __unary_function<type_index, size_t>
97{105{
98 _LIBCPP_INLINE_VISIBILITY106 _LIBCPP_INLINE_VISIBILITY
99 size_t operator()(type_index __index) const _NOEXCEPT107 size_t operator()(type_index __index) const _NOEXCEPT
lib/libcxx/include/typeinfo+2-1
...@@ -56,6 +56,7 @@ public:...@@ -56,6 +56,7 @@ public:
5656
57*/57*/
5858
59#include <__assert> // all public C++ headers provide the assertion handler
59#include <__availability>60#include <__availability>
60#include <__config>61#include <__config>
61#include <cstddef>62#include <cstddef>
...@@ -68,7 +69,7 @@ public:...@@ -68,7 +69,7 @@ public:
68#endif69#endif
6970
70#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)71#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
71#pragma GCC system_header72# pragma GCC system_header
72#endif73#endif
7374
74#if defined(_LIBCPP_ABI_VCRUNTIME)75#if defined(_LIBCPP_ABI_VCRUNTIME)
lib/libcxx/include/uchar.h created+52
...@@ -0,0 +1,52 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP_UCHAR_H
11#define _LIBCPP_UCHAR_H
12
13/*
14 uchar.h synopsis // since C++11
15
16Macros:
17
18 __STDC_UTF_16__
19 __STDC_UTF_32__
20
21Types:
22
23 mbstate_t
24 size_t
25
26size_t mbrtoc16(char16_t* pc16, const char* s, size_t n, mbstate_t* ps);
27size_t c16rtomb(char* s, char16_t c16, mbstate_t* ps);
28size_t mbrtoc32(char32_t* pc32, const char* s, size_t n, mbstate_t* ps);
29size_t c32rtomb(char* s, char32_t c32, mbstate_t* ps);
30
31*/
32
33#include <__config>
34
35#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
36# pragma GCC system_header
37#endif
38
39#if !defined(_LIBCPP_CXX03_LANG)
40
41// Some platforms don't implement <uchar.h> and we don't want to give a hard
42// error on those platforms. When the platform doesn't provide <uchar.h>, at
43// least include <stddef.h> so we get the declaration for size_t.
44#if __has_include_next(<uchar.h>)
45# include_next <uchar.h>
46#else
47# include <stddef.h>
48#endif
49
50#endif // _LIBCPP_CXX03_LANG
51
52#endif // _LIBCPP_UCHAR_H
lib/libcxx/include/unordered_map+64-53
...@@ -514,23 +514,44 @@ template <class Key, class T, class Hash, class Pred, class Alloc>...@@ -514,23 +514,44 @@ template <class Key, class T, class Hash, class Pred, class Alloc>
514514
515*/515*/
516516
517#include <__algorithm/is_permutation.h>
518#include <__assert> // all public C++ headers provide the assertion handler
517#include <__config>519#include <__config>
518#include <__debug>520#include <__debug>
519#include <__functional/is_transparent.h>521#include <__functional/is_transparent.h>
522#include <__functional/operations.h>
520#include <__hash_table>523#include <__hash_table>
524#include <__iterator/distance.h>
525#include <__iterator/erase_if_container.h>
521#include <__iterator/iterator_traits.h>526#include <__iterator/iterator_traits.h>
522#include <__memory/addressof.h>527#include <__memory/addressof.h>
523#include <__node_handle>528#include <__node_handle>
524#include <__utility/forward.h>529#include <__utility/forward.h>
525#include <compare>
526#include <functional>
527#include <iterator> // __libcpp_erase_if_container
528#include <stdexcept>530#include <stdexcept>
529#include <tuple>531#include <tuple>
530#include <version>532#include <version>
531533
534#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
535# include <algorithm>
536# include <bit>
537# include <iterator>
538#endif
539
540// standard-mandated includes
541
542// [iterator.range]
543#include <__iterator/access.h>
544#include <__iterator/data.h>
545#include <__iterator/empty.h>
546#include <__iterator/reverse_access.h>
547#include <__iterator/size.h>
548
549// [unord.map.syn]
550#include <compare>
551#include <initializer_list>
552
532#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)553#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
533#pragma GCC system_header554# pragma GCC system_header
534#endif555#endif
535556
536_LIBCPP_BEGIN_NAMESPACE_STD557_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -855,9 +876,7 @@ public:...@@ -855,9 +876,7 @@ public:
855 }876 }
856877
857 template <class _ValueTp,878 template <class _ValueTp,
858 class = typename enable_if<879 class = __enable_if_t<__is_same_uncvref<_ValueTp, value_type>::value>
859 __is_same_uncvref<_ValueTp, value_type>::value
860 >::type
861 >880 >
862 _LIBCPP_INLINE_VISIBILITY881 _LIBCPP_INLINE_VISIBILITY
863 __hash_value_type& operator=(_ValueTp&& __v)882 __hash_value_type& operator=(_ValueTp&& __v)
...@@ -1012,9 +1031,9 @@ public:...@@ -1012,9 +1031,9 @@ public:
1012 // types1031 // types
1013 typedef _Key key_type;1032 typedef _Key key_type;
1014 typedef _Tp mapped_type;1033 typedef _Tp mapped_type;
1015 typedef __identity_t<_Hash> hasher;1034 typedef __type_identity_t<_Hash> hasher;
1016 typedef __identity_t<_Pred> key_equal;1035 typedef __type_identity_t<_Pred> key_equal;
1017 typedef __identity_t<_Alloc> allocator_type;1036 typedef __type_identity_t<_Alloc> allocator_type;
1018 typedef pair<const key_type, mapped_type> value_type;1037 typedef pair<const key_type, mapped_type> value_type;
1019 typedef value_type& reference;1038 typedef value_type& reference;
1020 typedef const value_type& const_reference;1039 typedef const value_type& const_reference;
...@@ -1216,13 +1235,13 @@ public:...@@ -1216,13 +1235,13 @@ public:
1216 }1235 }
12171236
1218 template <class _Pp,1237 template <class _Pp,
1219 class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>1238 class = __enable_if_t<is_constructible<value_type, _Pp>::value> >
1220 _LIBCPP_INLINE_VISIBILITY1239 _LIBCPP_INLINE_VISIBILITY
1221 pair<iterator, bool> insert(_Pp&& __x)1240 pair<iterator, bool> insert(_Pp&& __x)
1222 {return __table_.__insert_unique(_VSTD::forward<_Pp>(__x));}1241 {return __table_.__insert_unique(_VSTD::forward<_Pp>(__x));}
12231242
1224 template <class _Pp,1243 template <class _Pp,
1225 class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>1244 class = __enable_if_t<is_constructible<value_type, _Pp>::value> >
1226 _LIBCPP_INLINE_VISIBILITY1245 _LIBCPP_INLINE_VISIBILITY
1227 iterator insert(const_iterator __p, _Pp&& __x)1246 iterator insert(const_iterator __p, _Pp&& __x)
1228 {1247 {
...@@ -1506,11 +1525,11 @@ public:...@@ -1506,11 +1525,11 @@ public:
1506 _LIBCPP_INLINE_VISIBILITY1525 _LIBCPP_INLINE_VISIBILITY
1507 void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);}1526 void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);}
1508 _LIBCPP_INLINE_VISIBILITY1527 _LIBCPP_INLINE_VISIBILITY
1509 void rehash(size_type __n) {__table_.rehash(__n);}1528 void rehash(size_type __n) {__table_.__rehash_unique(__n);}
1510 _LIBCPP_INLINE_VISIBILITY1529 _LIBCPP_INLINE_VISIBILITY
1511 void reserve(size_type __n) {__table_.reserve(__n);}1530 void reserve(size_type __n) {__table_.__reserve_unique(__n);}
15121531
1513#if _LIBCPP_DEBUG_LEVEL == 21532#ifdef _LIBCPP_ENABLE_DEBUG_MODE
15141533
1515 bool __dereferenceable(const const_iterator* __i) const1534 bool __dereferenceable(const const_iterator* __i) const
1516 {return __table_.__dereferenceable(_VSTD::addressof(__i->__i_));}1535 {return __table_.__dereferenceable(_VSTD::addressof(__i->__i_));}
...@@ -1521,7 +1540,7 @@ public:...@@ -1521,7 +1540,7 @@ public:
1521 bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const1540 bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const
1522 {return __table_.__addable(_VSTD::addressof(__i->__i_), __n);}1541 {return __table_.__addable(_VSTD::addressof(__i->__i_), __n);}
15231542
1524#endif // _LIBCPP_DEBUG_LEVEL == 21543#endif // _LIBCPP_ENABLE_DEBUG_MODE
15251544
1526private:1545private:
15271546
...@@ -1607,7 +1626,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(...@@ -1607,7 +1626,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1607 : __table_(__hf, __eql)1626 : __table_(__hf, __eql)
1608{1627{
1609 _VSTD::__debug_db_insert_c(this);1628 _VSTD::__debug_db_insert_c(this);
1610 __table_.rehash(__n);1629 __table_.__rehash_unique(__n);
1611}1630}
16121631
1613template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>1632template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
...@@ -1617,7 +1636,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(...@@ -1617,7 +1636,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1617 : __table_(__hf, __eql, typename __table::allocator_type(__a))1636 : __table_(__hf, __eql, typename __table::allocator_type(__a))
1618{1637{
1619 _VSTD::__debug_db_insert_c(this);1638 _VSTD::__debug_db_insert_c(this);
1620 __table_.rehash(__n);1639 __table_.__rehash_unique(__n);
1621}1640}
16221641
1623template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>1642template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
...@@ -1646,7 +1665,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(...@@ -1646,7 +1665,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1646 : __table_(__hf, __eql)1665 : __table_(__hf, __eql)
1647{1666{
1648 _VSTD::__debug_db_insert_c(this);1667 _VSTD::__debug_db_insert_c(this);
1649 __table_.rehash(__n);1668 __table_.__rehash_unique(__n);
1650 insert(__first, __last);1669 insert(__first, __last);
1651}1670}
16521671
...@@ -1658,7 +1677,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(...@@ -1658,7 +1677,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1658 : __table_(__hf, __eql, typename __table::allocator_type(__a))1677 : __table_(__hf, __eql, typename __table::allocator_type(__a))
1659{1678{
1660 _VSTD::__debug_db_insert_c(this);1679 _VSTD::__debug_db_insert_c(this);
1661 __table_.rehash(__n);1680 __table_.__rehash_unique(__n);
1662 insert(__first, __last);1681 insert(__first, __last);
1663}1682}
16641683
...@@ -1668,7 +1687,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(...@@ -1668,7 +1687,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1668 : __table_(__u.__table_)1687 : __table_(__u.__table_)
1669{1688{
1670 _VSTD::__debug_db_insert_c(this);1689 _VSTD::__debug_db_insert_c(this);
1671 __table_.rehash(__u.bucket_count());1690 __table_.__rehash_unique(__u.bucket_count());
1672 insert(__u.begin(), __u.end());1691 insert(__u.begin(), __u.end());
1673}1692}
16741693
...@@ -1678,7 +1697,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(...@@ -1678,7 +1697,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1678 : __table_(__u.__table_, typename __table::allocator_type(__a))1697 : __table_(__u.__table_, typename __table::allocator_type(__a))
1679{1698{
1680 _VSTD::__debug_db_insert_c(this);1699 _VSTD::__debug_db_insert_c(this);
1681 __table_.rehash(__u.bucket_count());1700 __table_.__rehash_unique(__u.bucket_count());
1682 insert(__u.begin(), __u.end());1701 insert(__u.begin(), __u.end());
1683}1702}
16841703
...@@ -1692,9 +1711,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(...@@ -1692,9 +1711,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1692 : __table_(_VSTD::move(__u.__table_))1711 : __table_(_VSTD::move(__u.__table_))
1693{1712{
1694 _VSTD::__debug_db_insert_c(this);1713 _VSTD::__debug_db_insert_c(this);
1695#if _LIBCPP_DEBUG_LEVEL == 21714 std::__debug_db_swap(this, std::addressof(__u));
1696 __get_db()->swap(this, _VSTD::addressof(__u));
1697#endif
1698}1715}
16991716
1700template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>1717template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
...@@ -1711,10 +1728,8 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(...@@ -1711,10 +1728,8 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1711 __u.__table_.remove((__i++).__i_)->__value_.__move());1728 __u.__table_.remove((__i++).__i_)->__value_.__move());
1712 }1729 }
1713 }1730 }
1714#if _LIBCPP_DEBUG_LEVEL == 2
1715 else1731 else
1716 __get_db()->swap(this, _VSTD::addressof(__u));1732 std::__debug_db_swap(this, std::addressof(__u));
1717#endif
1718}1733}
17191734
1720template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>1735template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
...@@ -1732,7 +1747,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(...@@ -1732,7 +1747,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1732 : __table_(__hf, __eql)1747 : __table_(__hf, __eql)
1733{1748{
1734 _VSTD::__debug_db_insert_c(this);1749 _VSTD::__debug_db_insert_c(this);
1735 __table_.rehash(__n);1750 __table_.__rehash_unique(__n);
1736 insert(__il.begin(), __il.end());1751 insert(__il.begin(), __il.end());
1737}1752}
17381753
...@@ -1743,7 +1758,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(...@@ -1743,7 +1758,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1743 : __table_(__hf, __eql, typename __table::allocator_type(__a))1758 : __table_(__hf, __eql, typename __table::allocator_type(__a))
1744{1759{
1745 _VSTD::__debug_db_insert_c(this);1760 _VSTD::__debug_db_insert_c(this);
1746 __table_.rehash(__n);1761 __table_.__rehash_unique(__n);
1747 insert(__il.begin(), __il.end());1762 insert(__il.begin(), __il.end());
1748}1763}
17491764
...@@ -1906,9 +1921,9 @@ public:...@@ -1906,9 +1921,9 @@ public:
1906 // types1921 // types
1907 typedef _Key key_type;1922 typedef _Key key_type;
1908 typedef _Tp mapped_type;1923 typedef _Tp mapped_type;
1909 typedef __identity_t<_Hash> hasher;1924 typedef __type_identity_t<_Hash> hasher;
1910 typedef __identity_t<_Pred> key_equal;1925 typedef __type_identity_t<_Pred> key_equal;
1911 typedef __identity_t<_Alloc> allocator_type;1926 typedef __type_identity_t<_Alloc> allocator_type;
1912 typedef pair<const key_type, mapped_type> value_type;1927 typedef pair<const key_type, mapped_type> value_type;
1913 typedef value_type& reference;1928 typedef value_type& reference;
1914 typedef const value_type& const_reference;1929 typedef const value_type& const_reference;
...@@ -2097,13 +2112,13 @@ public:...@@ -2097,13 +2112,13 @@ public:
2097 {return __table_.__insert_multi(__p.__i_, _VSTD::move(__x));}2112 {return __table_.__insert_multi(__p.__i_, _VSTD::move(__x));}
20982113
2099 template <class _Pp,2114 template <class _Pp,
2100 class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>2115 class = __enable_if_t<is_constructible<value_type, _Pp>::value> >
2101 _LIBCPP_INLINE_VISIBILITY2116 _LIBCPP_INLINE_VISIBILITY
2102 iterator insert(_Pp&& __x)2117 iterator insert(_Pp&& __x)
2103 {return __table_.__insert_multi(_VSTD::forward<_Pp>(__x));}2118 {return __table_.__insert_multi(_VSTD::forward<_Pp>(__x));}
21042119
2105 template <class _Pp,2120 template <class _Pp,
2106 class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>2121 class = __enable_if_t<is_constructible<value_type, _Pp>::value> >
2107 _LIBCPP_INLINE_VISIBILITY2122 _LIBCPP_INLINE_VISIBILITY
2108 iterator insert(const_iterator __p, _Pp&& __x)2123 iterator insert(const_iterator __p, _Pp&& __x)
2109 {return __table_.__insert_multi(__p.__i_, _VSTD::forward<_Pp>(__x));}2124 {return __table_.__insert_multi(__p.__i_, _VSTD::forward<_Pp>(__x));}
...@@ -2286,11 +2301,11 @@ public:...@@ -2286,11 +2301,11 @@ public:
2286 _LIBCPP_INLINE_VISIBILITY2301 _LIBCPP_INLINE_VISIBILITY
2287 void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);}2302 void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);}
2288 _LIBCPP_INLINE_VISIBILITY2303 _LIBCPP_INLINE_VISIBILITY
2289 void rehash(size_type __n) {__table_.rehash(__n);}2304 void rehash(size_type __n) {__table_.__rehash_multi(__n);}
2290 _LIBCPP_INLINE_VISIBILITY2305 _LIBCPP_INLINE_VISIBILITY
2291 void reserve(size_type __n) {__table_.reserve(__n);}2306 void reserve(size_type __n) {__table_.__reserve_multi(__n);}
22922307
2293#if _LIBCPP_DEBUG_LEVEL == 22308#ifdef _LIBCPP_ENABLE_DEBUG_MODE
22942309
2295 bool __dereferenceable(const const_iterator* __i) const2310 bool __dereferenceable(const const_iterator* __i) const
2296 {return __table_.__dereferenceable(_VSTD::addressof(__i->__i_));}2311 {return __table_.__dereferenceable(_VSTD::addressof(__i->__i_));}
...@@ -2301,7 +2316,7 @@ public:...@@ -2301,7 +2316,7 @@ public:
2301 bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const2316 bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const
2302 {return __table_.__addable(_VSTD::addressof(__i->__i_), __n);}2317 {return __table_.__addable(_VSTD::addressof(__i->__i_), __n);}
23032318
2304#endif // _LIBCPP_DEBUG_LEVEL == 22319#endif // _LIBCPP_ENABLE_DEBUG_MODE
23052320
23062321
2307};2322};
...@@ -2383,7 +2398,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(...@@ -2383,7 +2398,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
2383 : __table_(__hf, __eql)2398 : __table_(__hf, __eql)
2384{2399{
2385 _VSTD::__debug_db_insert_c(this);2400 _VSTD::__debug_db_insert_c(this);
2386 __table_.rehash(__n);2401 __table_.__rehash_multi(__n);
2387}2402}
23882403
2389template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>2404template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
...@@ -2393,7 +2408,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(...@@ -2393,7 +2408,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
2393 : __table_(__hf, __eql, typename __table::allocator_type(__a))2408 : __table_(__hf, __eql, typename __table::allocator_type(__a))
2394{2409{
2395 _VSTD::__debug_db_insert_c(this);2410 _VSTD::__debug_db_insert_c(this);
2396 __table_.rehash(__n);2411 __table_.__rehash_multi(__n);
2397}2412}
23982413
2399template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>2414template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
...@@ -2413,7 +2428,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(...@@ -2413,7 +2428,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
2413 : __table_(__hf, __eql)2428 : __table_(__hf, __eql)
2414{2429{
2415 _VSTD::__debug_db_insert_c(this);2430 _VSTD::__debug_db_insert_c(this);
2416 __table_.rehash(__n);2431 __table_.__rehash_multi(__n);
2417 insert(__first, __last);2432 insert(__first, __last);
2418}2433}
24192434
...@@ -2425,7 +2440,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(...@@ -2425,7 +2440,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
2425 : __table_(__hf, __eql, typename __table::allocator_type(__a))2440 : __table_(__hf, __eql, typename __table::allocator_type(__a))
2426{2441{
2427 _VSTD::__debug_db_insert_c(this);2442 _VSTD::__debug_db_insert_c(this);
2428 __table_.rehash(__n);2443 __table_.__rehash_multi(__n);
2429 insert(__first, __last);2444 insert(__first, __last);
2430}2445}
24312446
...@@ -2444,7 +2459,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(...@@ -2444,7 +2459,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
2444 : __table_(__u.__table_)2459 : __table_(__u.__table_)
2445{2460{
2446 _VSTD::__debug_db_insert_c(this);2461 _VSTD::__debug_db_insert_c(this);
2447 __table_.rehash(__u.bucket_count());2462 __table_.__rehash_multi(__u.bucket_count());
2448 insert(__u.begin(), __u.end());2463 insert(__u.begin(), __u.end());
2449}2464}
24502465
...@@ -2454,7 +2469,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(...@@ -2454,7 +2469,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
2454 : __table_(__u.__table_, typename __table::allocator_type(__a))2469 : __table_(__u.__table_, typename __table::allocator_type(__a))
2455{2470{
2456 _VSTD::__debug_db_insert_c(this);2471 _VSTD::__debug_db_insert_c(this);
2457 __table_.rehash(__u.bucket_count());2472 __table_.__rehash_multi(__u.bucket_count());
2458 insert(__u.begin(), __u.end());2473 insert(__u.begin(), __u.end());
2459}2474}
24602475
...@@ -2468,9 +2483,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(...@@ -2468,9 +2483,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
2468 : __table_(_VSTD::move(__u.__table_))2483 : __table_(_VSTD::move(__u.__table_))
2469{2484{
2470 _VSTD::__debug_db_insert_c(this);2485 _VSTD::__debug_db_insert_c(this);
2471#if _LIBCPP_DEBUG_LEVEL == 22486 std::__debug_db_swap(this, std::addressof(__u));
2472 __get_db()->swap(this, _VSTD::addressof(__u));
2473#endif
2474}2487}
24752488
2476template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>2489template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
...@@ -2488,10 +2501,8 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(...@@ -2488,10 +2501,8 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
2488 __u.__table_.remove((__i++).__i_)->__value_.__move());2501 __u.__table_.remove((__i++).__i_)->__value_.__move());
2489 }2502 }
2490 }2503 }
2491#if _LIBCPP_DEBUG_LEVEL == 2
2492 else2504 else
2493 __get_db()->swap(this, _VSTD::addressof(__u));2505 std::__debug_db_swap(this, std::addressof(__u));
2494#endif
2495}2506}
24962507
2497template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>2508template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
...@@ -2509,7 +2520,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(...@@ -2509,7 +2520,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
2509 : __table_(__hf, __eql)2520 : __table_(__hf, __eql)
2510{2521{
2511 _VSTD::__debug_db_insert_c(this);2522 _VSTD::__debug_db_insert_c(this);
2512 __table_.rehash(__n);2523 __table_.__rehash_multi(__n);
2513 insert(__il.begin(), __il.end());2524 insert(__il.begin(), __il.end());
2514}2525}
25152526
...@@ -2520,7 +2531,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(...@@ -2520,7 +2531,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
2520 : __table_(__hf, __eql, typename __table::allocator_type(__a))2531 : __table_(__hf, __eql, typename __table::allocator_type(__a))
2521{2532{
2522 _VSTD::__debug_db_insert_c(this);2533 _VSTD::__debug_db_insert_c(this);
2523 __table_.rehash(__n);2534 __table_.__rehash_multi(__n);
2524 insert(__il.begin(), __il.end());2535 insert(__il.begin(), __il.end());
2525}2536}
25262537
lib/libcxx/include/unordered_set+82-83
...@@ -459,20 +459,41 @@ template <class Value, class Hash, class Pred, class Alloc>...@@ -459,20 +459,41 @@ template <class Value, class Hash, class Pred, class Alloc>
459459
460*/460*/
461461
462#include <__algorithm/is_permutation.h>
463#include <__assert> // all public C++ headers provide the assertion handler
462#include <__config>464#include <__config>
463#include <__debug>465#include <__debug>
464#include <__functional/is_transparent.h>466#include <__functional/is_transparent.h>
467#include <__functional/operations.h>
465#include <__hash_table>468#include <__hash_table>
469#include <__iterator/distance.h>
470#include <__iterator/erase_if_container.h>
471#include <__iterator/iterator_traits.h>
466#include <__memory/addressof.h>472#include <__memory/addressof.h>
467#include <__node_handle>473#include <__node_handle>
468#include <__utility/forward.h>474#include <__utility/forward.h>
469#include <compare>
470#include <functional>
471#include <iterator> // __libcpp_erase_if_container
472#include <version>475#include <version>
473476
477#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
478# include <functional>
479# include <iterator>
480#endif
481
482// standard-mandated includes
483
484// [iterator.range]
485#include <__iterator/access.h>
486#include <__iterator/data.h>
487#include <__iterator/empty.h>
488#include <__iterator/reverse_access.h>
489#include <__iterator/size.h>
490
491// [unord.set.syn]
492#include <compare>
493#include <initializer_list>
494
474#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)495#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
475#pragma GCC system_header496# pragma GCC system_header
476#endif497#endif
477498
478_LIBCPP_BEGIN_NAMESPACE_STD499_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -488,9 +509,9 @@ public:...@@ -488,9 +509,9 @@ public:
488 // types509 // types
489 typedef _Value key_type;510 typedef _Value key_type;
490 typedef key_type value_type;511 typedef key_type value_type;
491 typedef __identity_t<_Hash> hasher;512 typedef __type_identity_t<_Hash> hasher;
492 typedef __identity_t<_Pred> key_equal;513 typedef __type_identity_t<_Pred> key_equal;
493 typedef __identity_t<_Alloc> allocator_type;514 typedef __type_identity_t<_Alloc> allocator_type;
494 typedef value_type& reference;515 typedef value_type& reference;
495 typedef const value_type& const_reference;516 typedef const value_type& const_reference;
496 static_assert((is_same<value_type, typename allocator_type::value_type>::value),517 static_assert((is_same<value_type, typename allocator_type::value_type>::value),
...@@ -637,36 +658,27 @@ public:...@@ -637,36 +658,27 @@ public:
637 pair<iterator, bool> emplace(_Args&&... __args)658 pair<iterator, bool> emplace(_Args&&... __args)
638 {return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...);}659 {return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...);}
639 template <class... _Args>660 template <class... _Args>
640 _LIBCPP_INLINE_VISIBILITY661 _LIBCPP_INLINE_VISIBILITY
641#if _LIBCPP_DEBUG_LEVEL == 2662 iterator emplace_hint(const_iterator __p, _Args&&... __args) {
642 iterator emplace_hint(const_iterator __p, _Args&&... __args)663 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(std::addressof(__p)) == this,
643 {664 "unordered_set::emplace_hint(const_iterator, args...) called with an iterator not"
644 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this,665 " referring to this unordered_set");
645 "unordered_set::emplace_hint(const_iterator, args...) called with an iterator not"666 (void)__p;
646 " referring to this unordered_set");667 return __table_.__emplace_unique(std::forward<_Args>(__args)...).first;
647 return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...).first;668 }
648 }
649#else
650 iterator emplace_hint(const_iterator, _Args&&... __args)
651 {return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...).first;}
652#endif
653669
654 _LIBCPP_INLINE_VISIBILITY670 _LIBCPP_INLINE_VISIBILITY
655 pair<iterator, bool> insert(value_type&& __x)671 pair<iterator, bool> insert(value_type&& __x)
656 {return __table_.__insert_unique(_VSTD::move(__x));}672 {return __table_.__insert_unique(_VSTD::move(__x));}
657 _LIBCPP_INLINE_VISIBILITY673 _LIBCPP_INLINE_VISIBILITY
658#if _LIBCPP_DEBUG_LEVEL == 2674 iterator insert(const_iterator __p, value_type&& __x) {
659 iterator insert(const_iterator __p, value_type&& __x)675 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(std::addressof(__p)) == this,
660 {676 "unordered_set::insert(const_iterator, value_type&&) called with an iterator not"
661 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this,677 " referring to this unordered_set");
662 "unordered_set::insert(const_iterator, value_type&&) called with an iterator not"678 (void)__p;
663 " referring to this unordered_set");679 return insert(std::move(__x)).first;
664 return insert(_VSTD::move(__x)).first;680 }
665 }681
666#else
667 iterator insert(const_iterator, value_type&& __x)
668 {return insert(_VSTD::move(__x)).first;}
669#endif
670 _LIBCPP_INLINE_VISIBILITY682 _LIBCPP_INLINE_VISIBILITY
671 void insert(initializer_list<value_type> __il)683 void insert(initializer_list<value_type> __il)
672 {insert(__il.begin(), __il.end());}684 {insert(__il.begin(), __il.end());}
...@@ -676,18 +688,13 @@ public:...@@ -676,18 +688,13 @@ public:
676 {return __table_.__insert_unique(__x);}688 {return __table_.__insert_unique(__x);}
677689
678 _LIBCPP_INLINE_VISIBILITY690 _LIBCPP_INLINE_VISIBILITY
679#if _LIBCPP_DEBUG_LEVEL == 2691 iterator insert(const_iterator __p, const value_type& __x) {
680 iterator insert(const_iterator __p, const value_type& __x)692 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(std::addressof(__p)) == this,
681 {693 "unordered_set::insert(const_iterator, const value_type&) called with an iterator not"
682 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this,694 " referring to this unordered_set");
683 "unordered_set::insert(const_iterator, const value_type&) called with an iterator not"695 (void)__p;
684 " referring to this unordered_set");696 return insert(__x).first;
685 return insert(__x).first;697 }
686 }
687#else
688 iterator insert(const_iterator, const value_type& __x)
689 {return insert(__x).first;}
690#endif
691 template <class _InputIterator>698 template <class _InputIterator>
692 _LIBCPP_INLINE_VISIBILITY699 _LIBCPP_INLINE_VISIBILITY
693 void insert(_InputIterator __first, _InputIterator __last);700 void insert(_InputIterator __first, _InputIterator __last);
...@@ -851,11 +858,11 @@ public:...@@ -851,11 +858,11 @@ public:
851 _LIBCPP_INLINE_VISIBILITY858 _LIBCPP_INLINE_VISIBILITY
852 void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);}859 void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);}
853 _LIBCPP_INLINE_VISIBILITY860 _LIBCPP_INLINE_VISIBILITY
854 void rehash(size_type __n) {__table_.rehash(__n);}861 void rehash(size_type __n) {__table_.__rehash_unique(__n);}
855 _LIBCPP_INLINE_VISIBILITY862 _LIBCPP_INLINE_VISIBILITY
856 void reserve(size_type __n) {__table_.reserve(__n);}863 void reserve(size_type __n) {__table_.__reserve_unique(__n);}
857864
858#if _LIBCPP_DEBUG_LEVEL == 2865#ifdef _LIBCPP_ENABLE_DEBUG_MODE
859866
860 bool __dereferenceable(const const_iterator* __i) const867 bool __dereferenceable(const const_iterator* __i) const
861 {return __table_.__dereferenceable(__i);}868 {return __table_.__dereferenceable(__i);}
...@@ -866,7 +873,7 @@ public:...@@ -866,7 +873,7 @@ public:
866 bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const873 bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const
867 {return __table_.__addable(__i, __n);}874 {return __table_.__addable(__i, __n);}
868875
869#endif // _LIBCPP_DEBUG_LEVEL == 2876#endif // _LIBCPP_ENABLE_DEBUG_MODE
870877
871};878};
872879
...@@ -935,7 +942,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(size_type __n,...@@ -935,7 +942,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(size_type __n,
935 : __table_(__hf, __eql)942 : __table_(__hf, __eql)
936{943{
937 _VSTD::__debug_db_insert_c(this);944 _VSTD::__debug_db_insert_c(this);
938 __table_.rehash(__n);945 __table_.__rehash_unique(__n);
939}946}
940947
941template <class _Value, class _Hash, class _Pred, class _Alloc>948template <class _Value, class _Hash, class _Pred, class _Alloc>
...@@ -944,7 +951,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(size_type __n,...@@ -944,7 +951,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(size_type __n,
944 : __table_(__hf, __eql, __a)951 : __table_(__hf, __eql, __a)
945{952{
946 _VSTD::__debug_db_insert_c(this);953 _VSTD::__debug_db_insert_c(this);
947 __table_.rehash(__n);954 __table_.__rehash_unique(__n);
948}955}
949956
950template <class _Value, class _Hash, class _Pred, class _Alloc>957template <class _Value, class _Hash, class _Pred, class _Alloc>
...@@ -964,7 +971,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(...@@ -964,7 +971,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
964 : __table_(__hf, __eql)971 : __table_(__hf, __eql)
965{972{
966 _VSTD::__debug_db_insert_c(this);973 _VSTD::__debug_db_insert_c(this);
967 __table_.rehash(__n);974 __table_.__rehash_unique(__n);
968 insert(__first, __last);975 insert(__first, __last);
969}976}
970977
...@@ -976,7 +983,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(...@@ -976,7 +983,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
976 : __table_(__hf, __eql, __a)983 : __table_(__hf, __eql, __a)
977{984{
978 _VSTD::__debug_db_insert_c(this);985 _VSTD::__debug_db_insert_c(this);
979 __table_.rehash(__n);986 __table_.__rehash_unique(__n);
980 insert(__first, __last);987 insert(__first, __last);
981}988}
982989
...@@ -995,7 +1002,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(...@@ -995,7 +1002,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
995 : __table_(__u.__table_)1002 : __table_(__u.__table_)
996{1003{
997 _VSTD::__debug_db_insert_c(this);1004 _VSTD::__debug_db_insert_c(this);
998 __table_.rehash(__u.bucket_count());1005 __table_.__rehash_unique(__u.bucket_count());
999 insert(__u.begin(), __u.end());1006 insert(__u.begin(), __u.end());
1000}1007}
10011008
...@@ -1005,7 +1012,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(...@@ -1005,7 +1012,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
1005 : __table_(__u.__table_, __a)1012 : __table_(__u.__table_, __a)
1006{1013{
1007 _VSTD::__debug_db_insert_c(this);1014 _VSTD::__debug_db_insert_c(this);
1008 __table_.rehash(__u.bucket_count());1015 __table_.__rehash_unique(__u.bucket_count());
1009 insert(__u.begin(), __u.end());1016 insert(__u.begin(), __u.end());
1010}1017}
10111018
...@@ -1019,9 +1026,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(...@@ -1019,9 +1026,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
1019 : __table_(_VSTD::move(__u.__table_))1026 : __table_(_VSTD::move(__u.__table_))
1020{1027{
1021 _VSTD::__debug_db_insert_c(this);1028 _VSTD::__debug_db_insert_c(this);
1022#if _LIBCPP_DEBUG_LEVEL == 21029 std::__debug_db_swap(this, std::addressof(__u));
1023 __get_db()->swap(this, _VSTD::addressof(__u));
1024#endif
1025}1030}
10261031
1027template <class _Value, class _Hash, class _Pred, class _Alloc>1032template <class _Value, class _Hash, class _Pred, class _Alloc>
...@@ -1036,10 +1041,8 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(...@@ -1036,10 +1041,8 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
1036 while (__u.size() != 0)1041 while (__u.size() != 0)
1037 __table_.__insert_unique(_VSTD::move(__u.__table_.remove(__i++)->__value_));1042 __table_.__insert_unique(_VSTD::move(__u.__table_.remove(__i++)->__value_));
1038 }1043 }
1039#if _LIBCPP_DEBUG_LEVEL == 2
1040 else1044 else
1041 __get_db()->swap(this, _VSTD::addressof(__u));1045 std::__debug_db_swap(this, std::addressof(__u));
1042#endif
1043}1046}
10441047
1045template <class _Value, class _Hash, class _Pred, class _Alloc>1048template <class _Value, class _Hash, class _Pred, class _Alloc>
...@@ -1057,7 +1060,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(...@@ -1057,7 +1060,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
1057 : __table_(__hf, __eql)1060 : __table_(__hf, __eql)
1058{1061{
1059 _VSTD::__debug_db_insert_c(this);1062 _VSTD::__debug_db_insert_c(this);
1060 __table_.rehash(__n);1063 __table_.__rehash_unique(__n);
1061 insert(__il.begin(), __il.end());1064 insert(__il.begin(), __il.end());
1062}1065}
10631066
...@@ -1068,7 +1071,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(...@@ -1068,7 +1071,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
1068 : __table_(__hf, __eql, __a)1071 : __table_(__hf, __eql, __a)
1069{1072{
1070 _VSTD::__debug_db_insert_c(this);1073 _VSTD::__debug_db_insert_c(this);
1071 __table_.rehash(__n);1074 __table_.__rehash_unique(__n);
1072 insert(__il.begin(), __il.end());1075 insert(__il.begin(), __il.end());
1073}1076}
10741077
...@@ -1162,9 +1165,9 @@ public:...@@ -1162,9 +1165,9 @@ public:
1162 // types1165 // types
1163 typedef _Value key_type;1166 typedef _Value key_type;
1164 typedef key_type value_type;1167 typedef key_type value_type;
1165 typedef __identity_t<_Hash> hasher;1168 typedef __type_identity_t<_Hash> hasher;
1166 typedef __identity_t<_Pred> key_equal;1169 typedef __type_identity_t<_Pred> key_equal;
1167 typedef __identity_t<_Alloc> allocator_type;1170 typedef __type_identity_t<_Alloc> allocator_type;
1168 typedef value_type& reference;1171 typedef value_type& reference;
1169 typedef const value_type& const_reference;1172 typedef const value_type& const_reference;
1170 static_assert((is_same<value_type, typename allocator_type::value_type>::value),1173 static_assert((is_same<value_type, typename allocator_type::value_type>::value),
...@@ -1493,11 +1496,11 @@ public:...@@ -1493,11 +1496,11 @@ public:
1493 _LIBCPP_INLINE_VISIBILITY1496 _LIBCPP_INLINE_VISIBILITY
1494 void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);}1497 void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);}
1495 _LIBCPP_INLINE_VISIBILITY1498 _LIBCPP_INLINE_VISIBILITY
1496 void rehash(size_type __n) {__table_.rehash(__n);}1499 void rehash(size_type __n) {__table_.__rehash_multi(__n);}
1497 _LIBCPP_INLINE_VISIBILITY1500 _LIBCPP_INLINE_VISIBILITY
1498 void reserve(size_type __n) {__table_.reserve(__n);}1501 void reserve(size_type __n) {__table_.__reserve_multi(__n);}
14991502
1500#if _LIBCPP_DEBUG_LEVEL == 21503#ifdef _LIBCPP_ENABLE_DEBUG_MODE
15011504
1502 bool __dereferenceable(const const_iterator* __i) const1505 bool __dereferenceable(const const_iterator* __i) const
1503 {return __table_.__dereferenceable(__i);}1506 {return __table_.__dereferenceable(__i);}
...@@ -1508,7 +1511,7 @@ public:...@@ -1508,7 +1511,7 @@ public:
1508 bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const1511 bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const
1509 {return __table_.__addable(__i, __n);}1512 {return __table_.__addable(__i, __n);}
15101513
1511#endif // _LIBCPP_DEBUG_LEVEL == 21514#endif // _LIBCPP_ENABLE_DEBUG_MODE
15121515
1513};1516};
15141517
...@@ -1575,7 +1578,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(...@@ -1575,7 +1578,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1575 : __table_(__hf, __eql)1578 : __table_(__hf, __eql)
1576{1579{
1577 _VSTD::__debug_db_insert_c(this);1580 _VSTD::__debug_db_insert_c(this);
1578 __table_.rehash(__n);1581 __table_.__rehash_multi(__n);
1579}1582}
15801583
1581template <class _Value, class _Hash, class _Pred, class _Alloc>1584template <class _Value, class _Hash, class _Pred, class _Alloc>
...@@ -1585,7 +1588,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(...@@ -1585,7 +1588,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1585 : __table_(__hf, __eql, __a)1588 : __table_(__hf, __eql, __a)
1586{1589{
1587 _VSTD::__debug_db_insert_c(this);1590 _VSTD::__debug_db_insert_c(this);
1588 __table_.rehash(__n);1591 __table_.__rehash_multi(__n);
1589}1592}
15901593
1591template <class _Value, class _Hash, class _Pred, class _Alloc>1594template <class _Value, class _Hash, class _Pred, class _Alloc>
...@@ -1605,7 +1608,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(...@@ -1605,7 +1608,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1605 : __table_(__hf, __eql)1608 : __table_(__hf, __eql)
1606{1609{
1607 _VSTD::__debug_db_insert_c(this);1610 _VSTD::__debug_db_insert_c(this);
1608 __table_.rehash(__n);1611 __table_.__rehash_multi(__n);
1609 insert(__first, __last);1612 insert(__first, __last);
1610}1613}
16111614
...@@ -1617,7 +1620,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(...@@ -1617,7 +1620,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1617 : __table_(__hf, __eql, __a)1620 : __table_(__hf, __eql, __a)
1618{1621{
1619 _VSTD::__debug_db_insert_c(this);1622 _VSTD::__debug_db_insert_c(this);
1620 __table_.rehash(__n);1623 __table_.__rehash_multi(__n);
1621 insert(__first, __last);1624 insert(__first, __last);
1622}1625}
16231626
...@@ -1636,7 +1639,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(...@@ -1636,7 +1639,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1636 : __table_(__u.__table_)1639 : __table_(__u.__table_)
1637{1640{
1638 _VSTD::__debug_db_insert_c(this);1641 _VSTD::__debug_db_insert_c(this);
1639 __table_.rehash(__u.bucket_count());1642 __table_.__rehash_multi(__u.bucket_count());
1640 insert(__u.begin(), __u.end());1643 insert(__u.begin(), __u.end());
1641}1644}
16421645
...@@ -1646,7 +1649,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(...@@ -1646,7 +1649,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1646 : __table_(__u.__table_, __a)1649 : __table_(__u.__table_, __a)
1647{1650{
1648 _VSTD::__debug_db_insert_c(this);1651 _VSTD::__debug_db_insert_c(this);
1649 __table_.rehash(__u.bucket_count());1652 __table_.__rehash_multi(__u.bucket_count());
1650 insert(__u.begin(), __u.end());1653 insert(__u.begin(), __u.end());
1651}1654}
16521655
...@@ -1660,9 +1663,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(...@@ -1660,9 +1663,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1660 : __table_(_VSTD::move(__u.__table_))1663 : __table_(_VSTD::move(__u.__table_))
1661{1664{
1662 _VSTD::__debug_db_insert_c(this);1665 _VSTD::__debug_db_insert_c(this);
1663#if _LIBCPP_DEBUG_LEVEL == 21666 std::__debug_db_swap(this, std::addressof(__u));
1664 __get_db()->swap(this, _VSTD::addressof(__u));
1665#endif
1666}1667}
16671668
1668template <class _Value, class _Hash, class _Pred, class _Alloc>1669template <class _Value, class _Hash, class _Pred, class _Alloc>
...@@ -1677,10 +1678,8 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(...@@ -1677,10 +1678,8 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1677 while (__u.size() != 0)1678 while (__u.size() != 0)
1678 __table_.__insert_multi(_VSTD::move(__u.__table_.remove(__i++)->__value_));1679 __table_.__insert_multi(_VSTD::move(__u.__table_.remove(__i++)->__value_));
1679 }1680 }
1680#if _LIBCPP_DEBUG_LEVEL == 2
1681 else1681 else
1682 __get_db()->swap(this, _VSTD::addressof(__u));1682 std::__debug_db_swap(this, std::addressof(__u));
1683#endif
1684}1683}
16851684
1686template <class _Value, class _Hash, class _Pred, class _Alloc>1685template <class _Value, class _Hash, class _Pred, class _Alloc>
...@@ -1698,7 +1697,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(...@@ -1698,7 +1697,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1698 : __table_(__hf, __eql)1697 : __table_(__hf, __eql)
1699{1698{
1700 _VSTD::__debug_db_insert_c(this);1699 _VSTD::__debug_db_insert_c(this);
1701 __table_.rehash(__n);1700 __table_.__rehash_multi(__n);
1702 insert(__il.begin(), __il.end());1701 insert(__il.begin(), __il.end());
1703}1702}
17041703
...@@ -1709,7 +1708,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(...@@ -1709,7 +1708,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1709 : __table_(__hf, __eql, __a)1708 : __table_(__hf, __eql, __a)
1710{1709{
1711 _VSTD::__debug_db_insert_c(this);1710 _VSTD::__debug_db_insert_c(this);
1712 __table_.rehash(__n);1711 __table_.__rehash_multi(__n);
1713 insert(__il.begin(), __il.end());1712 insert(__il.begin(), __il.end());
1714}1713}
17151714
lib/libcxx/include/utility+17-3
...@@ -95,6 +95,12 @@ struct pair...@@ -95,6 +95,12 @@ struct pair
95 is_nothrow_swappable_v<T2>); // constexpr in C++2095 is_nothrow_swappable_v<T2>); // constexpr in C++20
96};96};
9797
98template<class T1, class T2, class U1, class U2, template<class> class TQual, template<class> class UQual>
99struct basic_common_reference<pair<T1, T2>, pair<U1, U2>, TQual, UQual>; // since C++23
100
101template<class T1, class T2, class U1, class U2>
102struct common_type<pair<T1, T2>, pair<U1, U2>>; // since C++23
103
98template<class T1, class T2> pair(T1, T2) -> pair<T1, T2>;104template<class T1, class T2> pair(T1, T2) -> pair<T1, T2>;
99105
100template <class T1, class T2> bool operator==(const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14106template <class T1, class T2> bool operator==(const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14
...@@ -214,8 +220,8 @@ template <class T>...@@ -214,8 +220,8 @@ template <class T>
214220
215*/221*/
216222
223#include <__assert> // all public C++ headers provide the assertion handler
217#include <__config>224#include <__config>
218#include <__debug>
219#include <__tuple>225#include <__tuple>
220#include <__utility/as_const.h>226#include <__utility/as_const.h>
221#include <__utility/auto_cast.h>227#include <__utility/auto_cast.h>
...@@ -233,12 +239,20 @@ template <class T>...@@ -233,12 +239,20 @@ template <class T>
233#include <__utility/swap.h>239#include <__utility/swap.h>
234#include <__utility/to_underlying.h>240#include <__utility/to_underlying.h>
235#include <__utility/transaction.h>241#include <__utility/transaction.h>
242#include <__utility/unreachable.h>
243#include <type_traits>
244#include <version>
245
246#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
247# include <iosfwd>
248#endif
249
250// standard-mandated includes
236#include <compare>251#include <compare>
237#include <initializer_list>252#include <initializer_list>
238#include <version>
239253
240#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)254#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
241#pragma GCC system_header255# pragma GCC system_header
242#endif256#endif
243257
244#endif // _LIBCPP_UTILITY258#endif // _LIBCPP_UTILITY
lib/libcxx/include/valarray+60-62
...@@ -341,17 +341,35 @@ template <class T> unspecified2 end(const valarray<T>& v);...@@ -341,17 +341,35 @@ template <class T> unspecified2 end(const valarray<T>& v);
341341
342*/342*/
343343
344#include <__algorithm/copy.h>
345#include <__algorithm/count.h>
346#include <__algorithm/fill.h>
347#include <__algorithm/max_element.h>
348#include <__algorithm/min.h>
349#include <__algorithm/min_element.h>
350#include <__algorithm/unwrap_iter.h>
351#include <__assert> // all public C++ headers provide the assertion handler
344#include <__config>352#include <__config>
345#include <algorithm>353#include <__functional/operations.h>
354#include <__memory/allocator.h>
355#include <__memory/uninitialized_algorithms.h>
356#include <__utility/move.h>
357#include <__utility/swap.h>
346#include <cmath>358#include <cmath>
347#include <cstddef>359#include <cstddef>
348#include <functional>
349#include <initializer_list>
350#include <new>360#include <new>
351#include <version>361#include <version>
352362
363#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
364# include <algorithm>
365# include <functional>
366#endif
367
368// standard-mandated includes
369#include <initializer_list>
370
353#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)371#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
354#pragma GCC system_header372# pragma GCC system_header
355#endif373#endif
356374
357_LIBCPP_PUSH_MACROS375_LIBCPP_PUSH_MACROS
...@@ -912,10 +930,14 @@ public:...@@ -912,10 +930,14 @@ public:
912#endif // _LIBCPP_CXX03_LANG930#endif // _LIBCPP_CXX03_LANG
913931
914 // unary operators:932 // unary operators:
915 valarray operator+() const;933 _LIBCPP_INLINE_VISIBILITY
916 valarray operator-() const;934 __val_expr<_UnaryOp<__unary_plus<_Tp>, const valarray&> > operator+() const;
917 valarray operator~() const;935 _LIBCPP_INLINE_VISIBILITY
918 valarray<bool> operator!() const;936 __val_expr<_UnaryOp<negate<_Tp>, const valarray&> > operator-() const;
937 _LIBCPP_INLINE_VISIBILITY
938 __val_expr<_UnaryOp<__bit_not<_Tp>, const valarray&> > operator~() const;
939 _LIBCPP_INLINE_VISIBILITY
940 __val_expr<_UnaryOp<logical_not<_Tp>, const valarray&> > operator!() const;
919941
920 // computed assignment:942 // computed assignment:
921 _LIBCPP_INLINE_VISIBILITY943 _LIBCPP_INLINE_VISIBILITY
...@@ -1089,7 +1111,7 @@ template<class _Tp, size_t _Size>...@@ -1089,7 +1111,7 @@ template<class _Tp, size_t _Size>
1089valarray(const _Tp(&)[_Size], size_t) -> valarray<_Tp>;1111valarray(const _Tp(&)[_Size], size_t) -> valarray<_Tp>;
1090#endif1112#endif
10911113
1092_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void valarray<size_t>::resize(size_t, size_t))1114extern template _LIBCPP_FUNC_VIS void valarray<size_t>::resize(size_t, size_t);
10931115
1094template <class _Op, class _Tp>1116template <class _Op, class _Tp>
1095struct _UnaryOp<_Op, valarray<_Tp> >1117struct _UnaryOp<_Op, valarray<_Tp> >
...@@ -1530,21 +1552,21 @@ public:...@@ -1530,21 +1552,21 @@ public:
1530 gslice(size_t __start, const valarray<size_t>& __size,1552 gslice(size_t __start, const valarray<size_t>& __size,
1531 valarray<size_t>&& __stride)1553 valarray<size_t>&& __stride)
1532 : __size_(__size),1554 : __size_(__size),
1533 __stride_(move(__stride))1555 __stride_(std::move(__stride))
1534 {__init(__start);}1556 {__init(__start);}
15351557
1536 _LIBCPP_INLINE_VISIBILITY1558 _LIBCPP_INLINE_VISIBILITY
1537 gslice(size_t __start, valarray<size_t>&& __size,1559 gslice(size_t __start, valarray<size_t>&& __size,
1538 const valarray<size_t>& __stride)1560 const valarray<size_t>& __stride)
1539 : __size_(move(__size)),1561 : __size_(std::move(__size)),
1540 __stride_(__stride)1562 __stride_(__stride)
1541 {__init(__start);}1563 {__init(__start);}
15421564
1543 _LIBCPP_INLINE_VISIBILITY1565 _LIBCPP_INLINE_VISIBILITY
1544 gslice(size_t __start, valarray<size_t>&& __size,1566 gslice(size_t __start, valarray<size_t>&& __size,
1545 valarray<size_t>&& __stride)1567 valarray<size_t>&& __stride)
1546 : __size_(move(__size)),1568 : __size_(std::move(__size)),
1547 __stride_(move(__stride))1569 __stride_(std::move(__stride))
1548 {__init(__start);}1570 {__init(__start);}
15491571
1550#endif // _LIBCPP_CXX03_LANG1572#endif // _LIBCPP_CXX03_LANG
...@@ -1695,7 +1717,7 @@ private:...@@ -1695,7 +1717,7 @@ private:
1695#ifndef _LIBCPP_CXX03_LANG1717#ifndef _LIBCPP_CXX03_LANG
1696 gslice_array(gslice&& __gs, const valarray<value_type>& __v)1718 gslice_array(gslice&& __gs, const valarray<value_type>& __v)
1697 : __vp_(const_cast<value_type*>(__v.__begin_)),1719 : __vp_(const_cast<value_type*>(__v.__begin_)),
1698 __1d_(move(__gs.__1d_))1720 __1d_(std::move(__gs.__1d_))
1699 {}1721 {}
1700#endif // _LIBCPP_CXX03_LANG1722#endif // _LIBCPP_CXX03_LANG
17011723
...@@ -2389,7 +2411,7 @@ private:...@@ -2389,7 +2411,7 @@ private:
2389 _LIBCPP_INLINE_VISIBILITY2411 _LIBCPP_INLINE_VISIBILITY
2390 indirect_array(valarray<size_t>&& __ia, const valarray<value_type>& __v)2412 indirect_array(valarray<size_t>&& __ia, const valarray<value_type>& __v)
2391 : __vp_(const_cast<value_type*>(__v.__begin_)),2413 : __vp_(const_cast<value_type*>(__v.__begin_)),
2392 __1d_(move(__ia))2414 __1d_(std::move(__ia))
2393 {}2415 {}
23942416
2395#endif // _LIBCPP_CXX03_LANG2417#endif // _LIBCPP_CXX03_LANG
...@@ -2608,7 +2630,7 @@ private:...@@ -2608,7 +2630,7 @@ private:
2608 _LIBCPP_INLINE_VISIBILITY2630 _LIBCPP_INLINE_VISIBILITY
2609 __indirect_expr(valarray<size_t>&& __ia, const _RmExpr& __e)2631 __indirect_expr(valarray<size_t>&& __ia, const _RmExpr& __e)
2610 : __expr_(__e),2632 : __expr_(__e),
2611 __1d_(move(__ia))2633 __1d_(std::move(__ia))
2612 {}2634 {}
26132635
2614#endif // _LIBCPP_CXX03_LANG2636#endif // _LIBCPP_CXX03_LANG
...@@ -3203,7 +3225,7 @@ inline...@@ -3203,7 +3225,7 @@ inline
3203__val_expr<__indirect_expr<const valarray<_Tp>&> >3225__val_expr<__indirect_expr<const valarray<_Tp>&> >
3204valarray<_Tp>::operator[](gslice&& __gs) const3226valarray<_Tp>::operator[](gslice&& __gs) const
3205{3227{
3206 return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(move(__gs.__1d_), *this));3228 return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(std::move(__gs.__1d_), *this));
3207}3229}
32083230
3209template <class _Tp>3231template <class _Tp>
...@@ -3211,7 +3233,7 @@ inline...@@ -3211,7 +3233,7 @@ inline
3211gslice_array<_Tp>3233gslice_array<_Tp>
3212valarray<_Tp>::operator[](gslice&& __gs)3234valarray<_Tp>::operator[](gslice&& __gs)
3213{3235{
3214 return gslice_array<value_type>(move(__gs), *this);3236 return gslice_array<value_type>(std::move(__gs), *this);
3215}3237}
32163238
3217#endif // _LIBCPP_CXX03_LANG3239#endif // _LIBCPP_CXX03_LANG
...@@ -3239,7 +3261,7 @@ inline...@@ -3239,7 +3261,7 @@ inline
3239__val_expr<__mask_expr<const valarray<_Tp>&> >3261__val_expr<__mask_expr<const valarray<_Tp>&> >
3240valarray<_Tp>::operator[](valarray<bool>&& __vb) const3262valarray<_Tp>::operator[](valarray<bool>&& __vb) const
3241{3263{
3242 return __val_expr<__mask_expr<const valarray&> >(__mask_expr<const valarray&>(move(__vb), *this));3264 return __val_expr<__mask_expr<const valarray&> >(__mask_expr<const valarray&>(std::move(__vb), *this));
3243}3265}
32443266
3245template <class _Tp>3267template <class _Tp>
...@@ -3247,7 +3269,7 @@ inline...@@ -3247,7 +3269,7 @@ inline
3247mask_array<_Tp>3269mask_array<_Tp>
3248valarray<_Tp>::operator[](valarray<bool>&& __vb)3270valarray<_Tp>::operator[](valarray<bool>&& __vb)
3249{3271{
3250 return mask_array<value_type>(move(__vb), *this);3272 return mask_array<value_type>(std::move(__vb), *this);
3251}3273}
32523274
3253#endif // _LIBCPP_CXX03_LANG3275#endif // _LIBCPP_CXX03_LANG
...@@ -3275,7 +3297,7 @@ inline...@@ -3275,7 +3297,7 @@ inline
3275__val_expr<__indirect_expr<const valarray<_Tp>&> >3297__val_expr<__indirect_expr<const valarray<_Tp>&> >
3276valarray<_Tp>::operator[](valarray<size_t>&& __vs) const3298valarray<_Tp>::operator[](valarray<size_t>&& __vs) const
3277{3299{
3278 return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(move(__vs), *this));3300 return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(std::move(__vs), *this));
3279}3301}
32803302
3281template <class _Tp>3303template <class _Tp>
...@@ -3283,69 +3305,45 @@ inline...@@ -3283,69 +3305,45 @@ inline
3283indirect_array<_Tp>3305indirect_array<_Tp>
3284valarray<_Tp>::operator[](valarray<size_t>&& __vs)3306valarray<_Tp>::operator[](valarray<size_t>&& __vs)
3285{3307{
3286 return indirect_array<value_type>(move(__vs), *this);3308 return indirect_array<value_type>(std::move(__vs), *this);
3287}3309}
32883310
3289#endif // _LIBCPP_CXX03_LANG3311#endif // _LIBCPP_CXX03_LANG
32903312
3291template <class _Tp>3313template <class _Tp>
3292valarray<_Tp>3314inline
3315__val_expr<_UnaryOp<__unary_plus<_Tp>, const valarray<_Tp>&> >
3293valarray<_Tp>::operator+() const3316valarray<_Tp>::operator+() const
3294{3317{
3295 valarray<value_type> __r;3318 using _Op = _UnaryOp<__unary_plus<_Tp>, const valarray<_Tp>&>;
3296 size_t __n = size();3319 return __val_expr<_Op>(_Op(__unary_plus<_Tp>(), *this));
3297 if (__n)
3298 {
3299 __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);
3300 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3301 ::new ((void*)__r.__end_) value_type(+*__p);
3302 }
3303 return __r;
3304}3320}
33053321
3306template <class _Tp>3322template <class _Tp>
3307valarray<_Tp>3323inline
3324__val_expr<_UnaryOp<negate<_Tp>, const valarray<_Tp>&> >
3308valarray<_Tp>::operator-() const3325valarray<_Tp>::operator-() const
3309{3326{
3310 valarray<value_type> __r;3327 using _Op = _UnaryOp<negate<_Tp>, const valarray<_Tp>&>;
3311 size_t __n = size();3328 return __val_expr<_Op>(_Op(negate<_Tp>(), *this));
3312 if (__n)
3313 {
3314 __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);
3315 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3316 ::new ((void*)__r.__end_) value_type(-*__p);
3317 }
3318 return __r;
3319}3329}
33203330
3321template <class _Tp>3331template <class _Tp>
3322valarray<_Tp>3332inline
3333__val_expr<_UnaryOp<__bit_not<_Tp>, const valarray<_Tp>&> >
3323valarray<_Tp>::operator~() const3334valarray<_Tp>::operator~() const
3324{3335{
3325 valarray<value_type> __r;3336 using _Op = _UnaryOp<__bit_not<_Tp>, const valarray<_Tp>&>;
3326 size_t __n = size();3337 return __val_expr<_Op>(_Op(__bit_not<_Tp>(), *this));
3327 if (__n)
3328 {
3329 __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);
3330 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3331 ::new ((void*)__r.__end_) value_type(~*__p);
3332 }
3333 return __r;
3334}3338}
33353339
3336template <class _Tp>3340template <class _Tp>
3337valarray<bool>3341inline
3342__val_expr<_UnaryOp<logical_not<_Tp>, const valarray<_Tp>&> >
3338valarray<_Tp>::operator!() const3343valarray<_Tp>::operator!() const
3339{3344{
3340 valarray<bool> __r;3345 using _Op = _UnaryOp<logical_not<_Tp>, const valarray<_Tp>&>;
3341 size_t __n = size();3346 return __val_expr<_Op>(_Op(logical_not<_Tp>(), *this));
3342 if (__n)
3343 {
3344 __r.__begin_ = __r.__end_ = allocator<bool>().allocate(__n);
3345 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3346 ::new ((void*)__r.__end_) bool(!*__p);
3347 }
3348 return __r;
3349}3347}
33503348
3351template <class _Tp>3349template <class _Tp>
lib/libcxx/include/variant+33-18
...@@ -199,24 +199,36 @@ namespace std {...@@ -199,24 +199,36 @@ namespace std {
199199
200*/200*/
201201
202#include <__assert> // all public C++ headers provide the assertion handler
202#include <__availability>203#include <__availability>
203#include <__config>204#include <__config>
204#include <__functional/hash.h>205#include <__functional/hash.h>
206#include <__functional/operations.h>
207#include <__functional/unary_function.h>
205#include <__tuple>208#include <__tuple>
206#include <__utility/forward.h>209#include <__utility/forward.h>
210#include <__utility/in_place.h>
211#include <__utility/move.h>
212#include <__utility/swap.h>
207#include <__variant/monostate.h>213#include <__variant/monostate.h>
208#include <compare>
209#include <exception>214#include <exception>
210#include <initializer_list>215#include <initializer_list>
211#include <limits>216#include <limits>
212#include <new>217#include <new>
213#include <tuple>218#include <tuple>
214#include <type_traits>219#include <type_traits>
215#include <utility>
216#include <version>220#include <version>
217221
222#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
223# include <typeinfo>
224# include <utility>
225#endif
226
227// standard-mandated includes
228#include <compare>
229
218#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)230#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
219#pragma GCC system_header231# pragma GCC system_header
220#endif232#endif
221233
222_LIBCPP_PUSH_MACROS234_LIBCPP_PUSH_MACROS
...@@ -533,7 +545,7 @@ private:...@@ -533,7 +545,7 @@ private:
533 template <class _Fp, class... _Vs>545 template <class _Fp, class... _Vs>
534 inline _LIBCPP_INLINE_VISIBILITY546 inline _LIBCPP_INLINE_VISIBILITY
535 static constexpr decltype(auto) __dispatch(_Fp __f, _Vs... __vs) {547 static constexpr decltype(auto) __dispatch(_Fp __f, _Vs... __vs) {
536 return _VSTD::__invoke_constexpr(548 return _VSTD::__invoke(
537 static_cast<_Fp>(__f),549 static_cast<_Fp>(__f),
538 __access::__base::__get_alt<_Is>(static_cast<_Vs>(__vs))...);550 __access::__base::__get_alt<_Is>(static_cast<_Vs>(__vs))...);
539 }551 }
...@@ -549,7 +561,7 @@ private:...@@ -549,7 +561,7 @@ private:
549 inline _LIBCPP_INLINE_VISIBILITY561 inline _LIBCPP_INLINE_VISIBILITY
550 static constexpr auto __make_fdiagonal_impl() {562 static constexpr auto __make_fdiagonal_impl() {
551 return __make_dispatch<_Fp, _Vs...>(563 return __make_dispatch<_Fp, _Vs...>(
552 index_sequence<((void)__identity<_Vs>{}, _Ip)...>{});564 index_sequence<((void)__type_identity<_Vs>{}, _Ip)...>{});
553 }565 }
554566
555 template <class _Fp, class... _Vs, size_t... _Is>567 template <class _Fp, class... _Vs, size_t... _Is>
...@@ -653,8 +665,8 @@ private:...@@ -653,8 +665,8 @@ private:
653 __std_visit_exhaustive_visitor_check<665 __std_visit_exhaustive_visitor_check<
654 _Visitor,666 _Visitor,
655 decltype((_VSTD::forward<_Alts>(__alts).__value))...>();667 decltype((_VSTD::forward<_Alts>(__alts).__value))...>();
656 return _VSTD::__invoke_constexpr(_VSTD::forward<_Visitor>(__visitor),668 return _VSTD::__invoke(_VSTD::forward<_Visitor>(__visitor),
657 _VSTD::forward<_Alts>(__alts).__value...);669 _VSTD::forward<_Alts>(__alts).__value...);
658 }670 }
659 _Visitor&& __visitor;671 _Visitor&& __visitor;
660 };672 };
...@@ -669,12 +681,12 @@ private:...@@ -669,12 +681,12 @@ private:
669 _Visitor,681 _Visitor,
670 decltype((_VSTD::forward<_Alts>(__alts).__value))...>();682 decltype((_VSTD::forward<_Alts>(__alts).__value))...>();
671 if constexpr (is_void_v<_Rp>) {683 if constexpr (is_void_v<_Rp>) {
672 _VSTD::__invoke_constexpr(_VSTD::forward<_Visitor>(__visitor),684 _VSTD::__invoke(_VSTD::forward<_Visitor>(__visitor),
673 _VSTD::forward<_Alts>(__alts).__value...);685 _VSTD::forward<_Alts>(__alts).__value...);
674 }686 }
675 else {687 else {
676 return _VSTD::__invoke_constexpr(_VSTD::forward<_Visitor>(__visitor),688 return _VSTD::__invoke(_VSTD::forward<_Visitor>(__visitor),
677 _VSTD::forward<_Alts>(__alts).__value...);689 _VSTD::forward<_Alts>(__alts).__value...);
678 }690 }
679 }691 }
680692
...@@ -765,8 +777,8 @@ public:...@@ -765,8 +777,8 @@ public:
765 using __index_t = __variant_index_t<sizeof...(_Types)>;777 using __index_t = __variant_index_t<sizeof...(_Types)>;
766778
767 inline _LIBCPP_INLINE_VISIBILITY779 inline _LIBCPP_INLINE_VISIBILITY
768 explicit constexpr __base(__valueless_t tag) noexcept780 explicit constexpr __base(__valueless_t __tag) noexcept
769 : __data(tag), __index(__variant_npos<__index_t>) {}781 : __data(__tag), __index(__variant_npos<__index_t>) {}
770782
771 template <size_t _Ip, class... _Args>783 template <size_t _Ip, class... _Args>
772 inline _LIBCPP_INLINE_VISIBILITY784 inline _LIBCPP_INLINE_VISIBILITY
...@@ -1121,8 +1133,11 @@ class _LIBCPP_TEMPLATE_VIS __impl...@@ -1121,8 +1133,11 @@ class _LIBCPP_TEMPLATE_VIS __impl
1121 using __base_type = __copy_assignment<__traits<_Types...>>;1133 using __base_type = __copy_assignment<__traits<_Types...>>;
11221134
1123public:1135public:
1124 using __base_type::__base_type;1136 using __base_type::__base_type; // get in_place_index_t constructor & friends
1125 using __base_type::operator=;1137 __impl(__impl const&) = default;
1138 __impl(__impl&&) = default;
1139 __impl& operator=(__impl const&) = default;
1140 __impl& operator=(__impl&&) = default;
11261141
1127 template <size_t _Ip, class _Arg>1142 template <size_t _Ip, class _Arg>
1128 inline _LIBCPP_INLINE_VISIBILITY1143 inline _LIBCPP_INLINE_VISIBILITY
...@@ -1186,12 +1201,12 @@ private:...@@ -1186,12 +1201,12 @@ private:
11861201
1187struct __no_narrowing_check {1202struct __no_narrowing_check {
1188 template <class _Dest, class _Source>1203 template <class _Dest, class _Source>
1189 using _Apply = __identity<_Dest>;1204 using _Apply = __type_identity<_Dest>;
1190};1205};
11911206
1192struct __narrowing_check {1207struct __narrowing_check {
1193 template <class _Dest>1208 template <class _Dest>
1194 static auto __test_impl(_Dest (&&)[1]) -> __identity<_Dest>;1209 static auto __test_impl(_Dest (&&)[1]) -> __type_identity<_Dest>;
1195 template <class _Dest, class _Source>1210 template <class _Dest, class _Source>
1196 using _Apply _LIBCPP_NODEBUG = decltype(__test_impl<_Dest>({declval<_Source>()}));1211 using _Apply _LIBCPP_NODEBUG = decltype(__test_impl<_Dest>({declval<_Source>()}));
1197};1212};
...@@ -1217,7 +1232,7 @@ template <class _Tp, size_t>...@@ -1217,7 +1232,7 @@ template <class _Tp, size_t>
1217struct __overload_bool {1232struct __overload_bool {
1218 template <class _Up, class _Ap = __uncvref_t<_Up>>1233 template <class _Up, class _Ap = __uncvref_t<_Up>>
1219 auto operator()(bool, _Up&&) const1234 auto operator()(bool, _Up&&) const
1220 -> enable_if_t<is_same_v<_Ap, bool>, __identity<_Tp>>;1235 -> enable_if_t<is_same_v<_Ap, bool>, __type_identity<_Tp>>;
1221};1236};
12221237
1223template <size_t _Idx>1238template <size_t _Idx>
lib/libcxx/include/vector+500-471
...@@ -271,20 +271,35 @@ erase_if(vector<T, Allocator>& c, Predicate pred); // C++20...@@ -271,20 +271,35 @@ erase_if(vector<T, Allocator>& c, Predicate pred); // C++20
271271
272*/272*/
273273
274#include <__algorithm/copy.h>
275#include <__algorithm/equal.h>
276#include <__algorithm/fill_n.h>
277#include <__algorithm/lexicographical_compare.h>
278#include <__algorithm/remove.h>
279#include <__algorithm/remove_if.h>
280#include <__algorithm/rotate.h>
281#include <__algorithm/unwrap_iter.h>
282#include <__assert> // all public C++ headers provide the assertion handler
274#include <__bit_reference>283#include <__bit_reference>
275#include <__config>284#include <__config>
276#include <__debug>285#include <__debug>
277#include <__functional_base>286#include <__format/enable_insertable.h>
287#include <__functional/hash.h>
288#include <__functional/unary_function.h>
289#include <__iterator/advance.h>
278#include <__iterator/iterator_traits.h>290#include <__iterator/iterator_traits.h>
291#include <__iterator/reverse_iterator.h>
279#include <__iterator/wrap_iter.h>292#include <__iterator/wrap_iter.h>
293#include <__memory/allocate_at_least.h>
294#include <__memory/pointer_traits.h>
295#include <__memory/swap_allocator.h>
280#include <__split_buffer>296#include <__split_buffer>
281#include <__utility/forward.h>297#include <__utility/forward.h>
282#include <algorithm>298#include <__utility/move.h>
299#include <__utility/swap.h>
283#include <climits>300#include <climits>
284#include <compare>
285#include <cstdlib>301#include <cstdlib>
286#include <cstring>302#include <cstring>
287#include <initializer_list>
288#include <iosfwd> // for forward declaration of vector303#include <iosfwd> // for forward declaration of vector
289#include <limits>304#include <limits>
290#include <memory>305#include <memory>
...@@ -292,8 +307,27 @@ erase_if(vector<T, Allocator>& c, Predicate pred); // C++20...@@ -292,8 +307,27 @@ erase_if(vector<T, Allocator>& c, Predicate pred); // C++20
292#include <type_traits>307#include <type_traits>
293#include <version>308#include <version>
294309
310#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
311# include <algorithm>
312# include <typeinfo>
313# include <utility>
314#endif
315
316// standard-mandated includes
317
318// [iterator.range]
319#include <__iterator/access.h>
320#include <__iterator/data.h>
321#include <__iterator/empty.h>
322#include <__iterator/reverse_access.h>
323#include <__iterator/size.h>
324
325// [vector.syn]
326#include <compare>
327#include <initializer_list>
328
295#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)329#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
296#pragma GCC system_header330# pragma GCC system_header
297#endif331#endif
298332
299_LIBCPP_PUSH_MACROS333_LIBCPP_PUSH_MACROS
...@@ -326,12 +360,12 @@ public:...@@ -326,12 +360,12 @@ public:
326 static_assert((is_same<typename allocator_type::value_type, value_type>::value),360 static_assert((is_same<typename allocator_type::value_type, value_type>::value),
327 "Allocator::value_type must be same type as value_type");361 "Allocator::value_type must be same type as value_type");
328362
329 _LIBCPP_INLINE_VISIBILITY363 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
330 vector() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)364 vector() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
331 {365 {
332 _VSTD::__debug_db_insert_c(this);366 _VSTD::__debug_db_insert_c(this);
333 }367 }
334 _LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a)368 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a)
335#if _LIBCPP_STD_VER <= 14369#if _LIBCPP_STD_VER <= 14
336 _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)370 _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)
337#else371#else
...@@ -341,13 +375,14 @@ public:...@@ -341,13 +375,14 @@ public:
341 {375 {
342 _VSTD::__debug_db_insert_c(this);376 _VSTD::__debug_db_insert_c(this);
343 }377 }
344 explicit vector(size_type __n);378 _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit vector(size_type __n);
345#if _LIBCPP_STD_VER > 11379#if _LIBCPP_STD_VER > 11
346 explicit vector(size_type __n, const allocator_type& __a);380 _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit vector(size_type __n, const allocator_type& __a);
347#endif381#endif
348 vector(size_type __n, const value_type& __x);382 _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(size_type __n, const value_type& __x);
349383
350 template <class = __enable_if_t<__is_allocator<_Allocator>::value> >384 template <class = __enable_if_t<__is_allocator<_Allocator>::value> >
385 _LIBCPP_CONSTEXPR_AFTER_CXX17
351 vector(size_type __n, const value_type& __x, const allocator_type& __a)386 vector(size_type __n, const value_type& __x, const allocator_type& __a)
352 : __end_cap_(nullptr, __a)387 : __end_cap_(nullptr, __a)
353 {388 {
...@@ -360,21 +395,22 @@ public:...@@ -360,21 +395,22 @@ public:
360 }395 }
361396
362 template <class _InputIterator>397 template <class _InputIterator>
398 _LIBCPP_CONSTEXPR_AFTER_CXX17
363 vector(_InputIterator __first,399 vector(_InputIterator __first,
364 typename enable_if<__is_cpp17_input_iterator <_InputIterator>::value &&400 typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
365 !__is_cpp17_forward_iterator<_InputIterator>::value &&
366 is_constructible<401 is_constructible<
367 value_type,402 value_type,
368 typename iterator_traits<_InputIterator>::reference>::value,403 typename iterator_traits<_InputIterator>::reference>::value,
369 _InputIterator>::type __last);404 _InputIterator>::type __last);
370 template <class _InputIterator>405 template <class _InputIterator>
406 _LIBCPP_CONSTEXPR_AFTER_CXX17
371 vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,407 vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,
372 typename enable_if<__is_cpp17_input_iterator <_InputIterator>::value &&408 typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
373 !__is_cpp17_forward_iterator<_InputIterator>::value &&
374 is_constructible<409 is_constructible<
375 value_type,410 value_type,
376 typename iterator_traits<_InputIterator>::reference>::value>::type* = 0);411 typename iterator_traits<_InputIterator>::reference>::value>::type* = 0);
377 template <class _ForwardIterator>412 template <class _ForwardIterator>
413 _LIBCPP_CONSTEXPR_AFTER_CXX17
378 vector(_ForwardIterator __first,414 vector(_ForwardIterator __first,
379 typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value &&415 typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value &&
380 is_constructible<416 is_constructible<
...@@ -382,19 +418,18 @@ public:...@@ -382,19 +418,18 @@ public:
382 typename iterator_traits<_ForwardIterator>::reference>::value,418 typename iterator_traits<_ForwardIterator>::reference>::value,
383 _ForwardIterator>::type __last);419 _ForwardIterator>::type __last);
384 template <class _ForwardIterator>420 template <class _ForwardIterator>
421 _LIBCPP_CONSTEXPR_AFTER_CXX17
385 vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,422 vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,
386 typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value &&423 typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value &&
387 is_constructible<424 is_constructible<
388 value_type,425 value_type,
389 typename iterator_traits<_ForwardIterator>::reference>::value>::type* = 0);426 typename iterator_traits<_ForwardIterator>::reference>::value>::type* = 0);
390427
391 _LIBCPP_INLINE_VISIBILITY428 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
392 ~vector()429 ~vector()
393 {430 {
394 __annotate_delete();431 __annotate_delete();
395#if _LIBCPP_DEBUG_LEVEL == 2432 std::__debug_db_erase_c(this);
396 __get_db()->__erase_c(this);
397#endif
398433
399 if (this->__begin_ != nullptr)434 if (this->__begin_ != nullptr)
400 {435 {
...@@ -403,43 +438,39 @@ public:...@@ -403,43 +438,39 @@ public:
403 }438 }
404 }439 }
405440
406 vector(const vector& __x);441 _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(const vector& __x);
407 vector(const vector& __x, const __identity_t<allocator_type>& __a);442 _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(const vector& __x, const __type_identity_t<allocator_type>& __a);
408 _LIBCPP_INLINE_VISIBILITY443 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
409 vector& operator=(const vector& __x);444 vector& operator=(const vector& __x);
410445
411#ifndef _LIBCPP_CXX03_LANG446#ifndef _LIBCPP_CXX03_LANG
412 _LIBCPP_INLINE_VISIBILITY447 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
413 vector(initializer_list<value_type> __il);448 vector(initializer_list<value_type> __il);
414449
415 _LIBCPP_INLINE_VISIBILITY450 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
416 vector(initializer_list<value_type> __il, const allocator_type& __a);451 vector(initializer_list<value_type> __il, const allocator_type& __a);
417452
418 _LIBCPP_INLINE_VISIBILITY453 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
454 vector& operator=(initializer_list<value_type> __il)
455 {assign(__il.begin(), __il.end()); return *this;}
456#endif // !_LIBCPP_CXX03_LANG
457
458 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
419 vector(vector&& __x)459 vector(vector&& __x)
420#if _LIBCPP_STD_VER > 14460#if _LIBCPP_STD_VER > 14
421 _NOEXCEPT;461 noexcept;
422#else462#else
423 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);463 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
424#endif464#endif
425465
426 _LIBCPP_INLINE_VISIBILITY466 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
427 vector(vector&& __x, const __identity_t<allocator_type>& __a);467 vector(vector&& __x, const __type_identity_t<allocator_type>& __a);
428 _LIBCPP_INLINE_VISIBILITY468 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
429 vector& operator=(vector&& __x)469 vector& operator=(vector&& __x)
430 _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value));470 _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value));
431471
432 _LIBCPP_INLINE_VISIBILITY
433 vector& operator=(initializer_list<value_type> __il)
434 {assign(__il.begin(), __il.end()); return *this;}
435
436#endif // !_LIBCPP_CXX03_LANG
437
438 template <class _InputIterator>472 template <class _InputIterator>
439 typename enable_if473 _LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
440 <
441 __is_cpp17_input_iterator <_InputIterator>::value &&
442 !__is_cpp17_forward_iterator<_InputIterator>::value &&
443 is_constructible<474 is_constructible<
444 value_type,475 value_type,
445 typename iterator_traits<_InputIterator>::reference>::value,476 typename iterator_traits<_InputIterator>::reference>::value,
...@@ -447,6 +478,7 @@ public:...@@ -447,6 +478,7 @@ public:
447 >::type478 >::type
448 assign(_InputIterator __first, _InputIterator __last);479 assign(_InputIterator __first, _InputIterator __last);
449 template <class _ForwardIterator>480 template <class _ForwardIterator>
481 _LIBCPP_CONSTEXPR_AFTER_CXX17
450 typename enable_if482 typename enable_if
451 <483 <
452 __is_cpp17_forward_iterator<_ForwardIterator>::value &&484 __is_cpp17_forward_iterator<_ForwardIterator>::value &&
...@@ -457,137 +489,120 @@ public:...@@ -457,137 +489,120 @@ public:
457 >::type489 >::type
458 assign(_ForwardIterator __first, _ForwardIterator __last);490 assign(_ForwardIterator __first, _ForwardIterator __last);
459491
460 void assign(size_type __n, const_reference __u);492 _LIBCPP_CONSTEXPR_AFTER_CXX17 void assign(size_type __n, const_reference __u);
461493
462#ifndef _LIBCPP_CXX03_LANG494#ifndef _LIBCPP_CXX03_LANG
463 _LIBCPP_INLINE_VISIBILITY495 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
464 void assign(initializer_list<value_type> __il)496 void assign(initializer_list<value_type> __il)
465 {assign(__il.begin(), __il.end());}497 {assign(__il.begin(), __il.end());}
466#endif498#endif
467499
468 _LIBCPP_INLINE_VISIBILITY500 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
469 allocator_type get_allocator() const _NOEXCEPT501 allocator_type get_allocator() const _NOEXCEPT
470 {return this->__alloc();}502 {return this->__alloc();}
471503
472 _LIBCPP_INLINE_VISIBILITY iterator begin() _NOEXCEPT;504 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY iterator begin() _NOEXCEPT;
473 _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT;505 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT;
474 _LIBCPP_INLINE_VISIBILITY iterator end() _NOEXCEPT;506 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY iterator end() _NOEXCEPT;
475 _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT;507 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT;
476508
477 _LIBCPP_INLINE_VISIBILITY509 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
478 reverse_iterator rbegin() _NOEXCEPT510 reverse_iterator rbegin() _NOEXCEPT
479 {return reverse_iterator(end());}511 {return reverse_iterator(end());}
480 _LIBCPP_INLINE_VISIBILITY512 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
481 const_reverse_iterator rbegin() const _NOEXCEPT513 const_reverse_iterator rbegin() const _NOEXCEPT
482 {return const_reverse_iterator(end());}514 {return const_reverse_iterator(end());}
483 _LIBCPP_INLINE_VISIBILITY515 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
484 reverse_iterator rend() _NOEXCEPT516 reverse_iterator rend() _NOEXCEPT
485 {return reverse_iterator(begin());}517 {return reverse_iterator(begin());}
486 _LIBCPP_INLINE_VISIBILITY518 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
487 const_reverse_iterator rend() const _NOEXCEPT519 const_reverse_iterator rend() const _NOEXCEPT
488 {return const_reverse_iterator(begin());}520 {return const_reverse_iterator(begin());}
489521
490 _LIBCPP_INLINE_VISIBILITY522 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
491 const_iterator cbegin() const _NOEXCEPT523 const_iterator cbegin() const _NOEXCEPT
492 {return begin();}524 {return begin();}
493 _LIBCPP_INLINE_VISIBILITY525 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
494 const_iterator cend() const _NOEXCEPT526 const_iterator cend() const _NOEXCEPT
495 {return end();}527 {return end();}
496 _LIBCPP_INLINE_VISIBILITY528 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
497 const_reverse_iterator crbegin() const _NOEXCEPT529 const_reverse_iterator crbegin() const _NOEXCEPT
498 {return rbegin();}530 {return rbegin();}
499 _LIBCPP_INLINE_VISIBILITY531 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
500 const_reverse_iterator crend() const _NOEXCEPT532 const_reverse_iterator crend() const _NOEXCEPT
501 {return rend();}533 {return rend();}
502534
503 _LIBCPP_INLINE_VISIBILITY535 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
504 size_type size() const _NOEXCEPT536 size_type size() const _NOEXCEPT
505 {return static_cast<size_type>(this->__end_ - this->__begin_);}537 {return static_cast<size_type>(this->__end_ - this->__begin_);}
506 _LIBCPP_INLINE_VISIBILITY538 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
507 size_type capacity() const _NOEXCEPT539 size_type capacity() const _NOEXCEPT
508 {return static_cast<size_type>(__end_cap() - this->__begin_);}540 {return static_cast<size_type>(__end_cap() - this->__begin_);}
509 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY541 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
510 bool empty() const _NOEXCEPT542 bool empty() const _NOEXCEPT
511 {return this->__begin_ == this->__end_;}543 {return this->__begin_ == this->__end_;}
512 size_type max_size() const _NOEXCEPT;544 _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type max_size() const _NOEXCEPT;
513 void reserve(size_type __n);545 _LIBCPP_CONSTEXPR_AFTER_CXX17 void reserve(size_type __n);
514 void shrink_to_fit() _NOEXCEPT;546 _LIBCPP_CONSTEXPR_AFTER_CXX17 void shrink_to_fit() _NOEXCEPT;
515547
516 _LIBCPP_INLINE_VISIBILITY reference operator[](size_type __n) _NOEXCEPT;548 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY reference operator[](size_type __n) _NOEXCEPT;
517 _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __n) const _NOEXCEPT;549 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __n) const _NOEXCEPT;
518 reference at(size_type __n);550 _LIBCPP_CONSTEXPR_AFTER_CXX17 reference at(size_type __n);
519 const_reference at(size_type __n) const;551 _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference at(size_type __n) const;
520552
521 _LIBCPP_INLINE_VISIBILITY reference front() _NOEXCEPT553 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY reference front() _NOEXCEPT
522 {554 {
523 _LIBCPP_ASSERT(!empty(), "front() called on an empty vector");555 _LIBCPP_ASSERT(!empty(), "front() called on an empty vector");
524 return *this->__begin_;556 return *this->__begin_;
525 }557 }
526 _LIBCPP_INLINE_VISIBILITY const_reference front() const _NOEXCEPT558 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_reference front() const _NOEXCEPT
527 {559 {
528 _LIBCPP_ASSERT(!empty(), "front() called on an empty vector");560 _LIBCPP_ASSERT(!empty(), "front() called on an empty vector");
529 return *this->__begin_;561 return *this->__begin_;
530 }562 }
531 _LIBCPP_INLINE_VISIBILITY reference back() _NOEXCEPT563 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY reference back() _NOEXCEPT
532 {564 {
533 _LIBCPP_ASSERT(!empty(), "back() called on an empty vector");565 _LIBCPP_ASSERT(!empty(), "back() called on an empty vector");
534 return *(this->__end_ - 1);566 return *(this->__end_ - 1);
535 }567 }
536 _LIBCPP_INLINE_VISIBILITY const_reference back() const _NOEXCEPT568 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_reference back() const _NOEXCEPT
537 {569 {
538 _LIBCPP_ASSERT(!empty(), "back() called on an empty vector");570 _LIBCPP_ASSERT(!empty(), "back() called on an empty vector");
539 return *(this->__end_ - 1);571 return *(this->__end_ - 1);
540 }572 }
541573
542 _LIBCPP_INLINE_VISIBILITY574 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
543 value_type* data() _NOEXCEPT575 value_type* data() _NOEXCEPT
544 {return _VSTD::__to_address(this->__begin_);}576 {return _VSTD::__to_address(this->__begin_);}
545 _LIBCPP_INLINE_VISIBILITY577
578 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
546 const value_type* data() const _NOEXCEPT579 const value_type* data() const _NOEXCEPT
547 {return _VSTD::__to_address(this->__begin_);}580 {return _VSTD::__to_address(this->__begin_);}
548581
549#ifdef _LIBCPP_CXX03_LANG582 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x);
550 _LIBCPP_INLINE_VISIBILITY
551 void __emplace_back(const value_type& __x) { push_back(__x); }
552#else
553 template <class _Arg>
554 _LIBCPP_INLINE_VISIBILITY
555 void __emplace_back(_Arg&& __arg) {
556 emplace_back(_VSTD::forward<_Arg>(__arg));
557 }
558#endif
559
560 _LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x);
561583
562#ifndef _LIBCPP_CXX03_LANG584 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void push_back(value_type&& __x);
563 _LIBCPP_INLINE_VISIBILITY void push_back(value_type&& __x);
564585
565 template <class... _Args>586 template <class... _Args>
566 _LIBCPP_INLINE_VISIBILITY587 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
567#if _LIBCPP_STD_VER > 14588#if _LIBCPP_STD_VER > 14
568 reference emplace_back(_Args&&... __args);589 reference emplace_back(_Args&&... __args);
569#else590#else
570 void emplace_back(_Args&&... __args);591 void emplace_back(_Args&&... __args);
571#endif592#endif
572#endif // !_LIBCPP_CXX03_LANG
573593
574 _LIBCPP_INLINE_VISIBILITY594 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
575 void pop_back();595 void pop_back();
576596
577 iterator insert(const_iterator __position, const_reference __x);597 _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator insert(const_iterator __position, const_reference __x);
578598
579#ifndef _LIBCPP_CXX03_LANG599 _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator insert(const_iterator __position, value_type&& __x);
580 iterator insert(const_iterator __position, value_type&& __x);
581 template <class... _Args>600 template <class... _Args>
582 iterator emplace(const_iterator __position, _Args&&... __args);601 _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator emplace(const_iterator __position, _Args&&... __args);
583#endif // !_LIBCPP_CXX03_LANG
584602
585 iterator insert(const_iterator __position, size_type __n, const_reference __x);603 _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator insert(const_iterator __position, size_type __n, const_reference __x);
586 template <class _InputIterator>604 template <class _InputIterator>
587 typename enable_if605 _LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
588 <
589 __is_cpp17_input_iterator <_InputIterator>::value &&
590 !__is_cpp17_forward_iterator<_InputIterator>::value &&
591 is_constructible<606 is_constructible<
592 value_type,607 value_type,
593 typename iterator_traits<_InputIterator>::reference>::value,608 typename iterator_traits<_InputIterator>::reference>::value,
...@@ -595,6 +610,7 @@ public:...@@ -595,6 +610,7 @@ public:
595 >::type610 >::type
596 insert(const_iterator __position, _InputIterator __first, _InputIterator __last);611 insert(const_iterator __position, _InputIterator __first, _InputIterator __last);
597 template <class _ForwardIterator>612 template <class _ForwardIterator>
613 _LIBCPP_CONSTEXPR_AFTER_CXX17
598 typename enable_if614 typename enable_if
599 <615 <
600 __is_cpp17_forward_iterator<_ForwardIterator>::value &&616 __is_cpp17_forward_iterator<_ForwardIterator>::value &&
...@@ -606,27 +622,27 @@ public:...@@ -606,27 +622,27 @@ public:
606 insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last);622 insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last);
607623
608#ifndef _LIBCPP_CXX03_LANG624#ifndef _LIBCPP_CXX03_LANG
609 _LIBCPP_INLINE_VISIBILITY625 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
610 iterator insert(const_iterator __position, initializer_list<value_type> __il)626 iterator insert(const_iterator __position, initializer_list<value_type> __il)
611 {return insert(__position, __il.begin(), __il.end());}627 {return insert(__position, __il.begin(), __il.end());}
612#endif628#endif
613629
614 _LIBCPP_INLINE_VISIBILITY iterator erase(const_iterator __position);630 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY iterator erase(const_iterator __position);
615 iterator erase(const_iterator __first, const_iterator __last);631 _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator erase(const_iterator __first, const_iterator __last);
616632
617 _LIBCPP_INLINE_VISIBILITY633 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
618 void clear() _NOEXCEPT634 void clear() _NOEXCEPT
619 {635 {
620 size_type __old_size = size();636 size_type __old_size = size();
621 __clear();637 __clear();
622 __annotate_shrink(__old_size);638 __annotate_shrink(__old_size);
623 __invalidate_all_iterators();639 std::__debug_db_invalidate_all(this);
624 }640 }
625641
626 void resize(size_type __sz);642 _LIBCPP_CONSTEXPR_AFTER_CXX17 void resize(size_type __sz);
627 void resize(size_type __sz, const_reference __x);643 _LIBCPP_CONSTEXPR_AFTER_CXX17 void resize(size_type __sz, const_reference __x);
628644
629 void swap(vector&)645 _LIBCPP_CONSTEXPR_AFTER_CXX17 void swap(vector&)
630#if _LIBCPP_STD_VER >= 14646#if _LIBCPP_STD_VER >= 14
631 _NOEXCEPT;647 _NOEXCEPT;
632#else648#else
...@@ -634,16 +650,16 @@ public:...@@ -634,16 +650,16 @@ public:
634 __is_nothrow_swappable<allocator_type>::value);650 __is_nothrow_swappable<allocator_type>::value);
635#endif651#endif
636652
637 bool __invariants() const;653 _LIBCPP_CONSTEXPR_AFTER_CXX17 bool __invariants() const;
638654
639#if _LIBCPP_DEBUG_LEVEL == 2655#ifdef _LIBCPP_ENABLE_DEBUG_MODE
640656
641 bool __dereferenceable(const const_iterator* __i) const;657 bool __dereferenceable(const const_iterator* __i) const;
642 bool __decrementable(const const_iterator* __i) const;658 bool __decrementable(const const_iterator* __i) const;
643 bool __addable(const const_iterator* __i, ptrdiff_t __n) const;659 bool __addable(const const_iterator* __i, ptrdiff_t __n) const;
644 bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const;660 bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const;
645661
646#endif // _LIBCPP_DEBUG_LEVEL == 2662#endif // _LIBCPP_ENABLE_DEBUG_MODE
647663
648private:664private:
649 pointer __begin_ = nullptr;665 pointer __begin_ = nullptr;
...@@ -651,95 +667,108 @@ private:...@@ -651,95 +667,108 @@ private:
651 __compressed_pair<pointer, allocator_type> __end_cap_ =667 __compressed_pair<pointer, allocator_type> __end_cap_ =
652 __compressed_pair<pointer, allocator_type>(nullptr, __default_init_tag());668 __compressed_pair<pointer, allocator_type>(nullptr, __default_init_tag());
653669
654 _LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators();
655 _LIBCPP_INLINE_VISIBILITY void __invalidate_iterators_past(pointer __new_last);670 _LIBCPP_INLINE_VISIBILITY void __invalidate_iterators_past(pointer __new_last);
656 void __vallocate(size_type __n);671
657 void __vdeallocate() _NOEXCEPT;672 // Allocate space for __n objects
658 _LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __new_size) const;673 // throws length_error if __n > max_size()
659 void __construct_at_end(size_type __n);674 // throws (probably bad_alloc) if memory run out
660 _LIBCPP_INLINE_VISIBILITY675 // Precondition: __begin_ == __end_ == __end_cap() == 0
676 // Precondition: __n > 0
677 // Postcondition: capacity() >= __n
678 // Postcondition: size() == 0
679 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI void __vallocate(size_type __n) {
680 if (__n > max_size())
681 __throw_length_error();
682 auto __allocation = std::__allocate_at_least(__alloc(), __n);
683 __begin_ = __allocation.ptr;
684 __end_ = __allocation.ptr;
685 __end_cap() = __begin_ + __allocation.count;
686 __annotate_new(0);
687 }
688
689 _LIBCPP_CONSTEXPR_AFTER_CXX17 void __vdeallocate() _NOEXCEPT;
690 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __new_size) const;
691 _LIBCPP_CONSTEXPR_AFTER_CXX17 void __construct_at_end(size_type __n);
692 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
661 void __construct_at_end(size_type __n, const_reference __x);693 void __construct_at_end(size_type __n, const_reference __x);
662 template <class _ForwardIterator>694 template <class _ForwardIterator>
695 _LIBCPP_CONSTEXPR_AFTER_CXX17
663 typename enable_if696 typename enable_if
664 <697 <
665 __is_cpp17_forward_iterator<_ForwardIterator>::value,698 __is_cpp17_forward_iterator<_ForwardIterator>::value,
666 void699 void
667 >::type700 >::type
668 __construct_at_end(_ForwardIterator __first, _ForwardIterator __last, size_type __n);701 __construct_at_end(_ForwardIterator __first, _ForwardIterator __last, size_type __n);
669 void __append(size_type __n);702 _LIBCPP_CONSTEXPR_AFTER_CXX17 void __append(size_type __n);
670 void __append(size_type __n, const_reference __x);703 _LIBCPP_CONSTEXPR_AFTER_CXX17 void __append(size_type __n, const_reference __x);
671 _LIBCPP_INLINE_VISIBILITY704 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
672 iterator __make_iter(pointer __p) _NOEXCEPT;705 iterator __make_iter(pointer __p) _NOEXCEPT;
673 _LIBCPP_INLINE_VISIBILITY706 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
674 const_iterator __make_iter(const_pointer __p) const _NOEXCEPT;707 const_iterator __make_iter(const_pointer __p) const _NOEXCEPT;
675 void __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v);708 _LIBCPP_CONSTEXPR_AFTER_CXX17 void __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v);
676 pointer __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p);709 _LIBCPP_CONSTEXPR_AFTER_CXX17 pointer __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p);
677 void __move_range(pointer __from_s, pointer __from_e, pointer __to);710 _LIBCPP_CONSTEXPR_AFTER_CXX17 void __move_range(pointer __from_s, pointer __from_e, pointer __to);
678 void __move_assign(vector& __c, true_type)711 _LIBCPP_CONSTEXPR_AFTER_CXX17 void __move_assign(vector& __c, true_type)
679 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value);712 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value);
680 void __move_assign(vector& __c, false_type)713 _LIBCPP_CONSTEXPR_AFTER_CXX17 void __move_assign(vector& __c, false_type)
681 _NOEXCEPT_(__alloc_traits::is_always_equal::value);714 _NOEXCEPT_(__alloc_traits::is_always_equal::value);
682 _LIBCPP_INLINE_VISIBILITY715 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
683 void __destruct_at_end(pointer __new_last) _NOEXCEPT716 void __destruct_at_end(pointer __new_last) _NOEXCEPT
684 {717 {
685 __invalidate_iterators_past(__new_last);718 if (!__libcpp_is_constant_evaluated())
719 __invalidate_iterators_past(__new_last);
686 size_type __old_size = size();720 size_type __old_size = size();
687 __base_destruct_at_end(__new_last);721 __base_destruct_at_end(__new_last);
688 __annotate_shrink(__old_size);722 __annotate_shrink(__old_size);
689 }723 }
690724
691#ifndef _LIBCPP_CXX03_LANG
692 template <class _Up>725 template <class _Up>
693 _LIBCPP_INLINE_VISIBILITY726 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
694 inline void __push_back_slow_path(_Up&& __x);727 inline void __push_back_slow_path(_Up&& __x);
695728
696 template <class... _Args>729 template <class... _Args>
697 _LIBCPP_INLINE_VISIBILITY730 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
698 inline void __emplace_back_slow_path(_Args&&... __args);731 inline void __emplace_back_slow_path(_Args&&... __args);
699#else
700 template <class _Up>
701 _LIBCPP_INLINE_VISIBILITY
702 inline void __push_back_slow_path(_Up& __x);
703#endif
704732
705 // The following functions are no-ops outside of AddressSanitizer mode.733 // The following functions are no-ops outside of AddressSanitizer mode.
706 // We call annotatations only for the default Allocator because other allocators734 // We call annotatations only for the default Allocator because other allocators
707 // may not meet the AddressSanitizer alignment constraints.735 // may not meet the AddressSanitizer alignment constraints.
708 // See the documentation for __sanitizer_annotate_contiguous_container for more details.736 // See the documentation for __sanitizer_annotate_contiguous_container for more details.
709#ifndef _LIBCPP_HAS_NO_ASAN737#ifndef _LIBCPP_HAS_NO_ASAN
738 _LIBCPP_CONSTEXPR_AFTER_CXX17
710 void __annotate_contiguous_container(const void *__beg, const void *__end,739 void __annotate_contiguous_container(const void *__beg, const void *__end,
711 const void *__old_mid,740 const void *__old_mid,
712 const void *__new_mid) const741 const void *__new_mid) const
713 {742 {
714743
715 if (__beg && is_same<allocator_type, __default_allocator_type>::value)744 if (!__libcpp_is_constant_evaluated() && __beg && is_same<allocator_type, __default_allocator_type>::value)
716 __sanitizer_annotate_contiguous_container(__beg, __end, __old_mid, __new_mid);745 __sanitizer_annotate_contiguous_container(__beg, __end, __old_mid, __new_mid);
717 }746 }
718#else747#else
719 _LIBCPP_INLINE_VISIBILITY748 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
720 void __annotate_contiguous_container(const void*, const void*, const void*,749 void __annotate_contiguous_container(const void*, const void*, const void*,
721 const void*) const _NOEXCEPT {}750 const void*) const _NOEXCEPT {}
722#endif751#endif
723 _LIBCPP_INLINE_VISIBILITY752 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
724 void __annotate_new(size_type __current_size) const _NOEXCEPT {753 void __annotate_new(size_type __current_size) const _NOEXCEPT {
725 __annotate_contiguous_container(data(), data() + capacity(),754 __annotate_contiguous_container(data(), data() + capacity(),
726 data() + capacity(), data() + __current_size);755 data() + capacity(), data() + __current_size);
727 }756 }
728757
729 _LIBCPP_INLINE_VISIBILITY758 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
730 void __annotate_delete() const _NOEXCEPT {759 void __annotate_delete() const _NOEXCEPT {
731 __annotate_contiguous_container(data(), data() + capacity(),760 __annotate_contiguous_container(data(), data() + capacity(),
732 data() + size(), data() + capacity());761 data() + size(), data() + capacity());
733 }762 }
734763
735 _LIBCPP_INLINE_VISIBILITY764 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
736 void __annotate_increase(size_type __n) const _NOEXCEPT765 void __annotate_increase(size_type __n) const _NOEXCEPT
737 {766 {
738 __annotate_contiguous_container(data(), data() + capacity(),767 __annotate_contiguous_container(data(), data() + capacity(),
739 data() + size(), data() + size() + __n);768 data() + size(), data() + size() + __n);
740 }769 }
741770
742 _LIBCPP_INLINE_VISIBILITY771 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
743 void __annotate_shrink(size_type __old_size) const _NOEXCEPT772 void __annotate_shrink(size_type __old_size) const _NOEXCEPT
744 {773 {
745 __annotate_contiguous_container(data(), data() + capacity(),774 __annotate_contiguous_container(data(), data() + capacity(),
...@@ -747,13 +776,14 @@ private:...@@ -747,13 +776,14 @@ private:
747 }776 }
748777
749 struct _ConstructTransaction {778 struct _ConstructTransaction {
779 _LIBCPP_CONSTEXPR_AFTER_CXX17
750 explicit _ConstructTransaction(vector &__v, size_type __n)780 explicit _ConstructTransaction(vector &__v, size_type __n)
751 : __v_(__v), __pos_(__v.__end_), __new_end_(__v.__end_ + __n) {781 : __v_(__v), __pos_(__v.__end_), __new_end_(__v.__end_ + __n) {
752#ifndef _LIBCPP_HAS_NO_ASAN782#ifndef _LIBCPP_HAS_NO_ASAN
753 __v_.__annotate_increase(__n);783 __v_.__annotate_increase(__n);
754#endif784#endif
755 }785 }
756 ~_ConstructTransaction() {786 _LIBCPP_CONSTEXPR_AFTER_CXX17 ~_ConstructTransaction() {
757 __v_.__end_ = __pos_;787 __v_.__end_ = __pos_;
758#ifndef _LIBCPP_HAS_NO_ASAN788#ifndef _LIBCPP_HAS_NO_ASAN
759 if (__pos_ != __new_end_) {789 if (__pos_ != __new_end_) {
...@@ -772,7 +802,7 @@ private:...@@ -772,7 +802,7 @@ private:
772 };802 };
773803
774 template <class ..._Args>804 template <class ..._Args>
775 _LIBCPP_INLINE_VISIBILITY805 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
776 void __construct_one_at_end(_Args&& ...__args) {806 void __construct_one_at_end(_Args&& ...__args) {
777 _ConstructTransaction __tx(*this, 1);807 _ConstructTransaction __tx(*this, 1);
778 __alloc_traits::construct(this->__alloc(), _VSTD::__to_address(__tx.__pos_),808 __alloc_traits::construct(this->__alloc(), _VSTD::__to_address(__tx.__pos_),
...@@ -780,23 +810,23 @@ private:...@@ -780,23 +810,23 @@ private:
780 ++__tx.__pos_;810 ++__tx.__pos_;
781 }811 }
782812
783 _LIBCPP_INLINE_VISIBILITY813 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
784 allocator_type& __alloc() _NOEXCEPT814 allocator_type& __alloc() _NOEXCEPT
785 {return this->__end_cap_.second();}815 {return this->__end_cap_.second();}
786 _LIBCPP_INLINE_VISIBILITY816 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
787 const allocator_type& __alloc() const _NOEXCEPT817 const allocator_type& __alloc() const _NOEXCEPT
788 {return this->__end_cap_.second();}818 {return this->__end_cap_.second();}
789 _LIBCPP_INLINE_VISIBILITY819 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
790 pointer& __end_cap() _NOEXCEPT820 pointer& __end_cap() _NOEXCEPT
791 {return this->__end_cap_.first();}821 {return this->__end_cap_.first();}
792 _LIBCPP_INLINE_VISIBILITY822 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
793 const pointer& __end_cap() const _NOEXCEPT823 const pointer& __end_cap() const _NOEXCEPT
794 {return this->__end_cap_.first();}824 {return this->__end_cap_.first();}
795825
796 _LIBCPP_INLINE_VISIBILITY826 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
797 void __clear() _NOEXCEPT {__base_destruct_at_end(this->__begin_);}827 void __clear() _NOEXCEPT {__base_destruct_at_end(this->__begin_);}
798828
799 _LIBCPP_INLINE_VISIBILITY829 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
800 void __base_destruct_at_end(pointer __new_last) _NOEXCEPT {830 void __base_destruct_at_end(pointer __new_last) _NOEXCEPT {
801 pointer __soon_to_be_end = this->__end_;831 pointer __soon_to_be_end = this->__end_;
802 while (__new_last != __soon_to_be_end)832 while (__new_last != __soon_to_be_end)
...@@ -804,12 +834,12 @@ private:...@@ -804,12 +834,12 @@ private:
804 this->__end_ = __new_last;834 this->__end_ = __new_last;
805 }835 }
806836
807 _LIBCPP_INLINE_VISIBILITY837 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
808 void __copy_assign_alloc(const vector& __c)838 void __copy_assign_alloc(const vector& __c)
809 {__copy_assign_alloc(__c, integral_constant<bool,839 {__copy_assign_alloc(__c, integral_constant<bool,
810 __alloc_traits::propagate_on_container_copy_assignment::value>());}840 __alloc_traits::propagate_on_container_copy_assignment::value>());}
811841
812 _LIBCPP_INLINE_VISIBILITY842 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
813 void __move_assign_alloc(vector& __c)843 void __move_assign_alloc(vector& __c)
814 _NOEXCEPT_(844 _NOEXCEPT_(
815 !__alloc_traits::propagate_on_container_move_assignment::value ||845 !__alloc_traits::propagate_on_container_move_assignment::value ||
...@@ -827,7 +857,7 @@ private:...@@ -827,7 +857,7 @@ private:
827 _VSTD::__throw_out_of_range("vector");857 _VSTD::__throw_out_of_range("vector");
828 }858 }
829859
830 _LIBCPP_INLINE_VISIBILITY860 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
831 void __copy_assign_alloc(const vector& __c, true_type)861 void __copy_assign_alloc(const vector& __c, true_type)
832 {862 {
833 if (__alloc() != __c.__alloc())863 if (__alloc() != __c.__alloc())
...@@ -839,18 +869,18 @@ private:...@@ -839,18 +869,18 @@ private:
839 __alloc() = __c.__alloc();869 __alloc() = __c.__alloc();
840 }870 }
841871
842 _LIBCPP_INLINE_VISIBILITY872 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
843 void __copy_assign_alloc(const vector&, false_type)873 void __copy_assign_alloc(const vector&, false_type)
844 {}874 {}
845875
846 _LIBCPP_INLINE_VISIBILITY876 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
847 void __move_assign_alloc(vector& __c, true_type)877 void __move_assign_alloc(vector& __c, true_type)
848 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)878 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
849 {879 {
850 __alloc() = _VSTD::move(__c.__alloc());880 __alloc() = _VSTD::move(__c.__alloc());
851 }881 }
852882
853 _LIBCPP_INLINE_VISIBILITY883 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
854 void __move_assign_alloc(vector&, false_type)884 void __move_assign_alloc(vector&, false_type)
855 _NOEXCEPT885 _NOEXCEPT
856 {}886 {}
...@@ -875,56 +905,46 @@ vector(_InputIterator, _InputIterator, _Alloc)...@@ -875,56 +905,46 @@ vector(_InputIterator, _InputIterator, _Alloc)
875#endif905#endif
876906
877template <class _Tp, class _Allocator>907template <class _Tp, class _Allocator>
908_LIBCPP_CONSTEXPR_AFTER_CXX17
878void909void
879vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v)910vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v)
880{911{
881
882 __annotate_delete();912 __annotate_delete();
883 _VSTD::__construct_backward_with_exception_guarantees(this->__alloc(), this->__begin_, this->__end_, __v.__begin_);913 using _RevIter = std::reverse_iterator<pointer>;
914 __v.__begin_ = std::__uninitialized_allocator_move_if_noexcept(
915 __alloc(), _RevIter(__end_), _RevIter(__begin_), _RevIter(__v.__begin_))
916 .base();
884 _VSTD::swap(this->__begin_, __v.__begin_);917 _VSTD::swap(this->__begin_, __v.__begin_);
885 _VSTD::swap(this->__end_, __v.__end_);918 _VSTD::swap(this->__end_, __v.__end_);
886 _VSTD::swap(this->__end_cap(), __v.__end_cap());919 _VSTD::swap(this->__end_cap(), __v.__end_cap());
887 __v.__first_ = __v.__begin_;920 __v.__first_ = __v.__begin_;
888 __annotate_new(size());921 __annotate_new(size());
889 __invalidate_all_iterators();922 std::__debug_db_invalidate_all(this);
890}923}
891924
892template <class _Tp, class _Allocator>925template <class _Tp, class _Allocator>
926_LIBCPP_CONSTEXPR_AFTER_CXX17
893typename vector<_Tp, _Allocator>::pointer927typename vector<_Tp, _Allocator>::pointer
894vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p)928vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p)
895{929{
896 __annotate_delete();930 __annotate_delete();
897 pointer __r = __v.__begin_;931 pointer __r = __v.__begin_;
898 _VSTD::__construct_backward_with_exception_guarantees(this->__alloc(), this->__begin_, __p, __v.__begin_);932 using _RevIter = std::reverse_iterator<pointer>;
899 _VSTD::__construct_forward_with_exception_guarantees(this->__alloc(), __p, this->__end_, __v.__end_);933 __v.__begin_ = std::__uninitialized_allocator_move_if_noexcept(
934 __alloc(), _RevIter(__p), _RevIter(__begin_), _RevIter(__v.__begin_))
935 .base();
936 __v.__end_ = std::__uninitialized_allocator_move_if_noexcept(__alloc(), __p, __end_, __v.__end_);
900 _VSTD::swap(this->__begin_, __v.__begin_);937 _VSTD::swap(this->__begin_, __v.__begin_);
901 _VSTD::swap(this->__end_, __v.__end_);938 _VSTD::swap(this->__end_, __v.__end_);
902 _VSTD::swap(this->__end_cap(), __v.__end_cap());939 _VSTD::swap(this->__end_cap(), __v.__end_cap());
903 __v.__first_ = __v.__begin_;940 __v.__first_ = __v.__begin_;
904 __annotate_new(size());941 __annotate_new(size());
905 __invalidate_all_iterators();942 std::__debug_db_invalidate_all(this);
906 return __r;943 return __r;
907}944}
908945
909// Allocate space for __n objects
910// throws length_error if __n > max_size()
911// throws (probably bad_alloc) if memory run out
912// Precondition: __begin_ == __end_ == __end_cap() == 0
913// Precondition: __n > 0
914// Postcondition: capacity() == __n
915// Postcondition: size() == 0
916template <class _Tp, class _Allocator>
917void
918vector<_Tp, _Allocator>::__vallocate(size_type __n)
919{
920 if (__n > max_size())
921 this->__throw_length_error();
922 this->__begin_ = this->__end_ = __alloc_traits::allocate(this->__alloc(), __n);
923 this->__end_cap() = this->__begin_ + __n;
924 __annotate_new(0);
925}
926
927template <class _Tp, class _Allocator>946template <class _Tp, class _Allocator>
947_LIBCPP_CONSTEXPR_AFTER_CXX17
928void948void
929vector<_Tp, _Allocator>::__vdeallocate() _NOEXCEPT949vector<_Tp, _Allocator>::__vdeallocate() _NOEXCEPT
930{950{
...@@ -937,6 +957,7 @@ vector<_Tp, _Allocator>::__vdeallocate() _NOEXCEPT...@@ -937,6 +957,7 @@ vector<_Tp, _Allocator>::__vdeallocate() _NOEXCEPT
937}957}
938958
939template <class _Tp, class _Allocator>959template <class _Tp, class _Allocator>
960_LIBCPP_CONSTEXPR_AFTER_CXX17
940typename vector<_Tp, _Allocator>::size_type961typename vector<_Tp, _Allocator>::size_type
941vector<_Tp, _Allocator>::max_size() const _NOEXCEPT962vector<_Tp, _Allocator>::max_size() const _NOEXCEPT
942{963{
...@@ -946,6 +967,7 @@ vector<_Tp, _Allocator>::max_size() const _NOEXCEPT...@@ -946,6 +967,7 @@ vector<_Tp, _Allocator>::max_size() const _NOEXCEPT
946967
947// Precondition: __new_size > capacity()968// Precondition: __new_size > capacity()
948template <class _Tp, class _Allocator>969template <class _Tp, class _Allocator>
970_LIBCPP_CONSTEXPR_AFTER_CXX17
949inline _LIBCPP_INLINE_VISIBILITY971inline _LIBCPP_INLINE_VISIBILITY
950typename vector<_Tp, _Allocator>::size_type972typename vector<_Tp, _Allocator>::size_type
951vector<_Tp, _Allocator>::__recommend(size_type __new_size) const973vector<_Tp, _Allocator>::__recommend(size_type __new_size) const
...@@ -965,6 +987,7 @@ vector<_Tp, _Allocator>::__recommend(size_type __new_size) const...@@ -965,6 +987,7 @@ vector<_Tp, _Allocator>::__recommend(size_type __new_size) const
965// Precondition: size() + __n <= capacity()987// Precondition: size() + __n <= capacity()
966// Postcondition: size() == size() + __n988// Postcondition: size() == size() + __n
967template <class _Tp, class _Allocator>989template <class _Tp, class _Allocator>
990_LIBCPP_CONSTEXPR_AFTER_CXX17
968void991void
969vector<_Tp, _Allocator>::__construct_at_end(size_type __n)992vector<_Tp, _Allocator>::__construct_at_end(size_type __n)
970{993{
...@@ -982,6 +1005,7 @@ vector<_Tp, _Allocator>::__construct_at_end(size_type __n)...@@ -982,6 +1005,7 @@ vector<_Tp, _Allocator>::__construct_at_end(size_type __n)
982// Postcondition: size() == old size() + __n1005// Postcondition: size() == old size() + __n
983// Postcondition: [i] == __x for all i in [size() - __n, __n)1006// Postcondition: [i] == __x for all i in [size() - __n, __n)
984template <class _Tp, class _Allocator>1007template <class _Tp, class _Allocator>
1008_LIBCPP_CONSTEXPR_AFTER_CXX17
985inline1009inline
986void1010void
987vector<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x)1011vector<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x)
...@@ -995,6 +1019,7 @@ vector<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x)...@@ -995,6 +1019,7 @@ vector<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x)
9951019
996template <class _Tp, class _Allocator>1020template <class _Tp, class _Allocator>
997template <class _ForwardIterator>1021template <class _ForwardIterator>
1022_LIBCPP_CONSTEXPR_AFTER_CXX17
998typename enable_if1023typename enable_if
999<1024<
1000 __is_cpp17_forward_iterator<_ForwardIterator>::value,1025 __is_cpp17_forward_iterator<_ForwardIterator>::value,
...@@ -1002,8 +1027,8 @@ typename enable_if...@@ -1002,8 +1027,8 @@ typename enable_if
1002>::type1027>::type
1003vector<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last, size_type __n)1028vector<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last, size_type __n)
1004{1029{
1005 _ConstructTransaction __tx(*this, __n);1030 _ConstructTransaction __tx(*this, __n);
1006 _VSTD::__construct_range_forward(this->__alloc(), __first, __last, __tx.__pos_);1031 __tx.__pos_ = std::__uninitialized_allocator_copy(__alloc(), __first, __last, __tx.__pos_);
1007}1032}
10081033
1009// Default constructs __n objects starting at __end_1034// Default constructs __n objects starting at __end_
...@@ -1011,6 +1036,7 @@ vector<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIt...@@ -1011,6 +1036,7 @@ vector<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIt
1011// Postcondition: size() == size() + __n1036// Postcondition: size() == size() + __n
1012// Exception safety: strong.1037// Exception safety: strong.
1013template <class _Tp, class _Allocator>1038template <class _Tp, class _Allocator>
1039_LIBCPP_CONSTEXPR_AFTER_CXX17
1014void1040void
1015vector<_Tp, _Allocator>::__append(size_type __n)1041vector<_Tp, _Allocator>::__append(size_type __n)
1016{1042{
...@@ -1030,6 +1056,7 @@ vector<_Tp, _Allocator>::__append(size_type __n)...@@ -1030,6 +1056,7 @@ vector<_Tp, _Allocator>::__append(size_type __n)
1030// Postcondition: size() == size() + __n1056// Postcondition: size() == size() + __n
1031// Exception safety: strong.1057// Exception safety: strong.
1032template <class _Tp, class _Allocator>1058template <class _Tp, class _Allocator>
1059_LIBCPP_CONSTEXPR_AFTER_CXX17
1033void1060void
1034vector<_Tp, _Allocator>::__append(size_type __n, const_reference __x)1061vector<_Tp, _Allocator>::__append(size_type __n, const_reference __x)
1035{1062{
...@@ -1045,6 +1072,7 @@ vector<_Tp, _Allocator>::__append(size_type __n, const_reference __x)...@@ -1045,6 +1072,7 @@ vector<_Tp, _Allocator>::__append(size_type __n, const_reference __x)
1045}1072}
10461073
1047template <class _Tp, class _Allocator>1074template <class _Tp, class _Allocator>
1075_LIBCPP_CONSTEXPR_AFTER_CXX17
1048vector<_Tp, _Allocator>::vector(size_type __n)1076vector<_Tp, _Allocator>::vector(size_type __n)
1049{1077{
1050 _VSTD::__debug_db_insert_c(this);1078 _VSTD::__debug_db_insert_c(this);
...@@ -1057,6 +1085,7 @@ vector<_Tp, _Allocator>::vector(size_type __n)...@@ -1057,6 +1085,7 @@ vector<_Tp, _Allocator>::vector(size_type __n)
10571085
1058#if _LIBCPP_STD_VER > 111086#if _LIBCPP_STD_VER > 11
1059template <class _Tp, class _Allocator>1087template <class _Tp, class _Allocator>
1088_LIBCPP_CONSTEXPR_AFTER_CXX17
1060vector<_Tp, _Allocator>::vector(size_type __n, const allocator_type& __a)1089vector<_Tp, _Allocator>::vector(size_type __n, const allocator_type& __a)
1061 : __end_cap_(nullptr, __a)1090 : __end_cap_(nullptr, __a)
1062{1091{
...@@ -1070,6 +1099,7 @@ vector<_Tp, _Allocator>::vector(size_type __n, const allocator_type& __a)...@@ -1070,6 +1099,7 @@ vector<_Tp, _Allocator>::vector(size_type __n, const allocator_type& __a)
1070#endif1099#endif
10711100
1072template <class _Tp, class _Allocator>1101template <class _Tp, class _Allocator>
1102_LIBCPP_CONSTEXPR_AFTER_CXX17
1073vector<_Tp, _Allocator>::vector(size_type __n, const value_type& __x)1103vector<_Tp, _Allocator>::vector(size_type __n, const value_type& __x)
1074{1104{
1075 _VSTD::__debug_db_insert_c(this);1105 _VSTD::__debug_db_insert_c(this);
...@@ -1082,9 +1112,9 @@ vector<_Tp, _Allocator>::vector(size_type __n, const value_type& __x)...@@ -1082,9 +1112,9 @@ vector<_Tp, _Allocator>::vector(size_type __n, const value_type& __x)
10821112
1083template <class _Tp, class _Allocator>1113template <class _Tp, class _Allocator>
1084template <class _InputIterator>1114template <class _InputIterator>
1115_LIBCPP_CONSTEXPR_AFTER_CXX17
1085vector<_Tp, _Allocator>::vector(_InputIterator __first,1116vector<_Tp, _Allocator>::vector(_InputIterator __first,
1086 typename enable_if<__is_cpp17_input_iterator <_InputIterator>::value &&1117 typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
1087 !__is_cpp17_forward_iterator<_InputIterator>::value &&
1088 is_constructible<1118 is_constructible<
1089 value_type,1119 value_type,
1090 typename iterator_traits<_InputIterator>::reference>::value,1120 typename iterator_traits<_InputIterator>::reference>::value,
...@@ -1092,14 +1122,14 @@ vector<_Tp, _Allocator>::vector(_InputIterator __first,...@@ -1092,14 +1122,14 @@ vector<_Tp, _Allocator>::vector(_InputIterator __first,
1092{1122{
1093 _VSTD::__debug_db_insert_c(this);1123 _VSTD::__debug_db_insert_c(this);
1094 for (; __first != __last; ++__first)1124 for (; __first != __last; ++__first)
1095 __emplace_back(*__first);1125 emplace_back(*__first);
1096}1126}
10971127
1098template <class _Tp, class _Allocator>1128template <class _Tp, class _Allocator>
1099template <class _InputIterator>1129template <class _InputIterator>
1130_LIBCPP_CONSTEXPR_AFTER_CXX17
1100vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,1131vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,
1101 typename enable_if<__is_cpp17_input_iterator <_InputIterator>::value &&1132 typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
1102 !__is_cpp17_forward_iterator<_InputIterator>::value &&
1103 is_constructible<1133 is_constructible<
1104 value_type,1134 value_type,
1105 typename iterator_traits<_InputIterator>::reference>::value>::type*)1135 typename iterator_traits<_InputIterator>::reference>::value>::type*)
...@@ -1107,11 +1137,12 @@ vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last, c...@@ -1107,11 +1137,12 @@ vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last, c
1107{1137{
1108 _VSTD::__debug_db_insert_c(this);1138 _VSTD::__debug_db_insert_c(this);
1109 for (; __first != __last; ++__first)1139 for (; __first != __last; ++__first)
1110 __emplace_back(*__first);1140 emplace_back(*__first);
1111}1141}
11121142
1113template <class _Tp, class _Allocator>1143template <class _Tp, class _Allocator>
1114template <class _ForwardIterator>1144template <class _ForwardIterator>
1145_LIBCPP_CONSTEXPR_AFTER_CXX17
1115vector<_Tp, _Allocator>::vector(_ForwardIterator __first,1146vector<_Tp, _Allocator>::vector(_ForwardIterator __first,
1116 typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value &&1147 typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value &&
1117 is_constructible<1148 is_constructible<
...@@ -1130,6 +1161,7 @@ vector<_Tp, _Allocator>::vector(_ForwardIterator __first,...@@ -1130,6 +1161,7 @@ vector<_Tp, _Allocator>::vector(_ForwardIterator __first,
11301161
1131template <class _Tp, class _Allocator>1162template <class _Tp, class _Allocator>
1132template <class _ForwardIterator>1163template <class _ForwardIterator>
1164_LIBCPP_CONSTEXPR_AFTER_CXX17
1133vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,1165vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,
1134 typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value &&1166 typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value &&
1135 is_constructible<1167 is_constructible<
...@@ -1147,6 +1179,7 @@ vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __las...@@ -1147,6 +1179,7 @@ vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __las
1147}1179}
11481180
1149template <class _Tp, class _Allocator>1181template <class _Tp, class _Allocator>
1182_LIBCPP_CONSTEXPR_AFTER_CXX17
1150vector<_Tp, _Allocator>::vector(const vector& __x)1183vector<_Tp, _Allocator>::vector(const vector& __x)
1151 : __end_cap_(nullptr, __alloc_traits::select_on_container_copy_construction(__x.__alloc()))1184 : __end_cap_(nullptr, __alloc_traits::select_on_container_copy_construction(__x.__alloc()))
1152{1185{
...@@ -1160,7 +1193,8 @@ vector<_Tp, _Allocator>::vector(const vector& __x)...@@ -1160,7 +1193,8 @@ vector<_Tp, _Allocator>::vector(const vector& __x)
1160}1193}
11611194
1162template <class _Tp, class _Allocator>1195template <class _Tp, class _Allocator>
1163vector<_Tp, _Allocator>::vector(const vector& __x, const __identity_t<allocator_type>& __a)1196_LIBCPP_CONSTEXPR_AFTER_CXX17
1197vector<_Tp, _Allocator>::vector(const vector& __x, const __type_identity_t<allocator_type>& __a)
1164 : __end_cap_(nullptr, __a)1198 : __end_cap_(nullptr, __a)
1165{1199{
1166 _VSTD::__debug_db_insert_c(this);1200 _VSTD::__debug_db_insert_c(this);
...@@ -1172,22 +1206,19 @@ vector<_Tp, _Allocator>::vector(const vector& __x, const __identity_t<allocator_...@@ -1172,22 +1206,19 @@ vector<_Tp, _Allocator>::vector(const vector& __x, const __identity_t<allocator_
1172 }1206 }
1173}1207}
11741208
1175#ifndef _LIBCPP_CXX03_LANG
1176
1177template <class _Tp, class _Allocator>1209template <class _Tp, class _Allocator>
1210_LIBCPP_CONSTEXPR_AFTER_CXX17
1178inline _LIBCPP_INLINE_VISIBILITY1211inline _LIBCPP_INLINE_VISIBILITY
1179vector<_Tp, _Allocator>::vector(vector&& __x)1212vector<_Tp, _Allocator>::vector(vector&& __x)
1180#if _LIBCPP_STD_VER > 141213#if _LIBCPP_STD_VER > 14
1181 _NOEXCEPT1214 noexcept
1182#else1215#else
1183 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)1216 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
1184#endif1217#endif
1185 : __end_cap_(nullptr, _VSTD::move(__x.__alloc()))1218 : __end_cap_(nullptr, _VSTD::move(__x.__alloc()))
1186{1219{
1187 _VSTD::__debug_db_insert_c(this);1220 _VSTD::__debug_db_insert_c(this);
1188#if _LIBCPP_DEBUG_LEVEL == 21221 std::__debug_db_swap(this, std::addressof(__x));
1189 __get_db()->swap(this, _VSTD::addressof(__x));
1190#endif
1191 this->__begin_ = __x.__begin_;1222 this->__begin_ = __x.__begin_;
1192 this->__end_ = __x.__end_;1223 this->__end_ = __x.__end_;
1193 this->__end_cap() = __x.__end_cap();1224 this->__end_cap() = __x.__end_cap();
...@@ -1195,8 +1226,9 @@ vector<_Tp, _Allocator>::vector(vector&& __x)...@@ -1195,8 +1226,9 @@ vector<_Tp, _Allocator>::vector(vector&& __x)
1195}1226}
11961227
1197template <class _Tp, class _Allocator>1228template <class _Tp, class _Allocator>
1229_LIBCPP_CONSTEXPR_AFTER_CXX17
1198inline _LIBCPP_INLINE_VISIBILITY1230inline _LIBCPP_INLINE_VISIBILITY
1199vector<_Tp, _Allocator>::vector(vector&& __x, const __identity_t<allocator_type>& __a)1231vector<_Tp, _Allocator>::vector(vector&& __x, const __type_identity_t<allocator_type>& __a)
1200 : __end_cap_(nullptr, __a)1232 : __end_cap_(nullptr, __a)
1201{1233{
1202 _VSTD::__debug_db_insert_c(this);1234 _VSTD::__debug_db_insert_c(this);
...@@ -1206,9 +1238,7 @@ vector<_Tp, _Allocator>::vector(vector&& __x, const __identity_t<allocator_type>...@@ -1206,9 +1238,7 @@ vector<_Tp, _Allocator>::vector(vector&& __x, const __identity_t<allocator_type>
1206 this->__end_ = __x.__end_;1238 this->__end_ = __x.__end_;
1207 this->__end_cap() = __x.__end_cap();1239 this->__end_cap() = __x.__end_cap();
1208 __x.__begin_ = __x.__end_ = __x.__end_cap() = nullptr;1240 __x.__begin_ = __x.__end_ = __x.__end_cap() = nullptr;
1209#if _LIBCPP_DEBUG_LEVEL == 21241 std::__debug_db_swap(this, std::addressof(__x));
1210 __get_db()->swap(this, _VSTD::addressof(__x));
1211#endif
1212 }1242 }
1213 else1243 else
1214 {1244 {
...@@ -1217,7 +1247,10 @@ vector<_Tp, _Allocator>::vector(vector&& __x, const __identity_t<allocator_type>...@@ -1217,7 +1247,10 @@ vector<_Tp, _Allocator>::vector(vector&& __x, const __identity_t<allocator_type>
1217 }1247 }
1218}1248}
12191249
1250#ifndef _LIBCPP_CXX03_LANG
1251
1220template <class _Tp, class _Allocator>1252template <class _Tp, class _Allocator>
1253_LIBCPP_CONSTEXPR_AFTER_CXX17
1221inline _LIBCPP_INLINE_VISIBILITY1254inline _LIBCPP_INLINE_VISIBILITY
1222vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il)1255vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il)
1223{1256{
...@@ -1230,6 +1263,7 @@ vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il)...@@ -1230,6 +1263,7 @@ vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il)
1230}1263}
12311264
1232template <class _Tp, class _Allocator>1265template <class _Tp, class _Allocator>
1266_LIBCPP_CONSTEXPR_AFTER_CXX17
1233inline _LIBCPP_INLINE_VISIBILITY1267inline _LIBCPP_INLINE_VISIBILITY
1234vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a)1268vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a)
1235 : __end_cap_(nullptr, __a)1269 : __end_cap_(nullptr, __a)
...@@ -1242,7 +1276,10 @@ vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il, const allocat...@@ -1242,7 +1276,10 @@ vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il, const allocat
1242 }1276 }
1243}1277}
12441278
1279#endif // _LIBCPP_CXX03_LANG
1280
1245template <class _Tp, class _Allocator>1281template <class _Tp, class _Allocator>
1282_LIBCPP_CONSTEXPR_AFTER_CXX17
1246inline _LIBCPP_INLINE_VISIBILITY1283inline _LIBCPP_INLINE_VISIBILITY
1247vector<_Tp, _Allocator>&1284vector<_Tp, _Allocator>&
1248vector<_Tp, _Allocator>::operator=(vector&& __x)1285vector<_Tp, _Allocator>::operator=(vector&& __x)
...@@ -1254,6 +1291,7 @@ vector<_Tp, _Allocator>::operator=(vector&& __x)...@@ -1254,6 +1291,7 @@ vector<_Tp, _Allocator>::operator=(vector&& __x)
1254}1291}
12551292
1256template <class _Tp, class _Allocator>1293template <class _Tp, class _Allocator>
1294_LIBCPP_CONSTEXPR_AFTER_CXX17
1257void1295void
1258vector<_Tp, _Allocator>::__move_assign(vector& __c, false_type)1296vector<_Tp, _Allocator>::__move_assign(vector& __c, false_type)
1259 _NOEXCEPT_(__alloc_traits::is_always_equal::value)1297 _NOEXCEPT_(__alloc_traits::is_always_equal::value)
...@@ -1268,6 +1306,7 @@ vector<_Tp, _Allocator>::__move_assign(vector& __c, false_type)...@@ -1268,6 +1306,7 @@ vector<_Tp, _Allocator>::__move_assign(vector& __c, false_type)
1268}1306}
12691307
1270template <class _Tp, class _Allocator>1308template <class _Tp, class _Allocator>
1309_LIBCPP_CONSTEXPR_AFTER_CXX17
1271void1310void
1272vector<_Tp, _Allocator>::__move_assign(vector& __c, true_type)1311vector<_Tp, _Allocator>::__move_assign(vector& __c, true_type)
1273 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)1312 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
...@@ -1278,14 +1317,11 @@ vector<_Tp, _Allocator>::__move_assign(vector& __c, true_type)...@@ -1278,14 +1317,11 @@ vector<_Tp, _Allocator>::__move_assign(vector& __c, true_type)
1278 this->__end_ = __c.__end_;1317 this->__end_ = __c.__end_;
1279 this->__end_cap() = __c.__end_cap();1318 this->__end_cap() = __c.__end_cap();
1280 __c.__begin_ = __c.__end_ = __c.__end_cap() = nullptr;1319 __c.__begin_ = __c.__end_ = __c.__end_cap() = nullptr;
1281#if _LIBCPP_DEBUG_LEVEL == 21320 std::__debug_db_swap(this, std::addressof(__c));
1282 __get_db()->swap(this, _VSTD::addressof(__c));
1283#endif
1284}1321}
12851322
1286#endif // !_LIBCPP_CXX03_LANG
1287
1288template <class _Tp, class _Allocator>1323template <class _Tp, class _Allocator>
1324_LIBCPP_CONSTEXPR_AFTER_CXX17
1289inline _LIBCPP_INLINE_VISIBILITY1325inline _LIBCPP_INLINE_VISIBILITY
1290vector<_Tp, _Allocator>&1326vector<_Tp, _Allocator>&
1291vector<_Tp, _Allocator>::operator=(const vector& __x)1327vector<_Tp, _Allocator>::operator=(const vector& __x)
...@@ -1300,10 +1336,7 @@ vector<_Tp, _Allocator>::operator=(const vector& __x)...@@ -1300,10 +1336,7 @@ vector<_Tp, _Allocator>::operator=(const vector& __x)
13001336
1301template <class _Tp, class _Allocator>1337template <class _Tp, class _Allocator>
1302template <class _InputIterator>1338template <class _InputIterator>
1303typename enable_if1339_LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
1304<
1305 __is_cpp17_input_iterator <_InputIterator>::value &&
1306 !__is_cpp17_forward_iterator<_InputIterator>::value &&
1307 is_constructible<1340 is_constructible<
1308 _Tp,1341 _Tp,
1309 typename iterator_traits<_InputIterator>::reference>::value,1342 typename iterator_traits<_InputIterator>::reference>::value,
...@@ -1313,11 +1346,12 @@ vector<_Tp, _Allocator>::assign(_InputIterator __first, _InputIterator __last)...@@ -1313,11 +1346,12 @@ vector<_Tp, _Allocator>::assign(_InputIterator __first, _InputIterator __last)
1313{1346{
1314 clear();1347 clear();
1315 for (; __first != __last; ++__first)1348 for (; __first != __last; ++__first)
1316 __emplace_back(*__first);1349 emplace_back(*__first);
1317}1350}
13181351
1319template <class _Tp, class _Allocator>1352template <class _Tp, class _Allocator>
1320template <class _ForwardIterator>1353template <class _ForwardIterator>
1354_LIBCPP_CONSTEXPR_AFTER_CXX17
1321typename enable_if1355typename enable_if
1322<1356<
1323 __is_cpp17_forward_iterator<_ForwardIterator>::value &&1357 __is_cpp17_forward_iterator<_ForwardIterator>::value &&
...@@ -1351,10 +1385,11 @@ vector<_Tp, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __las...@@ -1351,10 +1385,11 @@ vector<_Tp, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __las
1351 __vallocate(__recommend(__new_size));1385 __vallocate(__recommend(__new_size));
1352 __construct_at_end(__first, __last, __new_size);1386 __construct_at_end(__first, __last, __new_size);
1353 }1387 }
1354 __invalidate_all_iterators();1388 std::__debug_db_invalidate_all(this);
1355}1389}
13561390
1357template <class _Tp, class _Allocator>1391template <class _Tp, class _Allocator>
1392_LIBCPP_CONSTEXPR_AFTER_CXX17
1358void1393void
1359vector<_Tp, _Allocator>::assign(size_type __n, const_reference __u)1394vector<_Tp, _Allocator>::assign(size_type __n, const_reference __u)
1360{1395{
...@@ -1373,66 +1408,47 @@ vector<_Tp, _Allocator>::assign(size_type __n, const_reference __u)...@@ -1373,66 +1408,47 @@ vector<_Tp, _Allocator>::assign(size_type __n, const_reference __u)
1373 __vallocate(__recommend(static_cast<size_type>(__n)));1408 __vallocate(__recommend(static_cast<size_type>(__n)));
1374 __construct_at_end(__n, __u);1409 __construct_at_end(__n, __u);
1375 }1410 }
1376 __invalidate_all_iterators();1411 std::__debug_db_invalidate_all(this);
1377}
1378
1379template <class _Tp, class _Allocator>
1380inline _LIBCPP_INLINE_VISIBILITY
1381typename vector<_Tp, _Allocator>::iterator
1382vector<_Tp, _Allocator>::__make_iter(pointer __p) _NOEXCEPT
1383{
1384#if _LIBCPP_DEBUG_LEVEL == 2
1385 return iterator(this, __p);
1386#else
1387 return iterator(__p);
1388#endif
1389}
1390
1391template <class _Tp, class _Allocator>
1392inline _LIBCPP_INLINE_VISIBILITY
1393typename vector<_Tp, _Allocator>::const_iterator
1394vector<_Tp, _Allocator>::__make_iter(const_pointer __p) const _NOEXCEPT
1395{
1396#if _LIBCPP_DEBUG_LEVEL == 2
1397 return const_iterator(this, __p);
1398#else
1399 return const_iterator(__p);
1400#endif
1401}1412}
14021413
1403template <class _Tp, class _Allocator>1414template <class _Tp, class _Allocator>
1415_LIBCPP_CONSTEXPR_AFTER_CXX17
1404inline _LIBCPP_INLINE_VISIBILITY1416inline _LIBCPP_INLINE_VISIBILITY
1405typename vector<_Tp, _Allocator>::iterator1417typename vector<_Tp, _Allocator>::iterator
1406vector<_Tp, _Allocator>::begin() _NOEXCEPT1418vector<_Tp, _Allocator>::begin() _NOEXCEPT
1407{1419{
1408 return __make_iter(this->__begin_);1420 return iterator(this, this->__begin_);
1409}1421}
14101422
1411template <class _Tp, class _Allocator>1423template <class _Tp, class _Allocator>
1424_LIBCPP_CONSTEXPR_AFTER_CXX17
1412inline _LIBCPP_INLINE_VISIBILITY1425inline _LIBCPP_INLINE_VISIBILITY
1413typename vector<_Tp, _Allocator>::const_iterator1426typename vector<_Tp, _Allocator>::const_iterator
1414vector<_Tp, _Allocator>::begin() const _NOEXCEPT1427vector<_Tp, _Allocator>::begin() const _NOEXCEPT
1415{1428{
1416 return __make_iter(this->__begin_);1429 return const_iterator(this, this->__begin_);
1417}1430}
14181431
1419template <class _Tp, class _Allocator>1432template <class _Tp, class _Allocator>
1433_LIBCPP_CONSTEXPR_AFTER_CXX17
1420inline _LIBCPP_INLINE_VISIBILITY1434inline _LIBCPP_INLINE_VISIBILITY
1421typename vector<_Tp, _Allocator>::iterator1435typename vector<_Tp, _Allocator>::iterator
1422vector<_Tp, _Allocator>::end() _NOEXCEPT1436vector<_Tp, _Allocator>::end() _NOEXCEPT
1423{1437{
1424 return __make_iter(this->__end_);1438 return iterator(this, this->__end_);
1425}1439}
14261440
1427template <class _Tp, class _Allocator>1441template <class _Tp, class _Allocator>
1442_LIBCPP_CONSTEXPR_AFTER_CXX17
1428inline _LIBCPP_INLINE_VISIBILITY1443inline _LIBCPP_INLINE_VISIBILITY
1429typename vector<_Tp, _Allocator>::const_iterator1444typename vector<_Tp, _Allocator>::const_iterator
1430vector<_Tp, _Allocator>::end() const _NOEXCEPT1445vector<_Tp, _Allocator>::end() const _NOEXCEPT
1431{1446{
1432 return __make_iter(this->__end_);1447 return const_iterator(this, this->__end_);
1433}1448}
14341449
1435template <class _Tp, class _Allocator>1450template <class _Tp, class _Allocator>
1451_LIBCPP_CONSTEXPR_AFTER_CXX17
1436inline _LIBCPP_INLINE_VISIBILITY1452inline _LIBCPP_INLINE_VISIBILITY
1437typename vector<_Tp, _Allocator>::reference1453typename vector<_Tp, _Allocator>::reference
1438vector<_Tp, _Allocator>::operator[](size_type __n) _NOEXCEPT1454vector<_Tp, _Allocator>::operator[](size_type __n) _NOEXCEPT
...@@ -1442,6 +1458,7 @@ vector<_Tp, _Allocator>::operator[](size_type __n) _NOEXCEPT...@@ -1442,6 +1458,7 @@ vector<_Tp, _Allocator>::operator[](size_type __n) _NOEXCEPT
1442}1458}
14431459
1444template <class _Tp, class _Allocator>1460template <class _Tp, class _Allocator>
1461_LIBCPP_CONSTEXPR_AFTER_CXX17
1445inline _LIBCPP_INLINE_VISIBILITY1462inline _LIBCPP_INLINE_VISIBILITY
1446typename vector<_Tp, _Allocator>::const_reference1463typename vector<_Tp, _Allocator>::const_reference
1447vector<_Tp, _Allocator>::operator[](size_type __n) const _NOEXCEPT1464vector<_Tp, _Allocator>::operator[](size_type __n) const _NOEXCEPT
...@@ -1451,6 +1468,7 @@ vector<_Tp, _Allocator>::operator[](size_type __n) const _NOEXCEPT...@@ -1451,6 +1468,7 @@ vector<_Tp, _Allocator>::operator[](size_type __n) const _NOEXCEPT
1451}1468}
14521469
1453template <class _Tp, class _Allocator>1470template <class _Tp, class _Allocator>
1471_LIBCPP_CONSTEXPR_AFTER_CXX17
1454typename vector<_Tp, _Allocator>::reference1472typename vector<_Tp, _Allocator>::reference
1455vector<_Tp, _Allocator>::at(size_type __n)1473vector<_Tp, _Allocator>::at(size_type __n)
1456{1474{
...@@ -1460,6 +1478,7 @@ vector<_Tp, _Allocator>::at(size_type __n)...@@ -1460,6 +1478,7 @@ vector<_Tp, _Allocator>::at(size_type __n)
1460}1478}
14611479
1462template <class _Tp, class _Allocator>1480template <class _Tp, class _Allocator>
1481_LIBCPP_CONSTEXPR_AFTER_CXX17
1463typename vector<_Tp, _Allocator>::const_reference1482typename vector<_Tp, _Allocator>::const_reference
1464vector<_Tp, _Allocator>::at(size_type __n) const1483vector<_Tp, _Allocator>::at(size_type __n) const
1465{1484{
...@@ -1469,6 +1488,7 @@ vector<_Tp, _Allocator>::at(size_type __n) const...@@ -1469,6 +1488,7 @@ vector<_Tp, _Allocator>::at(size_type __n) const
1469}1488}
14701489
1471template <class _Tp, class _Allocator>1490template <class _Tp, class _Allocator>
1491_LIBCPP_CONSTEXPR_AFTER_CXX17
1472void1492void
1473vector<_Tp, _Allocator>::reserve(size_type __n)1493vector<_Tp, _Allocator>::reserve(size_type __n)
1474{1494{
...@@ -1483,6 +1503,7 @@ vector<_Tp, _Allocator>::reserve(size_type __n)...@@ -1483,6 +1503,7 @@ vector<_Tp, _Allocator>::reserve(size_type __n)
1483}1503}
14841504
1485template <class _Tp, class _Allocator>1505template <class _Tp, class _Allocator>
1506_LIBCPP_CONSTEXPR_AFTER_CXX17
1486void1507void
1487vector<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT1508vector<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT
1488{1509{
...@@ -1506,12 +1527,9 @@ vector<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT...@@ -1506,12 +1527,9 @@ vector<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT
15061527
1507template <class _Tp, class _Allocator>1528template <class _Tp, class _Allocator>
1508template <class _Up>1529template <class _Up>
1530_LIBCPP_CONSTEXPR_AFTER_CXX17
1509void1531void
1510#ifndef _LIBCPP_CXX03_LANG
1511vector<_Tp, _Allocator>::__push_back_slow_path(_Up&& __x)1532vector<_Tp, _Allocator>::__push_back_slow_path(_Up&& __x)
1512#else
1513vector<_Tp, _Allocator>::__push_back_slow_path(_Up& __x)
1514#endif
1515{1533{
1516 allocator_type& __a = this->__alloc();1534 allocator_type& __a = this->__alloc();
1517 __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), size(), __a);1535 __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), size(), __a);
...@@ -1522,6 +1540,7 @@ vector<_Tp, _Allocator>::__push_back_slow_path(_Up& __x)...@@ -1522,6 +1540,7 @@ vector<_Tp, _Allocator>::__push_back_slow_path(_Up& __x)
1522}1540}
15231541
1524template <class _Tp, class _Allocator>1542template <class _Tp, class _Allocator>
1543_LIBCPP_CONSTEXPR_AFTER_CXX17
1525inline _LIBCPP_INLINE_VISIBILITY1544inline _LIBCPP_INLINE_VISIBILITY
1526void1545void
1527vector<_Tp, _Allocator>::push_back(const_reference __x)1546vector<_Tp, _Allocator>::push_back(const_reference __x)
...@@ -1534,9 +1553,8 @@ vector<_Tp, _Allocator>::push_back(const_reference __x)...@@ -1534,9 +1553,8 @@ vector<_Tp, _Allocator>::push_back(const_reference __x)
1534 __push_back_slow_path(__x);1553 __push_back_slow_path(__x);
1535}1554}
15361555
1537#ifndef _LIBCPP_CXX03_LANG
1538
1539template <class _Tp, class _Allocator>1556template <class _Tp, class _Allocator>
1557_LIBCPP_CONSTEXPR_AFTER_CXX17
1540inline _LIBCPP_INLINE_VISIBILITY1558inline _LIBCPP_INLINE_VISIBILITY
1541void1559void
1542vector<_Tp, _Allocator>::push_back(value_type&& __x)1560vector<_Tp, _Allocator>::push_back(value_type&& __x)
...@@ -1551,6 +1569,7 @@ vector<_Tp, _Allocator>::push_back(value_type&& __x)...@@ -1551,6 +1569,7 @@ vector<_Tp, _Allocator>::push_back(value_type&& __x)
15511569
1552template <class _Tp, class _Allocator>1570template <class _Tp, class _Allocator>
1553template <class... _Args>1571template <class... _Args>
1572_LIBCPP_CONSTEXPR_AFTER_CXX17
1554void1573void
1555vector<_Tp, _Allocator>::__emplace_back_slow_path(_Args&&... __args)1574vector<_Tp, _Allocator>::__emplace_back_slow_path(_Args&&... __args)
1556{1575{
...@@ -1564,6 +1583,7 @@ vector<_Tp, _Allocator>::__emplace_back_slow_path(_Args&&... __args)...@@ -1564,6 +1583,7 @@ vector<_Tp, _Allocator>::__emplace_back_slow_path(_Args&&... __args)
15641583
1565template <class _Tp, class _Allocator>1584template <class _Tp, class _Allocator>
1566template <class... _Args>1585template <class... _Args>
1586_LIBCPP_CONSTEXPR_AFTER_CXX17
1567inline1587inline
1568#if _LIBCPP_STD_VER > 141588#if _LIBCPP_STD_VER > 14
1569typename vector<_Tp, _Allocator>::reference1589typename vector<_Tp, _Allocator>::reference
...@@ -1583,9 +1603,8 @@ vector<_Tp, _Allocator>::emplace_back(_Args&&... __args)...@@ -1583,9 +1603,8 @@ vector<_Tp, _Allocator>::emplace_back(_Args&&... __args)
1583#endif1603#endif
1584}1604}
15851605
1586#endif // !_LIBCPP_CXX03_LANG
1587
1588template <class _Tp, class _Allocator>1606template <class _Tp, class _Allocator>
1607_LIBCPP_CONSTEXPR_AFTER_CXX17
1589inline1608inline
1590void1609void
1591vector<_Tp, _Allocator>::pop_back()1610vector<_Tp, _Allocator>::pop_back()
...@@ -1595,6 +1614,7 @@ vector<_Tp, _Allocator>::pop_back()...@@ -1595,6 +1614,7 @@ vector<_Tp, _Allocator>::pop_back()
1595}1614}
15961615
1597template <class _Tp, class _Allocator>1616template <class _Tp, class _Allocator>
1617_LIBCPP_CONSTEXPR_AFTER_CXX17
1598inline _LIBCPP_INLINE_VISIBILITY1618inline _LIBCPP_INLINE_VISIBILITY
1599typename vector<_Tp, _Allocator>::iterator1619typename vector<_Tp, _Allocator>::iterator
1600vector<_Tp, _Allocator>::erase(const_iterator __position)1620vector<_Tp, _Allocator>::erase(const_iterator __position)
...@@ -1606,12 +1626,14 @@ vector<_Tp, _Allocator>::erase(const_iterator __position)...@@ -1606,12 +1626,14 @@ vector<_Tp, _Allocator>::erase(const_iterator __position)
1606 difference_type __ps = __position - cbegin();1626 difference_type __ps = __position - cbegin();
1607 pointer __p = this->__begin_ + __ps;1627 pointer __p = this->__begin_ + __ps;
1608 this->__destruct_at_end(_VSTD::move(__p + 1, this->__end_, __p));1628 this->__destruct_at_end(_VSTD::move(__p + 1, this->__end_, __p));
1609 this->__invalidate_iterators_past(__p-1);1629 if (!__libcpp_is_constant_evaluated())
1610 iterator __r = __make_iter(__p);1630 this->__invalidate_iterators_past(__p - 1);
1631 iterator __r = iterator(this, __p);
1611 return __r;1632 return __r;
1612}1633}
16131634
1614template <class _Tp, class _Allocator>1635template <class _Tp, class _Allocator>
1636_LIBCPP_CONSTEXPR_AFTER_CXX17
1615typename vector<_Tp, _Allocator>::iterator1637typename vector<_Tp, _Allocator>::iterator
1616vector<_Tp, _Allocator>::erase(const_iterator __first, const_iterator __last)1638vector<_Tp, _Allocator>::erase(const_iterator __first, const_iterator __last)
1617{1639{
...@@ -1624,13 +1646,15 @@ vector<_Tp, _Allocator>::erase(const_iterator __first, const_iterator __last)...@@ -1624,13 +1646,15 @@ vector<_Tp, _Allocator>::erase(const_iterator __first, const_iterator __last)
1624 pointer __p = this->__begin_ + (__first - begin());1646 pointer __p = this->__begin_ + (__first - begin());
1625 if (__first != __last) {1647 if (__first != __last) {
1626 this->__destruct_at_end(_VSTD::move(__p + (__last - __first), this->__end_, __p));1648 this->__destruct_at_end(_VSTD::move(__p + (__last - __first), this->__end_, __p));
1627 this->__invalidate_iterators_past(__p - 1);1649 if (!__libcpp_is_constant_evaluated())
1650 this->__invalidate_iterators_past(__p - 1);
1628 }1651 }
1629 iterator __r = __make_iter(__p);1652 iterator __r = iterator(this, __p);
1630 return __r;1653 return __r;
1631}1654}
16321655
1633template <class _Tp, class _Allocator>1656template <class _Tp, class _Allocator>
1657_LIBCPP_CONSTEXPR_AFTER_CXX17
1634void1658void
1635vector<_Tp, _Allocator>::__move_range(pointer __from_s, pointer __from_e, pointer __to)1659vector<_Tp, _Allocator>::__move_range(pointer __from_s, pointer __from_e, pointer __to)
1636{1660{
...@@ -1650,13 +1674,15 @@ vector<_Tp, _Allocator>::__move_range(pointer __from_s, pointer __from_e, pointe...@@ -1650,13 +1674,15 @@ vector<_Tp, _Allocator>::__move_range(pointer __from_s, pointer __from_e, pointe
1650}1674}
16511675
1652template <class _Tp, class _Allocator>1676template <class _Tp, class _Allocator>
1677_LIBCPP_CONSTEXPR_AFTER_CXX17
1653typename vector<_Tp, _Allocator>::iterator1678typename vector<_Tp, _Allocator>::iterator
1654vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x)1679vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x)
1655{1680{
1656 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__position)) == this,1681 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__position)) == this,
1657 "vector::insert(iterator, x) called with an iterator not referring to this vector");1682 "vector::insert(iterator, x) called with an iterator not referring to this vector");
1658 pointer __p = this->__begin_ + (__position - begin());1683 pointer __p = this->__begin_ + (__position - begin());
1659 if (this->__end_ < this->__end_cap())1684 // We can't compare unrelated pointers inside constant expressions
1685 if (!__libcpp_is_constant_evaluated() && this->__end_ < this->__end_cap())
1660 {1686 {
1661 if (__p == this->__end_)1687 if (__p == this->__end_)
1662 {1688 {
...@@ -1678,12 +1704,11 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x)...@@ -1678,12 +1704,11 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x)
1678 __v.push_back(__x);1704 __v.push_back(__x);
1679 __p = __swap_out_circular_buffer(__v, __p);1705 __p = __swap_out_circular_buffer(__v, __p);
1680 }1706 }
1681 return __make_iter(__p);1707 return iterator(this, __p);
1682}1708}
16831709
1684#ifndef _LIBCPP_CXX03_LANG
1685
1686template <class _Tp, class _Allocator>1710template <class _Tp, class _Allocator>
1711_LIBCPP_CONSTEXPR_AFTER_CXX17
1687typename vector<_Tp, _Allocator>::iterator1712typename vector<_Tp, _Allocator>::iterator
1688vector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x)1713vector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x)
1689{1714{
...@@ -1709,11 +1734,12 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x)...@@ -1709,11 +1734,12 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x)
1709 __v.push_back(_VSTD::move(__x));1734 __v.push_back(_VSTD::move(__x));
1710 __p = __swap_out_circular_buffer(__v, __p);1735 __p = __swap_out_circular_buffer(__v, __p);
1711 }1736 }
1712 return __make_iter(__p);1737 return iterator(this, __p);
1713}1738}
17141739
1715template <class _Tp, class _Allocator>1740template <class _Tp, class _Allocator>
1716template <class... _Args>1741template <class... _Args>
1742_LIBCPP_CONSTEXPR_AFTER_CXX17
1717typename vector<_Tp, _Allocator>::iterator1743typename vector<_Tp, _Allocator>::iterator
1718vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args)1744vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args)
1719{1745{
...@@ -1740,12 +1766,11 @@ vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args)...@@ -1740,12 +1766,11 @@ vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args)
1740 __v.emplace_back(_VSTD::forward<_Args>(__args)...);1766 __v.emplace_back(_VSTD::forward<_Args>(__args)...);
1741 __p = __swap_out_circular_buffer(__v, __p);1767 __p = __swap_out_circular_buffer(__v, __p);
1742 }1768 }
1743 return __make_iter(__p);1769 return iterator(this, __p);
1744}1770}
17451771
1746#endif // !_LIBCPP_CXX03_LANG
1747
1748template <class _Tp, class _Allocator>1772template <class _Tp, class _Allocator>
1773_LIBCPP_CONSTEXPR_AFTER_CXX17
1749typename vector<_Tp, _Allocator>::iterator1774typename vector<_Tp, _Allocator>::iterator
1750vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_reference __x)1775vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_reference __x)
1751{1776{
...@@ -1754,7 +1779,8 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_...@@ -1754,7 +1779,8 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_
1754 pointer __p = this->__begin_ + (__position - begin());1779 pointer __p = this->__begin_ + (__position - begin());
1755 if (__n > 0)1780 if (__n > 0)
1756 {1781 {
1757 if (__n <= static_cast<size_type>(this->__end_cap() - this->__end_))1782 // We can't compare unrelated pointers inside constant expressions
1783 if (!__libcpp_is_constant_evaluated() && __n <= static_cast<size_type>(this->__end_cap() - this->__end_))
1758 {1784 {
1759 size_type __old_n = __n;1785 size_type __old_n = __n;
1760 pointer __old_last = this->__end_;1786 pointer __old_last = this->__end_;
...@@ -1781,15 +1807,12 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_...@@ -1781,15 +1807,12 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_
1781 __p = __swap_out_circular_buffer(__v, __p);1807 __p = __swap_out_circular_buffer(__v, __p);
1782 }1808 }
1783 }1809 }
1784 return __make_iter(__p);1810 return iterator(this, __p);
1785}1811}
17861812
1787template <class _Tp, class _Allocator>1813template <class _Tp, class _Allocator>
1788template <class _InputIterator>1814template <class _InputIterator>
1789typename enable_if1815_LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
1790<
1791 __is_cpp17_input_iterator <_InputIterator>::value &&
1792 !__is_cpp17_forward_iterator<_InputIterator>::value &&
1793 is_constructible<1816 is_constructible<
1794 _Tp,1817 _Tp,
1795 typename iterator_traits<_InputIterator>::reference>::value,1818 typename iterator_traits<_InputIterator>::reference>::value,
...@@ -1824,19 +1847,20 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, _InputIterator __firs...@@ -1824,19 +1847,20 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, _InputIterator __firs
1824 }1847 }
1825 catch (...)1848 catch (...)
1826 {1849 {
1827 erase(__make_iter(__old_last), end());1850 erase(iterator(this, __old_last), end());
1828 throw;1851 throw;
1829 }1852 }
1830#endif // _LIBCPP_NO_EXCEPTIONS1853#endif // _LIBCPP_NO_EXCEPTIONS
1831 }1854 }
1832 __p = _VSTD::rotate(__p, __old_last, this->__end_);1855 __p = _VSTD::rotate(__p, __old_last, this->__end_);
1833 insert(__make_iter(__p), _VSTD::make_move_iterator(__v.begin()),1856 insert(iterator(this, __p), _VSTD::make_move_iterator(__v.begin()),
1834 _VSTD::make_move_iterator(__v.end()));1857 _VSTD::make_move_iterator(__v.end()));
1835 return begin() + __off;1858 return begin() + __off;
1836}1859}
18371860
1838template <class _Tp, class _Allocator>1861template <class _Tp, class _Allocator>
1839template <class _ForwardIterator>1862template <class _ForwardIterator>
1863_LIBCPP_CONSTEXPR_AFTER_CXX17
1840typename enable_if1864typename enable_if
1841<1865<
1842 __is_cpp17_forward_iterator<_ForwardIterator>::value &&1866 __is_cpp17_forward_iterator<_ForwardIterator>::value &&
...@@ -1881,10 +1905,11 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, _ForwardIterator __fi...@@ -1881,10 +1905,11 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, _ForwardIterator __fi
1881 __p = __swap_out_circular_buffer(__v, __p);1905 __p = __swap_out_circular_buffer(__v, __p);
1882 }1906 }
1883 }1907 }
1884 return __make_iter(__p);1908 return iterator(this, __p);
1885}1909}
18861910
1887template <class _Tp, class _Allocator>1911template <class _Tp, class _Allocator>
1912_LIBCPP_CONSTEXPR_AFTER_CXX17
1888void1913void
1889vector<_Tp, _Allocator>::resize(size_type __sz)1914vector<_Tp, _Allocator>::resize(size_type __sz)
1890{1915{
...@@ -1896,6 +1921,7 @@ vector<_Tp, _Allocator>::resize(size_type __sz)...@@ -1896,6 +1921,7 @@ vector<_Tp, _Allocator>::resize(size_type __sz)
1896}1921}
18971922
1898template <class _Tp, class _Allocator>1923template <class _Tp, class _Allocator>
1924_LIBCPP_CONSTEXPR_AFTER_CXX17
1899void1925void
1900vector<_Tp, _Allocator>::resize(size_type __sz, const_reference __x)1926vector<_Tp, _Allocator>::resize(size_type __sz, const_reference __x)
1901{1927{
...@@ -1907,6 +1933,7 @@ vector<_Tp, _Allocator>::resize(size_type __sz, const_reference __x)...@@ -1907,6 +1933,7 @@ vector<_Tp, _Allocator>::resize(size_type __sz, const_reference __x)
1907}1933}
19081934
1909template <class _Tp, class _Allocator>1935template <class _Tp, class _Allocator>
1936_LIBCPP_CONSTEXPR_AFTER_CXX17
1910void1937void
1911vector<_Tp, _Allocator>::swap(vector& __x)1938vector<_Tp, _Allocator>::swap(vector& __x)
1912#if _LIBCPP_STD_VER >= 141939#if _LIBCPP_STD_VER >= 14
...@@ -1925,12 +1952,11 @@ vector<_Tp, _Allocator>::swap(vector& __x)...@@ -1925,12 +1952,11 @@ vector<_Tp, _Allocator>::swap(vector& __x)
1925 _VSTD::swap(this->__end_cap(), __x.__end_cap());1952 _VSTD::swap(this->__end_cap(), __x.__end_cap());
1926 _VSTD::__swap_allocator(this->__alloc(), __x.__alloc(),1953 _VSTD::__swap_allocator(this->__alloc(), __x.__alloc(),
1927 integral_constant<bool,__alloc_traits::propagate_on_container_swap::value>());1954 integral_constant<bool,__alloc_traits::propagate_on_container_swap::value>());
1928#if _LIBCPP_DEBUG_LEVEL == 21955 std::__debug_db_swap(this, std::addressof(__x));
1929 __get_db()->swap(this, _VSTD::addressof(__x));
1930#endif
1931}1956}
19321957
1933template <class _Tp, class _Allocator>1958template <class _Tp, class _Allocator>
1959_LIBCPP_CONSTEXPR_AFTER_CXX17
1934bool1960bool
1935vector<_Tp, _Allocator>::__invariants() const1961vector<_Tp, _Allocator>::__invariants() const
1936{1962{
...@@ -1951,7 +1977,7 @@ vector<_Tp, _Allocator>::__invariants() const...@@ -1951,7 +1977,7 @@ vector<_Tp, _Allocator>::__invariants() const
1951 return true;1977 return true;
1952}1978}
19531979
1954#if _LIBCPP_DEBUG_LEVEL == 21980#ifdef _LIBCPP_ENABLE_DEBUG_MODE
19551981
1956template <class _Tp, class _Allocator>1982template <class _Tp, class _Allocator>
1957bool1983bool
...@@ -1983,24 +2009,13 @@ vector<_Tp, _Allocator>::__subscriptable(const const_iterator* __i, ptrdiff_t __...@@ -1983,24 +2009,13 @@ vector<_Tp, _Allocator>::__subscriptable(const const_iterator* __i, ptrdiff_t __
1983 return this->__begin_ <= __p && __p < this->__end_;2009 return this->__begin_ <= __p && __p < this->__end_;
1984}2010}
19852011
1986#endif // _LIBCPP_DEBUG_LEVEL == 22012#endif // _LIBCPP_ENABLE_DEBUG_MODE
1987
1988template <class _Tp, class _Allocator>
1989inline _LIBCPP_INLINE_VISIBILITY
1990void
1991vector<_Tp, _Allocator>::__invalidate_all_iterators()
1992{
1993#if _LIBCPP_DEBUG_LEVEL == 2
1994 __get_db()->__invalidate_all(this);
1995#endif
1996}
1997
19982013
1999template <class _Tp, class _Allocator>2014template <class _Tp, class _Allocator>
2000inline _LIBCPP_INLINE_VISIBILITY2015inline _LIBCPP_INLINE_VISIBILITY
2001void2016void
2002vector<_Tp, _Allocator>::__invalidate_iterators_past(pointer __new_last) {2017vector<_Tp, _Allocator>::__invalidate_iterators_past(pointer __new_last) {
2003#if _LIBCPP_DEBUG_LEVEL == 22018#ifdef _LIBCPP_ENABLE_DEBUG_MODE
2004 __c_node* __c = __get_db()->__find_c_and_lock(this);2019 __c_node* __c = __get_db()->__find_c_and_lock(this);
2005 for (__i_node** __p = __c->end_; __p != __c->beg_; ) {2020 for (__i_node** __p = __c->end_; __p != __c->beg_; ) {
2006 --__p;2021 --__p;
...@@ -2058,182 +2073,181 @@ private:...@@ -2058,182 +2073,181 @@ private:
2058 __compressed_pair<size_type, __storage_allocator> __cap_alloc_;2073 __compressed_pair<size_type, __storage_allocator> __cap_alloc_;
2059public:2074public:
2060 typedef __bit_reference<vector> reference;2075 typedef __bit_reference<vector> reference;
2076#ifdef _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL
2077 using const_reference = bool;
2078#else
2061 typedef __bit_const_reference<vector> const_reference;2079 typedef __bit_const_reference<vector> const_reference;
2080#endif
2062private:2081private:
2063 _LIBCPP_INLINE_VISIBILITY2082 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2064 size_type& __cap() _NOEXCEPT2083 size_type& __cap() _NOEXCEPT
2065 {return __cap_alloc_.first();}2084 {return __cap_alloc_.first();}
2066 _LIBCPP_INLINE_VISIBILITY2085 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2067 const size_type& __cap() const _NOEXCEPT2086 const size_type& __cap() const _NOEXCEPT
2068 {return __cap_alloc_.first();}2087 {return __cap_alloc_.first();}
2069 _LIBCPP_INLINE_VISIBILITY2088 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2070 __storage_allocator& __alloc() _NOEXCEPT2089 __storage_allocator& __alloc() _NOEXCEPT
2071 {return __cap_alloc_.second();}2090 {return __cap_alloc_.second();}
2072 _LIBCPP_INLINE_VISIBILITY2091 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2073 const __storage_allocator& __alloc() const _NOEXCEPT2092 const __storage_allocator& __alloc() const _NOEXCEPT
2074 {return __cap_alloc_.second();}2093 {return __cap_alloc_.second();}
20752094
2076 static const unsigned __bits_per_word = static_cast<unsigned>(sizeof(__storage_type) * CHAR_BIT);2095 static const unsigned __bits_per_word = static_cast<unsigned>(sizeof(__storage_type) * CHAR_BIT);
20772096
2078 _LIBCPP_INLINE_VISIBILITY2097 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2079 static size_type __internal_cap_to_external(size_type __n) _NOEXCEPT2098 static size_type __internal_cap_to_external(size_type __n) _NOEXCEPT
2080 {return __n * __bits_per_word;}2099 {return __n * __bits_per_word;}
2081 _LIBCPP_INLINE_VISIBILITY2100 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2082 static size_type __external_cap_to_internal(size_type __n) _NOEXCEPT2101 static size_type __external_cap_to_internal(size_type __n) _NOEXCEPT
2083 {return (__n - 1) / __bits_per_word + 1;}2102 {return (__n - 1) / __bits_per_word + 1;}
20842103
2085public:2104public:
2086 _LIBCPP_INLINE_VISIBILITY2105 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2087 vector() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);2106 vector() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);
20882107
2089 _LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a)2108 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit vector(const allocator_type& __a)
2090#if _LIBCPP_STD_VER <= 142109#if _LIBCPP_STD_VER <= 14
2091 _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value);2110 _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value);
2092#else2111#else
2093 _NOEXCEPT;2112 _NOEXCEPT;
2094#endif2113#endif
2095 ~vector();2114 _LIBCPP_CONSTEXPR_AFTER_CXX17 ~vector();
2096 explicit vector(size_type __n);2115 _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit vector(size_type __n);
2097#if _LIBCPP_STD_VER > 112116#if _LIBCPP_STD_VER > 11
2098 explicit vector(size_type __n, const allocator_type& __a);2117 _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit vector(size_type __n, const allocator_type& __a);
2099#endif2118#endif
2100 vector(size_type __n, const value_type& __v);2119 _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(size_type __n, const value_type& __v);
2101 vector(size_type __n, const value_type& __v, const allocator_type& __a);2120 _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(size_type __n, const value_type& __v, const allocator_type& __a);
2102 template <class _InputIterator>2121 template <class _InputIterator>
2103 vector(_InputIterator __first, _InputIterator __last,2122 _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(_InputIterator __first, _InputIterator __last,
2104 typename enable_if<__is_cpp17_input_iterator <_InputIterator>::value &&2123 typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value>::type* = 0);
2105 !__is_cpp17_forward_iterator<_InputIterator>::value>::type* = 0);
2106 template <class _InputIterator>2124 template <class _InputIterator>
2107 vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,2125 _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,
2108 typename enable_if<__is_cpp17_input_iterator <_InputIterator>::value &&2126 typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value>::type* = 0);
2109 !__is_cpp17_forward_iterator<_InputIterator>::value>::type* = 0);
2110 template <class _ForwardIterator>2127 template <class _ForwardIterator>
2111 vector(_ForwardIterator __first, _ForwardIterator __last,2128 _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(_ForwardIterator __first, _ForwardIterator __last,
2112 typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type* = 0);2129 typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type* = 0);
2113 template <class _ForwardIterator>2130 template <class _ForwardIterator>
2114 vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,2131 _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,
2115 typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type* = 0);2132 typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type* = 0);
21162133
2117 vector(const vector& __v);2134 _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(const vector& __v);
2118 vector(const vector& __v, const allocator_type& __a);2135 _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(const vector& __v, const allocator_type& __a);
2119 vector& operator=(const vector& __v);2136 _LIBCPP_CONSTEXPR_AFTER_CXX17 vector& operator=(const vector& __v);
21202137
2121#ifndef _LIBCPP_CXX03_LANG2138#ifndef _LIBCPP_CXX03_LANG
2122 vector(initializer_list<value_type> __il);2139 _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(initializer_list<value_type> __il);
2123 vector(initializer_list<value_type> __il, const allocator_type& __a);2140 _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(initializer_list<value_type> __il, const allocator_type& __a);
2141
2142 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2143 vector& operator=(initializer_list<value_type> __il)
2144 {assign(__il.begin(), __il.end()); return *this;}
2145
2146#endif // !_LIBCPP_CXX03_LANG
21242147
2125 _LIBCPP_INLINE_VISIBILITY2148 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2126 vector(vector&& __v)2149 vector(vector&& __v)
2127#if _LIBCPP_STD_VER > 142150#if _LIBCPP_STD_VER > 14
2128 _NOEXCEPT;2151 noexcept;
2129#else2152#else
2130 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);2153 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
2131#endif2154#endif
2132 vector(vector&& __v, const __identity_t<allocator_type>& __a);2155 _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(vector&& __v, const __type_identity_t<allocator_type>& __a);
2133 _LIBCPP_INLINE_VISIBILITY2156 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2134 vector& operator=(vector&& __v)2157 vector& operator=(vector&& __v)
2135 _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value));2158 _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value));
21362159
2137 _LIBCPP_INLINE_VISIBILITY
2138 vector& operator=(initializer_list<value_type> __il)
2139 {assign(__il.begin(), __il.end()); return *this;}
2140
2141#endif // !_LIBCPP_CXX03_LANG
2142
2143 template <class _InputIterator>2160 template <class _InputIterator>
2144 typename enable_if2161 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value,
2145 <
2146 __is_cpp17_input_iterator<_InputIterator>::value &&
2147 !__is_cpp17_forward_iterator<_InputIterator>::value,
2148 void2162 void
2149 >::type2163 >::type
2150 assign(_InputIterator __first, _InputIterator __last);2164 _LIBCPP_CONSTEXPR_AFTER_CXX17 assign(_InputIterator __first, _InputIterator __last);
2151 template <class _ForwardIterator>2165 template <class _ForwardIterator>
2152 typename enable_if2166 typename enable_if
2153 <2167 <
2154 __is_cpp17_forward_iterator<_ForwardIterator>::value,2168 __is_cpp17_forward_iterator<_ForwardIterator>::value,
2155 void2169 void
2156 >::type2170 >::type
2157 assign(_ForwardIterator __first, _ForwardIterator __last);2171 _LIBCPP_CONSTEXPR_AFTER_CXX17 assign(_ForwardIterator __first, _ForwardIterator __last);
21582172
2159 void assign(size_type __n, const value_type& __x);2173 _LIBCPP_CONSTEXPR_AFTER_CXX17 void assign(size_type __n, const value_type& __x);
21602174
2161#ifndef _LIBCPP_CXX03_LANG2175#ifndef _LIBCPP_CXX03_LANG
2162 _LIBCPP_INLINE_VISIBILITY2176 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2163 void assign(initializer_list<value_type> __il)2177 void assign(initializer_list<value_type> __il)
2164 {assign(__il.begin(), __il.end());}2178 {assign(__il.begin(), __il.end());}
2165#endif2179#endif
21662180
2167 _LIBCPP_INLINE_VISIBILITY allocator_type get_allocator() const _NOEXCEPT2181 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 allocator_type get_allocator() const _NOEXCEPT
2168 {return allocator_type(this->__alloc());}2182 {return allocator_type(this->__alloc());}
21692183
2170 size_type max_size() const _NOEXCEPT;2184 _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type max_size() const _NOEXCEPT;
2171 _LIBCPP_INLINE_VISIBILITY2185 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2172 size_type capacity() const _NOEXCEPT2186 size_type capacity() const _NOEXCEPT
2173 {return __internal_cap_to_external(__cap());}2187 {return __internal_cap_to_external(__cap());}
2174 _LIBCPP_INLINE_VISIBILITY2188 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2175 size_type size() const _NOEXCEPT2189 size_type size() const _NOEXCEPT
2176 {return __size_;}2190 {return __size_;}
2177 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY2191 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2178 bool empty() const _NOEXCEPT2192 bool empty() const _NOEXCEPT
2179 {return __size_ == 0;}2193 {return __size_ == 0;}
2180 void reserve(size_type __n);2194 _LIBCPP_CONSTEXPR_AFTER_CXX17 void reserve(size_type __n);
2181 void shrink_to_fit() _NOEXCEPT;2195 _LIBCPP_CONSTEXPR_AFTER_CXX17 void shrink_to_fit() _NOEXCEPT;
21822196
2183 _LIBCPP_INLINE_VISIBILITY2197 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2184 iterator begin() _NOEXCEPT2198 iterator begin() _NOEXCEPT
2185 {return __make_iter(0);}2199 {return __make_iter(0);}
2186 _LIBCPP_INLINE_VISIBILITY2200 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2187 const_iterator begin() const _NOEXCEPT2201 const_iterator begin() const _NOEXCEPT
2188 {return __make_iter(0);}2202 {return __make_iter(0);}
2189 _LIBCPP_INLINE_VISIBILITY2203 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2190 iterator end() _NOEXCEPT2204 iterator end() _NOEXCEPT
2191 {return __make_iter(__size_);}2205 {return __make_iter(__size_);}
2192 _LIBCPP_INLINE_VISIBILITY2206 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2193 const_iterator end() const _NOEXCEPT2207 const_iterator end() const _NOEXCEPT
2194 {return __make_iter(__size_);}2208 {return __make_iter(__size_);}
21952209
2196 _LIBCPP_INLINE_VISIBILITY2210 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2197 reverse_iterator rbegin() _NOEXCEPT2211 reverse_iterator rbegin() _NOEXCEPT
2198 {return reverse_iterator(end());}2212 {return reverse_iterator(end());}
2199 _LIBCPP_INLINE_VISIBILITY2213 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2200 const_reverse_iterator rbegin() const _NOEXCEPT2214 const_reverse_iterator rbegin() const _NOEXCEPT
2201 {return const_reverse_iterator(end());}2215 {return const_reverse_iterator(end());}
2202 _LIBCPP_INLINE_VISIBILITY2216 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2203 reverse_iterator rend() _NOEXCEPT2217 reverse_iterator rend() _NOEXCEPT
2204 {return reverse_iterator(begin());}2218 {return reverse_iterator(begin());}
2205 _LIBCPP_INLINE_VISIBILITY2219 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2206 const_reverse_iterator rend() const _NOEXCEPT2220 const_reverse_iterator rend() const _NOEXCEPT
2207 {return const_reverse_iterator(begin());}2221 {return const_reverse_iterator(begin());}
22082222
2209 _LIBCPP_INLINE_VISIBILITY2223 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2210 const_iterator cbegin() const _NOEXCEPT2224 const_iterator cbegin() const _NOEXCEPT
2211 {return __make_iter(0);}2225 {return __make_iter(0);}
2212 _LIBCPP_INLINE_VISIBILITY2226 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2213 const_iterator cend() const _NOEXCEPT2227 const_iterator cend() const _NOEXCEPT
2214 {return __make_iter(__size_);}2228 {return __make_iter(__size_);}
2215 _LIBCPP_INLINE_VISIBILITY2229 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2216 const_reverse_iterator crbegin() const _NOEXCEPT2230 const_reverse_iterator crbegin() const _NOEXCEPT
2217 {return rbegin();}2231 {return rbegin();}
2218 _LIBCPP_INLINE_VISIBILITY2232 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2219 const_reverse_iterator crend() const _NOEXCEPT2233 const_reverse_iterator crend() const _NOEXCEPT
2220 {return rend();}2234 {return rend();}
22212235
2222 _LIBCPP_INLINE_VISIBILITY reference operator[](size_type __n) {return __make_ref(__n);}2236 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 reference operator[](size_type __n) {return __make_ref(__n);}
2223 _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __n) const {return __make_ref(__n);}2237 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference operator[](size_type __n) const {return __make_ref(__n);}
2224 reference at(size_type __n);2238 reference at(size_type __n);
2225 const_reference at(size_type __n) const;2239 const_reference at(size_type __n) const;
22262240
2227 _LIBCPP_INLINE_VISIBILITY reference front() {return __make_ref(0);}2241 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 reference front() {return __make_ref(0);}
2228 _LIBCPP_INLINE_VISIBILITY const_reference front() const {return __make_ref(0);}2242 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference front() const {return __make_ref(0);}
2229 _LIBCPP_INLINE_VISIBILITY reference back() {return __make_ref(__size_ - 1);}2243 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 reference back() {return __make_ref(__size_ - 1);}
2230 _LIBCPP_INLINE_VISIBILITY const_reference back() const {return __make_ref(__size_ - 1);}2244 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference back() const {return __make_ref(__size_ - 1);}
22312245
2232 void push_back(const value_type& __x);2246 _LIBCPP_CONSTEXPR_AFTER_CXX17 void push_back(const value_type& __x);
2233#if _LIBCPP_STD_VER > 112247#if _LIBCPP_STD_VER > 11
2234 template <class... _Args>2248 template <class... _Args>
2235#if _LIBCPP_STD_VER > 142249#if _LIBCPP_STD_VER > 14
2236 _LIBCPP_INLINE_VISIBILITY reference emplace_back(_Args&&... __args)2250 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 reference emplace_back(_Args&&... __args)
2237#else2251#else
2238 _LIBCPP_INLINE_VISIBILITY void emplace_back(_Args&&... __args)2252 _LIBCPP_INLINE_VISIBILITY void emplace_back(_Args&&... __args)
2239#endif2253#endif
...@@ -2245,58 +2259,54 @@ public:...@@ -2245,58 +2259,54 @@ public:
2245 }2259 }
2246#endif2260#endif
22472261
2248 _LIBCPP_INLINE_VISIBILITY void pop_back() {--__size_;}2262 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void pop_back() {--__size_;}
22492263
2250#if _LIBCPP_STD_VER > 112264#if _LIBCPP_STD_VER > 11
2251 template <class... _Args>2265 template <class... _Args>
2252 _LIBCPP_INLINE_VISIBILITY iterator emplace(const_iterator position, _Args&&... __args)2266 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator emplace(const_iterator __position, _Args&&... __args)
2253 { return insert ( position, value_type ( _VSTD::forward<_Args>(__args)... )); }2267 { return insert ( __position, value_type ( _VSTD::forward<_Args>(__args)... )); }
2254#endif2268#endif
22552269
2256 iterator insert(const_iterator __position, const value_type& __x);2270 _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator insert(const_iterator __position, const value_type& __x);
2257 iterator insert(const_iterator __position, size_type __n, const value_type& __x);2271 _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator insert(const_iterator __position, size_type __n, const value_type& __x);
2258 iterator insert(const_iterator __position, size_type __n, const_reference __x);
2259 template <class _InputIterator>2272 template <class _InputIterator>
2260 typename enable_if2273 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value,
2261 <
2262 __is_cpp17_input_iterator <_InputIterator>::value &&
2263 !__is_cpp17_forward_iterator<_InputIterator>::value,
2264 iterator2274 iterator
2265 >::type2275 >::type
2266 insert(const_iterator __position, _InputIterator __first, _InputIterator __last);2276 _LIBCPP_CONSTEXPR_AFTER_CXX17 insert(const_iterator __position, _InputIterator __first, _InputIterator __last);
2267 template <class _ForwardIterator>2277 template <class _ForwardIterator>
2268 typename enable_if2278 typename enable_if
2269 <2279 <
2270 __is_cpp17_forward_iterator<_ForwardIterator>::value,2280 __is_cpp17_forward_iterator<_ForwardIterator>::value,
2271 iterator2281 iterator
2272 >::type2282 >::type
2273 insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last);2283 _LIBCPP_CONSTEXPR_AFTER_CXX17 insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last);
22742284
2275#ifndef _LIBCPP_CXX03_LANG2285#ifndef _LIBCPP_CXX03_LANG
2276 _LIBCPP_INLINE_VISIBILITY2286 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2277 iterator insert(const_iterator __position, initializer_list<value_type> __il)2287 iterator insert(const_iterator __position, initializer_list<value_type> __il)
2278 {return insert(__position, __il.begin(), __il.end());}2288 {return insert(__position, __il.begin(), __il.end());}
2279#endif2289#endif
22802290
2281 _LIBCPP_INLINE_VISIBILITY iterator erase(const_iterator __position);2291 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator erase(const_iterator __position);
2282 iterator erase(const_iterator __first, const_iterator __last);2292 _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator erase(const_iterator __first, const_iterator __last);
22832293
2284 _LIBCPP_INLINE_VISIBILITY2294 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2285 void clear() _NOEXCEPT {__size_ = 0;}2295 void clear() _NOEXCEPT {__size_ = 0;}
22862296
2287 void swap(vector&)2297 _LIBCPP_CONSTEXPR_AFTER_CXX17 void swap(vector&)
2288#if _LIBCPP_STD_VER >= 142298#if _LIBCPP_STD_VER >= 14
2289 _NOEXCEPT;2299 _NOEXCEPT;
2290#else2300#else
2291 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||2301 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
2292 __is_nothrow_swappable<allocator_type>::value);2302 __is_nothrow_swappable<allocator_type>::value);
2293#endif2303#endif
2294 static void swap(reference __x, reference __y) _NOEXCEPT { _VSTD::swap(__x, __y); }2304 _LIBCPP_CONSTEXPR_AFTER_CXX17 static void swap(reference __x, reference __y) _NOEXCEPT { _VSTD::swap(__x, __y); }
22952305
2296 void resize(size_type __sz, value_type __x = false);2306 _LIBCPP_CONSTEXPR_AFTER_CXX17 void resize(size_type __sz, value_type __x = false);
2297 void flip() _NOEXCEPT;2307 _LIBCPP_CONSTEXPR_AFTER_CXX17 void flip() _NOEXCEPT;
22982308
2299 bool __invariants() const;2309 _LIBCPP_CONSTEXPR_AFTER_CXX17 bool __invariants() const;
23002310
2301private:2311private:
2302 _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI2312 _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI
...@@ -2309,43 +2319,63 @@ private:...@@ -2309,43 +2319,63 @@ private:
2309 _VSTD::__throw_out_of_range("vector");2319 _VSTD::__throw_out_of_range("vector");
2310 }2320 }
23112321
2312 _LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators();2322 // Allocate space for __n objects
2313 void __vallocate(size_type __n);2323 // throws length_error if __n > max_size()
2314 void __vdeallocate() _NOEXCEPT;2324 // throws (probably bad_alloc) if memory run out
2315 _LIBCPP_INLINE_VISIBILITY2325 // Precondition: __begin_ == __end_ == __cap() == 0
2326 // Precondition: __n > 0
2327 // Postcondition: capacity() >= __n
2328 // Postcondition: size() == 0
2329 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __vallocate(size_type __n) {
2330 if (__n > max_size())
2331 __throw_length_error();
2332 auto __allocation = std::__allocate_at_least(__alloc(), __external_cap_to_internal(__n));
2333 __begin_ = __allocation.ptr;
2334 __size_ = 0;
2335 __cap() = __allocation.count;
2336 if (__libcpp_is_constant_evaluated()) {
2337 for (size_type __i = 0; __i != __cap(); ++__i)
2338 std::__construct_at(std::__to_address(__begin_) + __i);
2339 }
2340 }
2341
2342 _LIBCPP_CONSTEXPR_AFTER_CXX17 void __vdeallocate() _NOEXCEPT;
2343 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2316 static size_type __align_it(size_type __new_size) _NOEXCEPT2344 static size_type __align_it(size_type __new_size) _NOEXCEPT
2317 {return __new_size + (__bits_per_word-1) & ~((size_type)__bits_per_word-1);}2345 {return (__new_size + (__bits_per_word-1)) & ~((size_type)__bits_per_word-1);}
2318 _LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __new_size) const;2346 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type __recommend(size_type __new_size) const;
2319 _LIBCPP_INLINE_VISIBILITY void __construct_at_end(size_type __n, bool __x);2347 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void __construct_at_end(size_type __n, bool __x);
2320 template <class _ForwardIterator>2348 template <class _ForwardIterator>
2321 typename enable_if2349 typename enable_if
2322 <2350 <
2323 __is_cpp17_forward_iterator<_ForwardIterator>::value,2351 __is_cpp17_forward_iterator<_ForwardIterator>::value,
2324 void2352 void
2325 >::type2353 >::type
2326 __construct_at_end(_ForwardIterator __first, _ForwardIterator __last);2354 _LIBCPP_CONSTEXPR_AFTER_CXX17 __construct_at_end(_ForwardIterator __first, _ForwardIterator __last);
2327 void __append(size_type __n, const_reference __x);2355 _LIBCPP_CONSTEXPR_AFTER_CXX17 void __append(size_type __n, const_reference __x);
2328 _LIBCPP_INLINE_VISIBILITY2356 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2329 reference __make_ref(size_type __pos) _NOEXCEPT2357 reference __make_ref(size_type __pos) _NOEXCEPT
2330 {return reference(__begin_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);}2358 {return reference(__begin_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);}
2331 _LIBCPP_INLINE_VISIBILITY2359 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2332 const_reference __make_ref(size_type __pos) const _NOEXCEPT2360 const_reference __make_ref(size_type __pos) const _NOEXCEPT {
2333 {return const_reference(__begin_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);}2361 return __bit_const_reference<vector>(__begin_ + __pos / __bits_per_word,
2334 _LIBCPP_INLINE_VISIBILITY2362 __storage_type(1) << __pos % __bits_per_word);
2363 }
2364 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2335 iterator __make_iter(size_type __pos) _NOEXCEPT2365 iterator __make_iter(size_type __pos) _NOEXCEPT
2336 {return iterator(__begin_ + __pos / __bits_per_word, static_cast<unsigned>(__pos % __bits_per_word));}2366 {return iterator(__begin_ + __pos / __bits_per_word, static_cast<unsigned>(__pos % __bits_per_word));}
2337 _LIBCPP_INLINE_VISIBILITY2367 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2338 const_iterator __make_iter(size_type __pos) const _NOEXCEPT2368 const_iterator __make_iter(size_type __pos) const _NOEXCEPT
2339 {return const_iterator(__begin_ + __pos / __bits_per_word, static_cast<unsigned>(__pos % __bits_per_word));}2369 {return const_iterator(__begin_ + __pos / __bits_per_word, static_cast<unsigned>(__pos % __bits_per_word));}
2340 _LIBCPP_INLINE_VISIBILITY2370 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2341 iterator __const_iterator_cast(const_iterator __p) _NOEXCEPT2371 iterator __const_iterator_cast(const_iterator __p) _NOEXCEPT
2342 {return begin() + (__p - cbegin());}2372 {return begin() + (__p - cbegin());}
23432373
2344 _LIBCPP_INLINE_VISIBILITY2374 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2345 void __copy_assign_alloc(const vector& __v)2375 void __copy_assign_alloc(const vector& __v)
2346 {__copy_assign_alloc(__v, integral_constant<bool,2376 {__copy_assign_alloc(__v, integral_constant<bool,
2347 __storage_traits::propagate_on_container_copy_assignment::value>());}2377 __storage_traits::propagate_on_container_copy_assignment::value>());}
2348 _LIBCPP_INLINE_VISIBILITY2378 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2349 void __copy_assign_alloc(const vector& __c, true_type)2379 void __copy_assign_alloc(const vector& __c, true_type)
2350 {2380 {
2351 if (__alloc() != __c.__alloc())2381 if (__alloc() != __c.__alloc())
...@@ -2353,33 +2383,33 @@ private:...@@ -2353,33 +2383,33 @@ private:
2353 __alloc() = __c.__alloc();2383 __alloc() = __c.__alloc();
2354 }2384 }
23552385
2356 _LIBCPP_INLINE_VISIBILITY2386 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2357 void __copy_assign_alloc(const vector&, false_type)2387 void __copy_assign_alloc(const vector&, false_type)
2358 {}2388 {}
23592389
2360 void __move_assign(vector& __c, false_type);2390 _LIBCPP_CONSTEXPR_AFTER_CXX17 void __move_assign(vector& __c, false_type);
2361 void __move_assign(vector& __c, true_type)2391 _LIBCPP_CONSTEXPR_AFTER_CXX17 void __move_assign(vector& __c, true_type)
2362 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value);2392 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value);
2363 _LIBCPP_INLINE_VISIBILITY2393 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2364 void __move_assign_alloc(vector& __c)2394 void __move_assign_alloc(vector& __c)
2365 _NOEXCEPT_(2395 _NOEXCEPT_(
2366 !__storage_traits::propagate_on_container_move_assignment::value ||2396 !__storage_traits::propagate_on_container_move_assignment::value ||
2367 is_nothrow_move_assignable<allocator_type>::value)2397 is_nothrow_move_assignable<allocator_type>::value)
2368 {__move_assign_alloc(__c, integral_constant<bool,2398 {__move_assign_alloc(__c, integral_constant<bool,
2369 __storage_traits::propagate_on_container_move_assignment::value>());}2399 __storage_traits::propagate_on_container_move_assignment::value>());}
2370 _LIBCPP_INLINE_VISIBILITY2400 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2371 void __move_assign_alloc(vector& __c, true_type)2401 void __move_assign_alloc(vector& __c, true_type)
2372 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)2402 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
2373 {2403 {
2374 __alloc() = _VSTD::move(__c.__alloc());2404 __alloc() = _VSTD::move(__c.__alloc());
2375 }2405 }
23762406
2377 _LIBCPP_INLINE_VISIBILITY2407 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2378 void __move_assign_alloc(vector&, false_type)2408 void __move_assign_alloc(vector&, false_type)
2379 _NOEXCEPT2409 _NOEXCEPT
2380 {}2410 {}
23812411
2382 size_t __hash_code() const _NOEXCEPT;2412 _LIBCPP_CONSTEXPR_AFTER_CXX17 size_t __hash_code() const _NOEXCEPT;
23832413
2384 friend class __bit_reference<vector>;2414 friend class __bit_reference<vector>;
2385 friend class __bit_const_reference<vector>;2415 friend class __bit_const_reference<vector>;
...@@ -2390,45 +2420,20 @@ private:...@@ -2390,45 +2420,20 @@ private:
2390};2420};
23912421
2392template <class _Allocator>2422template <class _Allocator>
2393inline _LIBCPP_INLINE_VISIBILITY2423_LIBCPP_CONSTEXPR_AFTER_CXX17 void
2394void
2395vector<bool, _Allocator>::__invalidate_all_iterators()
2396{
2397}
2398
2399// Allocate space for __n objects
2400// throws length_error if __n > max_size()
2401// throws (probably bad_alloc) if memory run out
2402// Precondition: __begin_ == __end_ == __cap() == 0
2403// Precondition: __n > 0
2404// Postcondition: capacity() == __n
2405// Postcondition: size() == 0
2406template <class _Allocator>
2407void
2408vector<bool, _Allocator>::__vallocate(size_type __n)
2409{
2410 if (__n > max_size())
2411 this->__throw_length_error();
2412 __n = __external_cap_to_internal(__n);
2413 this->__begin_ = __storage_traits::allocate(this->__alloc(), __n);
2414 this->__size_ = 0;
2415 this->__cap() = __n;
2416}
2417
2418template <class _Allocator>
2419void
2420vector<bool, _Allocator>::__vdeallocate() _NOEXCEPT2424vector<bool, _Allocator>::__vdeallocate() _NOEXCEPT
2421{2425{
2422 if (this->__begin_ != nullptr)2426 if (this->__begin_ != nullptr)
2423 {2427 {
2424 __storage_traits::deallocate(this->__alloc(), this->__begin_, __cap());2428 __storage_traits::deallocate(this->__alloc(), this->__begin_, __cap());
2425 __invalidate_all_iterators();2429 std::__debug_db_invalidate_all(this);
2426 this->__begin_ = nullptr;2430 this->__begin_ = nullptr;
2427 this->__size_ = this->__cap() = 0;2431 this->__size_ = this->__cap() = 0;
2428 }2432 }
2429}2433}
24302434
2431template <class _Allocator>2435template <class _Allocator>
2436_LIBCPP_CONSTEXPR_AFTER_CXX17
2432typename vector<bool, _Allocator>::size_type2437typename vector<bool, _Allocator>::size_type
2433vector<bool, _Allocator>::max_size() const _NOEXCEPT2438vector<bool, _Allocator>::max_size() const _NOEXCEPT
2434{2439{
...@@ -2441,7 +2446,7 @@ vector<bool, _Allocator>::max_size() const _NOEXCEPT...@@ -2441,7 +2446,7 @@ vector<bool, _Allocator>::max_size() const _NOEXCEPT
24412446
2442// Precondition: __new_size > capacity()2447// Precondition: __new_size > capacity()
2443template <class _Allocator>2448template <class _Allocator>
2444inline _LIBCPP_INLINE_VISIBILITY2449inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2445typename vector<bool, _Allocator>::size_type2450typename vector<bool, _Allocator>::size_type
2446vector<bool, _Allocator>::__recommend(size_type __new_size) const2451vector<bool, _Allocator>::__recommend(size_type __new_size) const
2447{2452{
...@@ -2459,7 +2464,7 @@ vector<bool, _Allocator>::__recommend(size_type __new_size) const...@@ -2459,7 +2464,7 @@ vector<bool, _Allocator>::__recommend(size_type __new_size) const
2459// Precondition: size() + __n <= capacity()2464// Precondition: size() + __n <= capacity()
2460// Postcondition: size() == size() + __n2465// Postcondition: size() == size() + __n
2461template <class _Allocator>2466template <class _Allocator>
2462inline _LIBCPP_INLINE_VISIBILITY2467inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2463void2468void
2464vector<bool, _Allocator>::__construct_at_end(size_type __n, bool __x)2469vector<bool, _Allocator>::__construct_at_end(size_type __n, bool __x)
2465{2470{
...@@ -2477,6 +2482,7 @@ vector<bool, _Allocator>::__construct_at_end(size_type __n, bool __x)...@@ -2477,6 +2482,7 @@ vector<bool, _Allocator>::__construct_at_end(size_type __n, bool __x)
24772482
2478template <class _Allocator>2483template <class _Allocator>
2479template <class _ForwardIterator>2484template <class _ForwardIterator>
2485_LIBCPP_CONSTEXPR_AFTER_CXX17
2480typename enable_if2486typename enable_if
2481<2487<
2482 __is_cpp17_forward_iterator<_ForwardIterator>::value,2488 __is_cpp17_forward_iterator<_ForwardIterator>::value,
...@@ -2497,7 +2503,7 @@ vector<bool, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardI...@@ -2497,7 +2503,7 @@ vector<bool, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardI
2497}2503}
24982504
2499template <class _Allocator>2505template <class _Allocator>
2500inline _LIBCPP_INLINE_VISIBILITY2506inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2501vector<bool, _Allocator>::vector()2507vector<bool, _Allocator>::vector()
2502 _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)2508 _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
2503 : __begin_(nullptr),2509 : __begin_(nullptr),
...@@ -2507,7 +2513,7 @@ vector<bool, _Allocator>::vector()...@@ -2507,7 +2513,7 @@ vector<bool, _Allocator>::vector()
2507}2513}
25082514
2509template <class _Allocator>2515template <class _Allocator>
2510inline _LIBCPP_INLINE_VISIBILITY2516inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2511vector<bool, _Allocator>::vector(const allocator_type& __a)2517vector<bool, _Allocator>::vector(const allocator_type& __a)
2512#if _LIBCPP_STD_VER <= 142518#if _LIBCPP_STD_VER <= 14
2513 _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)2519 _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)
...@@ -2521,6 +2527,7 @@ vector<bool, _Allocator>::vector(const allocator_type& __a)...@@ -2521,6 +2527,7 @@ vector<bool, _Allocator>::vector(const allocator_type& __a)
2521}2527}
25222528
2523template <class _Allocator>2529template <class _Allocator>
2530_LIBCPP_CONSTEXPR_AFTER_CXX17
2524vector<bool, _Allocator>::vector(size_type __n)2531vector<bool, _Allocator>::vector(size_type __n)
2525 : __begin_(nullptr),2532 : __begin_(nullptr),
2526 __size_(0),2533 __size_(0),
...@@ -2535,6 +2542,7 @@ vector<bool, _Allocator>::vector(size_type __n)...@@ -2535,6 +2542,7 @@ vector<bool, _Allocator>::vector(size_type __n)
25352542
2536#if _LIBCPP_STD_VER > 112543#if _LIBCPP_STD_VER > 11
2537template <class _Allocator>2544template <class _Allocator>
2545_LIBCPP_CONSTEXPR_AFTER_CXX17
2538vector<bool, _Allocator>::vector(size_type __n, const allocator_type& __a)2546vector<bool, _Allocator>::vector(size_type __n, const allocator_type& __a)
2539 : __begin_(nullptr),2547 : __begin_(nullptr),
2540 __size_(0),2548 __size_(0),
...@@ -2549,6 +2557,7 @@ vector<bool, _Allocator>::vector(size_type __n, const allocator_type& __a)...@@ -2549,6 +2557,7 @@ vector<bool, _Allocator>::vector(size_type __n, const allocator_type& __a)
2549#endif2557#endif
25502558
2551template <class _Allocator>2559template <class _Allocator>
2560_LIBCPP_CONSTEXPR_AFTER_CXX17
2552vector<bool, _Allocator>::vector(size_type __n, const value_type& __x)2561vector<bool, _Allocator>::vector(size_type __n, const value_type& __x)
2553 : __begin_(nullptr),2562 : __begin_(nullptr),
2554 __size_(0),2563 __size_(0),
...@@ -2562,6 +2571,7 @@ vector<bool, _Allocator>::vector(size_type __n, const value_type& __x)...@@ -2562,6 +2571,7 @@ vector<bool, _Allocator>::vector(size_type __n, const value_type& __x)
2562}2571}
25632572
2564template <class _Allocator>2573template <class _Allocator>
2574_LIBCPP_CONSTEXPR_AFTER_CXX17
2565vector<bool, _Allocator>::vector(size_type __n, const value_type& __x, const allocator_type& __a)2575vector<bool, _Allocator>::vector(size_type __n, const value_type& __x, const allocator_type& __a)
2566 : __begin_(nullptr),2576 : __begin_(nullptr),
2567 __size_(0),2577 __size_(0),
...@@ -2576,9 +2586,9 @@ vector<bool, _Allocator>::vector(size_type __n, const value_type& __x, const all...@@ -2576,9 +2586,9 @@ vector<bool, _Allocator>::vector(size_type __n, const value_type& __x, const all
25762586
2577template <class _Allocator>2587template <class _Allocator>
2578template <class _InputIterator>2588template <class _InputIterator>
2589_LIBCPP_CONSTEXPR_AFTER_CXX17
2579vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last,2590vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last,
2580 typename enable_if<__is_cpp17_input_iterator <_InputIterator>::value &&2591 typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value>::type*)
2581 !__is_cpp17_forward_iterator<_InputIterator>::value>::type*)
2582 : __begin_(nullptr),2592 : __begin_(nullptr),
2583 __size_(0),2593 __size_(0),
2584 __cap_alloc_(0, __default_init_tag())2594 __cap_alloc_(0, __default_init_tag())
...@@ -2595,7 +2605,7 @@ vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last,...@@ -2595,7 +2605,7 @@ vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last,
2595 {2605 {
2596 if (__begin_ != nullptr)2606 if (__begin_ != nullptr)
2597 __storage_traits::deallocate(__alloc(), __begin_, __cap());2607 __storage_traits::deallocate(__alloc(), __begin_, __cap());
2598 __invalidate_all_iterators();2608 std::__debug_db_invalidate_all(this);
2599 throw;2609 throw;
2600 }2610 }
2601#endif // _LIBCPP_NO_EXCEPTIONS2611#endif // _LIBCPP_NO_EXCEPTIONS
...@@ -2603,9 +2613,9 @@ vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last,...@@ -2603,9 +2613,9 @@ vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last,
26032613
2604template <class _Allocator>2614template <class _Allocator>
2605template <class _InputIterator>2615template <class _InputIterator>
2616_LIBCPP_CONSTEXPR_AFTER_CXX17
2606vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,2617vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,
2607 typename enable_if<__is_cpp17_input_iterator <_InputIterator>::value &&2618 typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value>::type*)
2608 !__is_cpp17_forward_iterator<_InputIterator>::value>::type*)
2609 : __begin_(nullptr),2619 : __begin_(nullptr),
2610 __size_(0),2620 __size_(0),
2611 __cap_alloc_(0, static_cast<__storage_allocator>(__a))2621 __cap_alloc_(0, static_cast<__storage_allocator>(__a))
...@@ -2622,7 +2632,7 @@ vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last,...@@ -2622,7 +2632,7 @@ vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last,
2622 {2632 {
2623 if (__begin_ != nullptr)2633 if (__begin_ != nullptr)
2624 __storage_traits::deallocate(__alloc(), __begin_, __cap());2634 __storage_traits::deallocate(__alloc(), __begin_, __cap());
2625 __invalidate_all_iterators();2635 std::__debug_db_invalidate_all(this);
2626 throw;2636 throw;
2627 }2637 }
2628#endif // _LIBCPP_NO_EXCEPTIONS2638#endif // _LIBCPP_NO_EXCEPTIONS
...@@ -2630,6 +2640,7 @@ vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last,...@@ -2630,6 +2640,7 @@ vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last,
26302640
2631template <class _Allocator>2641template <class _Allocator>
2632template <class _ForwardIterator>2642template <class _ForwardIterator>
2643_LIBCPP_CONSTEXPR_AFTER_CXX17
2633vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last,2644vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last,
2634 typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type*)2645 typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type*)
2635 : __begin_(nullptr),2646 : __begin_(nullptr),
...@@ -2646,6 +2657,7 @@ vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __la...@@ -2646,6 +2657,7 @@ vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __la
26462657
2647template <class _Allocator>2658template <class _Allocator>
2648template <class _ForwardIterator>2659template <class _ForwardIterator>
2660_LIBCPP_CONSTEXPR_AFTER_CXX17
2649vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,2661vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,
2650 typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type*)2662 typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type*)
2651 : __begin_(nullptr),2663 : __begin_(nullptr),
...@@ -2663,6 +2675,7 @@ vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __la...@@ -2663,6 +2675,7 @@ vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __la
2663#ifndef _LIBCPP_CXX03_LANG2675#ifndef _LIBCPP_CXX03_LANG
26642676
2665template <class _Allocator>2677template <class _Allocator>
2678_LIBCPP_CONSTEXPR_AFTER_CXX17
2666vector<bool, _Allocator>::vector(initializer_list<value_type> __il)2679vector<bool, _Allocator>::vector(initializer_list<value_type> __il)
2667 : __begin_(nullptr),2680 : __begin_(nullptr),
2668 __size_(0),2681 __size_(0),
...@@ -2677,6 +2690,7 @@ vector<bool, _Allocator>::vector(initializer_list<value_type> __il)...@@ -2677,6 +2690,7 @@ vector<bool, _Allocator>::vector(initializer_list<value_type> __il)
2677}2690}
26782691
2679template <class _Allocator>2692template <class _Allocator>
2693_LIBCPP_CONSTEXPR_AFTER_CXX17
2680vector<bool, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a)2694vector<bool, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a)
2681 : __begin_(nullptr),2695 : __begin_(nullptr),
2682 __size_(0),2696 __size_(0),
...@@ -2693,14 +2707,16 @@ vector<bool, _Allocator>::vector(initializer_list<value_type> __il, const alloca...@@ -2693,14 +2707,16 @@ vector<bool, _Allocator>::vector(initializer_list<value_type> __il, const alloca
2693#endif // _LIBCPP_CXX03_LANG2707#endif // _LIBCPP_CXX03_LANG
26942708
2695template <class _Allocator>2709template <class _Allocator>
2710_LIBCPP_CONSTEXPR_AFTER_CXX17
2696vector<bool, _Allocator>::~vector()2711vector<bool, _Allocator>::~vector()
2697{2712{
2698 if (__begin_ != nullptr)2713 if (__begin_ != nullptr)
2699 __storage_traits::deallocate(__alloc(), __begin_, __cap());2714 __storage_traits::deallocate(__alloc(), __begin_, __cap());
2700 __invalidate_all_iterators();2715 std::__debug_db_invalidate_all(this);
2701}2716}
27022717
2703template <class _Allocator>2718template <class _Allocator>
2719_LIBCPP_CONSTEXPR_AFTER_CXX17
2704vector<bool, _Allocator>::vector(const vector& __v)2720vector<bool, _Allocator>::vector(const vector& __v)
2705 : __begin_(nullptr),2721 : __begin_(nullptr),
2706 __size_(0),2722 __size_(0),
...@@ -2714,6 +2730,7 @@ vector<bool, _Allocator>::vector(const vector& __v)...@@ -2714,6 +2730,7 @@ vector<bool, _Allocator>::vector(const vector& __v)
2714}2730}
27152731
2716template <class _Allocator>2732template <class _Allocator>
2733_LIBCPP_CONSTEXPR_AFTER_CXX17
2717vector<bool, _Allocator>::vector(const vector& __v, const allocator_type& __a)2734vector<bool, _Allocator>::vector(const vector& __v, const allocator_type& __a)
2718 : __begin_(nullptr),2735 : __begin_(nullptr),
2719 __size_(0),2736 __size_(0),
...@@ -2727,6 +2744,7 @@ vector<bool, _Allocator>::vector(const vector& __v, const allocator_type& __a)...@@ -2727,6 +2744,7 @@ vector<bool, _Allocator>::vector(const vector& __v, const allocator_type& __a)
2727}2744}
27282745
2729template <class _Allocator>2746template <class _Allocator>
2747_LIBCPP_CONSTEXPR_AFTER_CXX17
2730vector<bool, _Allocator>&2748vector<bool, _Allocator>&
2731vector<bool, _Allocator>::operator=(const vector& __v)2749vector<bool, _Allocator>::operator=(const vector& __v)
2732{2750{
...@@ -2747,10 +2765,8 @@ vector<bool, _Allocator>::operator=(const vector& __v)...@@ -2747,10 +2765,8 @@ vector<bool, _Allocator>::operator=(const vector& __v)
2747 return *this;2765 return *this;
2748}2766}
27492767
2750#ifndef _LIBCPP_CXX03_LANG
2751
2752template <class _Allocator>2768template <class _Allocator>
2753inline _LIBCPP_INLINE_VISIBILITY vector<bool, _Allocator>::vector(vector&& __v)2769inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 vector<bool, _Allocator>::vector(vector&& __v)
2754#if _LIBCPP_STD_VER > 142770#if _LIBCPP_STD_VER > 14
2755 _NOEXCEPT2771 _NOEXCEPT
2756#else2772#else
...@@ -2765,7 +2781,8 @@ inline _LIBCPP_INLINE_VISIBILITY vector<bool, _Allocator>::vector(vector&& __v)...@@ -2765,7 +2781,8 @@ inline _LIBCPP_INLINE_VISIBILITY vector<bool, _Allocator>::vector(vector&& __v)
2765}2781}
27662782
2767template <class _Allocator>2783template <class _Allocator>
2768vector<bool, _Allocator>::vector(vector&& __v, const __identity_t<allocator_type>& __a)2784_LIBCPP_CONSTEXPR_AFTER_CXX17
2785vector<bool, _Allocator>::vector(vector&& __v, const __type_identity_t<allocator_type>& __a)
2769 : __begin_(nullptr),2786 : __begin_(nullptr),
2770 __size_(0),2787 __size_(0),
2771 __cap_alloc_(0, __a)2788 __cap_alloc_(0, __a)
...@@ -2786,7 +2803,7 @@ vector<bool, _Allocator>::vector(vector&& __v, const __identity_t<allocator_type...@@ -2786,7 +2803,7 @@ vector<bool, _Allocator>::vector(vector&& __v, const __identity_t<allocator_type
2786}2803}
27872804
2788template <class _Allocator>2805template <class _Allocator>
2789inline _LIBCPP_INLINE_VISIBILITY2806inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2790vector<bool, _Allocator>&2807vector<bool, _Allocator>&
2791vector<bool, _Allocator>::operator=(vector&& __v)2808vector<bool, _Allocator>::operator=(vector&& __v)
2792 _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value))2809 _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value))
...@@ -2797,7 +2814,7 @@ vector<bool, _Allocator>::operator=(vector&& __v)...@@ -2797,7 +2814,7 @@ vector<bool, _Allocator>::operator=(vector&& __v)
2797}2814}
27982815
2799template <class _Allocator>2816template <class _Allocator>
2800void2817_LIBCPP_CONSTEXPR_AFTER_CXX17 void
2801vector<bool, _Allocator>::__move_assign(vector& __c, false_type)2818vector<bool, _Allocator>::__move_assign(vector& __c, false_type)
2802{2819{
2803 if (__alloc() != __c.__alloc())2820 if (__alloc() != __c.__alloc())
...@@ -2807,7 +2824,7 @@ vector<bool, _Allocator>::__move_assign(vector& __c, false_type)...@@ -2807,7 +2824,7 @@ vector<bool, _Allocator>::__move_assign(vector& __c, false_type)
2807}2824}
28082825
2809template <class _Allocator>2826template <class _Allocator>
2810void2827_LIBCPP_CONSTEXPR_AFTER_CXX17 void
2811vector<bool, _Allocator>::__move_assign(vector& __c, true_type)2828vector<bool, _Allocator>::__move_assign(vector& __c, true_type)
2812 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)2829 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
2813{2830{
...@@ -2820,10 +2837,8 @@ vector<bool, _Allocator>::__move_assign(vector& __c, true_type)...@@ -2820,10 +2837,8 @@ vector<bool, _Allocator>::__move_assign(vector& __c, true_type)
2820 __c.__cap() = __c.__size_ = 0;2837 __c.__cap() = __c.__size_ = 0;
2821}2838}
28222839
2823#endif // !_LIBCPP_CXX03_LANG
2824
2825template <class _Allocator>2840template <class _Allocator>
2826void2841_LIBCPP_CONSTEXPR_AFTER_CXX17 void
2827vector<bool, _Allocator>::assign(size_type __n, const value_type& __x)2842vector<bool, _Allocator>::assign(size_type __n, const value_type& __x)
2828{2843{
2829 __size_ = 0;2844 __size_ = 0;
...@@ -2841,15 +2856,12 @@ vector<bool, _Allocator>::assign(size_type __n, const value_type& __x)...@@ -2841,15 +2856,12 @@ vector<bool, _Allocator>::assign(size_type __n, const value_type& __x)
2841 }2856 }
2842 _VSTD::fill_n(begin(), __n, __x);2857 _VSTD::fill_n(begin(), __n, __x);
2843 }2858 }
2844 __invalidate_all_iterators();2859 std::__debug_db_invalidate_all(this);
2845}2860}
28462861
2847template <class _Allocator>2862template <class _Allocator>
2848template <class _InputIterator>2863template <class _InputIterator>
2849typename enable_if2864_LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value,
2850<
2851 __is_cpp17_input_iterator<_InputIterator>::value &&
2852 !__is_cpp17_forward_iterator<_InputIterator>::value,
2853 void2865 void
2854>::type2866>::type
2855vector<bool, _Allocator>::assign(_InputIterator __first, _InputIterator __last)2867vector<bool, _Allocator>::assign(_InputIterator __first, _InputIterator __last)
...@@ -2861,6 +2873,7 @@ vector<bool, _Allocator>::assign(_InputIterator __first, _InputIterator __last)...@@ -2861,6 +2873,7 @@ vector<bool, _Allocator>::assign(_InputIterator __first, _InputIterator __last)
28612873
2862template <class _Allocator>2874template <class _Allocator>
2863template <class _ForwardIterator>2875template <class _ForwardIterator>
2876_LIBCPP_CONSTEXPR_AFTER_CXX17
2864typename enable_if2877typename enable_if
2865<2878<
2866 __is_cpp17_forward_iterator<_ForwardIterator>::value,2879 __is_cpp17_forward_iterator<_ForwardIterator>::value,
...@@ -2884,7 +2897,7 @@ vector<bool, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __la...@@ -2884,7 +2897,7 @@ vector<bool, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __la
2884}2897}
28852898
2886template <class _Allocator>2899template <class _Allocator>
2887void2900_LIBCPP_CONSTEXPR_AFTER_CXX17 void
2888vector<bool, _Allocator>::reserve(size_type __n)2901vector<bool, _Allocator>::reserve(size_type __n)
2889{2902{
2890 if (__n > capacity())2903 if (__n > capacity())
...@@ -2895,12 +2908,12 @@ vector<bool, _Allocator>::reserve(size_type __n)...@@ -2895,12 +2908,12 @@ vector<bool, _Allocator>::reserve(size_type __n)
2895 __v.__vallocate(__n);2908 __v.__vallocate(__n);
2896 __v.__construct_at_end(this->begin(), this->end());2909 __v.__construct_at_end(this->begin(), this->end());
2897 swap(__v);2910 swap(__v);
2898 __invalidate_all_iterators();2911 std::__debug_db_invalidate_all(this);
2899 }2912 }
2900}2913}
29012914
2902template <class _Allocator>2915template <class _Allocator>
2903void2916_LIBCPP_CONSTEXPR_AFTER_CXX17 void
2904vector<bool, _Allocator>::shrink_to_fit() _NOEXCEPT2917vector<bool, _Allocator>::shrink_to_fit() _NOEXCEPT
2905{2918{
2906 if (__external_cap_to_internal(size()) > __cap())2919 if (__external_cap_to_internal(size()) > __cap())
...@@ -2938,7 +2951,7 @@ vector<bool, _Allocator>::at(size_type __n) const...@@ -2938,7 +2951,7 @@ vector<bool, _Allocator>::at(size_type __n) const
2938}2951}
29392952
2940template <class _Allocator>2953template <class _Allocator>
2941void2954_LIBCPP_CONSTEXPR_AFTER_CXX17 void
2942vector<bool, _Allocator>::push_back(const value_type& __x)2955vector<bool, _Allocator>::push_back(const value_type& __x)
2943{2956{
2944 if (this->__size_ == this->capacity())2957 if (this->__size_ == this->capacity())
...@@ -2948,7 +2961,7 @@ vector<bool, _Allocator>::push_back(const value_type& __x)...@@ -2948,7 +2961,7 @@ vector<bool, _Allocator>::push_back(const value_type& __x)
2948}2961}
29492962
2950template <class _Allocator>2963template <class _Allocator>
2951typename vector<bool, _Allocator>::iterator2964_LIBCPP_CONSTEXPR_AFTER_CXX17 typename vector<bool, _Allocator>::iterator
2952vector<bool, _Allocator>::insert(const_iterator __position, const value_type& __x)2965vector<bool, _Allocator>::insert(const_iterator __position, const value_type& __x)
2953{2966{
2954 iterator __r;2967 iterator __r;
...@@ -2973,7 +2986,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, const value_type& __...@@ -2973,7 +2986,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, const value_type& __
2973}2986}
29742987
2975template <class _Allocator>2988template <class _Allocator>
2976typename vector<bool, _Allocator>::iterator2989_LIBCPP_CONSTEXPR_AFTER_CXX17 typename vector<bool, _Allocator>::iterator
2977vector<bool, _Allocator>::insert(const_iterator __position, size_type __n, const value_type& __x)2990vector<bool, _Allocator>::insert(const_iterator __position, size_type __n, const value_type& __x)
2978{2991{
2979 iterator __r;2992 iterator __r;
...@@ -3000,10 +3013,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, size_type __n, const...@@ -3000,10 +3013,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, size_type __n, const
30003013
3001template <class _Allocator>3014template <class _Allocator>
3002template <class _InputIterator>3015template <class _InputIterator>
3003typename enable_if3016_LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value,
3004<
3005 __is_cpp17_input_iterator <_InputIterator>::value &&
3006 !__is_cpp17_forward_iterator<_InputIterator>::value,
3007 typename vector<bool, _Allocator>::iterator3017 typename vector<bool, _Allocator>::iterator
3008>::type3018>::type
3009vector<bool, _Allocator>::insert(const_iterator __position, _InputIterator __first, _InputIterator __last)3019vector<bool, _Allocator>::insert(const_iterator __position, _InputIterator __first, _InputIterator __last)
...@@ -3045,6 +3055,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, _InputIterator __fir...@@ -3045,6 +3055,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, _InputIterator __fir
30453055
3046template <class _Allocator>3056template <class _Allocator>
3047template <class _ForwardIterator>3057template <class _ForwardIterator>
3058_LIBCPP_CONSTEXPR_AFTER_CXX17
3048typename enable_if3059typename enable_if
3049<3060<
3050 __is_cpp17_forward_iterator<_ForwardIterator>::value,3061 __is_cpp17_forward_iterator<_ForwardIterator>::value,
...@@ -3078,7 +3089,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, _ForwardIterator __f...@@ -3078,7 +3089,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, _ForwardIterator __f
3078}3089}
30793090
3080template <class _Allocator>3091template <class _Allocator>
3081inline _LIBCPP_INLINE_VISIBILITY3092inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
3082typename vector<bool, _Allocator>::iterator3093typename vector<bool, _Allocator>::iterator
3083vector<bool, _Allocator>::erase(const_iterator __position)3094vector<bool, _Allocator>::erase(const_iterator __position)
3084{3095{
...@@ -3089,6 +3100,7 @@ vector<bool, _Allocator>::erase(const_iterator __position)...@@ -3089,6 +3100,7 @@ vector<bool, _Allocator>::erase(const_iterator __position)
3089}3100}
30903101
3091template <class _Allocator>3102template <class _Allocator>
3103_LIBCPP_CONSTEXPR_AFTER_CXX17
3092typename vector<bool, _Allocator>::iterator3104typename vector<bool, _Allocator>::iterator
3093vector<bool, _Allocator>::erase(const_iterator __first, const_iterator __last)3105vector<bool, _Allocator>::erase(const_iterator __first, const_iterator __last)
3094{3106{
...@@ -3100,7 +3112,7 @@ vector<bool, _Allocator>::erase(const_iterator __first, const_iterator __last)...@@ -3100,7 +3112,7 @@ vector<bool, _Allocator>::erase(const_iterator __first, const_iterator __last)
3100}3112}
31013113
3102template <class _Allocator>3114template <class _Allocator>
3103void3115_LIBCPP_CONSTEXPR_AFTER_CXX17 void
3104vector<bool, _Allocator>::swap(vector& __x)3116vector<bool, _Allocator>::swap(vector& __x)
3105#if _LIBCPP_STD_VER >= 143117#if _LIBCPP_STD_VER >= 14
3106 _NOEXCEPT3118 _NOEXCEPT
...@@ -3117,7 +3129,7 @@ vector<bool, _Allocator>::swap(vector& __x)...@@ -3117,7 +3129,7 @@ vector<bool, _Allocator>::swap(vector& __x)
3117}3129}
31183130
3119template <class _Allocator>3131template <class _Allocator>
3120void3132_LIBCPP_CONSTEXPR_AFTER_CXX17 void
3121vector<bool, _Allocator>::resize(size_type __sz, value_type __x)3133vector<bool, _Allocator>::resize(size_type __sz, value_type __x)
3122{3134{
3123 size_type __cs = size();3135 size_type __cs = size();
...@@ -3146,7 +3158,7 @@ vector<bool, _Allocator>::resize(size_type __sz, value_type __x)...@@ -3146,7 +3158,7 @@ vector<bool, _Allocator>::resize(size_type __sz, value_type __x)
3146}3158}
31473159
3148template <class _Allocator>3160template <class _Allocator>
3149void3161_LIBCPP_CONSTEXPR_AFTER_CXX17 void
3150vector<bool, _Allocator>::flip() _NOEXCEPT3162vector<bool, _Allocator>::flip() _NOEXCEPT
3151{3163{
3152 // do middle whole words3164 // do middle whole words
...@@ -3165,7 +3177,7 @@ vector<bool, _Allocator>::flip() _NOEXCEPT...@@ -3165,7 +3177,7 @@ vector<bool, _Allocator>::flip() _NOEXCEPT
3165}3177}
31663178
3167template <class _Allocator>3179template <class _Allocator>
3168bool3180_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
3169vector<bool, _Allocator>::__invariants() const3181vector<bool, _Allocator>::__invariants() const
3170{3182{
3171 if (this->__begin_ == nullptr)3183 if (this->__begin_ == nullptr)
...@@ -3184,7 +3196,7 @@ vector<bool, _Allocator>::__invariants() const...@@ -3184,7 +3196,7 @@ vector<bool, _Allocator>::__invariants() const
3184}3196}
31853197
3186template <class _Allocator>3198template <class _Allocator>
3187size_t3199_LIBCPP_CONSTEXPR_AFTER_CXX17 size_t
3188vector<bool, _Allocator>::__hash_code() const _NOEXCEPT3200vector<bool, _Allocator>::__hash_code() const _NOEXCEPT
3189{3201{
3190 size_t __h = 0;3202 size_t __h = 0;
...@@ -3204,14 +3216,15 @@ vector<bool, _Allocator>::__hash_code() const _NOEXCEPT...@@ -3204,14 +3216,15 @@ vector<bool, _Allocator>::__hash_code() const _NOEXCEPT
32043216
3205template <class _Allocator>3217template <class _Allocator>
3206struct _LIBCPP_TEMPLATE_VIS hash<vector<bool, _Allocator> >3218struct _LIBCPP_TEMPLATE_VIS hash<vector<bool, _Allocator> >
3207 : public unary_function<vector<bool, _Allocator>, size_t>3219 : public __unary_function<vector<bool, _Allocator>, size_t>
3208{3220{
3209 _LIBCPP_INLINE_VISIBILITY3221 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
3210 size_t operator()(const vector<bool, _Allocator>& __vec) const _NOEXCEPT3222 size_t operator()(const vector<bool, _Allocator>& __vec) const _NOEXCEPT
3211 {return __vec.__hash_code();}3223 {return __vec.__hash_code();}
3212};3224};
32133225
3214template <class _Tp, class _Allocator>3226template <class _Tp, class _Allocator>
3227_LIBCPP_CONSTEXPR_AFTER_CXX17
3215inline _LIBCPP_INLINE_VISIBILITY3228inline _LIBCPP_INLINE_VISIBILITY
3216bool3229bool
3217operator==(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)3230operator==(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
...@@ -3221,6 +3234,7 @@ operator==(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __...@@ -3221,6 +3234,7 @@ operator==(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __
3221}3234}
32223235
3223template <class _Tp, class _Allocator>3236template <class _Tp, class _Allocator>
3237_LIBCPP_CONSTEXPR_AFTER_CXX17
3224inline _LIBCPP_INLINE_VISIBILITY3238inline _LIBCPP_INLINE_VISIBILITY
3225bool3239bool
3226operator!=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)3240operator!=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
...@@ -3229,6 +3243,7 @@ operator!=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __...@@ -3229,6 +3243,7 @@ operator!=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __
3229}3243}
32303244
3231template <class _Tp, class _Allocator>3245template <class _Tp, class _Allocator>
3246_LIBCPP_CONSTEXPR_AFTER_CXX17
3232inline _LIBCPP_INLINE_VISIBILITY3247inline _LIBCPP_INLINE_VISIBILITY
3233bool3248bool
3234operator< (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)3249operator< (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
...@@ -3237,6 +3252,7 @@ operator< (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __...@@ -3237,6 +3252,7 @@ operator< (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __
3237}3252}
32383253
3239template <class _Tp, class _Allocator>3254template <class _Tp, class _Allocator>
3255_LIBCPP_CONSTEXPR_AFTER_CXX17
3240inline _LIBCPP_INLINE_VISIBILITY3256inline _LIBCPP_INLINE_VISIBILITY
3241bool3257bool
3242operator> (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)3258operator> (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
...@@ -3245,6 +3261,7 @@ operator> (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __...@@ -3245,6 +3261,7 @@ operator> (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __
3245}3261}
32463262
3247template <class _Tp, class _Allocator>3263template <class _Tp, class _Allocator>
3264_LIBCPP_CONSTEXPR_AFTER_CXX17
3248inline _LIBCPP_INLINE_VISIBILITY3265inline _LIBCPP_INLINE_VISIBILITY
3249bool3266bool
3250operator>=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)3267operator>=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
...@@ -3253,6 +3270,7 @@ operator>=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __...@@ -3253,6 +3270,7 @@ operator>=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __
3253}3270}
32543271
3255template <class _Tp, class _Allocator>3272template <class _Tp, class _Allocator>
3273_LIBCPP_CONSTEXPR_AFTER_CXX17
3256inline _LIBCPP_INLINE_VISIBILITY3274inline _LIBCPP_INLINE_VISIBILITY
3257bool3275bool
3258operator<=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)3276operator<=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
...@@ -3261,6 +3279,7 @@ operator<=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __...@@ -3261,6 +3279,7 @@ operator<=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __
3261}3279}
32623280
3263template <class _Tp, class _Allocator>3281template <class _Tp, class _Allocator>
3282_LIBCPP_CONSTEXPR_AFTER_CXX17
3264inline _LIBCPP_INLINE_VISIBILITY3283inline _LIBCPP_INLINE_VISIBILITY
3265void3284void
3266swap(vector<_Tp, _Allocator>& __x, vector<_Tp, _Allocator>& __y)3285swap(vector<_Tp, _Allocator>& __x, vector<_Tp, _Allocator>& __y)
...@@ -3271,6 +3290,7 @@ swap(vector<_Tp, _Allocator>& __x, vector<_Tp, _Allocator>& __y)...@@ -3271,6 +3290,7 @@ swap(vector<_Tp, _Allocator>& __x, vector<_Tp, _Allocator>& __y)
32713290
3272#if _LIBCPP_STD_VER > 173291#if _LIBCPP_STD_VER > 17
3273template <class _Tp, class _Allocator, class _Up>3292template <class _Tp, class _Allocator, class _Up>
3293_LIBCPP_CONSTEXPR_AFTER_CXX17
3274inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::size_type3294inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::size_type
3275erase(vector<_Tp, _Allocator>& __c, const _Up& __v) {3295erase(vector<_Tp, _Allocator>& __c, const _Up& __v) {
3276 auto __old_size = __c.size();3296 auto __old_size = __c.size();
...@@ -3279,14 +3299,23 @@ erase(vector<_Tp, _Allocator>& __c, const _Up& __v) {...@@ -3279,14 +3299,23 @@ erase(vector<_Tp, _Allocator>& __c, const _Up& __v) {
3279}3299}
32803300
3281template <class _Tp, class _Allocator, class _Predicate>3301template <class _Tp, class _Allocator, class _Predicate>
3302_LIBCPP_CONSTEXPR_AFTER_CXX17
3282inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::size_type3303inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::size_type
3283erase_if(vector<_Tp, _Allocator>& __c, _Predicate __pred) {3304erase_if(vector<_Tp, _Allocator>& __c, _Predicate __pred) {
3284 auto __old_size = __c.size();3305 auto __old_size = __c.size();
3285 __c.erase(_VSTD::remove_if(__c.begin(), __c.end(), __pred), __c.end());3306 __c.erase(_VSTD::remove_if(__c.begin(), __c.end(), __pred), __c.end());
3286 return __old_size - __c.size();3307 return __old_size - __c.size();
3287}3308}
3309
3310template <>
3311inline constexpr bool __format::__enable_insertable<std::vector<char>> = true;
3312#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
3313template <>
3314inline constexpr bool __format::__enable_insertable<std::vector<wchar_t>> = true;
3288#endif3315#endif
32893316
3317#endif // _LIBCPP_STD_VER > 17
3318
3290_LIBCPP_END_NAMESPACE_STD3319_LIBCPP_END_NAMESPACE_STD
32913320
3292_LIBCPP_POP_MACROS3321_LIBCPP_POP_MACROS
lib/libcxx/include/version+46-20
...@@ -38,6 +38,7 @@ __cpp_lib_atomic_shared_ptr 201711L <atomic>...@@ -38,6 +38,7 @@ __cpp_lib_atomic_shared_ptr 201711L <atomic>
38__cpp_lib_atomic_value_initialization 201911L <atomic> <memory>38__cpp_lib_atomic_value_initialization 201911L <atomic> <memory>
39__cpp_lib_atomic_wait 201907L <atomic>39__cpp_lib_atomic_wait 201907L <atomic>
40__cpp_lib_barrier 201907L <barrier>40__cpp_lib_barrier 201907L <barrier>
41__cpp_lib_bind_back 202202L <functional>
41__cpp_lib_bind_front 201907L <functional>42__cpp_lib_bind_front 201907L <functional>
42__cpp_lib_bit_cast 201806L <bit>43__cpp_lib_bit_cast 201806L <bit>
43__cpp_lib_bitops 201907L <bit>44__cpp_lib_bitops 201907L <bit>
...@@ -46,7 +47,7 @@ __cpp_lib_bounded_array_traits 201902L <type_traits>...@@ -46,7 +47,7 @@ __cpp_lib_bounded_array_traits 201902L <type_traits>
46__cpp_lib_boyer_moore_searcher 201603L <functional>47__cpp_lib_boyer_moore_searcher 201603L <functional>
47__cpp_lib_byte 201603L <cstddef>48__cpp_lib_byte 201603L <cstddef>
48__cpp_lib_byteswap 202110L <bit>49__cpp_lib_byteswap 202110L <bit>
49__cpp_lib_char8_t 201811L <atomic> <filesystem> <istream>50__cpp_lib_char8_t 201907L <atomic> <filesystem> <istream>
50 <limits> <locale> <ostream>51 <limits> <locale> <ostream>
51 <string> <string_view>52 <string> <string_view>
52__cpp_lib_chrono 201611L <chrono>53__cpp_lib_chrono 201611L <chrono>
...@@ -55,13 +56,14 @@ __cpp_lib_clamp 201603L <algorithm>...@@ -55,13 +56,14 @@ __cpp_lib_clamp 201603L <algorithm>
55__cpp_lib_complex_udls 201309L <complex>56__cpp_lib_complex_udls 201309L <complex>
56__cpp_lib_concepts 202002L <concepts>57__cpp_lib_concepts 202002L <concepts>
57__cpp_lib_constexpr_algorithms 201806L <algorithm>58__cpp_lib_constexpr_algorithms 201806L <algorithm>
59__cpp_lib_constexpr_cmath 202202L <cmath> <cstdlib>
58__cpp_lib_constexpr_complex 201711L <complex>60__cpp_lib_constexpr_complex 201711L <complex>
59__cpp_lib_constexpr_dynamic_alloc 201907L <memory>61__cpp_lib_constexpr_dynamic_alloc 201907L <memory>
60__cpp_lib_constexpr_functional 201907L <functional>62__cpp_lib_constexpr_functional 201907L <functional>
61__cpp_lib_constexpr_iterator 201811L <iterator>63__cpp_lib_constexpr_iterator 201811L <iterator>
62__cpp_lib_constexpr_memory 201811L <memory>64__cpp_lib_constexpr_memory 201811L <memory>
63__cpp_lib_constexpr_numeric 201911L <numeric>65__cpp_lib_constexpr_numeric 201911L <numeric>
64__cpp_lib_constexpr_string 201811L <string>66__cpp_lib_constexpr_string 201907L <string>
65__cpp_lib_constexpr_string_view 201811L <string_view>67__cpp_lib_constexpr_string_view 201811L <string_view>
66__cpp_lib_constexpr_tuple 201811L <tuple>68__cpp_lib_constexpr_tuple 201811L <tuple>
67__cpp_lib_constexpr_typeinfo 202106L <typeinfo>69__cpp_lib_constexpr_typeinfo 202106L <typeinfo>
...@@ -115,7 +117,6 @@ __cpp_lib_map_try_emplace 201411L <map>...@@ -115,7 +117,6 @@ __cpp_lib_map_try_emplace 201411L <map>
115__cpp_lib_math_constants 201907L <numbers>117__cpp_lib_math_constants 201907L <numbers>
116__cpp_lib_math_special_functions 201603L <cmath>118__cpp_lib_math_special_functions 201603L <cmath>
117__cpp_lib_memory_resource 201603L <memory_resource>119__cpp_lib_memory_resource 201603L <memory_resource>
118__cpp_lib_monadic_optional 202110L <optional>
119__cpp_lib_move_only_function 202110L <functional>120__cpp_lib_move_only_function 202110L <functional>
120__cpp_lib_node_extract 201606L <map> <set> <unordered_map>121__cpp_lib_node_extract 201606L <map> <set> <unordered_map>
121 <unordered_set>122 <unordered_set>
...@@ -125,16 +126,27 @@ __cpp_lib_nonmember_container_access 201411L <array> <deque>...@@ -125,16 +126,27 @@ __cpp_lib_nonmember_container_access 201411L <array> <deque>
125 <unordered_map> <unordered_set> <vector>126 <unordered_map> <unordered_set> <vector>
126__cpp_lib_not_fn 201603L <functional>127__cpp_lib_not_fn 201603L <functional>
127__cpp_lib_null_iterators 201304L <iterator>128__cpp_lib_null_iterators 201304L <iterator>
128__cpp_lib_optional 201606L <optional>129__cpp_lib_optional 202110L <optional>
130 201606L // C++17
129__cpp_lib_out_ptr 202106L <memory>131__cpp_lib_out_ptr 202106L <memory>
130__cpp_lib_parallel_algorithm 201603L <algorithm> <numeric>132__cpp_lib_parallel_algorithm 201603L <algorithm> <numeric>
131__cpp_lib_polymorphic_allocator 201902L <memory_resource>133__cpp_lib_polymorphic_allocator 201902L <memory_resource>
132__cpp_lib_quoted_string_io 201304L <iomanip>134__cpp_lib_quoted_string_io 201304L <iomanip>
133__cpp_lib_ranges 201811L <algorithm> <functional> <iterator>135__cpp_lib_ranges 201811L <algorithm> <functional> <iterator>
134 <memory> <ranges>136 <memory> <ranges>
137__cpp_lib_ranges_chunk 202202L <ranges>
138__cpp_lib_ranges_chunk_by 202202L <ranges>
139__cpp_lib_ranges_iota 202202L <numeric>
140__cpp_lib_ranges_join_with 202202L <ranges>
141__cpp_lib_ranges_slide 202202L <ranges>
135__cpp_lib_ranges_starts_ends_with 202106L <algorithm>142__cpp_lib_ranges_starts_ends_with 202106L <algorithm>
143__cpp_lib_ranges_to_container 202202L <deque> <forward_list> <list>
144 <map> <priority_queue> <queue>
145 <set> <stack> <string>
146 <unordered_map> <unordered_set> <vector>
136__cpp_lib_ranges_zip 202110L <ranges> <tuple> <utility>147__cpp_lib_ranges_zip 202110L <ranges> <tuple> <utility>
137__cpp_lib_raw_memory_algorithms 201606L <memory>148__cpp_lib_raw_memory_algorithms 201606L <memory>
149__cpp_lib_reference_from_temporary 202202L <type_traits>
138__cpp_lib_remove_cvref 201711L <type_traits>150__cpp_lib_remove_cvref 201711L <type_traits>
139__cpp_lib_result_of_sfinae 201210L <functional> <type_traits>151__cpp_lib_result_of_sfinae 201210L <functional> <type_traits>
140__cpp_lib_robust_nonmodifying_seq_ops 201304L <algorithm>152__cpp_lib_robust_nonmodifying_seq_ops 201304L <algorithm>
...@@ -142,7 +154,8 @@ __cpp_lib_sample 201603L <algorithm>...@@ -142,7 +154,8 @@ __cpp_lib_sample 201603L <algorithm>
142__cpp_lib_scoped_lock 201703L <mutex>154__cpp_lib_scoped_lock 201703L <mutex>
143__cpp_lib_semaphore 201907L <semaphore>155__cpp_lib_semaphore 201907L <semaphore>
144__cpp_lib_shared_mutex 201505L <shared_mutex>156__cpp_lib_shared_mutex 201505L <shared_mutex>
145__cpp_lib_shared_ptr_arrays 201611L <memory>157__cpp_lib_shared_ptr_arrays 201707L <memory>
158 201611L // C++17
146__cpp_lib_shared_ptr_weak_type 201606L <memory>159__cpp_lib_shared_ptr_weak_type 201606L <memory>
147__cpp_lib_shared_timed_mutex 201402L <shared_mutex>160__cpp_lib_shared_timed_mutex 201402L <shared_mutex>
148__cpp_lib_shift 201806L <algorithm>161__cpp_lib_shift 201806L <algorithm>
...@@ -174,16 +187,18 @@ __cpp_lib_type_identity 201806L <type_traits>...@@ -174,16 +187,18 @@ __cpp_lib_type_identity 201806L <type_traits>
174__cpp_lib_type_trait_variable_templates 201510L <type_traits>187__cpp_lib_type_trait_variable_templates 201510L <type_traits>
175__cpp_lib_uncaught_exceptions 201411L <exception>188__cpp_lib_uncaught_exceptions 201411L <exception>
176__cpp_lib_unordered_map_try_emplace 201411L <unordered_map>189__cpp_lib_unordered_map_try_emplace 201411L <unordered_map>
190__cpp_lib_unreachable 202202L <utility>
177__cpp_lib_unwrap_ref 201811L <functional>191__cpp_lib_unwrap_ref 201811L <functional>
178__cpp_lib_variant 202102L <variant>192__cpp_lib_variant 202102L <variant>
179__cpp_lib_void_t 201411L <type_traits>193__cpp_lib_void_t 201411L <type_traits>
180194
181*/195*/
182196
197#include <__assert> // all public C++ headers provide the assertion handler
183#include <__config>198#include <__config>
184199
185#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)200#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
186#pragma GCC system_header201# pragma GCC system_header
187#endif202#endif
188203
189// clang-format off204// clang-format off
...@@ -222,7 +237,7 @@ __cpp_lib_void_t 201411L <type_traits>...@@ -222,7 +237,7 @@ __cpp_lib_void_t 201411L <type_traits>
222# define __cpp_lib_as_const 201510L237# define __cpp_lib_as_const 201510L
223# define __cpp_lib_atomic_is_always_lock_free 201603L238# define __cpp_lib_atomic_is_always_lock_free 201603L
224# define __cpp_lib_bool_constant 201505L239# define __cpp_lib_bool_constant 201505L
225// # define __cpp_lib_boyer_moore_searcher 201603L240# define __cpp_lib_boyer_moore_searcher 201603L
226# define __cpp_lib_byte 201603L241# define __cpp_lib_byte 201603L
227# define __cpp_lib_chrono 201611L242# define __cpp_lib_chrono 201611L
228# define __cpp_lib_clamp 201603L243# define __cpp_lib_clamp 201603L
...@@ -232,7 +247,9 @@ __cpp_lib_void_t 201411L <type_traits>...@@ -232,7 +247,9 @@ __cpp_lib_void_t 201411L <type_traits>
232# define __cpp_lib_filesystem 201703L247# define __cpp_lib_filesystem 201703L
233# endif248# endif
234# define __cpp_lib_gcd_lcm 201606L249# define __cpp_lib_gcd_lcm 201606L
235// # define __cpp_lib_hardware_interference_size 201703L250# if defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE)
251# define __cpp_lib_hardware_interference_size 201703L
252# endif
236# define __cpp_lib_has_unique_object_representations 201606L253# define __cpp_lib_has_unique_object_representations 201606L
237# define __cpp_lib_hypot 201603L254# define __cpp_lib_hypot 201603L
238# define __cpp_lib_incomplete_container_elements 201505L255# define __cpp_lib_incomplete_container_elements 201505L
...@@ -273,7 +290,7 @@ __cpp_lib_void_t 201411L <type_traits>...@@ -273,7 +290,7 @@ __cpp_lib_void_t 201411L <type_traits>
273#if _LIBCPP_STD_VER > 17290#if _LIBCPP_STD_VER > 17
274# undef __cpp_lib_array_constexpr291# undef __cpp_lib_array_constexpr
275# define __cpp_lib_array_constexpr 201811L292# define __cpp_lib_array_constexpr 201811L
276// # define __cpp_lib_assume_aligned 201811L293# define __cpp_lib_assume_aligned 201811L
277# define __cpp_lib_atomic_flag_test 201907L294# define __cpp_lib_atomic_flag_test 201907L
278// # define __cpp_lib_atomic_float 201711L295// # define __cpp_lib_atomic_float 201711L
279# define __cpp_lib_atomic_lock_free_type_aliases 201907L296# define __cpp_lib_atomic_lock_free_type_aliases 201907L
...@@ -291,7 +308,7 @@ __cpp_lib_void_t 201411L <type_traits>...@@ -291,7 +308,7 @@ __cpp_lib_void_t 201411L <type_traits>
291// # define __cpp_lib_bitops 201907L308// # define __cpp_lib_bitops 201907L
292# define __cpp_lib_bounded_array_traits 201902L309# define __cpp_lib_bounded_array_traits 201902L
293# if !defined(_LIBCPP_HAS_NO_CHAR8_T)310# if !defined(_LIBCPP_HAS_NO_CHAR8_T)
294# define __cpp_lib_char8_t 201811L311# define __cpp_lib_char8_t 201907L
295# endif312# endif
296# define __cpp_lib_concepts 202002L313# define __cpp_lib_concepts 202002L
297# define __cpp_lib_constexpr_algorithms 201806L314# define __cpp_lib_constexpr_algorithms 201806L
...@@ -301,7 +318,7 @@ __cpp_lib_void_t 201411L <type_traits>...@@ -301,7 +318,7 @@ __cpp_lib_void_t 201411L <type_traits>
301# define __cpp_lib_constexpr_iterator 201811L318# define __cpp_lib_constexpr_iterator 201811L
302# define __cpp_lib_constexpr_memory 201811L319# define __cpp_lib_constexpr_memory 201811L
303# define __cpp_lib_constexpr_numeric 201911L320# define __cpp_lib_constexpr_numeric 201911L
304# define __cpp_lib_constexpr_string 201811L321# define __cpp_lib_constexpr_string 201907L
305# define __cpp_lib_constexpr_string_view 201811L322# define __cpp_lib_constexpr_string_view 201811L
306# define __cpp_lib_constexpr_tuple 201811L323# define __cpp_lib_constexpr_tuple 201811L
307# define __cpp_lib_constexpr_utility 201811L324# define __cpp_lib_constexpr_utility 201811L
...@@ -319,9 +336,7 @@ __cpp_lib_void_t 201411L <type_traits>...@@ -319,9 +336,7 @@ __cpp_lib_void_t 201411L <type_traits>
319# endif336# endif
320# define __cpp_lib_generic_unordered_lookup 201811L337# define __cpp_lib_generic_unordered_lookup 201811L
321# define __cpp_lib_int_pow2 202002L338# define __cpp_lib_int_pow2 202002L
322# if !defined(_LIBCPP_HAS_NO_CONCEPTS)339# define __cpp_lib_integer_comparison_functions 202002L
323# define __cpp_lib_integer_comparison_functions 202002L
324# endif
325# define __cpp_lib_interpolate 201902L340# define __cpp_lib_interpolate 201902L
326# define __cpp_lib_is_constant_evaluated 201811L341# define __cpp_lib_is_constant_evaluated 201811L
327// # define __cpp_lib_is_layout_compatible 201907L342// # define __cpp_lib_is_layout_compatible 201907L
...@@ -334,15 +349,15 @@ __cpp_lib_void_t 201411L <type_traits>...@@ -334,15 +349,15 @@ __cpp_lib_void_t 201411L <type_traits>
334# define __cpp_lib_latch 201907L349# define __cpp_lib_latch 201907L
335# endif350# endif
336# define __cpp_lib_list_remove_return_type 201806L351# define __cpp_lib_list_remove_return_type 201806L
337# if !defined(_LIBCPP_HAS_NO_CONCEPTS)352# define __cpp_lib_math_constants 201907L
338# define __cpp_lib_math_constants 201907L
339# endif
340// # define __cpp_lib_polymorphic_allocator 201902L353// # define __cpp_lib_polymorphic_allocator 201902L
341// # define __cpp_lib_ranges 201811L354// # define __cpp_lib_ranges 201811L
342# define __cpp_lib_remove_cvref 201711L355# define __cpp_lib_remove_cvref 201711L
343# if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_semaphore)356# if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_semaphore)
344# define __cpp_lib_semaphore 201907L357# define __cpp_lib_semaphore 201907L
345# endif358# endif
359# undef __cpp_lib_shared_ptr_arrays
360# define __cpp_lib_shared_ptr_arrays 201707L
346# define __cpp_lib_shift 201806L361# define __cpp_lib_shift 201806L
347// # define __cpp_lib_smart_ptr_for_overwrite 202002L362// # define __cpp_lib_smart_ptr_for_overwrite 202002L
348// # define __cpp_lib_source_location 201907L363// # define __cpp_lib_source_location 201907L
...@@ -361,23 +376,34 @@ __cpp_lib_void_t 201411L <type_traits>...@@ -361,23 +376,34 @@ __cpp_lib_void_t 201411L <type_traits>
361376
362#if _LIBCPP_STD_VER > 20377#if _LIBCPP_STD_VER > 20
363# define __cpp_lib_adaptor_iterator_pair_constructor 202106L378# define __cpp_lib_adaptor_iterator_pair_constructor 202106L
364// # define __cpp_lib_allocate_at_least 202106L379# define __cpp_lib_allocate_at_least 202106L
365// # define __cpp_lib_associative_heterogeneous_erasure 202110L380// # define __cpp_lib_associative_heterogeneous_erasure 202110L
381// # define __cpp_lib_bind_back 202202L
366# define __cpp_lib_byteswap 202110L382# define __cpp_lib_byteswap 202110L
383// # define __cpp_lib_constexpr_cmath 202202L
367// # define __cpp_lib_constexpr_typeinfo 202106L384// # define __cpp_lib_constexpr_typeinfo 202106L
368// # define __cpp_lib_invoke_r 202106L385// # define __cpp_lib_invoke_r 202106L
369# define __cpp_lib_is_scoped_enum 202011L386# define __cpp_lib_is_scoped_enum 202011L
370# define __cpp_lib_monadic_optional 202110L
371// # define __cpp_lib_move_only_function 202110L387// # define __cpp_lib_move_only_function 202110L
388# undef __cpp_lib_optional
389# define __cpp_lib_optional 202110L
372// # define __cpp_lib_out_ptr 202106L390// # define __cpp_lib_out_ptr 202106L
391// # define __cpp_lib_ranges_chunk 202202L
392// # define __cpp_lib_ranges_chunk_by 202202L
393// # define __cpp_lib_ranges_iota 202202L
394// # define __cpp_lib_ranges_join_with 202202L
395// # define __cpp_lib_ranges_slide 202202L
373// # define __cpp_lib_ranges_starts_ends_with 202106L396// # define __cpp_lib_ranges_starts_ends_with 202106L
397// # define __cpp_lib_ranges_to_container 202202L
374// # define __cpp_lib_ranges_zip 202110L398// # define __cpp_lib_ranges_zip 202110L
399// # define __cpp_lib_reference_from_temporary 202202L
375// # define __cpp_lib_spanstream 202106L400// # define __cpp_lib_spanstream 202106L
376// # define __cpp_lib_stacktrace 202011L401// # define __cpp_lib_stacktrace 202011L
377// # define __cpp_lib_stdatomic_h 202011L402# define __cpp_lib_stdatomic_h 202011L
378# define __cpp_lib_string_contains 202011L403# define __cpp_lib_string_contains 202011L
379# define __cpp_lib_string_resize_and_overwrite 202110L404# define __cpp_lib_string_resize_and_overwrite 202110L
380# define __cpp_lib_to_underlying 202102L405# define __cpp_lib_to_underlying 202102L
406# define __cpp_lib_unreachable 202202L
381#endif407#endif
382408
383// clang-format on409// clang-format on
lib/libcxx/include/wchar.h+6-6
...@@ -10,7 +10,7 @@...@@ -10,7 +10,7 @@
10#if defined(__need_wint_t) || defined(__need_mbstate_t)10#if defined(__need_wint_t) || defined(__need_mbstate_t)
1111
12#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)12#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
13#pragma GCC system_header13# pragma GCC system_header
14#endif14#endif
1515
16#include_next <wchar.h>16#include_next <wchar.h>
...@@ -113,7 +113,7 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len,...@@ -113,7 +113,7 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len,
113#endif113#endif
114114
115#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)115#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
116#pragma GCC system_header116# pragma GCC system_header
117#endif117#endif
118118
119#ifdef __cplusplus119#ifdef __cplusplus
...@@ -176,10 +176,10 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD...@@ -176,10 +176,10 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
176176
177#if defined(__cplusplus) && (defined(_LIBCPP_MSVCRT_LIKE) || defined(__MVS__))177#if defined(__cplusplus) && (defined(_LIBCPP_MSVCRT_LIKE) || defined(__MVS__))
178extern "C" {178extern "C" {
179size_t mbsnrtowcs(wchar_t *__restrict dst, const char **__restrict src,179size_t mbsnrtowcs(wchar_t *__restrict __dst, const char **__restrict __src,
180 size_t nmc, size_t len, mbstate_t *__restrict ps);180 size_t __nmc, size_t __len, mbstate_t *__restrict __ps);
181size_t wcsnrtombs(char *__restrict dst, const wchar_t **__restrict src,181size_t wcsnrtombs(char *__restrict __dst, const wchar_t **__restrict __src,
182 size_t nwc, size_t len, mbstate_t *__restrict ps);182 size_t __nwc, size_t __len, mbstate_t *__restrict __ps);
183} // extern "C"183} // extern "C"
184#endif // __cplusplus && (_LIBCPP_MSVCRT || __MVS__)184#endif // __cplusplus && (_LIBCPP_MSVCRT || __MVS__)
185185
lib/libcxx/include/wctype.h+1-1
...@@ -51,7 +51,7 @@ wctrans_t wctrans(const char* property);...@@ -51,7 +51,7 @@ wctrans_t wctrans(const char* property);
51#endif51#endif
5252
53#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)53#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
54#pragma GCC system_header54# pragma GCC system_header
55#endif55#endif
5656
57// TODO:57// TODO:
lib/libcxx/src/algorithm.cpp+3-1
...@@ -6,10 +6,12 @@...@@ -6,10 +6,12 @@
6//6//
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9#include "algorithm"9#include <algorithm>
1010
11_LIBCPP_BEGIN_NAMESPACE_STD11_LIBCPP_BEGIN_NAMESPACE_STD
1212
13// TODO(varconst): this currently doesn't benefit `ranges::sort` because it uses `ranges::less` instead of `__less`.
14
13template void __sort<__less<char>&, char*>(char*, char*, __less<char>&);15template void __sort<__less<char>&, char*>(char*, char*, __less<char>&);
14#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS16#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
15template void __sort<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&);17template void __sort<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&);
lib/libcxx/src/any.cpp+1-1
...@@ -6,7 +6,7 @@...@@ -6,7 +6,7 @@
6//6//
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9#include "any"9#include <any>
1010
11namespace std {11namespace std {
12const char* bad_any_cast::what() const noexcept {12const char* bad_any_cast::what() const noexcept {
lib/libcxx/src/barrier.cpp+1-1
...@@ -90,7 +90,7 @@ void __destroy_barrier_algorithm_base(__barrier_algorithm_base* __barrier)...@@ -90,7 +90,7 @@ void __destroy_barrier_algorithm_base(__barrier_algorithm_base* __barrier)
90 delete __barrier;90 delete __barrier;
91}91}
9292
93#endif //!defined(_LIBCPP_HAS_NO_TREE_BARRIER)93#endif // !defined(_LIBCPP_HAS_NO_TREE_BARRIER)
9494
95_LIBCPP_END_NAMESPACE_STD95_LIBCPP_END_NAMESPACE_STD
9696
lib/libcxx/src/bind.cpp+1-1
...@@ -6,7 +6,7 @@...@@ -6,7 +6,7 @@
6//6//
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9#include "functional"9#include <functional>
1010
11_LIBCPP_BEGIN_NAMESPACE_STD11_LIBCPP_BEGIN_NAMESPACE_STD
1212
lib/libcxx/src/charconv.cpp+9-119
...@@ -6,144 +6,34 @@...@@ -6,144 +6,34 @@
6//6//
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9#include "charconv"9#include <charconv>
10#include <string.h>10#include <string.h>
1111
12#include "include/ryu/digit_table.h"
13#include "include/to_chars_floating_point.h"12#include "include/to_chars_floating_point.h"
1413
15_LIBCPP_BEGIN_NAMESPACE_STD14_LIBCPP_BEGIN_NAMESPACE_STD
1615
17namespace __itoa16#ifndef _LIBCPP_ABI_DO_NOT_EXPORT_TO_CHARS_BASE_10
18{
19
20template <typename T>
21inline _LIBCPP_INLINE_VISIBILITY char*
22append1(char* buffer, T i) noexcept
23{
24 *buffer = '0' + static_cast<char>(i);
25 return buffer + 1;
26}
27
28template <typename T>
29inline _LIBCPP_INLINE_VISIBILITY char*
30append2(char* buffer, T i) noexcept
31{
32 memcpy(buffer, &__DIGIT_TABLE[(i)*2], 2);
33 return buffer + 2;
34}
35
36template <typename T>
37inline _LIBCPP_INLINE_VISIBILITY char*
38append3(char* buffer, T i) noexcept
39{
40 return append2(append1(buffer, (i) / 100), (i) % 100);
41}
4217
43template <typename T>18namespace __itoa
44inline _LIBCPP_INLINE_VISIBILITY char*
45append4(char* buffer, T i) noexcept
46{
47 return append2(append2(buffer, (i) / 100), (i) % 100);
48}
49
50template <typename T>
51inline _LIBCPP_INLINE_VISIBILITY char*
52append2_no_zeros(char* buffer, T v) noexcept
53{
54 if (v < 10)
55 return append1(buffer, v);
56 else
57 return append2(buffer, v);
58}
59
60template <typename T>
61inline _LIBCPP_INLINE_VISIBILITY char*
62append4_no_zeros(char* buffer, T v) noexcept
63{
64 if (v < 100)
65 return append2_no_zeros(buffer, v);
66 else if (v < 1000)
67 return append3(buffer, v);
68 else
69 return append4(buffer, v);
70}
71
72template <typename T>
73inline _LIBCPP_INLINE_VISIBILITY char*
74append8_no_zeros(char* buffer, T v) noexcept
75{19{
76 if (v < 10000)
77 {
78 buffer = append4_no_zeros(buffer, v);
79 }
80 else
81 {
82 buffer = append4_no_zeros(buffer, v / 10000);
83 buffer = append4(buffer, v % 10000);
84 }
85 return buffer;
86}
8720
88char*21_LIBCPP_FUNC_VIS char*
89__u32toa(uint32_t value, char* buffer) noexcept22__u32toa(uint32_t value, char* buffer) noexcept
90{23{
91 if (value < 100000000)24 return __base_10_u32(buffer, value);
92 {
93 buffer = append8_no_zeros(buffer, value);
94 }
95 else
96 {
97 // value = aabbbbcccc in decimal
98 const uint32_t a = value / 100000000; // 1 to 42
99 value %= 100000000;
100
101 buffer = append2_no_zeros(buffer, a);
102 buffer = append4(buffer, value / 10000);
103 buffer = append4(buffer, value % 10000);
104 }
105
106 return buffer;
107}25}
10826
109char*27_LIBCPP_FUNC_VIS char*
110__u64toa(uint64_t value, char* buffer) noexcept28__u64toa(uint64_t value, char* buffer) noexcept
111{29{
112 if (value < 100000000)30 return __base_10_u64(buffer, value);
113 {
114 uint32_t v = static_cast<uint32_t>(value);
115 buffer = append8_no_zeros(buffer, v);
116 }
117 else if (value < 10000000000000000)
118 {
119 const uint32_t v0 = static_cast<uint32_t>(value / 100000000);
120 const uint32_t v1 = static_cast<uint32_t>(value % 100000000);
121
122 buffer = append8_no_zeros(buffer, v0);
123 buffer = append4(buffer, v1 / 10000);
124 buffer = append4(buffer, v1 % 10000);
125 }
126 else
127 {
128 const uint32_t a =
129 static_cast<uint32_t>(value / 10000000000000000); // 1 to 1844
130 value %= 10000000000000000;
131
132 buffer = append4_no_zeros(buffer, a);
133
134 const uint32_t v0 = static_cast<uint32_t>(value / 100000000);
135 const uint32_t v1 = static_cast<uint32_t>(value % 100000000);
136 buffer = append4(buffer, v0 / 10000);
137 buffer = append4(buffer, v0 % 10000);
138 buffer = append4(buffer, v1 / 10000);
139 buffer = append4(buffer, v1 % 10000);
140 }
141
142 return buffer;
143}31}
14432
145} // namespace __itoa33} // namespace __itoa
14634
35#endif // _LIBCPP_ABI_DO_NOT_EXPORT_TO_CHARS_BASE_10
36
147// The original version of floating-point to_chars was written by Microsoft and37// The original version of floating-point to_chars was written by Microsoft and
148// contributed with the following license.38// contributed with the following license.
14939
lib/libcxx/src/chrono.cpp+3-3
...@@ -12,9 +12,9 @@...@@ -12,9 +12,9 @@
12#define _LARGE_TIME_API12#define _LARGE_TIME_API
13#endif13#endif
1414
15#include "chrono"15#include <cerrno> // errno
16#include "cerrno" // errno16#include <chrono>
17#include "system_error" // __throw_system_error17#include <system_error> // __throw_system_error
1818
19#if defined(__MVS__)19#if defined(__MVS__)
20#include <__support/ibm/gettod_zos.h> // gettimeofdayMonotonic20#include <__support/ibm/gettod_zos.h> // gettimeofdayMonotonic
lib/libcxx/src/condition_variable.cpp+10-6
...@@ -6,19 +6,21 @@...@@ -6,19 +6,21 @@
6//6//
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9#include "__config"9#include <__config>
1010
11#ifndef _LIBCPP_HAS_NO_THREADS11#ifndef _LIBCPP_HAS_NO_THREADS
1212
13#include "condition_variable"13#include <condition_variable>
14#include "thread"14#include <thread>
15#include "system_error"15#include <system_error>
16#include "__undef_macros"
1716
18#if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB)17#if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB)
19#pragma comment(lib, "pthread")18# pragma comment(lib, "pthread")
20#endif19#endif
2120
21_LIBCPP_PUSH_MACROS
22#include <__undef_macros>
23
22_LIBCPP_BEGIN_NAMESPACE_STD24_LIBCPP_BEGIN_NAMESPACE_STD
2325
24// ~condition_variable is defined elsewhere.26// ~condition_variable is defined elsewhere.
...@@ -90,4 +92,6 @@ notify_all_at_thread_exit(condition_variable& cond, unique_lock<mutex> lk)...@@ -90,4 +92,6 @@ notify_all_at_thread_exit(condition_variable& cond, unique_lock<mutex> lk)
9092
91_LIBCPP_END_NAMESPACE_STD93_LIBCPP_END_NAMESPACE_STD
9294
95_LIBCPP_POP_MACROS
96
93#endif // !_LIBCPP_HAS_NO_THREADS97#endif // !_LIBCPP_HAS_NO_THREADS
lib/libcxx/src/condition_variable_destructor.cpp+2-2
...@@ -11,8 +11,8 @@...@@ -11,8 +11,8 @@
11// On some platforms ~condition_variable has been made trivial and the11// On some platforms ~condition_variable has been made trivial and the
12// definition is only provided for ABI compatibility.12// definition is only provided for ABI compatibility.
1313
14#include "__config"14#include <__config>
15#include "__threading_support"15#include <__threading_support>
1616
17#if !defined(_LIBCPP_HAS_NO_THREADS)17#if !defined(_LIBCPP_HAS_NO_THREADS)
18# if _LIBCPP_ABI_VERSION == 1 || !defined(_LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION)18# if _LIBCPP_ABI_VERSION == 1 || !defined(_LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION)
lib/libcxx/src/debug.cpp+13-32
...@@ -6,43 +6,24 @@...@@ -6,43 +6,24 @@
6//6//
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9#include "__config"9#include <__assert>
10#include "__debug"10#include <__config>
11#include "functional"11#include <__debug>
12#include "algorithm"12#include <__hash_table>
13#include "string"13#include <algorithm>
14#include "cstdio"14#include <cstdio>
15#include "__hash_table"15#include <functional>
16#include <string>
17
16#ifndef _LIBCPP_HAS_NO_THREADS18#ifndef _LIBCPP_HAS_NO_THREADS
17#include "mutex"19# include <mutex>
18#if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB)20# if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB)
19#pragma comment(lib, "pthread")21# pragma comment(lib, "pthread")
20#endif22# endif
21#endif23#endif
2224
23_LIBCPP_BEGIN_NAMESPACE_STD25_LIBCPP_BEGIN_NAMESPACE_STD
2426
25std::string __libcpp_debug_info::what() const {
26 string msg = __file_;
27 msg += ":" + to_string(__line_) + ": _LIBCPP_ASSERT '";
28 msg += __pred_;
29 msg += "' failed. ";
30 msg += __msg_;
31 return msg;
32}
33_LIBCPP_NORETURN void __libcpp_abort_debug_function(__libcpp_debug_info const& info) {
34 std::fprintf(stderr, "%s\n", info.what().c_str());
35 std::abort();
36}
37
38_LIBCPP_SAFE_STATIC __libcpp_debug_function_type
39 __libcpp_debug_function = __libcpp_abort_debug_function;
40
41bool __libcpp_set_debug_function(__libcpp_debug_function_type __func) {
42 __libcpp_debug_function = __func;
43 return true;
44}
45
46_LIBCPP_FUNC_VIS27_LIBCPP_FUNC_VIS
47__libcpp_db*28__libcpp_db*
48__get_db()29__get_db()
lib/libcxx/src/exception.cpp+3-3
...@@ -6,9 +6,9 @@...@@ -6,9 +6,9 @@
6//6//
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9#include "exception"9#include <exception>
10#include "new"10#include <new>
11#include "typeinfo"11#include <typeinfo>
1212
13#if defined(LIBCXXRT) || defined(LIBCXX_BUILDING_LIBCXXABI)13#if defined(LIBCXXRT) || defined(LIBCXX_BUILDING_LIBCXXABI)
14 #include <cxxabi.h>14 #include <cxxabi.h>
lib/libcxx/src/experimental/memory_resource.cpp+9-9
...@@ -6,15 +6,15 @@...@@ -6,15 +6,15 @@
6//6//
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9#include "experimental/memory_resource"9#include <experimental/memory_resource>
1010
11#ifndef _LIBCPP_HAS_NO_ATOMIC_HEADER11#ifndef _LIBCPP_HAS_NO_ATOMIC_HEADER
12#include "atomic"12# include <atomic>
13#elif !defined(_LIBCPP_HAS_NO_THREADS)13#elif !defined(_LIBCPP_HAS_NO_THREADS)
14#include "mutex"14# include <mutex>
15#if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB)15# if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB)
16#pragma comment(lib, "pthread")16# pragma comment(lib, "pthread")
17#endif17# endif
18#endif18#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR20_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
...@@ -97,7 +97,7 @@ static memory_resource *...@@ -97,7 +97,7 @@ static memory_resource *
97__default_memory_resource(bool set = false, memory_resource * new_res = nullptr) noexcept97__default_memory_resource(bool set = false, memory_resource * new_res = nullptr) noexcept
98{98{
99#ifndef _LIBCPP_HAS_NO_ATOMIC_HEADER99#ifndef _LIBCPP_HAS_NO_ATOMIC_HEADER
100 _LIBCPP_SAFE_STATIC static atomic<memory_resource*> __res{&res_init.resources.new_delete_res};100 static constinit atomic<memory_resource*> __res{&res_init.resources.new_delete_res};
101 if (set) {101 if (set) {
102 new_res = new_res ? new_res : new_delete_resource();102 new_res = new_res ? new_res : new_delete_resource();
103 // TODO: Can a weaker ordering be used?103 // TODO: Can a weaker ordering be used?
...@@ -109,7 +109,7 @@ __default_memory_resource(bool set = false, memory_resource * new_res = nullptr)...@@ -109,7 +109,7 @@ __default_memory_resource(bool set = false, memory_resource * new_res = nullptr)
109 &__res, memory_order_acquire);109 &__res, memory_order_acquire);
110 }110 }
111#elif !defined(_LIBCPP_HAS_NO_THREADS)111#elif !defined(_LIBCPP_HAS_NO_THREADS)
112 _LIBCPP_SAFE_STATIC static memory_resource * res = &res_init.resources.new_delete_res;112 static constinit memory_resource *res = &res_init.resources.new_delete_res;
113 static mutex res_lock;113 static mutex res_lock;
114 if (set) {114 if (set) {
115 new_res = new_res ? new_res : new_delete_resource();115 new_res = new_res ? new_res : new_delete_resource();
...@@ -122,7 +122,7 @@ __default_memory_resource(bool set = false, memory_resource * new_res = nullptr)...@@ -122,7 +122,7 @@ __default_memory_resource(bool set = false, memory_resource * new_res = nullptr)
122 return res;122 return res;
123 }123 }
124#else124#else
125 _LIBCPP_SAFE_STATIC static memory_resource* res = &res_init.resources.new_delete_res;125 static constinit memory_resource *res = &res_init.resources.new_delete_res;
126 if (set) {126 if (set) {
127 new_res = new_res ? new_res : new_delete_resource();127 new_res = new_res ? new_res : new_delete_resource();
128 memory_resource * old_res = res;128 memory_resource * old_res = res;
lib/libcxx/src/experimental/memory_resource_init_helper.h+1-1
...@@ -1,2 +1,2 @@...@@ -1,2 +1,2 @@
1#pragma GCC system_header1#pragma GCC system_header
2_LIBCPP_SAFE_STATIC ResourceInitHelper res_init _LIBCPP_INIT_PRIORITY_MAX;2static constinit ResourceInitHelper res_init _LIBCPP_INIT_PRIORITY_MAX;
lib/libcxx/src/filesystem/directory_iterator.cpp+13-12
...@@ -6,10 +6,11 @@...@@ -6,10 +6,11 @@
6//6//
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9#include "__config"9#include <__assert>
10#include "filesystem"10#include <__config>
11#include "stack"
12#include <errno.h>11#include <errno.h>
12#include <filesystem>
13#include <stack>
1314
14#include "filesystem_common.h"15#include "filesystem_common.h"
1516
...@@ -24,8 +25,8 @@ public:...@@ -24,8 +25,8 @@ public:
24 __dir_stream& operator=(const __dir_stream&) = delete;25 __dir_stream& operator=(const __dir_stream&) = delete;
2526
26 __dir_stream(__dir_stream&& __ds) noexcept : __stream_(__ds.__stream_),27 __dir_stream(__dir_stream&& __ds) noexcept : __stream_(__ds.__stream_),
27 __root_(move(__ds.__root_)),28 __root_(std::move(__ds.__root_)),
28 __entry_(move(__ds.__entry_)) {29 __entry_(std::move(__ds.__entry_)) {
29 __ds.__stream_ = INVALID_HANDLE_VALUE;30 __ds.__stream_ = INVALID_HANDLE_VALUE;
30 }31 }
3132
...@@ -103,8 +104,8 @@ public:...@@ -103,8 +104,8 @@ public:
103 __dir_stream& operator=(const __dir_stream&) = delete;104 __dir_stream& operator=(const __dir_stream&) = delete;
104105
105 __dir_stream(__dir_stream&& other) noexcept : __stream_(other.__stream_),106 __dir_stream(__dir_stream&& other) noexcept : __stream_(other.__stream_),
106 __root_(move(other.__root_)),107 __root_(std::move(other.__root_)),
107 __entry_(move(other.__entry_)) {108 __entry_(std::move(other.__entry_)) {
108 other.__stream_ = nullptr;109 other.__stream_ = nullptr;
109 }110 }
110111
...@@ -186,7 +187,7 @@ directory_iterator& directory_iterator::__increment(error_code* ec) {...@@ -186,7 +187,7 @@ directory_iterator& directory_iterator::__increment(error_code* ec) {
186187
187 error_code m_ec;188 error_code m_ec;
188 if (!__imp_->advance(m_ec)) {189 if (!__imp_->advance(m_ec)) {
189 path root = move(__imp_->__root_);190 path root = std::move(__imp_->__root_);
190 __imp_.reset();191 __imp_.reset();
191 if (m_ec)192 if (m_ec)
192 err.report(m_ec, "at root " PATH_CSTR_FMT, root.c_str());193 err.report(m_ec, "at root " PATH_CSTR_FMT, root.c_str());
...@@ -220,7 +221,7 @@ recursive_directory_iterator::recursive_directory_iterator(...@@ -220,7 +221,7 @@ recursive_directory_iterator::recursive_directory_iterator(
220221
221 __imp_ = make_shared<__shared_imp>();222 __imp_ = make_shared<__shared_imp>();
222 __imp_->__options_ = opt;223 __imp_->__options_ = opt;
223 __imp_->__stack_.push(move(new_s));224 __imp_->__stack_.push(std::move(new_s));
224}225}
225226
226void recursive_directory_iterator::__pop(error_code* ec) {227void recursive_directory_iterator::__pop(error_code* ec) {
...@@ -274,7 +275,7 @@ void recursive_directory_iterator::__advance(error_code* ec) {...@@ -274,7 +275,7 @@ void recursive_directory_iterator::__advance(error_code* ec) {
274 }275 }
275276
276 if (m_ec) {277 if (m_ec) {
277 path root = move(stack.top().__root_);278 path root = std::move(stack.top().__root_);
278 __imp_.reset();279 __imp_.reset();
279 err.report(m_ec, "at root " PATH_CSTR_FMT, root.c_str());280 err.report(m_ec, "at root " PATH_CSTR_FMT, root.c_str());
280 } else {281 } else {
...@@ -308,7 +309,7 @@ bool recursive_directory_iterator::__try_recursion(error_code* ec) {...@@ -308,7 +309,7 @@ bool recursive_directory_iterator::__try_recursion(error_code* ec) {
308 if (!skip_rec) {309 if (!skip_rec) {
309 __dir_stream new_it(curr_it.__entry_.path(), __imp_->__options_, m_ec);310 __dir_stream new_it(curr_it.__entry_.path(), __imp_->__options_, m_ec);
310 if (new_it.good()) {311 if (new_it.good()) {
311 __imp_->__stack_.push(move(new_it));312 __imp_->__stack_.push(std::move(new_it));
312 return true;313 return true;
313 }314 }
314 }315 }
...@@ -319,7 +320,7 @@ bool recursive_directory_iterator::__try_recursion(error_code* ec) {...@@ -319,7 +320,7 @@ bool recursive_directory_iterator::__try_recursion(error_code* ec) {
319 if (ec)320 if (ec)
320 ec->clear();321 ec->clear();
321 } else {322 } else {
322 path at_ent = move(curr_it.__entry_.__p_);323 path at_ent = std::move(curr_it.__entry_.__p_);
323 __imp_.reset();324 __imp_.reset();
324 err.report(m_ec, "attempting recursion into " PATH_CSTR_FMT,325 err.report(m_ec, "attempting recursion into " PATH_CSTR_FMT,
325 at_ent.c_str());326 at_ent.c_str());
lib/libcxx/src/filesystem/filesystem_common.h+25-25
...@@ -9,31 +9,30 @@...@@ -9,31 +9,30 @@
9#ifndef FILESYSTEM_COMMON_H9#ifndef FILESYSTEM_COMMON_H
10#define FILESYSTEM_COMMON_H10#define FILESYSTEM_COMMON_H
1111
12#include "__config"12#include <__assert>
13#include "array"13#include <__config>
14#include "chrono"14#include <array>
15#include "climits"15#include <chrono>
16#include "cstdarg"16#include <climits>
17#include "cstdlib"17#include <cstdarg>
18#include "ctime"18#include <ctime>
19#include "filesystem"19#include <filesystem>
20#include "ratio"20#include <ratio>
21#include "system_error"21#include <system_error>
22#include <utility>
2223
23#if defined(_LIBCPP_WIN32API)24#if defined(_LIBCPP_WIN32API)
24# define WIN32_LEAN_AND_MEAN25# define WIN32_LEAN_AND_MEAN
25# define NOMINMAX26# define NOMINMAX
26# include <windows.h>27# include <windows.h>
27#endif28#else
28
29#if !defined(_LIBCPP_WIN32API)
30# include <dirent.h> // for DIR & friends29# include <dirent.h> // for DIR & friends
31# include <fcntl.h> /* values for fchmodat */30# include <fcntl.h> /* values for fchmodat */
32# include <sys/stat.h>31# include <sys/stat.h>
33# include <sys/statvfs.h>32# include <sys/statvfs.h>
34# include <sys/time.h> // for ::utimes as used in __last_write_time33# include <sys/time.h> // for ::utimes as used in __last_write_time
35# include <unistd.h>34# include <unistd.h>
36#endif35#endif // defined(_LIBCPP_WIN32API)
3736
38#include "../include/apple_availability.h"37#include "../include/apple_availability.h"
3938
...@@ -45,17 +44,16 @@...@@ -45,17 +44,16 @@
45#endif44#endif
46#endif45#endif
4746
48#if defined(__GNUC__) || defined(__clang__)47_LIBCPP_DIAGNOSTIC_PUSH
49#pragma GCC diagnostic push48_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wunused-function")
50#pragma GCC diagnostic ignored "-Wunused-function"49_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wunused-function")
51#endif
5250
53#if defined(_LIBCPP_WIN32API)51#if defined(_LIBCPP_WIN32API)
54#define PS(x) (L##x)52# define PATHSTR(x) (L##x)
55#define PATH_CSTR_FMT "\"%ls\""53# define PATH_CSTR_FMT "\"%ls\""
56#else54#else
57#define PS(x) (x)55# define PATHSTR(x) (x)
58#define PATH_CSTR_FMT "\"%s\""56# define PATH_CSTR_FMT "\"%s\""
59#endif57#endif
6058
61_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM59_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
...@@ -113,7 +111,7 @@ format_string(const char* msg, ...) {...@@ -113,7 +111,7 @@ format_string(const char* msg, ...) {
113}111}
114112
115error_code capture_errno() {113error_code capture_errno() {
116 _LIBCPP_ASSERT(errno, "Expected errno to be non-zero");114 _LIBCPP_ASSERT(errno != 0, "Expected errno to be non-zero");
117 return error_code(errno, generic_category());115 return error_code(errno, generic_category());
118}116}
119117
...@@ -178,7 +176,7 @@ struct ErrorHandler {...@@ -178,7 +176,7 @@ struct ErrorHandler {
178 case 2:176 case 2:
179 __throw_filesystem_error(what, *p1_, *p2_, ec);177 __throw_filesystem_error(what, *p1_, *p2_, ec);
180 }178 }
181 _LIBCPP_UNREACHABLE();179 __libcpp_unreachable();
182 }180 }
183181
184 _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 3, 0)182 _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 3, 0)
...@@ -197,7 +195,7 @@ struct ErrorHandler {...@@ -197,7 +195,7 @@ struct ErrorHandler {
197 case 2:195 case 2:
198 __throw_filesystem_error(what, *p1_, *p2_, ec);196 __throw_filesystem_error(what, *p1_, *p2_, ec);
199 }197 }
200 _LIBCPP_UNREACHABLE();198 __libcpp_unreachable();
201 }199 }
202200
203 _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 3, 4)201 _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 3, 4)
...@@ -610,4 +608,6 @@ static file_time_type get_write_time(const WIN32_FIND_DATAW& data) {...@@ -610,4 +608,6 @@ static file_time_type get_write_time(const WIN32_FIND_DATAW& data) {
610608
611_LIBCPP_END_NAMESPACE_FILESYSTEM609_LIBCPP_END_NAMESPACE_FILESYSTEM
612610
611_LIBCPP_DIAGNOSTIC_POP
612
613#endif // FILESYSTEM_COMMON_H613#endif // FILESYSTEM_COMMON_H
lib/libcxx/src/filesystem/int128_builtins.cpp+2-2
...@@ -13,8 +13,8 @@...@@ -13,8 +13,8 @@
13 *13 *
14 * ===----------------------------------------------------------------------===14 * ===----------------------------------------------------------------------===
15 */15 */
16#include "__config"16#include <__config>
17#include "climits"17#include <climits>
1818
19#if !defined(_LIBCPP_HAS_NO_INT128)19#if !defined(_LIBCPP_HAS_NO_INT128)
2020
lib/libcxx/src/filesystem/operations.cpp+40-38
...@@ -6,14 +6,16 @@...@@ -6,14 +6,16 @@
6//6//
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9#include "filesystem"9#include <__assert>
10#include "array"10#include <__utility/unreachable.h>
11#include "iterator"11#include <array>
12#include "string_view"12#include <climits>
13#include "type_traits"13#include <cstdlib>
14#include "vector"14#include <filesystem>
15#include "cstdlib"15#include <iterator>
16#include "climits"16#include <string_view>
17#include <type_traits>
18#include <vector>
1719
18#include "filesystem_common.h"20#include "filesystem_common.h"
1921
...@@ -39,7 +41,7 @@...@@ -39,7 +41,7 @@
39# include <copyfile.h>41# include <copyfile.h>
40# define _LIBCPP_FILESYSTEM_USE_COPYFILE42# define _LIBCPP_FILESYSTEM_USE_COPYFILE
41#else43#else
42# include "fstream"44# include <fstream>
43# define _LIBCPP_FILESYSTEM_USE_FSTREAM45# define _LIBCPP_FILESYSTEM_USE_FSTREAM
44#endif46#endif
4547
...@@ -154,7 +156,7 @@ public:...@@ -154,7 +156,7 @@ public:
154 return makeState(PS_AtEnd);156 return makeState(PS_AtEnd);
155157
156 case PS_AtEnd:158 case PS_AtEnd:
157 _LIBCPP_UNREACHABLE();159 __libcpp_unreachable();
158 }160 }
159 }161 }
160162
...@@ -202,7 +204,7 @@ public:...@@ -202,7 +204,7 @@ public:
202 return makeState(PS_InRootName, Path.data(), RStart + 1);204 return makeState(PS_InRootName, Path.data(), RStart + 1);
203 case PS_InRootName:205 case PS_InRootName:
204 case PS_BeforeBegin:206 case PS_BeforeBegin:
205 _LIBCPP_UNREACHABLE();207 __libcpp_unreachable();
206 }208 }
207 }209 }
208210
...@@ -212,19 +214,19 @@ public:...@@ -212,19 +214,19 @@ public:
212 switch (State) {214 switch (State) {
213 case PS_BeforeBegin:215 case PS_BeforeBegin:
214 case PS_AtEnd:216 case PS_AtEnd:
215 return PS("");217 return PATHSTR("");
216 case PS_InRootDir:218 case PS_InRootDir:
217 if (RawEntry[0] == '\\')219 if (RawEntry[0] == '\\')
218 return PS("\\");220 return PATHSTR("\\");
219 else221 else
220 return PS("/");222 return PATHSTR("/");
221 case PS_InTrailingSep:223 case PS_InTrailingSep:
222 return PS("");224 return PATHSTR("");
223 case PS_InRootName:225 case PS_InRootName:
224 case PS_InFilenames:226 case PS_InFilenames:
225 return RawEntry;227 return RawEntry;
226 }228 }
227 _LIBCPP_UNREACHABLE();229 __libcpp_unreachable();
228 }230 }
229231
230 explicit operator bool() const noexcept {232 explicit operator bool() const noexcept {
...@@ -285,7 +287,7 @@ private:...@@ -285,7 +287,7 @@ private:
285 case PS_AtEnd:287 case PS_AtEnd:
286 return getAfterBack();288 return getAfterBack();
287 }289 }
288 _LIBCPP_UNREACHABLE();290 __libcpp_unreachable();
289 }291 }
290292
291 /// \brief Return a pointer to the first character in the currently lexed293 /// \brief Return a pointer to the first character in the currently lexed
...@@ -302,7 +304,7 @@ private:...@@ -302,7 +304,7 @@ private:
302 case PS_AtEnd:304 case PS_AtEnd:
303 return &Path.back() + 1;305 return &Path.back() + 1;
304 }306 }
305 _LIBCPP_UNREACHABLE();307 __libcpp_unreachable();
306 }308 }
307309
308 // Consume all consecutive separators.310 // Consume all consecutive separators.
...@@ -385,8 +387,8 @@ private:...@@ -385,8 +387,8 @@ private:
385};387};
386388
387string_view_pair separate_filename(string_view_t const& s) {389string_view_pair separate_filename(string_view_t const& s) {
388 if (s == PS(".") || s == PS("..") || s.empty())390 if (s == PATHSTR(".") || s == PATHSTR("..") || s.empty())
389 return string_view_pair{s, PS("")};391 return string_view_pair{s, PATHSTR("")};
390 auto pos = s.find_last_of('.');392 auto pos = s.find_last_of('.');
391 if (pos == string_view_t::npos || pos == 0)393 if (pos == string_view_t::npos || pos == 0)
392 return string_view_pair{s, string_view_t{}};394 return string_view_pair{s, string_view_t{}};
...@@ -681,7 +683,7 @@ void filesystem_error::__create_what(int __num_paths) {...@@ -681,7 +683,7 @@ void filesystem_error::__create_what(int __num_paths) {
681 return detail::format_string("filesystem error: %s [" PATH_CSTR_FMT "] [" PATH_CSTR_FMT "]",683 return detail::format_string("filesystem error: %s [" PATH_CSTR_FMT "] [" PATH_CSTR_FMT "]",
682 derived_what, path1().c_str(), path2().c_str());684 derived_what, path1().c_str(), path2().c_str());
683 }685 }
684 _LIBCPP_UNREACHABLE();686 __libcpp_unreachable();
685 }();687 }();
686}688}
687689
...@@ -1188,7 +1190,7 @@ bool __fs_is_empty(const path& p, error_code* ec) {...@@ -1188,7 +1190,7 @@ bool __fs_is_empty(const path& p, error_code* ec) {
1188 } else if (is_regular_file(st))1190 } else if (is_regular_file(st))
1189 return static_cast<uintmax_t>(pst.st_size) == 0;1191 return static_cast<uintmax_t>(pst.st_size) == 0;
11901192
1191 _LIBCPP_UNREACHABLE();1193 __libcpp_unreachable();
1192}1194}
11931195
1194static file_time_type __extract_last_write_time(const path& p, const StatT& st,1196static file_time_type __extract_last_write_time(const path& p, const StatT& st,
...@@ -1614,7 +1616,7 @@ path& path::replace_extension(path const& replacement) {...@@ -1614,7 +1616,7 @@ path& path::replace_extension(path const& replacement) {
1614 }1616 }
1615 if (!replacement.empty()) {1617 if (!replacement.empty()) {
1616 if (replacement.native()[0] != '.') {1618 if (replacement.native()[0] != '.') {
1617 __pn_ += PS(".");1619 __pn_ += PATHSTR(".");
1618 }1620 }
1619 __pn_.append(replacement.__pn_);1621 __pn_.append(replacement.__pn_);
1620 }1622 }
...@@ -1736,14 +1738,14 @@ enum PathPartKind : unsigned char {...@@ -1736,14 +1738,14 @@ enum PathPartKind : unsigned char {
1736static PathPartKind ClassifyPathPart(string_view_t Part) {1738static PathPartKind ClassifyPathPart(string_view_t Part) {
1737 if (Part.empty())1739 if (Part.empty())
1738 return PK_TrailingSep;1740 return PK_TrailingSep;
1739 if (Part == PS("."))1741 if (Part == PATHSTR("."))
1740 return PK_Dot;1742 return PK_Dot;
1741 if (Part == PS(".."))1743 if (Part == PATHSTR(".."))
1742 return PK_DotDot;1744 return PK_DotDot;
1743 if (Part == PS("/"))1745 if (Part == PATHSTR("/"))
1744 return PK_RootSep;1746 return PK_RootSep;
1745#if defined(_LIBCPP_WIN32API)1747#if defined(_LIBCPP_WIN32API)
1746 if (Part == PS("\\"))1748 if (Part == PATHSTR("\\"))
1747 return PK_RootSep;1749 return PK_RootSep;
1748#endif1750#endif
1749 return PK_Filename;1751 return PK_Filename;
...@@ -1793,7 +1795,7 @@ path path::lexically_normal() const {...@@ -1793,7 +1795,7 @@ path path::lexically_normal() const {
1793 NewPathSize -= Parts.back().first.size();1795 NewPathSize -= Parts.back().first.size();
1794 Parts.pop_back();1796 Parts.pop_back();
1795 } else if (LastKind != PK_RootSep)1797 } else if (LastKind != PK_RootSep)
1796 AddPart(PK_DotDot, PS(".."));1798 AddPart(PK_DotDot, PATHSTR(".."));
1797 MaybeNeedTrailingSep = LastKind == PK_Filename;1799 MaybeNeedTrailingSep = LastKind == PK_Filename;
1798 break;1800 break;
1799 }1801 }
...@@ -1803,12 +1805,12 @@ path path::lexically_normal() const {...@@ -1803,12 +1805,12 @@ path path::lexically_normal() const {
1803 break;1805 break;
1804 }1806 }
1805 case PK_None:1807 case PK_None:
1806 _LIBCPP_UNREACHABLE();1808 __libcpp_unreachable();
1807 }1809 }
1808 }1810 }
1809 // [fs.path.generic]p6.8: If the path is empty, add a dot.1811 // [fs.path.generic]p6.8: If the path is empty, add a dot.
1810 if (Parts.empty())1812 if (Parts.empty())
1811 return PS(".");1813 return PATHSTR(".");
18121814
1813 // [fs.path.generic]p6.7: If the last filename is dot-dot, remove any1815 // [fs.path.generic]p6.7: If the last filename is dot-dot, remove any
1814 // trailing directory-separator.1816 // trailing directory-separator.
...@@ -1820,7 +1822,7 @@ path path::lexically_normal() const {...@@ -1820,7 +1822,7 @@ path path::lexically_normal() const {
1820 Result /= PK.first;1822 Result /= PK.first;
18211823
1822 if (NeedTrailingSep)1824 if (NeedTrailingSep)
1823 Result /= PS("");1825 Result /= PATHSTR("");
18241826
1825 Result.make_preferred();1827 Result.make_preferred();
1826 return Result;1828 return Result;
...@@ -1830,9 +1832,9 @@ static int DetermineLexicalElementCount(PathParser PP) {...@@ -1830,9 +1832,9 @@ static int DetermineLexicalElementCount(PathParser PP) {
1830 int Count = 0;1832 int Count = 0;
1831 for (; PP; ++PP) {1833 for (; PP; ++PP) {
1832 auto Elem = *PP;1834 auto Elem = *PP;
1833 if (Elem == PS(".."))1835 if (Elem == PATHSTR(".."))
1834 --Count;1836 --Count;
1835 else if (Elem != PS(".") && Elem != PS(""))1837 else if (Elem != PATHSTR(".") && Elem != PATHSTR(""))
1836 ++Count;1838 ++Count;
1837 }1839 }
1838 return Count;1840 return Count;
...@@ -1879,15 +1881,15 @@ path path::lexically_relative(const path& base) const {...@@ -1879,15 +1881,15 @@ path path::lexically_relative(const path& base) const {
1879 return {};1881 return {};
18801882
1881 // if n == 0 and (a == end() || a->empty()), returns path("."); otherwise1883 // if n == 0 and (a == end() || a->empty()), returns path("."); otherwise
1882 if (ElemCount == 0 && (PP.atEnd() || *PP == PS("")))1884 if (ElemCount == 0 && (PP.atEnd() || *PP == PATHSTR("")))
1883 return PS(".");1885 return PATHSTR(".");
18841886
1885 // return a path constructed with 'n' dot-dot elements, followed by the the1887 // return a path constructed with 'n' dot-dot elements, followed by the
1886 // elements of '*this' after the mismatch.1888 // elements of '*this' after the mismatch.
1887 path Result;1889 path Result;
1888 // FIXME: Reserve enough room in Result that it won't have to re-allocate.1890 // FIXME: Reserve enough room in Result that it won't have to re-allocate.
1889 while (ElemCount--)1891 while (ElemCount--)
1890 Result /= PS("..");1892 Result /= PATHSTR("..");
1891 for (; PP; ++PP)1893 for (; PP; ++PP)
1892 Result /= *PP;1894 Result /= *PP;
1893 return Result;1895 return Result;
...@@ -1900,7 +1902,7 @@ static int CompareRootName(PathParser *LHS, PathParser *RHS) {...@@ -1900,7 +1902,7 @@ static int CompareRootName(PathParser *LHS, PathParser *RHS) {
1900 return 0;1902 return 0;
19011903
1902 auto GetRootName = [](PathParser *Parser) -> string_view_t {1904 auto GetRootName = [](PathParser *Parser) -> string_view_t {
1903 return Parser->inRootName() ? **Parser : PS("");1905 return Parser->inRootName() ? **Parser : PATHSTR("");
1904 };1906 };
1905 int res = GetRootName(LHS).compare(GetRootName(RHS));1907 int res = GetRootName(LHS).compare(GetRootName(RHS));
1906 ConsumeRootName(LHS);1908 ConsumeRootName(LHS);
lib/libcxx/src/filesystem/posix_compat.h+2-1
...@@ -23,7 +23,8 @@...@@ -23,7 +23,8 @@
23#ifndef POSIX_COMPAT_H23#ifndef POSIX_COMPAT_H
24#define POSIX_COMPAT_H24#define POSIX_COMPAT_H
2525
26#include "filesystem"26#include <__assert>
27#include <filesystem>
2728
28#include "filesystem_common.h"29#include "filesystem_common.h"
2930
lib/libcxx/src/format.cpp+1-1
...@@ -6,7 +6,7 @@...@@ -6,7 +6,7 @@
6//6//
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9#include "format"9#include <format>
1010
11_LIBCPP_BEGIN_NAMESPACE_STD11_LIBCPP_BEGIN_NAMESPACE_STD
1212
lib/libcxx/src/functional.cpp+1-1
...@@ -6,7 +6,7 @@...@@ -6,7 +6,7 @@
6//6//
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9#include "functional"9#include <functional>
1010
11_LIBCPP_BEGIN_NAMESPACE_STD11_LIBCPP_BEGIN_NAMESPACE_STD
1212
lib/libcxx/src/future.cpp+7-15
...@@ -6,12 +6,12 @@...@@ -6,12 +6,12 @@
6//6//
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9#include "__config"9#include <__config>
1010
11#ifndef _LIBCPP_HAS_NO_THREADS11#ifndef _LIBCPP_HAS_NO_THREADS
1212
13#include "future"13#include <future>
14#include "string"14#include <string>
1515
16_LIBCPP_BEGIN_NAMESPACE_STD16_LIBCPP_BEGIN_NAMESPACE_STD
1717
...@@ -29,13 +29,9 @@ __future_error_category::name() const noexcept...@@ -29,13 +29,9 @@ __future_error_category::name() const noexcept
29 return "future";29 return "future";
30}30}
3131
32#if defined(__clang__)32_LIBCPP_DIAGNOSTIC_PUSH
33#pragma clang diagnostic push33_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wswitch")
34#pragma clang diagnostic ignored "-Wswitch"34_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wswitch")
35#elif defined(__GNUC__) || defined(__GNUG__)
36#pragma GCC diagnostic push
37#pragma GCC diagnostic ignored "-Wswitch"
38#endif
3935
40string36string
41__future_error_category::message(int ev) const37__future_error_category::message(int ev) const
...@@ -58,11 +54,7 @@ __future_error_category::message(int ev) const...@@ -58,11 +54,7 @@ __future_error_category::message(int ev) const
58 return string("unspecified future_errc value\n");54 return string("unspecified future_errc value\n");
59}55}
6056
61#if defined(__clang__)57_LIBCPP_DIAGNOSTIC_POP
62#pragma clang diagnostic pop
63#elif defined(__GNUC__) || defined(__GNUG__)
64#pragma GCC diagnostic pop
65#endif
6658
67const error_category&59const error_category&
68future_category() noexcept60future_category() noexcept
lib/libcxx/src/hash.cpp+6-8
...@@ -6,14 +6,12 @@...@@ -6,14 +6,12 @@
6//6//
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9#include "__hash_table"9#include <__hash_table>
10#include "algorithm"10#include <algorithm>
11#include "stdexcept"11#include <stdexcept>
12#include "type_traits"12#include <type_traits>
1313
14#ifdef __clang__14_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wtautological-constant-out-of-range-compare")
15#pragma clang diagnostic ignored "-Wtautological-constant-out-of-range-compare"
16#endif
1715
18_LIBCPP_BEGIN_NAMESPACE_STD16_LIBCPP_BEGIN_NAMESPACE_STD
1917
lib/libcxx/src/include/atomic_support.h+2-2
...@@ -9,8 +9,8 @@...@@ -9,8 +9,8 @@
9#ifndef ATOMIC_SUPPORT_H9#ifndef ATOMIC_SUPPORT_H
10#define ATOMIC_SUPPORT_H10#define ATOMIC_SUPPORT_H
1111
12#include "__config"12#include <__config>
13#include "memory" // for __libcpp_relaxed_load13#include <memory> // for __libcpp_relaxed_load
1414
15#if defined(__clang__) && __has_builtin(__atomic_load_n) \15#if defined(__clang__) && __has_builtin(__atomic_load_n) \
16 && __has_builtin(__atomic_store_n) \16 && __has_builtin(__atomic_store_n) \
lib/libcxx/src/include/config_elast.h+2
...@@ -29,6 +29,8 @@...@@ -29,6 +29,8 @@
29// No _LIBCPP_ELAST needed on Fuchsia29// No _LIBCPP_ELAST needed on Fuchsia
30#elif defined(__wasi__)30#elif defined(__wasi__)
31// No _LIBCPP_ELAST needed on WASI31// No _LIBCPP_ELAST needed on WASI
32#elif defined(__EMSCRIPTEN__)
33// No _LIBCPP_ELAST needed on Emscripten
32#elif defined(__linux__) || defined(_LIBCPP_HAS_MUSL_LIBC)34#elif defined(__linux__) || defined(_LIBCPP_HAS_MUSL_LIBC)
33#define _LIBCPP_ELAST 409535#define _LIBCPP_ELAST 4095
34#elif defined(__APPLE__)36#elif defined(__APPLE__)
lib/libcxx/src/include/ryu/common.h+1
...@@ -42,6 +42,7 @@...@@ -42,6 +42,7 @@
42// Avoid formatting to keep the changes with the original code minimal.42// Avoid formatting to keep the changes with the original code minimal.
43// clang-format off43// clang-format off
4444
45#include <__assert>
45#include "__config"46#include "__config"
4647
47_LIBCPP_BEGIN_NAMESPACE_STD48_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/src/include/ryu/d2fixed.h+2-2
...@@ -42,8 +42,8 @@...@@ -42,8 +42,8 @@
42// Avoid formatting to keep the changes with the original code minimal.42// Avoid formatting to keep the changes with the original code minimal.
43// clang-format off43// clang-format off
4444
45#include "__config"45#include <__config>
46#include "cstdint"46#include <cstdint>
4747
48_LIBCPP_BEGIN_NAMESPACE_STD48_LIBCPP_BEGIN_NAMESPACE_STD
4949
lib/libcxx/src/include/ryu/d2fixed_full_table.h+1-1
...@@ -42,7 +42,7 @@...@@ -42,7 +42,7 @@
42// Avoid formatting to keep the changes with the original code minimal.42// Avoid formatting to keep the changes with the original code minimal.
43// clang-format off43// clang-format off
4444
45#include "__config"45#include <__config>
4646
47_LIBCPP_BEGIN_NAMESPACE_STD47_LIBCPP_BEGIN_NAMESPACE_STD
4848
lib/libcxx/src/include/ryu/d2s.h+1-1
...@@ -42,7 +42,7 @@...@@ -42,7 +42,7 @@
42// Avoid formatting to keep the changes with the original code minimal.42// Avoid formatting to keep the changes with the original code minimal.
43// clang-format off43// clang-format off
4444
45#include "__config"45#include <__config>
4646
47_LIBCPP_BEGIN_NAMESPACE_STD47_LIBCPP_BEGIN_NAMESPACE_STD
4848
lib/libcxx/src/include/ryu/d2s_full_table.h+1-1
...@@ -42,7 +42,7 @@...@@ -42,7 +42,7 @@
42// Avoid formatting to keep the changes with the original code minimal.42// Avoid formatting to keep the changes with the original code minimal.
43// clang-format off43// clang-format off
4444
45#include "__config"45#include <__config>
4646
47_LIBCPP_BEGIN_NAMESPACE_STD47_LIBCPP_BEGIN_NAMESPACE_STD
4848
lib/libcxx/src/include/ryu/d2s_intrinsics.h+4-1
...@@ -42,7 +42,10 @@...@@ -42,7 +42,10 @@
42// Avoid formatting to keep the changes with the original code minimal.42// Avoid formatting to keep the changes with the original code minimal.
43// clang-format off43// clang-format off
4444
45#include "__config"45#include <__assert>
46#include <__config>
47
48#include "include/ryu/ryu.h"
4649
47_LIBCPP_BEGIN_NAMESPACE_STD50_LIBCPP_BEGIN_NAMESPACE_STD
4851
lib/libcxx/src/include/ryu/digit_table.h+7-18
...@@ -39,30 +39,19 @@...@@ -39,30 +39,19 @@
39#ifndef _LIBCPP_SRC_INCLUDE_RYU_DIGIT_TABLE_H39#ifndef _LIBCPP_SRC_INCLUDE_RYU_DIGIT_TABLE_H
40#define _LIBCPP_SRC_INCLUDE_RYU_DIGIT_TABLE_H40#define _LIBCPP_SRC_INCLUDE_RYU_DIGIT_TABLE_H
4141
42// Avoid formatting to keep the changes with the original code minimal.42#include <__charconv/tables.h>
43// clang-format off43#include <__config>
44
45#include "__config"
4644
47_LIBCPP_BEGIN_NAMESPACE_STD45_LIBCPP_BEGIN_NAMESPACE_STD
4846
49// A table of all two-digit numbers. This is used to speed up decimal digit47// A table of all two-digit numbers. This is used to speed up decimal digit
50// generation by copying pairs of digits into the final output.48// generation by copying pairs of digits into the final output.
51inline constexpr char __DIGIT_TABLE[200] = {49//
52 '0','0','0','1','0','2','0','3','0','4','0','5','0','6','0','7','0','8','0','9',50// In order to minimize the diff in the Ryu code between MSVC STL and libc++
53 '1','0','1','1','1','2','1','3','1','4','1','5','1','6','1','7','1','8','1','9',51// the code uses the name __DIGIT_TABLE. In order to avoid code duplication it
54 '2','0','2','1','2','2','2','3','2','4','2','5','2','6','2','7','2','8','2','9',52// reuses the table already available in libc++.
55 '3','0','3','1','3','2','3','3','3','4','3','5','3','6','3','7','3','8','3','9',53inline constexpr auto& __DIGIT_TABLE = __itoa::__table<>::__digits_base_10;
56 '4','0','4','1','4','2','4','3','4','4','4','5','4','6','4','7','4','8','4','9',
57 '5','0','5','1','5','2','5','3','5','4','5','5','5','6','5','7','5','8','5','9',
58 '6','0','6','1','6','2','6','3','6','4','6','5','6','6','6','7','6','8','6','9',
59 '7','0','7','1','7','2','7','3','7','4','7','5','7','6','7','7','7','8','7','9',
60 '8','0','8','1','8','2','8','3','8','4','8','5','8','6','8','7','8','8','8','9',
61 '9','0','9','1','9','2','9','3','9','4','9','5','9','6','9','7','9','8','9','9'
62};
6354
64_LIBCPP_END_NAMESPACE_STD55_LIBCPP_END_NAMESPACE_STD
6556
66// clang-format on
67
68#endif // _LIBCPP_SRC_INCLUDE_RYU_DIGIT_TABLE_H57#endif // _LIBCPP_SRC_INCLUDE_RYU_DIGIT_TABLE_H
lib/libcxx/src/include/ryu/f2s.h+1-1
...@@ -42,7 +42,7 @@...@@ -42,7 +42,7 @@
42// Avoid formatting to keep the changes with the original code minimal.42// Avoid formatting to keep the changes with the original code minimal.
43// clang-format off43// clang-format off
4444
45#include "__config"45#include <__config>
4646
47_LIBCPP_BEGIN_NAMESPACE_STD47_LIBCPP_BEGIN_NAMESPACE_STD
4848
lib/libcxx/src/include/ryu/ryu.h+14-13
...@@ -44,21 +44,22 @@...@@ -44,21 +44,22 @@
44// Avoid formatting to keep the changes with the original code minimal.44// Avoid formatting to keep the changes with the original code minimal.
45// clang-format off45// clang-format off
4646
47#include "__charconv/chars_format.h"47#include <__charconv/chars_format.h>
48#include "__charconv/to_chars_result.h"48#include <__charconv/to_chars_result.h>
49#include "__config"49#include <__config>
50#include "__debug"50#include <__debug>
51#include "__errc"51#include <__errc>
52#include "cstdint"52#include <cstdint>
53#include "cstring"53#include <cstring>
54#include "type_traits"54#include <type_traits>
55
55#include "include/ryu/f2s.h"56#include "include/ryu/f2s.h"
56#include "include/ryu/d2s.h"57#include "include/ryu/d2s.h"
57#include "include/ryu/d2fixed.h"58#include "include/ryu/d2fixed.h"
5859
59#if defined(_M_X64) && defined(_LIBCPP_COMPILER_MSVC)60#if defined(_MSC_VER)
60#include <intrin0.h> // for _umul128() and __shiftright128()61#include <intrin.h> // for _umul128(), __shiftright128(), _BitScanForward{,64}
61#endif // defined(_M_X64) && defined(_LIBCPP_COMPILER_MSVC)62#endif // defined(_MSC_VER)
6263
63#if defined(_WIN64) || defined(_M_AMD64) || defined(__x86_64__) || defined(__aarch64__)64#if defined(_WIN64) || defined(_M_AMD64) || defined(__x86_64__) || defined(__aarch64__)
64#define _LIBCPP_64_BIT65#define _LIBCPP_64_BIT
...@@ -68,7 +69,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -68,7 +69,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
6869
69// https://github.com/ulfjack/ryu/tree/59661c3/ryu70// https://github.com/ulfjack/ryu/tree/59661c3/ryu
7071
71#if !defined(_LIBCPP_COMPILER_MSVC)72#if !defined(_MSC_VER)
72_LIBCPP_HIDE_FROM_ABI inline unsigned char _BitScanForward64(unsigned long* __index, unsigned long long __mask) {73_LIBCPP_HIDE_FROM_ABI inline unsigned char _BitScanForward64(unsigned long* __index, unsigned long long __mask) {
73 if (__mask == 0) {74 if (__mask == 0) {
74 return false;75 return false;
...@@ -84,7 +85,7 @@ _LIBCPP_HIDE_FROM_ABI inline unsigned char _BitScanForward(unsigned long* __inde...@@ -84,7 +85,7 @@ _LIBCPP_HIDE_FROM_ABI inline unsigned char _BitScanForward(unsigned long* __inde
84 *__index = __builtin_ctz(__mask);85 *__index = __builtin_ctz(__mask);
85 return true;86 return true;
86}87}
87#endif // _LIBCPP_COMPILER_MSVC88#endif // !_MSC_VER
8889
89template <class _Floating>90template <class _Floating>
90[[nodiscard]] to_chars_result _Floating_to_chars_ryu(91[[nodiscard]] to_chars_result _Floating_to_chars_ryu(
lib/libcxx/src/include/sso_allocator.h+5
...@@ -41,6 +41,11 @@ public:...@@ -41,6 +41,11 @@ public:
41 typedef _Tp* pointer;41 typedef _Tp* pointer;
42 typedef _Tp value_type;42 typedef _Tp value_type;
4343
44 template <class U>
45 struct rebind {
46 using other = __sso_allocator<U, _Np>;
47 };
48
44 _LIBCPP_INLINE_VISIBILITY __sso_allocator() throw() : __allocated_(false) {}49 _LIBCPP_INLINE_VISIBILITY __sso_allocator() throw() : __allocated_(false) {}
45 _LIBCPP_INLINE_VISIBILITY __sso_allocator(const __sso_allocator&) throw() : __allocated_(false) {}50 _LIBCPP_INLINE_VISIBILITY __sso_allocator(const __sso_allocator&) throw() : __allocated_(false) {}
46 template <class _Up> _LIBCPP_INLINE_VISIBILITY __sso_allocator(const __sso_allocator<_Up, _Np>&) throw()51 template <class _Up> _LIBCPP_INLINE_VISIBILITY __sso_allocator(const __sso_allocator<_Up, _Np>&) throw()
lib/libcxx/src/include/to_chars_floating_point.h+13-10
...@@ -17,16 +17,19 @@...@@ -17,16 +17,19 @@
17// Avoid formatting to keep the changes with the original code minimal.17// Avoid formatting to keep the changes with the original code minimal.
18// clang-format off18// clang-format off
1919
20#include "__algorithm/find.h"20#include <__algorithm/find.h>
21#include "__algorithm/find_if.h"21#include <__algorithm/find_if.h>
22#include "__algorithm/lower_bound.h"22#include <__algorithm/lower_bound.h>
23#include "__algorithm/min.h"23#include <__algorithm/min.h>
24#include "__config"24#include <__assert>
25#include "__iterator/access.h"25#include <__config>
26#include "__iterator/size.h"26#include <__functional/operations.h>
27#include "bit"27#include <__iterator/access.h>
28#include "cfloat"28#include <__iterator/size.h>
29#include "climits"29#include <bit>
30#include <cfloat>
31#include <climits>
32
30#include "include/ryu/ryu.h"33#include "include/ryu/ryu.h"
3134
32_LIBCPP_BEGIN_NAMESPACE_STD35_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/src/ios.cpp+13-11
...@@ -6,20 +6,20 @@...@@ -6,20 +6,20 @@
6//6//
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9#include "__config"9#include <__config>
1010#include <__locale>
11#include "ios"11#include <algorithm>
1212#include <ios>
13#include <limits>
14#include <memory>
15#include <new>
13#include <stdlib.h>16#include <stdlib.h>
17#include <string>
1418
15#include "__locale"
16#include "algorithm"
17#include "include/config_elast.h"19#include "include/config_elast.h"
18#include "limits"20
19#include "memory"21_LIBCPP_PUSH_MACROS
20#include "new"22#include <__undef_macros>
21#include "string"
22#include "__undef_macros"
2323
24_LIBCPP_BEGIN_NAMESPACE_STD24_LIBCPP_BEGIN_NAMESPACE_STD
2525
...@@ -439,3 +439,5 @@ ios_base::sync_with_stdio(bool sync)...@@ -439,3 +439,5 @@ ios_base::sync_with_stdio(bool sync)
439}439}
440440
441_LIBCPP_END_NAMESPACE_STD441_LIBCPP_END_NAMESPACE_STD
442
443_LIBCPP_POP_MACROS
lib/libcxx/src/ios.instantiations.cpp+7-8
...@@ -6,14 +6,13 @@...@@ -6,14 +6,13 @@
6//6//
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9#include "__config"9#include <__config>
10#include "fstream"10#include <fstream>
11#include "ios"11#include <ios>
12#include "istream"12#include <istream>
13#include "ostream"13#include <ostream>
14#include "sstream"14#include <sstream>
15#include "streambuf"15#include <streambuf>
16
1716
18_LIBCPP_BEGIN_NAMESPACE_STD17_LIBCPP_BEGIN_NAMESPACE_STD
1918
lib/libcxx/src/iostream.cpp+4-4
...@@ -6,10 +6,10 @@...@@ -6,10 +6,10 @@
6//6//
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9#include "__std_stream"9#include <__locale>
10#include "__locale"10#include <__std_stream>
11#include "string"11#include <new>
12#include "new"12#include <string>
1313
14#define _str(s) #s14#define _str(s) #s
15#define str(s) _str(s)15#define str(s) _str(s)
lib/libcxx/src/legacy_debug_handler.cpp created+54
...@@ -0,0 +1,54 @@
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 <cstdio>
11#include <cstdlib>
12#include <string>
13
14// This file defines the legacy default debug handler and related mechanisms
15// to set it. This is for backwards ABI compatibility with code that has been
16// using this debug handler previously.
17
18_LIBCPP_BEGIN_NAMESPACE_STD
19
20struct _LIBCPP_TEMPLATE_VIS __libcpp_debug_info {
21 _LIBCPP_EXPORTED_FROM_ABI string what() const;
22
23 const char* __file_;
24 int __line_;
25 const char* __pred_;
26 const char* __msg_;
27};
28
29std::string __libcpp_debug_info::what() const {
30 string msg = __file_;
31 msg += ":" + std::to_string(__line_) + ": _LIBCPP_ASSERT '";
32 msg += __pred_;
33 msg += "' failed. ";
34 msg += __msg_;
35 return msg;
36}
37
38_LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void __libcpp_abort_debug_function(__libcpp_debug_info const& info) {
39 std::fprintf(stderr, "%s\n", info.what().c_str());
40 std::abort();
41}
42
43typedef void (*__libcpp_debug_function_type)(__libcpp_debug_info const&);
44
45_LIBCPP_EXPORTED_FROM_ABI
46constinit __libcpp_debug_function_type __libcpp_debug_function = __libcpp_abort_debug_function;
47
48_LIBCPP_EXPORTED_FROM_ABI
49bool __libcpp_set_debug_function(__libcpp_debug_function_type __func) {
50 __libcpp_debug_function = __func;
51 return true;
52}
53
54_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/legacy_pointer_safety.cpp+1-1
...@@ -6,7 +6,7 @@...@@ -6,7 +6,7 @@
6//6//
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9#include "__config"9#include <__config>
10#include <memory>10#include <memory>
1111
12// Support for garbage collection was removed in C++23 by https://wg21.link/P2186R2. Libc++ implements12// Support for garbage collection was removed in C++23 by https://wg21.link/P2186R2. Libc++ implements
lib/libcxx/src/locale.cpp+45-33
...@@ -12,20 +12,21 @@...@@ -12,20 +12,21 @@
12#define _LCONV_C9912#define _LCONV_C99
13#endif13#endif
1414
15#include "algorithm"15#include <__utility/unreachable.h>
16#include "clocale"16#include <algorithm>
17#include "codecvt"17#include <clocale>
18#include "cstdio"18#include <codecvt>
19#include "cstdlib"19#include <cstdio>
20#include "cstring"20#include <cstdlib>
21#include "locale"21#include <cstring>
22#include "string"22#include <locale>
23#include "type_traits"23#include <string>
24#include "typeinfo"24#include <type_traits>
25#include "vector"25#include <typeinfo>
26#include <vector>
2627
27#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS28#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
28# include "cwctype"29# include <cwctype>
29#endif30#endif
3031
31#if defined(_AIX)32#if defined(_AIX)
...@@ -44,13 +45,13 @@...@@ -44,13 +45,13 @@
4445
45#include "include/atomic_support.h"46#include "include/atomic_support.h"
46#include "include/sso_allocator.h"47#include "include/sso_allocator.h"
47#include "__undef_macros"
4848
49// On Linux, wint_t and wchar_t have different signed-ness, and this causes49// On Linux, wint_t and wchar_t have different signed-ness, and this causes
50// lots of noise in the build log, but no bugs that I know of.50// lots of noise in the build log, but no bugs that I know of.
51#if defined(__clang__)51_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wsign-conversion")
52#pragma clang diagnostic ignored "-Wsign-conversion"52
53#endif53_LIBCPP_PUSH_MACROS
54#include <__undef_macros>
5455
55_LIBCPP_BEGIN_NAMESPACE_STD56_LIBCPP_BEGIN_NAMESPACE_STD
5657
...@@ -127,11 +128,6 @@ _LIBCPP_NORETURN static void __throw_runtime_error(const string &msg)...@@ -127,11 +128,6 @@ _LIBCPP_NORETURN static void __throw_runtime_error(const string &msg)
127128
128}129}
129130
130#if defined(_AIX)
131// Set priority to INT_MIN + 256 + 150
132# pragma priority ( -2147483242 )
133#endif
134
135const locale::category locale::none;131const locale::category locale::none;
136const locale::category locale::collate;132const locale::category locale::collate;
137const locale::category locale::ctype;133const locale::category locale::ctype;
...@@ -1528,7 +1524,7 @@ char...@@ -1528,7 +1524,7 @@ char
1528ctype_byname<wchar_t>::do_narrow(char_type c, char dfault) const1524ctype_byname<wchar_t>::do_narrow(char_type c, char dfault) const
1529{1525{
1530 int r = __libcpp_wctob_l(c, __l);1526 int r = __libcpp_wctob_l(c, __l);
1531 return r != static_cast<int>(WEOF) ? static_cast<char>(r) : dfault;1527 return (r != EOF) ? static_cast<char>(r) : dfault;
1532}1528}
15331529
1534const wchar_t*1530const wchar_t*
...@@ -1537,7 +1533,7 @@ ctype_byname<wchar_t>::do_narrow(const char_type* low, const char_type* high, ch...@@ -1537,7 +1533,7 @@ ctype_byname<wchar_t>::do_narrow(const char_type* low, const char_type* high, ch
1537 for (; low != high; ++low, ++dest)1533 for (; low != high; ++low, ++dest)
1538 {1534 {
1539 int r = __libcpp_wctob_l(*low, __l);1535 int r = __libcpp_wctob_l(*low, __l);
1540 *dest = r != static_cast<int>(WEOF) ? static_cast<char>(r) : dfault;1536 *dest = (r != EOF) ? static_cast<char>(r) : dfault;
1541 }1537 }
1542 return low;1538 return low;
1543}1539}
...@@ -1835,6 +1831,7 @@ codecvt<wchar_t, char, mbstate_t>::do_max_length() const noexcept...@@ -1835,6 +1831,7 @@ codecvt<wchar_t, char, mbstate_t>::do_max_length() const noexcept
1835// 040000 - 0FFFFF D8C0 - DBBF, DC00 - DFFF F1 - F3, 80 - BF, 80 - BF, 80 - BF 7864321831// 040000 - 0FFFFF D8C0 - DBBF, DC00 - DFFF F1 - F3, 80 - BF, 80 - BF, 80 - BF 786432
1836// 100000 - 10FFFF DBC0 - DBFF, DC00 - DFFF F4 - F4, 80 - 8F, 80 - BF, 80 - BF 655361832// 100000 - 10FFFF DBC0 - DBFF, DC00 - DFFF F4 - F4, 80 - 8F, 80 - BF, 80 - BF 65536
18371833
1834_LIBCPP_SUPPRESS_DEPRECATED_PUSH
1838static1835static
1839codecvt_base::result1836codecvt_base::result
1840utf16_to_utf8(const uint16_t* frm, const uint16_t* frm_end, const uint16_t*& frm_nxt,1837utf16_to_utf8(const uint16_t* frm, const uint16_t* frm_end, const uint16_t*& frm_nxt,
...@@ -3208,6 +3205,8 @@ utf16le_to_ucs2_length(const uint8_t* frm, const uint8_t* frm_end,...@@ -3208,6 +3205,8 @@ utf16le_to_ucs2_length(const uint8_t* frm, const uint8_t* frm_end,
3208 return static_cast<int>(frm_nxt - frm);3205 return static_cast<int>(frm_nxt - frm);
3209}3206}
32103207
3208_LIBCPP_SUPPRESS_DEPRECATED_POP
3209
3211// template <> class codecvt<char16_t, char, mbstate_t>3210// template <> class codecvt<char16_t, char, mbstate_t>
32123211
3213locale::id codecvt<char16_t, char, mbstate_t>::id;3212locale::id codecvt<char16_t, char, mbstate_t>::id;
...@@ -3615,6 +3614,7 @@ __codecvt_utf8<wchar_t>::do_length(state_type&,...@@ -3615,6 +3614,7 @@ __codecvt_utf8<wchar_t>::do_length(state_type&,
3615#endif3614#endif
3616}3615}
36173616
3617_LIBCPP_SUPPRESS_DEPRECATED_PUSH
3618int3618int
3619__codecvt_utf8<wchar_t>::do_max_length() const noexcept3619__codecvt_utf8<wchar_t>::do_max_length() const noexcept
3620{3620{
...@@ -3697,6 +3697,7 @@ __codecvt_utf8<char16_t>::do_length(state_type&,...@@ -3697,6 +3697,7 @@ __codecvt_utf8<char16_t>::do_length(state_type&,
3697 return utf8_to_ucs2_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);3697 return utf8_to_ucs2_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
3698}3698}
36993699
3700_LIBCPP_SUPPRESS_DEPRECATED_PUSH
3700int3701int
3701__codecvt_utf8<char16_t>::do_max_length() const noexcept3702__codecvt_utf8<char16_t>::do_max_length() const noexcept
3702{3703{
...@@ -3704,6 +3705,7 @@ __codecvt_utf8<char16_t>::do_max_length() const noexcept...@@ -3704,6 +3705,7 @@ __codecvt_utf8<char16_t>::do_max_length() const noexcept
3704 return 6;3705 return 6;
3705 return 3;3706 return 3;
3706}3707}
3708_LIBCPP_SUPPRESS_DEPRECATED_POP
37073709
3708// __codecvt_utf8<char32_t>3710// __codecvt_utf8<char32_t>
37093711
...@@ -3772,6 +3774,7 @@ __codecvt_utf8<char32_t>::do_length(state_type&,...@@ -3772,6 +3774,7 @@ __codecvt_utf8<char32_t>::do_length(state_type&,
3772 return utf8_to_ucs4_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);3774 return utf8_to_ucs4_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
3773}3775}
37743776
3777_LIBCPP_SUPPRESS_DEPRECATED_PUSH
3775int3778int
3776__codecvt_utf8<char32_t>::do_max_length() const noexcept3779__codecvt_utf8<char32_t>::do_max_length() const noexcept
3777{3780{
...@@ -3779,6 +3782,7 @@ __codecvt_utf8<char32_t>::do_max_length() const noexcept...@@ -3779,6 +3782,7 @@ __codecvt_utf8<char32_t>::do_max_length() const noexcept
3779 return 7;3782 return 7;
3780 return 4;3783 return 4;
3781}3784}
3785_LIBCPP_SUPPRESS_DEPRECATED_POP
37823786
3783// __codecvt_utf16<wchar_t, false>3787// __codecvt_utf16<wchar_t, false>
37843788
...@@ -4057,6 +4061,7 @@ __codecvt_utf16<char16_t, false>::do_length(state_type&,...@@ -4057,6 +4061,7 @@ __codecvt_utf16<char16_t, false>::do_length(state_type&,
4057 return utf16be_to_ucs2_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);4061 return utf16be_to_ucs2_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
4058}4062}
40594063
4064_LIBCPP_SUPPRESS_DEPRECATED_PUSH
4060int4065int
4061__codecvt_utf16<char16_t, false>::do_max_length() const noexcept4066__codecvt_utf16<char16_t, false>::do_max_length() const noexcept
4062{4067{
...@@ -4064,6 +4069,7 @@ __codecvt_utf16<char16_t, false>::do_max_length() const noexcept...@@ -4064,6 +4069,7 @@ __codecvt_utf16<char16_t, false>::do_max_length() const noexcept
4064 return 4;4069 return 4;
4065 return 2;4070 return 2;
4066}4071}
4072_LIBCPP_SUPPRESS_DEPRECATED_POP
40674073
4068// __codecvt_utf16<char16_t, true>4074// __codecvt_utf16<char16_t, true>
40694075
...@@ -4132,6 +4138,7 @@ __codecvt_utf16<char16_t, true>::do_length(state_type&,...@@ -4132,6 +4138,7 @@ __codecvt_utf16<char16_t, true>::do_length(state_type&,
4132 return utf16le_to_ucs2_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);4138 return utf16le_to_ucs2_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
4133}4139}
41344140
4141_LIBCPP_SUPPRESS_DEPRECATED_PUSH
4135int4142int
4136__codecvt_utf16<char16_t, true>::do_max_length() const noexcept4143__codecvt_utf16<char16_t, true>::do_max_length() const noexcept
4137{4144{
...@@ -4139,6 +4146,7 @@ __codecvt_utf16<char16_t, true>::do_max_length() const noexcept...@@ -4139,6 +4146,7 @@ __codecvt_utf16<char16_t, true>::do_max_length() const noexcept
4139 return 4;4146 return 4;
4140 return 2;4147 return 2;
4141}4148}
4149_LIBCPP_SUPPRESS_DEPRECATED_POP
41424150
4143// __codecvt_utf16<char32_t, false>4151// __codecvt_utf16<char32_t, false>
41444152
...@@ -4207,6 +4215,7 @@ __codecvt_utf16<char32_t, false>::do_length(state_type&,...@@ -4207,6 +4215,7 @@ __codecvt_utf16<char32_t, false>::do_length(state_type&,
4207 return utf16be_to_ucs4_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);4215 return utf16be_to_ucs4_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
4208}4216}
42094217
4218_LIBCPP_SUPPRESS_DEPRECATED_PUSH
4210int4219int
4211__codecvt_utf16<char32_t, false>::do_max_length() const noexcept4220__codecvt_utf16<char32_t, false>::do_max_length() const noexcept
4212{4221{
...@@ -4214,6 +4223,7 @@ __codecvt_utf16<char32_t, false>::do_max_length() const noexcept...@@ -4214,6 +4223,7 @@ __codecvt_utf16<char32_t, false>::do_max_length() const noexcept
4214 return 6;4223 return 6;
4215 return 4;4224 return 4;
4216}4225}
4226_LIBCPP_SUPPRESS_DEPRECATED_POP
42174227
4218// __codecvt_utf16<char32_t, true>4228// __codecvt_utf16<char32_t, true>
42194229
...@@ -4282,6 +4292,7 @@ __codecvt_utf16<char32_t, true>::do_length(state_type&,...@@ -4282,6 +4292,7 @@ __codecvt_utf16<char32_t, true>::do_length(state_type&,
4282 return utf16le_to_ucs4_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);4292 return utf16le_to_ucs4_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
4283}4293}
42844294
4295_LIBCPP_SUPPRESS_DEPRECATED_PUSH
4285int4296int
4286__codecvt_utf16<char32_t, true>::do_max_length() const noexcept4297__codecvt_utf16<char32_t, true>::do_max_length() const noexcept
4287{4298{
...@@ -4289,6 +4300,7 @@ __codecvt_utf16<char32_t, true>::do_max_length() const noexcept...@@ -4289,6 +4300,7 @@ __codecvt_utf16<char32_t, true>::do_max_length() const noexcept
4289 return 6;4300 return 6;
4290 return 4;4301 return 4;
4291}4302}
4303_LIBCPP_SUPPRESS_DEPRECATED_POP
42924304
4293// __codecvt_utf8_utf16<wchar_t>4305// __codecvt_utf8_utf16<wchar_t>
42944306
...@@ -4446,6 +4458,7 @@ __codecvt_utf8_utf16<char16_t>::do_length(state_type&,...@@ -4446,6 +4458,7 @@ __codecvt_utf8_utf16<char16_t>::do_length(state_type&,
4446 return utf8_to_utf16_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);4458 return utf8_to_utf16_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
4447}4459}
44484460
4461_LIBCPP_SUPPRESS_DEPRECATED_PUSH
4449int4462int
4450__codecvt_utf8_utf16<char16_t>::do_max_length() const noexcept4463__codecvt_utf8_utf16<char16_t>::do_max_length() const noexcept
4451{4464{
...@@ -4453,6 +4466,7 @@ __codecvt_utf8_utf16<char16_t>::do_max_length() const noexcept...@@ -4453,6 +4466,7 @@ __codecvt_utf8_utf16<char16_t>::do_max_length() const noexcept
4453 return 7;4466 return 7;
4454 return 4;4467 return 4;
4455}4468}
4469_LIBCPP_SUPPRESS_DEPRECATED_POP
44564470
4457// __codecvt_utf8_utf16<char32_t>4471// __codecvt_utf8_utf16<char32_t>
44584472
...@@ -4521,6 +4535,7 @@ __codecvt_utf8_utf16<char32_t>::do_length(state_type&,...@@ -4521,6 +4535,7 @@ __codecvt_utf8_utf16<char32_t>::do_length(state_type&,
4521 return utf8_to_utf16_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);4535 return utf8_to_utf16_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
4522}4536}
45234537
4538_LIBCPP_SUPPRESS_DEPRECATED_PUSH
4524int4539int
4525__codecvt_utf8_utf16<char32_t>::do_max_length() const noexcept4540__codecvt_utf8_utf16<char32_t>::do_max_length() const noexcept
4526{4541{
...@@ -4528,6 +4543,7 @@ __codecvt_utf8_utf16<char32_t>::do_max_length() const noexcept...@@ -4528,6 +4543,7 @@ __codecvt_utf8_utf16<char32_t>::do_max_length() const noexcept
4528 return 7;4543 return 7;
4529 return 4;4544 return 4;
4530}4545}
4546_LIBCPP_SUPPRESS_DEPRECATED_POP
45314547
4532// __narrow_to_utf8<16>4548// __narrow_to_utf8<16>
45334549
...@@ -4623,7 +4639,7 @@ static bool checked_string_to_char_convert(char& dest,...@@ -4623,7 +4639,7 @@ static bool checked_string_to_char_convert(char& dest,
46234639
4624 return false;4640 return false;
4625#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS4641#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
4626 _LIBCPP_UNREACHABLE();4642 __libcpp_unreachable();
4627}4643}
46284644
46294645
...@@ -5200,12 +5216,8 @@ __time_get::~__time_get()...@@ -5200,12 +5216,8 @@ __time_get::~__time_get()
5200{5216{
5201 freelocale(__loc_);5217 freelocale(__loc_);
5202}5218}
5203#if defined(__clang__)5219
5204#pragma clang diagnostic ignored "-Wmissing-field-initializers"5220_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wmissing-field-initializers")
5205#endif
5206#if defined(__GNUG__)
5207#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
5208#endif
52095221
5210template <>5222template <>
5211string5223string
...@@ -5351,9 +5363,7 @@ __time_get_storage<char>::__analyze(char fmt, const ctype<char>& ct)...@@ -5351,9 +5363,7 @@ __time_get_storage<char>::__analyze(char fmt, const ctype<char>& ct)
5351 return result;5363 return result;
5352}5364}
53535365
5354#if defined(__clang__)5366_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wmissing-braces")
5355#pragma clang diagnostic ignored "-Wmissing-braces"
5356#endif
53575367
5358#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS5368#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
5359template <>5369template <>
...@@ -6599,3 +6609,5 @@ template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS codecvt_byname<char32_t,...@@ -6599,3 +6609,5 @@ template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS codecvt_byname<char32_t,
6599#endif6609#endif
66006610
6601_LIBCPP_END_NAMESPACE_STD6611_LIBCPP_END_NAMESPACE_STD
6612
6613_LIBCPP_POP_MACROS
lib/libcxx/src/memory.cpp+28-24
...@@ -6,14 +6,21 @@...@@ -6,14 +6,21 @@
6//6//
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9#include "memory"9#include <__config>
10#ifdef _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS
11# define _LIBCPP_SHARED_PTR_DEFINE_LEGACY_INLINE_FUNCTIONS
12#endif
13
14#include <memory>
15
10#ifndef _LIBCPP_HAS_NO_THREADS16#ifndef _LIBCPP_HAS_NO_THREADS
11# include "mutex"17# include <mutex>
12# include "thread"18# include <thread>
13# if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB)19# if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB)
14# pragma comment(lib, "pthread")20# pragma comment(lib, "pthread")
15# endif21# endif
16#endif22#endif
23
17#include "include/atomic_support.h"24#include "include/atomic_support.h"
1825
19_LIBCPP_BEGIN_NAMESPACE_STD26_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -36,7 +43,7 @@ __shared_weak_count::~__shared_weak_count()...@@ -36,7 +43,7 @@ __shared_weak_count::~__shared_weak_count()
36{43{
37}44}
3845
39#if defined(_LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS)46#if defined(_LIBCPP_SHARED_PTR_DEFINE_LEGACY_INLINE_FUNCTIONS)
40void47void
41__shared_count::__add_shared() noexcept48__shared_count::__add_shared() noexcept
42{49{
...@@ -72,8 +79,7 @@ __shared_weak_count::__release_shared() noexcept...@@ -72,8 +79,7 @@ __shared_weak_count::__release_shared() noexcept
72 if (__shared_count::__release_shared())79 if (__shared_count::__release_shared())
73 __release_weak();80 __release_weak();
74}81}
7582#endif // _LIBCPP_SHARED_PTR_DEFINE_LEGACY_INLINE_FUNCTIONS
76#endif // _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS
7783
78void84void
79__shared_weak_count::__release_weak() noexcept85__shared_weak_count::__release_weak() noexcept
...@@ -132,9 +138,13 @@ __shared_weak_count::__get_deleter(const type_info&) const noexcept...@@ -132,9 +138,13 @@ __shared_weak_count::__get_deleter(const type_info&) const noexcept
132138
133#if !defined(_LIBCPP_HAS_NO_THREADS)139#if !defined(_LIBCPP_HAS_NO_THREADS)
134140
135_LIBCPP_SAFE_STATIC static const std::size_t __sp_mut_count = 16;141static constexpr std::size_t __sp_mut_count = 32;
136_LIBCPP_SAFE_STATIC static __libcpp_mutex_t mut_back[__sp_mut_count] =142static constinit __libcpp_mutex_t mut_back[__sp_mut_count] =
137{143{
144 _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER,
145 _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER,
146 _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER,
147 _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER,
138 _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER,148 _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER,
139 _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER,149 _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER,
140 _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER,150 _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER,
...@@ -150,16 +160,7 @@ void...@@ -150,16 +160,7 @@ void
150__sp_mut::lock() noexcept160__sp_mut::lock() noexcept
151{161{
152 auto m = static_cast<__libcpp_mutex_t*>(__lx);162 auto m = static_cast<__libcpp_mutex_t*>(__lx);
153 unsigned count = 0;163 __libcpp_mutex_lock(m);
154 while (!__libcpp_mutex_trylock(m))
155 {
156 if (++count > 16)
157 {
158 __libcpp_mutex_lock(m);
159 break;
160 }
161 this_thread::yield();
162 }
163}164}
164165
165void166void
...@@ -171,12 +172,15 @@ __sp_mut::unlock() noexcept...@@ -171,12 +172,15 @@ __sp_mut::unlock() noexcept
171__sp_mut&172__sp_mut&
172__get_sp_mut(const void* p)173__get_sp_mut(const void* p)
173{174{
174 static __sp_mut muts[__sp_mut_count]175 static constinit __sp_mut muts[__sp_mut_count] = {
175 {
176 &mut_back[ 0], &mut_back[ 1], &mut_back[ 2], &mut_back[ 3],176 &mut_back[ 0], &mut_back[ 1], &mut_back[ 2], &mut_back[ 3],
177 &mut_back[ 4], &mut_back[ 5], &mut_back[ 6], &mut_back[ 7],177 &mut_back[ 4], &mut_back[ 5], &mut_back[ 6], &mut_back[ 7],
178 &mut_back[ 8], &mut_back[ 9], &mut_back[10], &mut_back[11],178 &mut_back[ 8], &mut_back[ 9], &mut_back[10], &mut_back[11],
179 &mut_back[12], &mut_back[13], &mut_back[14], &mut_back[15]179 &mut_back[12], &mut_back[13], &mut_back[14], &mut_back[15],
180 &mut_back[16], &mut_back[17], &mut_back[18], &mut_back[19],
181 &mut_back[20], &mut_back[21], &mut_back[22], &mut_back[23],
182 &mut_back[24], &mut_back[25], &mut_back[26], &mut_back[27],
183 &mut_back[28], &mut_back[29], &mut_back[30], &mut_back[31]
180 };184 };
181 return muts[hash<const void*>()(p) & (__sp_mut_count-1)];185 return muts[hash<const void*>()(p) & (__sp_mut_count-1)];
182}186}
lib/libcxx/src/mutex.cpp+16-9
...@@ -6,19 +6,24 @@...@@ -6,19 +6,24 @@
6//6//
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9#include "mutex"9#include <__assert>
10#include "limits"10#include <limits>
11#include "system_error"11#include <mutex>
12#include <system_error>
13
12#include "include/atomic_support.h"14#include "include/atomic_support.h"
13#include "__undef_macros"
1415
15#ifndef _LIBCPP_HAS_NO_THREADS16#ifndef _LIBCPP_HAS_NO_THREADS
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")
18#endif19# endif
19#endif20#endif
2021
22_LIBCPP_PUSH_MACROS
23#include <__undef_macros>
24
21_LIBCPP_BEGIN_NAMESPACE_STD25_LIBCPP_BEGIN_NAMESPACE_STD
26
22#ifndef _LIBCPP_HAS_NO_THREADS27#ifndef _LIBCPP_HAS_NO_THREADS
2328
24const defer_lock_t defer_lock{};29const defer_lock_t defer_lock{};
...@@ -196,8 +201,8 @@ recursive_timed_mutex::unlock() noexcept...@@ -196,8 +201,8 @@ recursive_timed_mutex::unlock() noexcept
196// keep in sync with: 7741191.201// keep in sync with: 7741191.
197202
198#ifndef _LIBCPP_HAS_NO_THREADS203#ifndef _LIBCPP_HAS_NO_THREADS
199_LIBCPP_SAFE_STATIC static __libcpp_mutex_t mut = _LIBCPP_MUTEX_INITIALIZER;204static constinit __libcpp_mutex_t mut = _LIBCPP_MUTEX_INITIALIZER;
200_LIBCPP_SAFE_STATIC static __libcpp_condvar_t cv = _LIBCPP_CONDVAR_INITIALIZER;205static constinit __libcpp_condvar_t cv = _LIBCPP_CONDVAR_INITIALIZER;
201#endif206#endif
202207
203void __call_once(volatile once_flag::_State_type& flag, void* arg,208void __call_once(volatile once_flag::_State_type& flag, void* arg,
...@@ -258,3 +263,5 @@ void __call_once(volatile once_flag::_State_type& flag, void* arg,...@@ -258,3 +263,5 @@ void __call_once(volatile once_flag::_State_type& flag, void* arg,
258}263}
259264
260_LIBCPP_END_NAMESPACE_STD265_LIBCPP_END_NAMESPACE_STD
266
267_LIBCPP_POP_MACROS
lib/libcxx/src/mutex_destructor.cpp+5-5
...@@ -16,13 +16,13 @@...@@ -16,13 +16,13 @@
16// we re-declare the entire class in this file instead of using16// we re-declare the entire class in this file instead of using
17// _LIBCPP_BUILDING_LIBRARY to change the definition in the headers.17// _LIBCPP_BUILDING_LIBRARY to change the definition in the headers.
1818
19#include "__config"19#include <__config>
20#include "__threading_support"20#include <__threading_support>
2121
22#if !defined(_LIBCPP_HAS_NO_THREADS)22#if !defined(_LIBCPP_HAS_NO_THREADS)
23#if _LIBCPP_ABI_VERSION == 1 || !defined(_LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION)23# if _LIBCPP_ABI_VERSION == 1 || !defined(_LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION)
24#define NEEDS_MUTEX_DESTRUCTOR24# define NEEDS_MUTEX_DESTRUCTOR
25#endif25# endif
26#endif26#endif
2727
28_LIBCPP_BEGIN_NAMESPACE_STD28_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/src/new.cpp+1-1
...@@ -6,9 +6,9 @@...@@ -6,9 +6,9 @@
6//6//
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9#include <new>
9#include <stdlib.h>10#include <stdlib.h>
1011
11#include "new"
12#include "include/atomic_support.h"12#include "include/atomic_support.h"
1313
14#if defined(_LIBCPP_ABI_MICROSOFT)14#if defined(_LIBCPP_ABI_MICROSOFT)
lib/libcxx/src/optional.cpp+2-2
...@@ -6,8 +6,8 @@...@@ -6,8 +6,8 @@
6//6//
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9#include "optional"9#include <__availability>
10#include "__availability"10#include <optional>
1111
12namespace std12namespace std
13{13{
lib/libcxx/src/random.cpp+3-3
...@@ -13,9 +13,9 @@...@@ -13,9 +13,9 @@
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 "limits"16#include <limits>
17#include "random"17#include <random>
18#include "system_error"18#include <system_error>
1919
20#if defined(__sun__)20#if defined(__sun__)
21# define rename solaris_headers_are_broken21# define rename solaris_headers_are_broken
lib/libcxx/src/random_shuffle.cpp+8-7
...@@ -6,19 +6,20 @@...@@ -6,19 +6,20 @@
6//6//
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9#include "algorithm"9#include <algorithm>
10#include "random"10#include <random>
11
11#ifndef _LIBCPP_HAS_NO_THREADS12#ifndef _LIBCPP_HAS_NO_THREADS
12# include "mutex"13# include <mutex>
13# if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB)14# if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB)
14# pragma comment(lib, "pthread")15# pragma comment(lib, "pthread")
15# endif16# endif
16#endif17#endif
1718
18_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
1920
20#ifndef _LIBCPP_HAS_NO_THREADS21#ifndef _LIBCPP_HAS_NO_THREADS
21_LIBCPP_SAFE_STATIC static __libcpp_mutex_t __rs_mut = _LIBCPP_MUTEX_INITIALIZER;22static constinit __libcpp_mutex_t __rs_mut = _LIBCPP_MUTEX_INITIALIZER;
22#endif23#endif
23unsigned __rs_default::__c_ = 0;24unsigned __rs_default::__c_ = 0;
2425
lib/libcxx/src/regex.cpp+3-3
...@@ -6,9 +6,9 @@...@@ -6,9 +6,9 @@
6//6//
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9#include "regex"9#include <algorithm>
10#include "algorithm"10#include <iterator>
11#include "iterator"11#include <regex>
1212
13_LIBCPP_BEGIN_NAMESPACE_STD13_LIBCPP_BEGIN_NAMESPACE_STD
1414
lib/libcxx/src/ryu/d2fixed.cpp+5-4
...@@ -39,10 +39,11 @@...@@ -39,10 +39,11 @@
39// Avoid formatting to keep the changes with the original code minimal.39// Avoid formatting to keep the changes with the original code minimal.
40// clang-format off40// clang-format off
4141
42#include "__config"42#include <__assert>
43#include "charconv"43#include <__config>
44#include "cstring"44#include <charconv>
45#include "system_error"45#include <cstring>
46#include <system_error>
4647
47#include "include/ryu/common.h"48#include "include/ryu/common.h"
48#include "include/ryu/d2fixed.h"49#include "include/ryu/d2fixed.h"
lib/libcxx/src/ryu/d2s.cpp+3-2
...@@ -39,8 +39,9 @@...@@ -39,8 +39,9 @@
39// Avoid formatting to keep the changes with the original code minimal.39// Avoid formatting to keep the changes with the original code minimal.
40// clang-format off40// clang-format off
4141
42#include "__config"42#include <__assert>
43#include "charconv"43#include <__config>
44#include <charconv>
4445
45#include "include/ryu/common.h"46#include "include/ryu/common.h"
46#include "include/ryu/d2fixed.h"47#include "include/ryu/d2fixed.h"
lib/libcxx/src/ryu/f2s.cpp+3-2
...@@ -39,8 +39,9 @@...@@ -39,8 +39,9 @@
39// Avoid formatting to keep the changes with the original code minimal.39// Avoid formatting to keep the changes with the original code minimal.
40// clang-format off40// clang-format off
4141
42#include "__config"42#include <__assert>
43#include "charconv"43#include <__config>
44#include <charconv>
4445
45#include "include/ryu/common.h"46#include "include/ryu/common.h"
46#include "include/ryu/d2fixed.h"47#include "include/ryu/d2fixed.h"
lib/libcxx/src/shared_mutex.cpp+4-3
...@@ -6,12 +6,13 @@...@@ -6,12 +6,13 @@
6//6//
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9#include "__config"9#include <__config>
10
10#ifndef _LIBCPP_HAS_NO_THREADS11#ifndef _LIBCPP_HAS_NO_THREADS
1112
12#include "shared_mutex"13#include <shared_mutex>
13#if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB)14#if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB)
14#pragma comment(lib, "pthread")15# pragma comment(lib, "pthread")
15#endif16#endif
1617
17_LIBCPP_BEGIN_NAMESPACE_STD18_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/src/stdexcept.cpp+4-5
...@@ -6,11 +6,10 @@...@@ -6,11 +6,10 @@
6//6//
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9#include "stdexcept"9#include <new>
10#include "new"10#include <stdexcept>
11#include "string"11#include <string>
12#include "system_error"12#include <system_error>
13
1413
15#ifdef _LIBCPP_ABI_VCRUNTIME14#ifdef _LIBCPP_ABI_VCRUNTIME
16#include "support/runtime/stdexcept_vcruntime.ipp"15#include "support/runtime/stdexcept_vcruntime.ipp"
lib/libcxx/src/string.cpp+94-216
...@@ -6,17 +6,17 @@...@@ -6,17 +6,17 @@
6//6//
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9#include "string"9#include <__assert>
10#include "charconv"10#include <cerrno>
11#include "cstdlib"11#include <charconv>
12#include "cerrno"12#include <cstdlib>
13#include "limits"13#include <limits>
14#include "stdexcept"14#include <stdexcept>
15#include <stdio.h>15#include <stdio.h>
16#include "__debug"16#include <string>
1717
18#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS18#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
19# include "cwchar"19# include <cwchar>
20#endif20#endif
2121
22_LIBCPP_BEGIN_NAMESPACE_STD22_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -56,42 +56,33 @@ void __basic_string_common<true>::__throw_out_of_range() const {...@@ -56,42 +56,33 @@ void __basic_string_common<true>::__throw_out_of_range() const {
56#endif56#endif
57#undef _LIBCPP_EXTERN_TEMPLATE_DEFINE57#undef _LIBCPP_EXTERN_TEMPLATE_DEFINE
5858
59template string operator+<char, char_traits<char>, allocator<char> >(char const*, string const&);59template string operator+<char, char_traits<char>, allocator<char>>(char const*, string const&);
6060
61namespace61namespace
62{62{
6363
64template<typename T>64template<typename T>
65inline65inline void throw_helper(const string& msg) {
66void throw_helper( const string& msg )
67{
68#ifndef _LIBCPP_NO_EXCEPTIONS66#ifndef _LIBCPP_NO_EXCEPTIONS
69 throw T( msg );67 throw T(msg);
70#else68#else
71 fprintf(stderr, "%s\n", msg.c_str());69 fprintf(stderr, "%s\n", msg.c_str());
72 _VSTD::abort();70 _VSTD::abort();
73#endif71#endif
74}72}
7573
76inline74inline void throw_from_string_out_of_range(const string& func) {
77void throw_from_string_out_of_range( const string& func )
78{
79 throw_helper<out_of_range>(func + ": out of range");75 throw_helper<out_of_range>(func + ": out of range");
80}76}
8177
82inline78inline void throw_from_string_invalid_arg(const string& func) {
83void throw_from_string_invalid_arg( const string& func )
84{
85 throw_helper<invalid_argument>(func + ": no conversion");79 throw_helper<invalid_argument>(func + ": no conversion");
86}80}
8781
88// as_integer82// as_integer
8983
90template<typename V, typename S, typename F>84template<typename V, typename S, typename F>
91inline85inline V as_integer_helper(const string& func, const S& str, size_t* idx, int base, F f) {
92V
93as_integer_helper(const string& func, const S& str, size_t* idx, int base, F f)
94{
95 typename S::value_type* ptr = nullptr;86 typename S::value_type* ptr = nullptr;
96 const typename S::value_type* const p = str.c_str();87 const typename S::value_type* const p = str.c_str();
97 typename remove_reference<decltype(errno)>::type errno_save = errno;88 typename remove_reference<decltype(errno)>::type errno_save = errno;
...@@ -108,109 +99,77 @@ as_integer_helper(const string& func, const S& str, size_t* idx, int base, F f)...@@ -108,109 +99,77 @@ as_integer_helper(const string& func, const S& str, size_t* idx, int base, F f)
108}99}
109100
110template<typename V, typename S>101template<typename V, typename S>
111inline102inline V as_integer(const string& func, const S& s, size_t* idx, int base);
112V
113as_integer(const string& func, const S& s, size_t* idx, int base);
114103
115// string104// string
116template<>105template<>
117inline106inline int as_integer(const string& func, const string& s, size_t* idx, int base) {
118int
119as_integer(const string& func, const string& s, size_t* idx, int base )
120{
121 // Use long as no Standard string to integer exists.107 // Use long as no Standard string to integer exists.
122 long r = as_integer_helper<long>( func, s, idx, base, strtol );108 long r = as_integer_helper<long>(func, s, idx, base, strtol);
123 if (r < numeric_limits<int>::min() || numeric_limits<int>::max() < r)109 if (r < numeric_limits<int>::min() || numeric_limits<int>::max() < r)
124 throw_from_string_out_of_range(func);110 throw_from_string_out_of_range(func);
125 return static_cast<int>(r);111 return static_cast<int>(r);
126}112}
127113
128template<>114template<>
129inline115inline long as_integer(const string& func, const string& s, size_t* idx, int base) {
130long116 return as_integer_helper<long>(func, s, idx, base, strtol);
131as_integer(const string& func, const string& s, size_t* idx, int base )
132{
133 return as_integer_helper<long>( func, s, idx, base, strtol );
134}117}
135118
136template<>119template<>
137inline120inline unsigned long as_integer(const string& func, const string& s, size_t* idx, int base) {
138unsigned long121 return as_integer_helper<unsigned long>(func, s, idx, base, strtoul);
139as_integer( const string& func, const string& s, size_t* idx, int base )
140{
141 return as_integer_helper<unsigned long>( func, s, idx, base, strtoul );
142}122}
143123
144template<>124template<>
145inline125inline long long as_integer(const string& func, const string& s, size_t* idx, int base) {
146long long126 return as_integer_helper<long long>(func, s, idx, base, strtoll);
147as_integer( const string& func, const string& s, size_t* idx, int base )
148{
149 return as_integer_helper<long long>( func, s, idx, base, strtoll );
150}127}
151128
152template<>129template<>
153inline130inline unsigned long long as_integer(const string& func, const string& s, size_t* idx, int base) {
154unsigned long long131 return as_integer_helper<unsigned long long>(func, s, idx, base, strtoull);
155as_integer( const string& func, const string& s, size_t* idx, int base )
156{
157 return as_integer_helper<unsigned long long>( func, s, idx, base, strtoull );
158}132}
159133
160#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS134#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
161// wstring135// wstring
162template<>136template<>
163inline137inline int as_integer(const string& func, const wstring& s, size_t* idx, int base) {
164int
165as_integer( const string& func, const wstring& s, size_t* idx, int base )
166{
167 // Use long as no Stantard string to integer exists.138 // Use long as no Stantard string to integer exists.
168 long r = as_integer_helper<long>( func, s, idx, base, wcstol );139 long r = as_integer_helper<long>(func, s, idx, base, wcstol);
169 if (r < numeric_limits<int>::min() || numeric_limits<int>::max() < r)140 if (r < numeric_limits<int>::min() || numeric_limits<int>::max() < r)
170 throw_from_string_out_of_range(func);141 throw_from_string_out_of_range(func);
171 return static_cast<int>(r);142 return static_cast<int>(r);
172}143}
173144
174template<>145template<>
175inline146inline long as_integer(const string& func, const wstring& s, size_t* idx, int base) {
176long147 return as_integer_helper<long>(func, s, idx, base, wcstol);
177as_integer( const string& func, const wstring& s, size_t* idx, int base )
178{
179 return as_integer_helper<long>( func, s, idx, base, wcstol );
180}148}
181149
182template<>150template<>
183inline151inline
184unsigned long152unsigned long
185as_integer( const string& func, const wstring& s, size_t* idx, int base )153as_integer(const string& func, const wstring& s, size_t* idx, int base)
186{154{
187 return as_integer_helper<unsigned long>( func, s, idx, base, wcstoul );155 return as_integer_helper<unsigned long>(func, s, idx, base, wcstoul);
188}156}
189157
190template<>158template<>
191inline159inline long long as_integer(const string& func, const wstring& s, size_t* idx, int base) {
192long long160 return as_integer_helper<long long>(func, s, idx, base, wcstoll);
193as_integer( const string& func, const wstring& s, size_t* idx, int base )
194{
195 return as_integer_helper<long long>( func, s, idx, base, wcstoll );
196}161}
197162
198template<>163template<>
199inline164inline unsigned long long as_integer(const string& func, const wstring& s, size_t* idx, int base) {
200unsigned long long165 return as_integer_helper<unsigned long long>(func, s, idx, base, wcstoull);
201as_integer( const string& func, const wstring& s, size_t* idx, int base )
202{
203 return as_integer_helper<unsigned long long>( func, s, idx, base, wcstoull );
204}166}
205#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS167#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
206168
207// as_float169// as_float
208170
209template<typename V, typename S, typename F>171template<typename V, typename S, typename F>
210inline172inline V as_float_helper(const string& func, const S& str, size_t* idx, F f) {
211V
212as_float_helper(const string& func, const S& str, size_t* idx, F f )
213{
214 typename S::value_type* ptr = nullptr;173 typename S::value_type* ptr = nullptr;
215 const typename S::value_type* const p = str.c_str();174 const typename S::value_type* const p = str.c_str();
216 typename remove_reference<decltype(errno)>::type errno_save = errno;175 typename remove_reference<decltype(errno)>::type errno_save = errno;
...@@ -227,172 +186,107 @@ as_float_helper(const string& func, const S& str, size_t* idx, F f )...@@ -227,172 +186,107 @@ as_float_helper(const string& func, const S& str, size_t* idx, F f )
227}186}
228187
229template<typename V, typename S>188template<typename V, typename S>
230inline189inline V as_float(const string& func, const S& s, size_t* idx = nullptr);
231V as_float( const string& func, const S& s, size_t* idx = nullptr );
232190
233template<>191template<>
234inline192inline float as_float(const string& func, const string& s, size_t* idx) {
235float193 return as_float_helper<float>(func, s, idx, strtof);
236as_float( const string& func, const string& s, size_t* idx )
237{
238 return as_float_helper<float>( func, s, idx, strtof );
239}194}
240195
241template<>196template<>
242inline197inline double as_float(const string& func, const string& s, size_t* idx) {
243double198 return as_float_helper<double>(func, s, idx, strtod);
244as_float(const string& func, const string& s, size_t* idx )
245{
246 return as_float_helper<double>( func, s, idx, strtod );
247}199}
248200
249template<>201template<>
250inline202inline long double as_float(const string& func, const string& s, size_t* idx) {
251long double203 return as_float_helper<long double>(func, s, idx, strtold);
252as_float( const string& func, const string& s, size_t* idx )
253{
254 return as_float_helper<long double>( func, s, idx, strtold );
255}204}
256205
257#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS206#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
258template<>207template<>
259inline208inline float as_float(const string& func, const wstring& s, size_t* idx) {
260float209 return as_float_helper<float>(func, s, idx, wcstof);
261as_float( const string& func, const wstring& s, size_t* idx )
262{
263 return as_float_helper<float>( func, s, idx, wcstof );
264}210}
265211
266template<>212template<>
267inline213inline double as_float(const string& func, const wstring& s, size_t* idx) {
268double214 return as_float_helper<double>(func, s, idx, wcstod);
269as_float( const string& func, const wstring& s, size_t* idx )
270{
271 return as_float_helper<double>( func, s, idx, wcstod );
272}215}
273216
274template<>217template<>
275inline218inline long double as_float(const string& func, const wstring& s, size_t* idx) {
276long double219 return as_float_helper<long double>(func, s, idx, wcstold);
277as_float( const string& func, const wstring& s, size_t* idx )
278{
279 return as_float_helper<long double>( func, s, idx, wcstold );
280}220}
281#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS221#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
282222
283} // unnamed namespace223} // unnamed namespace
284224
285int225int stoi(const string& str, size_t* idx, int base) {
286stoi(const string& str, size_t* idx, int base)226 return as_integer<int>("stoi", str, idx, base);
287{
288 return as_integer<int>( "stoi", str, idx, base );
289}227}
290228
291#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS229long stol(const string& str, size_t* idx, int base) {
292int230 return as_integer<long>("stol", str, idx, base);
293stoi(const wstring& str, size_t* idx, int base)
294{
295 return as_integer<int>( "stoi", str, idx, base );
296}231}
297#endif
298232
299long233unsigned long stoul(const string& str, size_t* idx, int base) {
300stol(const string& str, size_t* idx, int base)234 return as_integer<unsigned long>("stoul", str, idx, base);
301{
302 return as_integer<long>( "stol", str, idx, base );
303}235}
304236
305#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS237long long stoll(const string& str, size_t* idx, int base) {
306long238 return as_integer<long long>("stoll", str, idx, base);
307stol(const wstring& str, size_t* idx, int base)
308{
309 return as_integer<long>( "stol", str, idx, base );
310}239}
311#endif
312240
313unsigned long241unsigned long long stoull(const string& str, size_t* idx, int base) {
314stoul(const string& str, size_t* idx, int base)242 return as_integer<unsigned long long>("stoull", str, idx, base);
315{
316 return as_integer<unsigned long>( "stoul", str, idx, base );
317}243}
318244
319#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS245float stof(const string& str, size_t* idx) {
320unsigned long246 return as_float<float>("stof", str, idx);
321stoul(const wstring& str, size_t* idx, int base)
322{
323 return as_integer<unsigned long>( "stoul", str, idx, base );
324}247}
325#endif
326248
327long long249double stod(const string& str, size_t* idx) {
328stoll(const string& str, size_t* idx, int base)250 return as_float<double>("stod", str, idx);
329{
330 return as_integer<long long>( "stoll", str, idx, base );
331}251}
332252
333#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS253long double stold(const string& str, size_t* idx) {
334long long254 return as_float<long double>("stold", str, idx);
335stoll(const wstring& str, size_t* idx, int base)
336{
337 return as_integer<long long>( "stoll", str, idx, base );
338}255}
339#endif
340256
341unsigned long long257#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
342stoull(const string& str, size_t* idx, int base)258int stoi(const wstring& str, size_t* idx, int base) {
343{259 return as_integer<int>("stoi", str, idx, base);
344 return as_integer<unsigned long long>( "stoull", str, idx, base );
345}260}
346261
347#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS262long stol(const wstring& str, size_t* idx, int base) {
348unsigned long long263 return as_integer<long>("stol", str, idx, base);
349stoull(const wstring& str, size_t* idx, int base)
350{
351 return as_integer<unsigned long long>( "stoull", str, idx, base );
352}264}
353#endif
354265
355float266unsigned long stoul(const wstring& str, size_t* idx, int base) {
356stof(const string& str, size_t* idx)267 return as_integer<unsigned long>("stoul", str, idx, base);
357{
358 return as_float<float>( "stof", str, idx );
359}268}
360269
361#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS270long long stoll(const wstring& str, size_t* idx, int base) {
362float271 return as_integer<long long>("stoll", str, idx, base);
363stof(const wstring& str, size_t* idx)
364{
365 return as_float<float>( "stof", str, idx );
366}272}
367#endif
368273
369double274unsigned long long stoull(const wstring& str, size_t* idx, int base) {
370stod(const string& str, size_t* idx)275 return as_integer<unsigned long long>("stoull", str, idx, base);
371{
372 return as_float<double>( "stod", str, idx );
373}276}
374277
375#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS278float stof(const wstring& str, size_t* idx) {
376double279 return as_float<float>("stof", str, idx);
377stod(const wstring& str, size_t* idx)
378{
379 return as_float<double>( "stod", str, idx );
380}280}
381#endif
382281
383long double282double stod(const wstring& str, size_t* idx) {
384stold(const string& str, size_t* idx)283 return as_float<double>("stod", str, idx);
385{
386 return as_float<long double>( "stold", str, idx );
387}284}
388285
389#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS286long double stold(const wstring& str, size_t* idx) {
390long double287 return as_float<long double>("stold", str, idx);
391stold(const wstring& str, size_t* idx)
392{
393 return as_float<long double>( "stold", str, idx );
394}288}
395#endif289#endif // !_LIBCPP_HAS_NO_WIDE_CHARACTERS
396290
397// to_string291// to_string
398292
...@@ -402,21 +296,15 @@ namespace...@@ -402,21 +296,15 @@ namespace
402// as_string296// as_string
403297
404template<typename S, typename P, typename V >298template<typename S, typename P, typename V >
405inline299inline S as_string(P sprintf_like, S s, const typename S::value_type* fmt, V a) {
406S
407as_string(P sprintf_like, S s, const typename S::value_type* fmt, V a)
408{
409 typedef typename S::size_type size_type;300 typedef typename S::size_type size_type;
410 size_type available = s.size();301 size_type available = s.size();
411 while (true)302 while (true) {
412 {
413 int status = sprintf_like(&s[0], available + 1, fmt, a);303 int status = sprintf_like(&s[0], available + 1, fmt, a);
414 if ( status >= 0 )304 if (status >= 0) {
415 {
416 size_type used = static_cast<size_type>(status);305 size_type used = static_cast<size_type>(status);
417 if ( used <= available )306 if (used <= available) {
418 {307 s.resize(used);
419 s.resize( used );
420 break;308 break;
421 }309 }
422 available = used; // Assume this is advice of how much space we need.310 available = used; // Assume this is advice of how much space we need.
...@@ -432,11 +320,8 @@ template <class S>...@@ -432,11 +320,8 @@ template <class S>
432struct initial_string;320struct initial_string;
433321
434template <>322template <>
435struct initial_string<string>323struct initial_string<string> {
436{324 string operator()() const {
437 string
438 operator()() const
439 {
440 string s;325 string s;
441 s.resize(s.capacity());326 s.resize(s.capacity());
442 return s;327 return s;
...@@ -445,11 +330,8 @@ struct initial_string<string>...@@ -445,11 +330,8 @@ struct initial_string<string>
445330
446#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS331#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
447template <>332template <>
448struct initial_string<wstring>333struct initial_string<wstring> {
449{334 wstring operator()() const {
450 wstring
451 operator()() const
452 {
453 wstring s(20, wchar_t());335 wstring s(20, wchar_t());
454 s.resize(s.capacity());336 s.resize(s.capacity());
455 return s;337 return s;
...@@ -458,10 +340,7 @@ struct initial_string<wstring>...@@ -458,10 +340,7 @@ struct initial_string<wstring>
458340
459typedef int (*wide_printf)(wchar_t* __restrict, size_t, const wchar_t*__restrict, ...);341typedef int (*wide_printf)(wchar_t* __restrict, size_t, const wchar_t*__restrict, ...);
460342
461inline343inline wide_printf get_swprintf() {
462wide_printf
463get_swprintf()
464{
465#ifndef _LIBCPP_MSVCRT344#ifndef _LIBCPP_MSVCRT
466 return swprintf;345 return swprintf;
467#else346#else
...@@ -471,8 +350,7 @@ get_swprintf()...@@ -471,8 +350,7 @@ get_swprintf()
471#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS350#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
472351
473template <typename S, typename V>352template <typename S, typename V>
474S i_to_string(V v)353S i_to_string(V v) {
475{
476// numeric_limits::digits10 returns value less on 1 than desired for unsigned numbers.354// numeric_limits::digits10 returns value less on 1 than desired for unsigned numbers.
477// For example, for 1-byte unsigned value digits10 is 2 (999 can not be represented),355// For example, for 1-byte unsigned value digits10 is 2 (999 can not be represented),
478// so we need +1 here.356// so we need +1 here.
lib/libcxx/src/strstream.cpp+13-8
...@@ -6,13 +6,16 @@...@@ -6,13 +6,16 @@
6//6//
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9#include "strstream"9#include <__assert>
10#include "algorithm"10#include <__utility/unreachable.h>
11#include "climits"11#include <algorithm>
12#include "cstring"12#include <climits>
13#include "cstdlib"13#include <cstdlib>
14#include "__debug"14#include <cstring>
15#include "__undef_macros"15#include <strstream>
16
17_LIBCPP_PUSH_MACROS
18#include <__undef_macros>
1619
17_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
1821
...@@ -268,7 +271,7 @@ strstreambuf::seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmod...@@ -268,7 +271,7 @@ strstreambuf::seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmod
268 newoff = seekhigh - eback();271 newoff = seekhigh - eback();
269 break;272 break;
270 default:273 default:
271 _LIBCPP_UNREACHABLE();274 __libcpp_unreachable();
272 }275 }
273 newoff += __off;276 newoff += __off;
274 if (0 <= newoff && newoff <= seekhigh - eback())277 if (0 <= newoff && newoff <= seekhigh - eback())
...@@ -333,3 +336,5 @@ strstream::~strstream()...@@ -333,3 +336,5 @@ strstream::~strstream()
333}336}
334337
335_LIBCPP_END_NAMESPACE_STD338_LIBCPP_END_NAMESPACE_STD
339
340_LIBCPP_POP_MACROS
lib/libcxx/src/support/ibm/xlocale_zos.cpp+9-8
...@@ -6,6 +6,7 @@...@@ -6,6 +6,7 @@
6//6//
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9#include <__assert>
9#include <__support/ibm/xlocale.h>10#include <__support/ibm/xlocale.h>
10#include <sstream>11#include <sstream>
11#include <vector>12#include <vector>
...@@ -31,7 +32,7 @@ locale_t newlocale(int category_mask, const char* locale, locale_t base) {...@@ -31,7 +32,7 @@ locale_t newlocale(int category_mask, const char* locale, locale_t base) {
31 }32 }
32 }33 }
33 }34 }
34 35
35 // Create new locale.36 // Create new locale.
36 locale_t newloc = new locale_struct();37 locale_t newloc = new locale_struct();
3738
...@@ -74,18 +75,18 @@ locale_t uselocale(locale_t newloc) {...@@ -74,18 +75,18 @@ locale_t uselocale(locale_t newloc) {
7475
75 if (newloc) {76 if (newloc) {
76 // Set locales and check for errors.77 // Set locales and check for errors.
77 bool is_error = 78 bool is_error =
78 (newloc->category_mask & LC_COLLATE_MASK && 79 (newloc->category_mask & LC_COLLATE_MASK &&
79 setlocale(LC_COLLATE, newloc->lc_collate.c_str()) == NULL) ||80 setlocale(LC_COLLATE, newloc->lc_collate.c_str()) == NULL) ||
80 (newloc->category_mask & LC_CTYPE_MASK && 81 (newloc->category_mask & LC_CTYPE_MASK &&
81 setlocale(LC_CTYPE, newloc->lc_ctype.c_str()) == NULL) ||82 setlocale(LC_CTYPE, newloc->lc_ctype.c_str()) == NULL) ||
82 (newloc->category_mask & LC_MONETARY_MASK && 83 (newloc->category_mask & LC_MONETARY_MASK &&
83 setlocale(LC_MONETARY, newloc->lc_monetary.c_str()) == NULL) ||84 setlocale(LC_MONETARY, newloc->lc_monetary.c_str()) == NULL) ||
84 (newloc->category_mask & LC_NUMERIC_MASK && 85 (newloc->category_mask & LC_NUMERIC_MASK &&
85 setlocale(LC_NUMERIC, newloc->lc_numeric.c_str()) == NULL) ||86 setlocale(LC_NUMERIC, newloc->lc_numeric.c_str()) == NULL) ||
86 (newloc->category_mask & LC_TIME_MASK && 87 (newloc->category_mask & LC_TIME_MASK &&
87 setlocale(LC_TIME, newloc->lc_time.c_str()) == NULL) ||88 setlocale(LC_TIME, newloc->lc_time.c_str()) == NULL) ||
88 (newloc->category_mask & LC_MESSAGES_MASK && 89 (newloc->category_mask & LC_MESSAGES_MASK &&
89 setlocale(LC_MESSAGES, newloc->lc_messages.c_str()) == NULL);90 setlocale(LC_MESSAGES, newloc->lc_messages.c_str()) == NULL);
9091
91 if (is_error) {92 if (is_error) {
lib/libcxx/src/support/runtime/exception_fallback.ipp+2-4
...@@ -11,9 +11,8 @@...@@ -11,9 +11,8 @@
1111
12namespace std {12namespace std {
1313
14_LIBCPP_SAFE_STATIC static std::terminate_handler __terminate_handler;14static constinit std::terminate_handler __terminate_handler = nullptr;
15_LIBCPP_SAFE_STATIC static std::unexpected_handler __unexpected_handler;15static constinit std::unexpected_handler __unexpected_handler = nullptr;
16
1716
18// libcxxrt provides implementations of these functions itself.17// libcxxrt provides implementations of these functions itself.
19unexpected_handler18unexpected_handler
...@@ -26,7 +25,6 @@ unexpected_handler...@@ -26,7 +25,6 @@ unexpected_handler
26get_unexpected() noexcept25get_unexpected() noexcept
27{26{
28 return __libcpp_atomic_load(&__unexpected_handler);27 return __libcpp_atomic_load(&__unexpected_handler);
29
30}28}
3129
32_LIBCPP_NORETURN30_LIBCPP_NORETURN
lib/libcxx/src/support/runtime/new_handler_fallback.ipp+1-1
...@@ -9,7 +9,7 @@...@@ -9,7 +9,7 @@
99
10namespace std {10namespace std {
1111
12_LIBCPP_SAFE_STATIC static std::new_handler __new_handler;12static constinit std::new_handler __new_handler = nullptr;
1313
14new_handler14new_handler
15set_new_handler(new_handler handler) noexcept15set_new_handler(new_handler handler) noexcept
lib/libcxx/src/support/win32/locale_win32.cpp+3-3
...@@ -97,10 +97,10 @@ int snprintf_l(char *ret, size_t n, locale_t loc, const char *format, ...)...@@ -97,10 +97,10 @@ int snprintf_l(char *ret, size_t n, locale_t loc, const char *format, ...)
97 ret, n, format, loc, ap);97 ret, n, format, loc, ap);
98#else98#else
99 __libcpp_locale_guard __current(loc);99 __libcpp_locale_guard __current(loc);
100#pragma clang diagnostic push100 _LIBCPP_DIAGNOSTIC_PUSH
101#pragma clang diagnostic ignored "-Wformat-nonliteral"101 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wformat-nonliteral")
102 int result = vsnprintf( ret, n, format, ap );102 int result = vsnprintf( ret, n, format, ap );
103#pragma clang diagnostic pop103 _LIBCPP_DIAGNOSTIC_POP
104#endif104#endif
105 va_end(ap);105 va_end(ap);
106 return result;106 return result;
lib/libcxx/src/support/win32/support.cpp+6-6
...@@ -23,10 +23,10 @@ int __libcpp_vasprintf( char **sptr, const char *__restrict format, va_list ap )...@@ -23,10 +23,10 @@ int __libcpp_vasprintf( char **sptr, const char *__restrict format, va_list ap )
23 // Query the count required.23 // Query the count required.
24 va_list ap_copy;24 va_list ap_copy;
25 va_copy(ap_copy, ap);25 va_copy(ap_copy, ap);
26#pragma clang diagnostic push26 _LIBCPP_DIAGNOSTIC_PUSH
27#pragma clang diagnostic ignored "-Wformat-nonliteral"27 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wformat-nonliteral")
28 int count = vsnprintf( NULL, 0, format, ap_copy );28 int count = vsnprintf( NULL, 0, format, ap_copy );
29#pragma clang diagnostic pop29 _LIBCPP_DIAGNOSTIC_POP
30 va_end(ap_copy);30 va_end(ap_copy);
31 if (count < 0)31 if (count < 0)
32 return count;32 return count;
...@@ -36,10 +36,10 @@ int __libcpp_vasprintf( char **sptr, const char *__restrict format, va_list ap )...@@ -36,10 +36,10 @@ int __libcpp_vasprintf( char **sptr, const char *__restrict format, va_list ap )
36 return -1;36 return -1;
37 // If we haven't used exactly what was required, something is wrong.37 // If we haven't used exactly what was required, something is wrong.
38 // Maybe bug in vsnprintf. Report the error and return.38 // Maybe bug in vsnprintf. Report the error and return.
39#pragma clang diagnostic push39 _LIBCPP_DIAGNOSTIC_PUSH
40#pragma clang diagnostic ignored "-Wformat-nonliteral"40 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wformat-nonliteral")
41 if (vsnprintf(p, buffer_size, format, ap) != count) {41 if (vsnprintf(p, buffer_size, format, ap) != count) {
42#pragma clang diagnostic pop42 _LIBCPP_DIAGNOSTIC_POP
43 free(p);43 free(p);
44 return -1;44 return -1;
45 }45 }
lib/libcxx/src/system_error.cpp+13-10
...@@ -6,18 +6,21 @@...@@ -6,18 +6,21 @@
6//6//
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9#include "__config"9#include <__config>
10#ifdef _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS
11# define _LIBCPP_ERROR_CATEGORY_DEFINE_LEGACY_INLINE_FUNCTIONS
12#endif
1013
11#include "system_error"14#include <__assert>
15#include <cerrno>
16#include <cstdio>
17#include <cstdlib>
18#include <cstring>
19#include <string>
20#include <string.h>
21#include <system_error>
1222
13#include "include/config_elast.h"23#include "include/config_elast.h"
14#include "cerrno"
15#include "cstring"
16#include "cstdio"
17#include "cstdlib"
18#include "string"
19#include "string.h"
20#include "__debug"
2124
22#if defined(__ANDROID__)25#if defined(__ANDROID__)
23#include <android/api-level.h>26#include <android/api-level.h>
...@@ -27,7 +30,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -27,7 +30,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2730
28// class error_category31// class error_category
2932
30#if defined(_LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS)33#if defined(_LIBCPP_ERROR_CATEGORY_DEFINE_LEGACY_INLINE_FUNCTIONS)
31error_category::error_category() noexcept34error_category::error_category() noexcept
32{35{
33}36}
lib/libcxx/src/thread.cpp+14-8
...@@ -6,14 +6,15 @@...@@ -6,14 +6,15 @@
6//6//
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9#include "__config"9#include <__config>
10
10#ifndef _LIBCPP_HAS_NO_THREADS11#ifndef _LIBCPP_HAS_NO_THREADS
1112
12#include "thread"13#include <exception>
13#include "exception"14#include <future>
14#include "vector"15#include <limits>
15#include "future"16#include <thread>
16#include "limits"17#include <vector>
1718
18#if __has_include(<unistd.h>)19#if __has_include(<unistd.h>)
19# include <unistd.h> // for sysconf20# include <unistd.h> // for sysconf
...@@ -114,8 +115,13 @@ sleep_for(const chrono::nanoseconds& ns)...@@ -114,8 +115,13 @@ sleep_for(const chrono::nanoseconds& ns)
114__thread_specific_ptr<__thread_struct>&115__thread_specific_ptr<__thread_struct>&
115__thread_local_data()116__thread_local_data()
116{117{
117 static __thread_specific_ptr<__thread_struct> __p;118 // Even though __thread_specific_ptr's destructor doesn't actually destroy
118 return __p;119 // anything (see comments there), we can't call it at all because threads may
120 // outlive the static variable and calling its destructor means accessing an
121 // object outside of its lifetime, which is UB.
122 alignas(__thread_specific_ptr<__thread_struct>) static char __b[sizeof(__thread_specific_ptr<__thread_struct>)];
123 static __thread_specific_ptr<__thread_struct>* __p = new (__b) __thread_specific_ptr<__thread_struct>();
124 return *__p;
119}125}
120126
121// __thread_struct_imp127// __thread_struct_imp
lib/libcxx/src/typeinfo.cpp+2-1
...@@ -6,9 +6,10 @@...@@ -6,9 +6,10 @@
6//6//
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9#include "typeinfo"9#include <typeinfo>
1010
11#if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_ABI_VCRUNTIME)11#if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_ABI_VCRUNTIME)
12
12#include <string.h>13#include <string.h>
1314
14int std::type_info::__compare(const type_info &__rhs) const noexcept {15int std::type_info::__compare(const type_info &__rhs) const noexcept {
lib/libcxx/src/utility.cpp+1-1
...@@ -6,7 +6,7 @@...@@ -6,7 +6,7 @@
6//6//
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9#include "utility"9#include <utility>
1010
11_LIBCPP_BEGIN_NAMESPACE_STD11_LIBCPP_BEGIN_NAMESPACE_STD
1212
lib/libcxx/src/valarray.cpp+1-1
...@@ -6,7 +6,7 @@...@@ -6,7 +6,7 @@
6//6//
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9#include "valarray"9#include <valarray>
1010
11_LIBCPP_BEGIN_NAMESPACE_STD11_LIBCPP_BEGIN_NAMESPACE_STD
1212
lib/libcxx/src/variant.cpp+1-1
...@@ -6,7 +6,7 @@...@@ -6,7 +6,7 @@
6//6//
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9#include "variant"9#include <variant>
1010
11namespace std {11namespace std {
1212
lib/libcxx/src/vector.cpp+1-1
...@@ -6,7 +6,7 @@...@@ -6,7 +6,7 @@
6//6//
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9#include "vector"9#include <vector>
1010
11_LIBCPP_BEGIN_NAMESPACE_STD11_LIBCPP_BEGIN_NAMESPACE_STD
1212
lib/libcxx/src/verbose_abort.cpp 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#include <__config>
10#include <__verbose_abort>
11#include <cstdarg>
12#include <cstdio>
13#include <cstdlib>
14
15#ifdef __BIONIC__
16# include <android/api-level.h>
17# if __ANDROID_API__ >= 21
18# include <syslog.h>
19extern "C" void android_set_abort_message(const char* msg);
20# else
21# include <assert.h>
22# endif // __ANDROID_API__ >= 21
23#endif // __BIONIC__
24
25#if defined(__APPLE__) && __has_include(<CrashReporterClient.h>)
26# include <CrashReporterClient.h>
27#endif
28
29_LIBCPP_BEGIN_NAMESPACE_STD
30
31_LIBCPP_WEAK
32void __libcpp_verbose_abort(char const* format, ...) {
33 // Write message to stderr. We do this before formatting into a
34 // buffer so that we still get some information out if that fails.
35 {
36 va_list list;
37 va_start(list, format);
38 std::vfprintf(stderr, format, list);
39 va_end(list);
40 }
41
42 // Format the arguments into an allocated buffer for CrashReport & friends.
43 // We leak the buffer on purpose, since we're about to abort() anyway.
44 char* buffer; (void)buffer;
45 va_list list;
46 va_start(list, format);
47
48#if defined(__APPLE__) && __has_include(<CrashReporterClient.h>)
49 // Note that we should technically synchronize accesses here (by e.g. taking a lock),
50 // however concretely we're only setting a pointer, so the likelihood of a race here
51 // is low.
52 vasprintf(&buffer, format, list);
53 CRSetCrashLogMessage(buffer);
54#elif defined(__BIONIC__)
55 vasprintf(&buffer, format, list);
56
57# if __ANDROID_API__ >= 21
58 // Show error in tombstone.
59 android_set_abort_message(buffer);
60
61 // Show error in logcat.
62 openlog("libc++", 0, 0);
63 syslog(LOG_CRIT, "%s", buffer);
64 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#endif
72 va_end(list);
73
74 std::abort();
75}
76
77_LIBCPP_END_NAMESPACE_STD
src/libcxx.zig+2
...@@ -54,6 +54,7 @@ const libcxx_files = [_][]const u8{...@@ -54,6 +54,7 @@ const libcxx_files = [_][]const u8{
54 "src/ios.cpp",54 "src/ios.cpp",
55 "src/ios.instantiations.cpp",55 "src/ios.instantiations.cpp",
56 "src/iostream.cpp",56 "src/iostream.cpp",
57 "src/legacy_debug_handler.cpp",
57 "src/legacy_pointer_safety.cpp",58 "src/legacy_pointer_safety.cpp",
58 "src/locale.cpp",59 "src/locale.cpp",
59 "src/memory.cpp",60 "src/memory.cpp",
...@@ -85,6 +86,7 @@ const libcxx_files = [_][]const u8{...@@ -85,6 +86,7 @@ const libcxx_files = [_][]const u8{
85 "src/valarray.cpp",86 "src/valarray.cpp",
86 "src/variant.cpp",87 "src/variant.cpp",
87 "src/vector.cpp",88 "src/vector.cpp",
89 "src/verbose_abort.cpp",
88};90};
8991
90pub fn buildLibCXX(comp: *Compilation) !void {92pub fn buildLibCXX(comp: *Compilation) !void {